gnome-commander r1708 - in trunk: . src



Author: epiotr
Date: Tue Apr 22 21:36:28 2008
New Revision: 1708
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=1708&view=rev

Log:
Properly handle CAPSLOCK and Super keys in shortcuts dialog

Modified:
   trunk/ChangeLog
   trunk/src/eggcellrendererkeys.cc
   trunk/src/eggcellrendererkeys.h
   trunk/src/gnome-cmd-key-shortcuts-dialog.cc

Modified: trunk/src/eggcellrendererkeys.cc
==============================================================================
--- trunk/src/eggcellrendererkeys.cc	(original)
+++ trunk/src/eggcellrendererkeys.cc	Tue Apr 22 21:36:28 2008
@@ -41,6 +41,7 @@
 #include <gdk/gdkkeysyms.h>
 #include "eggcellrendererkeys.h"
 #include "gnome-cmd-includes.h"
+#include "utils.h"
 
 #define EGG_CELL_RENDERER_TEXT_PATH "egg-cell-renderer-text"
 
@@ -441,23 +442,38 @@
 }
 
 
-static gboolean grab_key_callback (GtkWidget *widget, GdkEventKey *event, void *data)
+static gboolean grab_key_callback (GtkWidget *widget, GdkEventKey *event, EggCellRendererKeys *keys)
 {
-    EggCellRendererKeys *keys = EGG_CELL_RENDERER_KEYS (data);
-
+#ifdef HAVE_GTK_2_10
+    if (event->is_modifier)
+        return TRUE;
+#else
     if (is_modifier (event->hardware_keycode))
         return TRUE;
+#endif
 
-    gboolean edited = FALSE;
-    guint consumed_modifiers = 0;
+    switch (event->keyval)
+    {
+        case GDK_Super_L:
+        case GDK_Super_R:
+        // case GDK_Meta_L:
+        // case GDK_Meta_R:
+        // case GDK_Hyper_L:
+        // case GDK_Hyper_R:
+            return TRUE;
+    }
 
     GdkDisplay *display = gtk_widget_get_display (widget);
 
-    gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (display),
-                                         event->hardware_keycode,
-                                         (GdkModifierType) event->state,
-                                         event->group,
-                                         NULL, NULL, NULL, (GdkModifierType *) &consumed_modifiers);
+    gboolean edited = FALSE;
+    guint consumed_modifiers = 0;
+
+    if (keys->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
+        gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (display),
+                                             event->hardware_keycode,
+                                             (GdkModifierType) event->state,
+                                             event->group,
+                                             NULL, NULL, NULL, (GdkModifierType *) &consumed_modifiers);
 
     guint accel_key = gdk_keyval_to_lower (event->keyval);
     guint accel_mods = 0;
@@ -477,8 +493,9 @@
         accel_mods &= ~consumed_modifiers;
 
     // put shift back if it changed the case of the key, not otherwise.
-    if (accel_key != event->keyval)
-        accel_mods |= GDK_SHIFT_MASK;
+    if (keys->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
+        if (accel_key != event->keyval)
+            accel_mods |= GDK_SHIFT_MASK;
 
     if (accel_mods == 0)
     {

Modified: trunk/src/eggcellrendererkeys.h
==============================================================================
--- trunk/src/eggcellrendererkeys.h	(original)
+++ trunk/src/eggcellrendererkeys.h	Tue Apr 22 21:36:28 2008
@@ -78,6 +78,14 @@
 GType egg_cell_renderer_keys_get_type (void);
 GtkCellRenderer *egg_cell_renderer_keys_new (void);
 
+#ifndef HAVE_GTK_2_10
+typedef enum
+{
+  GTK_CELL_RENDERER_ACCEL_MODE_GTK,
+  GTK_CELL_RENDERER_ACCEL_MODE_OTHER
+} GtkCellRendererAccelMode;
+#endif
+
 void  egg_cell_renderer_keys_set_accelerator (EggCellRendererKeys *keys, guint keyval, GdkModifierType mask);
 void  egg_cell_renderer_keys_get_accelerator (EggCellRendererKeys *keys, guint *keyval, GdkModifierType *mask);
 void  egg_cell_renderer_keys_set_accel_mode (EggCellRendererKeys *keys, GtkCellRendererAccelMode accel_mode);

Modified: trunk/src/gnome-cmd-key-shortcuts-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-key-shortcuts-dialog.cc	(original)
+++ trunk/src/gnome-cmd-key-shortcuts-dialog.cc	Tue Apr 22 21:36:28 2008
@@ -247,7 +247,7 @@
 
     g_object_set (renderer,
                   "editable", TRUE,
-                  "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,
+                  "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_OTHER,
                   NULL);
 
     GtkTreeViewColumn *col = gtk_tree_view_column_new_with_attributes (title,



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