[gtk+/gtk-3-10: 3/5] Allow applications to use gtk-menu-bar-accel in 3.10



commit 3b6156fdb5cf3685ccf1edd17f364e7441e2cf24
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Sep 23 13:10:19 2013 -0400

    Allow applications to use gtk-menu-bar-accel in 3.10
    
    gnome-terminal is still using this setting, so we'll let
    applications override it for another cycle. It is no longer
    backed by a system-wide setting, though, and it will still
    go away eventually.
    
    This partically reverts b26c74e5dac0b5fd869d2c8cc7a0edb6b01aeebd

 gtk/gtkmenubar.c  |   53 ++++++++++++++++++++++++++++++++++++-----------------
 gtk/gtksettings.c |    5 +++--
 2 files changed, 39 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index 24872af..8aa9c40 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -696,35 +696,54 @@ window_key_press_handler (GtkWidget   *widget,
                           GdkEventKey *event,
                           gpointer     data)
 {
+  gchar *accel = NULL;
   gboolean retval = FALSE;
-  guint keyval = GDK_KEY_F10;
 
-  /* FIXME this is wrong, needs to be in the global accel resolution
-   * thing, to properly consider i18n etc., but that probably requires
-   * AccelGroup changes etc.
-   */
-  if (event->keyval == keyval && event->state == 0)
+  g_object_get (gtk_widget_get_settings (widget),
+                "gtk-menu-bar-accel", &accel,
+                NULL);
+
+  if (accel && *accel)
     {
-      GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
-      GList *menubars;
+      guint keyval = 0;
+      GdkModifierType mods = 0;
 
-      menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
-                                            GTK_DIR_TAB_FORWARD, NULL);
-      g_list_free (tmp_menubars);
+      gtk_accelerator_parse (accel, &keyval, &mods);
 
-      if (menubars)
+      if (keyval == 0)
+        g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
+
+      /* FIXME this is wrong, needs to be in the global accel resolution
+       * thing, to properly consider i18n etc., but that probably requires
+       * AccelGroup changes etc.
+       */
+      if (event->keyval == keyval &&
+          ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
+          (mods & gtk_accelerator_get_default_mod_mask ())))
         {
-          GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
+          GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
+          GList *menubars;
 
-          _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
-          gtk_menu_shell_select_first (menu_shell, FALSE);
+          menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
+                                                GTK_DIR_TAB_FORWARD, NULL);
+          g_list_free (tmp_menubars);
 
-          g_list_free (menubars);
+          if (menubars)
+            {
+              GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
+
+              _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
+              gtk_menu_shell_select_first (menu_shell, FALSE);
+
+              g_list_free (menubars);
 
-          retval = TRUE;
+              retval = TRUE;
+            }
         }
     }
 
+  g_free (accel);
+
   return retval;
 }
 
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 57ad653..2794dfa 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -473,14 +473,15 @@ gtk_settings_class_init (GtkSettingsClass *class)
    *
    * Keybinding to activate the menu bar.
    *
-   * Deprecated: 3.10: This setting is ignored.
+   * Deprecated: 3.10: This setting can still be used for application
+   *      overrides, but will be ignored in the future
    */
   result = settings_install_property_parser (class,
                                              g_param_spec_string ("gtk-menu-bar-accel",
                                                                   P_("Menu bar accelerator"),
                                                                   P_("Keybinding to activate the menu bar"),
                                                                   "F10",
-                                                                  GTK_PARAM_READWRITE | G_PARAM_DEPRECATED),
+                                                                  GTK_PARAM_READWRITE),
                                              NULL);
   g_assert (result == PROP_MENU_BAR_ACCEL);
 


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