2004-11-30 [colin] 0.9.12cvs177
authorColin Leroy <colin@colino.net>
Tue, 30 Nov 2004 10:31:29 +0000 (10:31 +0000)
committerColin Leroy <colin@colino.net>
Tue, 30 Nov 2004 10:31:29 +0000 (10:31 +0000)
* src/gtk/prefswindow.c
* src/gtk/pluginwindow.c
Add shortcut keys to prefs window
and plugin window. Patch by Fabien Vantard.

ChangeLog.claws
PATCHSETS
configure.ac
src/gtk/pluginwindow.c
src/gtk/prefswindow.c

index a654c79..4bf5329 100644 (file)
@@ -1,3 +1,10 @@
+2004-11-30 [colin]     0.9.12cvs177
+
+       * src/gtk/prefswindow.c
+       * src/gtk/pluginwindow.c
+               Add shortcut keys to prefs window
+               and plugin window. Patch by Fabien Vantard.
+
 2004-11-29 [colin]     0.9.12cvs176
 
        * src/folderview.c
index 62cb506..a0c45ec 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.70 -r 1.71 src/pop.c; ) > 0.9.12cvs174.patchset
 ( cvs diff -u -r 1.95 -r 1.96 src/procmime.c; ) > 0.9.12cvs175.patchset
 ( cvs diff -u -r 1.252 -r 1.253 src/folderview.c; ) > 0.9.12cvs176.patchset
+( cvs diff -u -r 1.16 -r 1.17 src/gtk/prefswindow.c; cvs diff -u -r 1.8 -r 1.9 src/gtk/pluginwindow.c; ) > 0.9.12cvs177.patchset
index 1d5b9d1..e341150 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=176
+EXTRA_VERSION=177
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index dd1cbde..f21c4a2 100644 (file)
@@ -24,6 +24,7 @@
 #include <string.h>
 
 #include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "intl.h"
 #include "plugin.h"
@@ -56,21 +57,24 @@ static void set_plugin_list(PluginWindow *pluginwindow)
        gchar *text[1];
        gint row;
        GtkCList *clist = GTK_CLIST(pluginwindow->plugin_list);
-       
+
        plugins = plugin_get_list();
        gtk_clist_freeze(clist);
        gtk_clist_clear(clist);
        gtk_editable_delete_text(GTK_EDITABLE(pluginwindow->plugin_desc), 0, -1);
        gtk_widget_set_sensitive(pluginwindow->unload_btn, FALSE);
-       
+
        for(cur = plugins; cur != NULL; cur = g_slist_next(cur)) {
                Plugin *plugin = (Plugin *) cur->data;
-               
+
                text[0] = (gchar *) plugin_get_name(plugin);
                row = gtk_clist_append(clist, text);
                gtk_clist_set_row_data(clist, row, plugin);
        }
        gtk_clist_thaw(clist);
+
+       if (pluginwindow->selected_plugin == NULL)
+               gtk_clist_select_row (clist, 0, -1);
 }
 
 static void select_row_cb(GtkCList *clist, gint row, gint column,
@@ -80,7 +84,7 @@ static void select_row_cb(GtkCList *clist, gint row, gint column,
        GtkEditable *plugin_desc = GTK_EDITABLE(pluginwindow->plugin_desc);
        const gchar *text;
        gint pos = 0;
-       
+
        plugin = (Plugin *) gtk_clist_get_row_data(clist, row);
        pluginwindow->selected_plugin = plugin;
 
@@ -103,9 +107,10 @@ static void unselect_row_cb(GtkCList * clist, gint row, gint column,
 static void unload_cb(GtkButton *button, PluginWindow *pluginwindow)
 {
        Plugin *plugin = pluginwindow->selected_plugin;
-       
+
        g_return_if_fail(plugin != NULL);
        plugin_unload(plugin);
+       pluginwindow->selected_plugin = NULL;
        set_plugin_list(pluginwindow);
 }
 
@@ -126,6 +131,34 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
        set_plugin_list(pluginwindow);          
 }
 
+static void pluginwindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
+                                    PluginWindow *pluginwindow)
+{
+       if (event) {
+               switch (event->keyval) {
+                       case GDK_Escape : 
+                       case GDK_Return : 
+                       case GDK_KP_Enter :
+                               close_cb(NULL, pluginwindow);
+                               break;
+                       case GDK_Insert : 
+                       case GDK_KP_Insert :
+                       case GDK_KP_Add : 
+                       case GDK_plus :
+                               load_cb(NULL, pluginwindow);
+                               break;
+                       case GDK_Delete : 
+                       case GDK_KP_Delete :
+                       case GDK_KP_Subtract : 
+                       case GDK_minus :
+                               unload_cb(NULL, pluginwindow);
+                               break;
+                       default :
+                               break;
+               }
+       }
+}
+
 void pluginwindow_create()
 {
        PluginWindow *pluginwindow;
@@ -172,6 +205,8 @@ void pluginwindow_create()
        gtk_container_add(GTK_CONTAINER(scrolledwindow2), plugin_list);
        gtk_clist_set_column_width(GTK_CLIST(plugin_list), 0, 80);
        gtk_clist_column_titles_show(GTK_CLIST(plugin_list));
+       gtk_clist_set_selection_mode(GTK_CLIST (plugin_list), GTK_SELECTION_BROWSE);
+       gtk_widget_grab_focus(GTK_WIDGET(plugin_list));
 
        label12 = gtk_label_new(_("Plugins"));
        gtk_widget_show(label12);
@@ -242,6 +277,8 @@ void pluginwindow_create()
                           GTK_SIGNAL_FUNC(select_row_cb), pluginwindow);
        gtk_signal_connect(GTK_OBJECT(plugin_list), "unselect-row",
                           GTK_SIGNAL_FUNC(unselect_row_cb), pluginwindow);
+       gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
+                          GTK_SIGNAL_FUNC(pluginwindow_key_pressed), pluginwindow);
 
        pluginwindow->window = window;
        pluginwindow->plugin_list = plugin_list;
