[gtk/shortcuts-rebased-again: 17/91] flowbox: Port bindings to use shortcuts



commit f4c13ddc3df65e19eff091fe67ca2a106a0d63e3
Author: Benjamin Otte <otte redhat com>
Date:   Sun Aug 12 03:45:09 2018 +0200

    flowbox: Port bindings to use shortcuts

 gtk/gtkflowbox.c | 112 +++++++++++++++++++++++++++----------------------------
 gtk/gtklistbox.c |   1 -
 2 files changed, 55 insertions(+), 58 deletions(-)
---
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 05a549a31d..5479009692 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -78,7 +78,6 @@
 #include "gtkflowbox.h"
 
 #include "gtkadjustment.h"
-#include "gtkbindings.h"
 #include "gtkcontainerprivate.h"
 #include "gtkcssnodeprivate.h"
 #include "gtkgesturedrag.h"
@@ -2987,7 +2986,7 @@ gtk_flow_box_focus (GtkWidget        *widget,
 }
 
 static void
-gtk_flow_box_add_move_binding (GtkBindingSet   *binding_set,
+gtk_flow_box_add_move_binding (GtkWidgetClass  *widget_class,
                                guint            keyval,
                                GdkModifierType  modmask,
                                GtkMovementStep  step,
@@ -2998,34 +2997,27 @@ gtk_flow_box_add_move_binding (GtkBindingSet   *binding_set,
   GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
 
   display = gdk_display_get_default ();
-  if (display)
-    {
-      extend_mod_mask = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
-                                                      GDK_MODIFIER_INTENT_EXTEND_SELECTION);
-      modify_mod_mask = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
-                                                      GDK_MODIFIER_INTENT_MODIFY_SELECTION);
-    }
-
-  gtk_binding_entry_add_signal (binding_set, keyval, modmask,
-                                "move-cursor", 2,
-                                GTK_TYPE_MOVEMENT_STEP, step,
-                                G_TYPE_INT, count,
-                                NULL);
-  gtk_binding_entry_add_signal (binding_set, keyval, modmask | extend_mod_mask,
-                                "move-cursor", 2,
-                                GTK_TYPE_MOVEMENT_STEP, step,
-                                G_TYPE_INT, count,
-                                NULL);
-  gtk_binding_entry_add_signal (binding_set, keyval, modmask | modify_mod_mask,
-                                "move-cursor", 2,
-                                GTK_TYPE_MOVEMENT_STEP, step,
-                                G_TYPE_INT, count,
-                                NULL);
-  gtk_binding_entry_add_signal (binding_set, keyval, modmask | extend_mod_mask | modify_mod_mask,
-                                "move-cursor", 2,
-                                GTK_TYPE_MOVEMENT_STEP, step,
-                                G_TYPE_INT, count,
-                                NULL);
+  extend_mod_mask = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
+                                                  GDK_MODIFIER_INTENT_EXTEND_SELECTION);
+  modify_mod_mask = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
+                                                  GDK_MODIFIER_INTENT_MODIFY_SELECTION);
+
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       keyval, modmask,
+                                       "move-cursor",
+                                       "(ii)", step, count);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       keyval, modmask | extend_mod_mask,
+                                       "move-cursor",
+                                       "(ii)", step, count);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       keyval, modmask | modify_mod_mask,
+                                       "move-cursor",
+                                       "(ii)", step, count);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       keyval, modmask | extend_mod_mask | modify_mod_mask,
+                                       "move-cursor",
+                                       "(ii)", step, count);
 }
 
 static void
@@ -3387,7 +3379,6 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
   GObjectClass      *object_class = G_OBJECT_CLASS (class);
   GtkWidgetClass    *widget_class = GTK_WIDGET_CLASS (class);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
-  GtkBindingSet     *binding_set;
 
   object_class->finalize = gtk_flow_box_finalize;
   object_class->get_property = gtk_flow_box_get_property;
@@ -3664,50 +3655,57 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
 
   widget_class->activate_signal = signals[ACTIVATE_CURSOR_CHILD];
 
-  binding_set = gtk_binding_set_by_class (class);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Home, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Home, 0,
                                  GTK_MOVEMENT_BUFFER_ENDS, -1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
                                  GTK_MOVEMENT_BUFFER_ENDS, -1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_End, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_End, 0,
                                  GTK_MOVEMENT_BUFFER_ENDS, 1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_End, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_End, 0,
                                  GTK_MOVEMENT_BUFFER_ENDS, 1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Up, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Up, 0,
                                  GTK_MOVEMENT_DISPLAY_LINES, -1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Up, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Up, 0,
                                  GTK_MOVEMENT_DISPLAY_LINES, -1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Down, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Down, 0,
                                  GTK_MOVEMENT_DISPLAY_LINES, 1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Down, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Down, 0,
                                  GTK_MOVEMENT_DISPLAY_LINES, 1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Page_Up, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Page_Up, 0,
                                  GTK_MOVEMENT_PAGES, -1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Page_Up, 0,
                                  GTK_MOVEMENT_PAGES, -1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Page_Down, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Page_Down, 0,
                                  GTK_MOVEMENT_PAGES, 1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0,
                                  GTK_MOVEMENT_PAGES, 1);
 
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Right, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Right, 0,
                                  GTK_MOVEMENT_VISUAL_POSITIONS, 1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Right, 0,
                                  GTK_MOVEMENT_VISUAL_POSITIONS, 1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Left, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Left, 0,
                                  GTK_MOVEMENT_VISUAL_POSITIONS, -1);
-  gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
+  gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Left, 0,
                                  GTK_MOVEMENT_VISUAL_POSITIONS, -1);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_CONTROL_MASK,
-                                "toggle-cursor-child", 0, NULL);
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, GDK_CONTROL_MASK,
-                                "toggle-cursor-child", 0, NULL);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
-                                "select-all", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
-                                "unselect-all", 0);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_space, GDK_CONTROL_MASK,
+                                       "toggle-cursor-child",
+                                       NULL);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_KP_Space, GDK_CONTROL_MASK,
+                                       "toggle-cursor-child",
+                                       NULL);
+
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_a, GDK_CONTROL_MASK,
+                                       "select-all",
+                                       NULL);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+                                       "unselect-all",
+                                       NULL);
 
   gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_FLOW_BOX_ACCESSIBLE);
   gtk_widget_class_set_css_name (widget_class, I_("flowbox"));
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 44743bfdae..3783dd3ece 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -21,7 +21,6 @@
 
 #include "gtkactionhelperprivate.h"
 #include "gtkadjustmentprivate.h"
-#include "gtkbindings.h"
 #include "gtkbuildable.h"
 #include "gtkcontainerprivate.h"
 #include "gtkcssnodeprivate.h"


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