[gtk/shortcuts-rebased-again: 27/91] menubar: Port bindings to use shortcuts



commit ba7cb52d9f0418616dc82f692cd7c3081d42b5f9
Author: Benjamin Otte <otte redhat com>
Date:   Sun Aug 12 16:28:00 2018 +0200

    menubar: Port bindings to use shortcuts

 gtk/gtkmenubar.c | 99 +++++++++++++++++++++++---------------------------------
 1 file changed, 40 insertions(+), 59 deletions(-)
---
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index 970c98ed00..7c400e194f 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -42,7 +42,6 @@
 #include "gtkmenubar.h"
 #include "gtkmenubarprivate.h"
 
-#include "gtkbindings.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
 #include "gtkmenuitemprivate.h"
@@ -113,12 +112,6 @@ gtk_menu_bar_get_items (GtkMenuShell *menu_shell)
   return gtk_container_get_children (GTK_CONTAINER (menu_bar->box));
 }
 
-static void
-gtk_menu_bar_finalize (GObject *object)
-{
-  G_OBJECT_CLASS (gtk_menu_bar_parent_class)->finalize (object);
-}
-
 static void
 gtk_menu_bar_dispose (GObject *object)
 {
@@ -148,9 +141,6 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
   GtkMenuShellClass *menu_shell_class = GTK_MENU_SHELL_CLASS (class);
 
-  GtkBindingSet *binding_set;
-
-  object_class->finalize = gtk_menu_bar_finalize;
   object_class->dispose = gtk_menu_bar_dispose;
 
   widget_class->measure = gtk_menu_bar_measure;
@@ -168,47 +158,38 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
   menu_shell_class->move_current = gtk_menu_bar_move_current;
   menu_shell_class->get_items = gtk_menu_bar_get_items;
 
-  binding_set = gtk_binding_set_by_class (class);
-  gtk_binding_entry_add_signal (binding_set,
-                               GDK_KEY_Left, 0,
-                               "move-current", 1,
-                               GTK_TYPE_MENU_DIRECTION_TYPE,
-                               GTK_MENU_DIR_PREV);
-  gtk_binding_entry_add_signal (binding_set,
-                               GDK_KEY_KP_Left, 0,
-                               "move-current", 1,
-                               GTK_TYPE_MENU_DIRECTION_TYPE,
-                               GTK_MENU_DIR_PREV);
-  gtk_binding_entry_add_signal (binding_set,
-                               GDK_KEY_Right, 0,
-                               "move-current", 1,
-                               GTK_TYPE_MENU_DIRECTION_TYPE,
-                               GTK_MENU_DIR_NEXT);
-  gtk_binding_entry_add_signal (binding_set,
-                               GDK_KEY_KP_Right, 0,
-                               "move-current", 1,
-                               GTK_TYPE_MENU_DIRECTION_TYPE,
-                               GTK_MENU_DIR_NEXT);
-  gtk_binding_entry_add_signal (binding_set,
-                               GDK_KEY_Up, 0,
-                               "move-current", 1,
-                               GTK_TYPE_MENU_DIRECTION_TYPE,
-                               GTK_MENU_DIR_PARENT);
-  gtk_binding_entry_add_signal (binding_set,
-                               GDK_KEY_KP_Up, 0,
-                               "move-current", 1,
-                               GTK_TYPE_MENU_DIRECTION_TYPE,
-                               GTK_MENU_DIR_PARENT);
-  gtk_binding_entry_add_signal (binding_set,
-                               GDK_KEY_Down, 0,
-                               "move-current", 1,
-                               GTK_TYPE_MENU_DIRECTION_TYPE,
-                               GTK_MENU_DIR_CHILD);
-  gtk_binding_entry_add_signal (binding_set,
-                               GDK_KEY_KP_Down, 0,
-                               "move-current", 1,
-                               GTK_TYPE_MENU_DIRECTION_TYPE,
-                               GTK_MENU_DIR_CHILD);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_Left, 0,
+                                       "move-current",
+                                       "(i)", GTK_MENU_DIR_PREV);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_KP_Left, 0,
+                                       "move-current",
+                                       "(i)", GTK_MENU_DIR_PREV);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_Right, 0,
+                                       "move-current",
+                                       "(i)", GTK_MENU_DIR_NEXT);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_KP_Right, 0,
+                                       "move-current",
+                                       "(i)", GTK_MENU_DIR_NEXT);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_Up, 0,
+                                       "move-current",
+                                       "(i)", GTK_MENU_DIR_PARENT);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_KP_Up, 0,
+                                       "move-current",
+                                       "(i)", GTK_MENU_DIR_PARENT);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_Down, 0,
+                                       "move-current",
+                                       "(i)", GTK_MENU_DIR_CHILD);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_KP_Down, 0,
+                                       "move-current",
+                                       "(i)", GTK_MENU_DIR_CHILD);
 
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_MENU_BAR);
   gtk_widget_class_set_css_name (widget_class, I_("menubar"));
@@ -285,15 +266,15 @@ _gtk_menu_bar_get_viewable_menu_bars (GtkWindow *window)
       gboolean viewable = TRUE;
       
       while (widget)
-       {
-         if (!gtk_widget_get_mapped (widget))
-           viewable = FALSE;
+        {
+          if (!gtk_widget_get_mapped (widget))
+            viewable = FALSE;
 
           widget = gtk_widget_get_parent (widget);
-       }
+        }
 
       if (viewable)
-       viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
+        viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
     }
 
   return g_list_reverse (viewable_menu_bars);
@@ -301,7 +282,7 @@ _gtk_menu_bar_get_viewable_menu_bars (GtkWindow *window)
 
 static void
 set_menu_bars (GtkWindow *window,
-              GList     *menubars)
+               GList     *menubars)
 {
   g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
 }
@@ -358,7 +339,7 @@ gtk_menu_bar_unroot (GtkWidget *widget)
  **/
 void
 _gtk_menu_bar_cycle_focus (GtkMenuBar       *menubar,
-                          GtkDirectionType  dir)
+                           GtkDirectionType  dir)
 {
   GtkWidget *toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (menubar)));
   GtkMenuItem *to_activate = NULL;
@@ -408,7 +389,7 @@ gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
 
 static void
 gtk_menu_bar_move_current (GtkMenuShell         *menu_shell,
-                          GtkMenuDirectionType  direction)
+                           GtkMenuDirectionType  direction)
 {
   GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
 


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