index d36b560..a1551b2 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <string.h>
 #include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "intl.h"
 #include "utils.h"
@@ -92,7 +93,7 @@ static gboolean ctree_select_row(GtkCTree *ctree, GList *node, gint column, gpoi
        while (page->path[i + 1] != 0)
                i++;
        labeltext = page->path[i];
-       
+
        gtk_label_set_text(GTK_LABEL(prefswindow->pagelabel), labeltext);
 
        pagenum = gtk_notebook_page_num(GTK_NOTEBOOK(prefswindow->notebook),
@@ -204,6 +205,24 @@ gint compare_func(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
                                                                  0;
 }
 
+static void prefswindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
+                                   gpointer data)
+{
+       if (event) {
+               switch (event->keyval) {
+                       case GDK_Escape :
+                               cancel_button_released(NULL, data);
+                               break;
+                       case GDK_Return : 
+                       case GDK_KP_Enter :
+                               ok_button_released(NULL, data);
+                               break;
+                       default:
+                               break;
+               }
+       }
+}
+
 void prefswindow_open_full(const gchar *title, GSList *prefs_pages, gpointer data, GtkDestroyNotify func)
 {
        static gchar *titles[1];
@@ -321,6 +340,7 @@ void prefswindow_open_full(const gchar *title, GSList *prefs_pages, gpointer dat
        gtk_clist_set_column_max_width(GTK_CLIST(prefswindow->ctree), 0, optsize);
        gtk_clist_set_compare_func(GTK_CLIST(prefswindow->ctree), compare_func);
        gtk_ctree_sort_recursive(GTK_CTREE(prefswindow->ctree), NULL);
+       gtk_widget_grab_focus(GTK_WIDGET(prefswindow->ctree));
 
        gtkut_button_set_create(&prefswindow->confirm_area,
                                &prefswindow->ok_btn,           _("OK"),
@@ -334,6 +354,8 @@ void prefswindow_open_full(const gchar *title, GSList *prefs_pages, gpointer dat
        gtk_signal_connect(GTK_OBJECT(prefswindow->cancel_btn), "released", GTK_SIGNAL_FUNC(cancel_button_released), prefswindow);
        gtk_signal_connect(GTK_OBJECT(prefswindow->apply_btn), "released", GTK_SIGNAL_FUNC(apply_button_released), prefswindow);
        gtk_signal_connect(GTK_OBJECT(prefswindow->window), "delete_event", GTK_SIGNAL_FUNC(window_closed), prefswindow);
+       gtk_signal_connect(GTK_OBJECT(prefswindow->window), "key_press_event",
+                          GTK_SIGNAL_FUNC(prefswindow_key_pressed), &(prefswindow->window));
 
        gtk_widget_show(prefswindow->window);
 }
@@ -341,4 +363,4 @@ void prefswindow_open_full(const gchar *title, GSList *prefs_pages, gpointer dat
 void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
 {
        prefswindow_open_full(title, prefs_pages, data, NULL);
-}
\ No newline at end of file
+}