[gtk/wip/ebassi/shortcut: 36/85] label: Port bindings to use shortcuts



commit 41733b9f920a6f92ecbc33fed1e94663fcf47f73
Author: Benjamin Otte <otte redhat com>
Date:   Sun Aug 12 16:55:43 2018 +0200

    label: Port bindings to use shortcuts

 gtk/gtklabel.c | 142 ++++++++++++++++++++++++++-------------------------------
 1 file changed, 64 insertions(+), 78 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 6e76d8ae3f..8b173eddfd 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -26,7 +26,6 @@
 
 #include "gtklabelprivate.h"
 
-#include "gtkbindings.h"
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
 #include "gtkcssnodeprivate.h"
@@ -605,7 +604,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_WIDGET,
                                                 gtk_label_buildable_interface_init))
 
 static void
-add_move_binding (GtkBindingSet  *binding_set,
+add_move_binding (GtkWidgetClass *widget_class,
                  guint           keyval,
                  guint           modmask,
                  GtkMovementStep step,
@@ -613,18 +612,16 @@ add_move_binding (GtkBindingSet  *binding_set,
 {
   g_return_if_fail ((modmask & GDK_SHIFT_MASK) == 0);
   
-  gtk_binding_entry_add_signal (binding_set, keyval, modmask,
-                               "move-cursor", 3,
-                               G_TYPE_ENUM, step,
-                               G_TYPE_INT, count,
-                               G_TYPE_BOOLEAN, FALSE);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       keyval, modmask,
+                                      "move-cursor",
+                                       "(iib)", step, count, FALSE);
 
   /* Selection-extending version */
-  gtk_binding_entry_add_signal (binding_set, keyval, modmask | GDK_SHIFT_MASK,
-                               "move-cursor", 3,
-                               G_TYPE_ENUM, step,
-                               G_TYPE_INT, count,
-                               G_TYPE_BOOLEAN, TRUE);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       keyval, modmask | GDK_SHIFT_MASK,
+                                      "move-cursor",
+                                       "(iib)", step, count, TRUE);
 }
 
 static void
@@ -632,7 +629,6 @@ gtk_label_class_init (GtkLabelClass *class)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
-  GtkBindingSet *binding_set;
 
   gobject_class->set_property = gtk_label_set_property;
   gobject_class->get_property = gtk_label_get_property;
@@ -1028,117 +1024,107 @@ gtk_label_class_init (GtkLabelClass *class)
   /*
    * Key bindings
    */
-  binding_set = gtk_binding_set_by_class (class);
 
   /* Moving the insertion point */
-  add_move_binding (binding_set, GDK_KEY_Right, 0,
+  add_move_binding (widget_class, GDK_KEY_Right, 0,
                    GTK_MOVEMENT_VISUAL_POSITIONS, 1);
 
-  add_move_binding (binding_set, GDK_KEY_Left, 0,
+  add_move_binding (widget_class, GDK_KEY_Left, 0,
                    GTK_MOVEMENT_VISUAL_POSITIONS, -1);
 
-  add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
+  add_move_binding (widget_class, GDK_KEY_KP_Right, 0,
                    GTK_MOVEMENT_VISUAL_POSITIONS, 1);
   
-  add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
+  add_move_binding (widget_class, GDK_KEY_KP_Left, 0,
                    GTK_MOVEMENT_VISUAL_POSITIONS, -1);
   
-  add_move_binding (binding_set, GDK_KEY_f, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_f, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
   
-  add_move_binding (binding_set, GDK_KEY_b, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_b, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_LOGICAL_POSITIONS, -1);
   
-  add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_Right, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_WORDS, 1);
 
-  add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_Left, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_WORDS, -1);
 
-  add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_WORDS, 1);
 
-  add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_WORDS, -1);
 
   /* select all */
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
-                               "move-cursor", 3,
-                               G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
-                               G_TYPE_INT, -1,
-                               G_TYPE_BOOLEAN, FALSE);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
-                               "move-cursor", 3,
-                               G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
-                               G_TYPE_INT, 1,
-                               G_TYPE_BOOLEAN, TRUE);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
-                               "move-cursor", 3,
-                               G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
-                               G_TYPE_INT, -1,
-                               G_TYPE_BOOLEAN, FALSE);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
-                               "move-cursor", 3,
-                               G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
-                               G_TYPE_INT, 1,
-                               G_TYPE_BOOLEAN, TRUE);
+  gtk_widget_class_add_binding (widget_class,
+                                GDK_KEY_a, GDK_CONTROL_MASK,
+                                (GtkShortcutFunc) gtk_label_select_all,
+                                NULL);
+  gtk_widget_class_add_binding (widget_class,
+                                GDK_KEY_slash, GDK_CONTROL_MASK,
+                                (GtkShortcutFunc) gtk_label_select_all,
+                                NULL);
 
   /* unselect all */
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
-                               "move-cursor", 3,
-                               G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
-                               G_TYPE_INT, 0,
-                               G_TYPE_BOOLEAN, FALSE);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK,
-                               "move-cursor", 3,
-                               G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
-                               G_TYPE_INT, 0,
-                               G_TYPE_BOOLEAN, FALSE);
-
-  add_move_binding (binding_set, GDK_KEY_f, GDK_MOD1_MASK,
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
+                                      "move-cursor",
+                                       "(iib)", GTK_MOVEMENT_PARAGRAPH_ENDS, 0, FALSE);
+
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_backslash, GDK_CONTROL_MASK,
+                                      "move-cursor",
+                                       "(iib)", GTK_MOVEMENT_PARAGRAPH_ENDS, 0, FALSE);
+
+  add_move_binding (widget_class, GDK_KEY_f, GDK_MOD1_MASK,
                    GTK_MOVEMENT_WORDS, 1);
 
