[gtk+/native-layout] Some improvements to the auto-mnemonics code



commit 779d3d58ea760751cef92a7809fd4cf5feeb962e
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 20 18:20:42 2009 -0500

    Some improvements to the auto-mnemonics code

 gtk/gtkmain.c      |    7 +++++--
 gtk/gtkmenushell.c |    8 ++++++--
 gtk/gtkwindow.c    |   21 +--------------------
 3 files changed, 12 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index af03f35..dfd517a 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1615,8 +1615,11 @@ gtk_main_do_event (GdkEvent *event)
 	  if (gtk_invoke_key_snoopers (grab_widget, event))
 	    break;
 	}
-      /* catch alt press to enable auto-mnemonics */
-      if (event->key.keyval == GDK_Alt_L || event->key.keyval == GDK_Alt_R)
+      /* Catch alt press to enable auto-mnemonics;
+       * menus are handled elsewhere
+       */
+      if ((event->key.keyval == GDK_Alt_L || event->key.keyval == GDK_Alt_R) &&
+          !GTK_IS_MENU_SHELL (grab_widget))
         {
           gboolean auto_mnemonics;
 
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index f5dbce8..db3a9f9 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -831,8 +831,12 @@ _gtk_menu_shell_update_mnemonics (GtkMenuShell *menu_shell)
        * not in the entire window.
        */
       if (GTK_IS_MENU_BAR (target))
-        _gtk_label_mnemonics_visible_apply_recursively (GTK_WIDGET (target),
-                                                        mnemonics_visible);
+        {
+          gtk_window_set_mnemonics_visible (GTK_WINDOW (gtk_widget_get_toplevel (target)),
+                                            FALSE);
+          _gtk_label_mnemonics_visible_apply_recursively (GTK_WIDGET (target),
+                                                          mnemonics_visible);
+        }
       else
         gtk_window_set_mnemonics_visible (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (target))),
                                           mnemonics_visible);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index f5ec59f..c70d660 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -42,6 +42,7 @@
 #include "gtkkeyhash.h"
 #include "gtkmain.h"
 #include "gtkmnemonichash.h"
+#include "gtkmenubar.h"
 #include "gtkiconfactory.h"
 #include "gtkicontheme.h"
 #include "gtkmarshalers.h"
@@ -235,8 +236,6 @@ static gint gtk_window_client_event	  (GtkWidget	     *widget,
 static void gtk_window_check_resize       (GtkContainer      *container);
 static gint gtk_window_focus              (GtkWidget        *widget,
 				           GtkDirectionType  direction);
-static void gtk_window_grab_notify        (GtkWidget         *widget,
-                                           gboolean           was_grabbed);
 static void gtk_window_real_set_focus     (GtkWindow         *window,
 					   GtkWidget         *focus);
 
@@ -464,7 +463,6 @@ gtk_window_class_init (GtkWindowClass *klass)
   widget_class->client_event = gtk_window_client_event;
   widget_class->focus = gtk_window_focus;
   widget_class->expose_event = gtk_window_expose;
-  widget_class->grab_notify = gtk_window_grab_notify;
 
   container_class->check_resize = gtk_window_check_resize;
 
@@ -5332,7 +5330,6 @@ gtk_window_focus_out_event (GtkWidget     *widget,
   if (auto_mnemonics)
     gtk_window_set_mnemonics_visible (window, FALSE);
 
-
   return FALSE;
 }
 
@@ -8506,22 +8503,6 @@ gtk_window_set_mnemonics_visible (GtkWindow *window,
   priv->mnemonics_visible_set = TRUE;
 }
 
-static void
-gtk_window_grab_notify (GtkWidget *widget,
-                        gboolean   was_grabbed)
-{
-  gboolean auto_mnemonics;
-
-  if (was_grabbed)
-    return;
-
-  g_object_get (gtk_widget_get_settings (widget), "gtk-auto-mnemonics",
-                &auto_mnemonics, NULL);
-
- if (auto_mnemonics)
-   gtk_window_set_mnemonics_visible (GTK_WINDOW (widget), FALSE);
-}
-
 #if defined (G_OS_WIN32) && !defined (_WIN64)
 
 #undef gtk_window_set_icon_from_file



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