[gthumb] selections: fixed keyboard shortcuts for some keyboard layouts



commit e49e208e5c5e6a4a3561adde71c3f4711e4d7b50
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Apr 11 17:30:26 2012 +0200

    selections: fixed keyboard shortcuts for some keyboard layouts
    
    Fixed the keyboard shortcuts for French keyboards (and maybe
    others as well) where the number keys are shifted.
    
    [bug #673872]

 extensions/selections/actions.c   |    2 +-
 extensions/selections/actions.h   |    2 +
 extensions/selections/callbacks.c |   54 +++++++++++++++++++++++++++++++-----
 gthumb/gth-empty-list.c           |    2 +-
 4 files changed, 50 insertions(+), 10 deletions(-)
---
diff --git a/extensions/selections/actions.c b/extensions/selections/actions.c
index 036f365..9b655ba 100644
--- a/extensions/selections/actions.c
+++ b/extensions/selections/actions.c
@@ -25,7 +25,7 @@
 #include "gth-selections-manager.h"
 
 
-static void
+void
 gth_browser_activate_action_show_selection (GthBrowser *browser,
 					    int         n_selection)
 {
diff --git a/extensions/selections/actions.h b/extensions/selections/actions.h
index bf641b6..1b4a4fd 100644
--- a/extensions/selections/actions.h
+++ b/extensions/selections/actions.h
@@ -26,6 +26,8 @@
 
 #define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
 
+void gth_browser_activate_action_show_selection        (GthBrowser *browser,
+							int         n_selection);
 void gth_browser_activate_action_add_to_selection      (GthBrowser *browser,
 						        int         n_selection);
 void gth_browser_activate_action_remove_from_selection (GthBrowser *browser,
diff --git a/extensions/selections/callbacks.c b/extensions/selections/callbacks.c
index 7a67c52..aab8704 100644
--- a/extensions/selections/callbacks.c
+++ b/extensions/selections/callbacks.c
@@ -159,6 +159,33 @@ selections__gth_browser_construct_cb (GthBrowser *browser)
 }
 
 
+static guint
+get_numeric_keyval (GthBrowser  *browser,
+		    GdkEventKey *event)
+{
+	guint keyval;
+
+	gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (browser))),
+					     event->hardware_keycode,
+	                                     event->state & ~GDK_SHIFT_MASK,
+	                                     event->group,
+	                                     &keyval,
+	                                     NULL, NULL, NULL);
+
+	/* This fixes the keyboard shortcuts for French keyboards (and
+	 * maybe others as well) where the number keys are shifted. */
+	if ((keyval < GDK_KEY_1) || (keyval > GDK_KEY_3))
+		gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (browser))),
+						     event->hardware_keycode,
+		                                     event->state | GDK_SHIFT_MASK,
+		                                     event->group,
+		                                     &keyval,
+		                                     NULL, NULL, NULL);
+
+	return keyval;
+}
+
+
 gpointer
 selections__gth_browser_file_list_key_press_cb (GthBrowser  *browser,
 						GdkEventKey *event)
@@ -167,16 +194,12 @@ selections__gth_browser_file_list_key_press_cb (GthBrowser  *browser,
 	guint    modifiers;
 
 	modifiers = gtk_accelerator_get_default_mod_mask ();
-	if (((event->state & modifiers) == GDK_MOD1_MASK) || ((event->state & modifiers) == (GDK_SHIFT_MASK|GDK_MOD1_MASK))) {
+	if (((event->state & modifiers) == GDK_MOD1_MASK)
+	    || ((event->state & modifiers) == (GDK_SHIFT_MASK|GDK_MOD1_MASK)))
+	{
 		guint keyval;
 
-		gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (browser))),
-						     event->hardware_keycode,
-		                                     event->state & ~GDK_SHIFT_MASK,
-		                                     event->group,
-		                                     &keyval,
-		                                     NULL, NULL, NULL);
-
+		keyval = get_numeric_keyval (browser, event);
 		switch (keyval) {
 		case GDK_KEY_1:
 		case GDK_KEY_2:
@@ -191,6 +214,21 @@ selections__gth_browser_file_list_key_press_cb (GthBrowser  *browser,
 		}
 	}
 
+	if ((event->state & modifiers) == GDK_CONTROL_MASK) {
+		guint keyval;
+
+		keyval = get_numeric_keyval (browser, event);
+		switch (keyval) {
+		case GDK_KEY_1:
+		case GDK_KEY_2:
+		case GDK_KEY_3:
+			/* Control+n => go to selection n */
+			gth_browser_activate_action_show_selection (browser, keyval - GDK_KEY_1 + 1);
+			result = GINT_TO_POINTER (1);
+			break;
+		}
+	}
+
 	return result;
 }
 
diff --git a/gthumb/gth-empty-list.c b/gthumb/gth-empty-list.c
index 6d4d678..f7e8cc0 100644
--- a/gthumb/gth-empty-list.c
+++ b/gthumb/gth-empty-list.c
@@ -163,7 +163,7 @@ gth_empty_list_unrealize (GtkWidget *widget)
 		self->priv->layout = NULL;
 	}
 
-	(* GTK_WIDGET_CLASS (gth_empty_list_parent_class)->unrealize) (widget);
+	GTK_WIDGET_CLASS (gth_empty_list_parent_class)->unrealize (widget);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]