-  add_move_binding (binding_set, GDK_KEY_b, GDK_MOD1_MASK,
+  add_move_binding (widget_class, GDK_KEY_b, GDK_MOD1_MASK,
                    GTK_MOVEMENT_WORDS, -1);
 
-  add_move_binding (binding_set, GDK_KEY_Home, 0,
+  add_move_binding (widget_class, GDK_KEY_Home, 0,
                    GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
 
-  add_move_binding (binding_set, GDK_KEY_End, 0,
+  add_move_binding (widget_class, GDK_KEY_End, 0,
                    GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
 
-  add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
+  add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
                    GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
 
-  add_move_binding (binding_set, GDK_KEY_KP_End, 0,
+  add_move_binding (widget_class, GDK_KEY_KP_End, 0,
                    GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
   
-  add_move_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_Home, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_BUFFER_ENDS, -1);
 
-  add_move_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_End, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_BUFFER_ENDS, 1);
 
-  add_move_binding (binding_set, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_BUFFER_ENDS, -1);
 
-  add_move_binding (binding_set, GDK_KEY_KP_End, GDK_CONTROL_MASK,
+  add_move_binding (widget_class, GDK_KEY_KP_End, GDK_CONTROL_MASK,
                    GTK_MOVEMENT_BUFFER_ENDS, 1);
 
   /* copy */
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
-                               "copy-clipboard", 0);
-
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
-                               "activate-current-link", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
-                               "activate-current-link", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
-                               "activate-current-link", 0);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_c, GDK_CONTROL_MASK,
+                                      "copy-clipboard",
+                                       NULL);
+
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_Return, 0,
+                                      "activate-current-link",
+                                       NULL);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_ISO_Enter, 0,
+                                      "activate-current-link",
+                                       NULL);
+  gtk_widget_class_add_binding_signal (widget_class,
+                                       GDK_KEY_KP_Enter, 0,
+                                      "activate-current-link",
+                                       NULL);
 
   gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LABEL_ACCESSIBLE);
 


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