[gtk/shortcuts-rebased-again: 115/159] text: Convert bindings from signals to actions



commit 21adfc61caad98ddb787e4954fec5ad003165057
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 21 15:11:28 2019 +0000

    text: Convert bindings from signals to actions
    
    With this change, the context menu picks up the
    accels for the actions. The conversion is not
    complete, since we don't have actions for all
    bindings yet.

 gtk/gtktext.c | 136 +++++++++++++++++++++++++++++-----------------------------
 1 file changed, 67 insertions(+), 69 deletions(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 7b1cdfbb6b..d5767210fc 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1173,9 +1173,25 @@ gtk_text_class_init (GtkTextClass *class)
                   NULL,
                   G_TYPE_NONE, 0);
 
-  /*
-   * Key bindings
-   */
+  /* Actions */
+
+  gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
+                                   gtk_text_activate_clipboard_cut);
+  gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
+                                   gtk_text_activate_clipboard_copy);
+  gtk_widget_class_install_action (widget_class, "clipboard.paste", NULL,
+                                   gtk_text_activate_clipboard_paste);
+  gtk_widget_class_install_action (widget_class, "selection.delete", NULL,
+                                   gtk_text_activate_selection_delete);
+  gtk_widget_class_install_action (widget_class, "selection.select-all", NULL,
+                                   gtk_text_activate_selection_select_all);
+  gtk_widget_class_install_action (widget_class, "misc.insert-emoji", NULL,
+                                   gtk_text_activate_misc_insert_emoji);
+  gtk_widget_class_install_property_action (widget_class,
+                                            "misc.toggle-visibility",
+                                            "visibility");
+
+  /* Key bindings */
 
   /* Moving the insertion point */
   add_move_binding (widget_class, GDK_KEY_Right, 0,
@@ -1226,16 +1242,14 @@ gtk_text_class_init (GtkTextClass *class)
   add_move_binding (widget_class, GDK_KEY_KP_End, GDK_CONTROL_MASK,
                     GTK_MOVEMENT_BUFFER_ENDS, 1);
 
-  /* Select all
-   */
-  gtk_widget_class_add_binding (widget_class,
+  gtk_widget_class_bind_action (widget_class,
                                 GDK_KEY_a, GDK_CONTROL_MASK,
-                                (GtkShortcutFunc) gtk_text_select_all,
+                                "selection.select-all",
                                 NULL);
 
-  gtk_widget_class_add_binding (widget_class,
+  gtk_widget_class_bind_action (widget_class,
                                 GDK_KEY_slash, GDK_CONTROL_MASK,
-                                (GtkShortcutFunc) gtk_text_select_all,
+                                "selection.select-all",
                                 NULL);
 
   /* Unselect all 
@@ -1304,44 +1318,44 @@ gtk_text_class_init (GtkTextClass *class)
                                        "(ii)", GTK_DELETE_WORD_ENDS, -1);
 
   /* Cut/copy/paste */
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_x, GDK_CONTROL_MASK,
-                                       "cut-clipboard",
-                                       NULL);
-  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_v, GDK_CONTROL_MASK,
-                                       "paste-clipboard",
-                                       NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_x, GDK_CONTROL_MASK,
+                                "clipboard.cut",
+                                NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_c, GDK_CONTROL_MASK,
+                                "clipboard.copy",
+                                NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_v, GDK_CONTROL_MASK,
+                                "clipboard.paste",
+                                NULL);
 
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_Delete, GDK_SHIFT_MASK,
-                                       "cut-clipboard",
-                                       NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_Insert, GDK_CONTROL_MASK,
-                                       "copy-clipboard",
-                                       NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_Insert, GDK_SHIFT_MASK,
-                                       "paste-clipboard",
-                                       NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_Delete, GDK_SHIFT_MASK,
+                                "clipboard.cut",
+                                NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_Insert, GDK_CONTROL_MASK,
+                                "clipboard.copy",
+                                NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_Insert, GDK_SHIFT_MASK,
+                                "clipboard.paste",
+                                NULL);
 
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
-                                       "cut-clipboard",
-                                       NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_KP_Insert, GDK_CONTROL_MASK,
-                                       "copy-clipboard",
-                                       NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_KP_Insert, GDK_SHIFT_MASK,
-                                       "paste-clipboard",
-                                       NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
+                                "clipboard.cut",
+                                NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_KP_Insert, GDK_CONTROL_MASK,
+                                "clipboard.copy",
+                                NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_KP_Insert, GDK_SHIFT_MASK,
+                                "clipboard.paste",
+                                NULL);
 
   /* Overwrite */
   gtk_widget_class_add_binding_signal (widget_class,
@@ -1354,33 +1368,17 @@ gtk_text_class_init (GtkTextClass *class)
                                        NULL);
 
   /* Emoji */
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_period, GDK_CONTROL_MASK,
-                                       "insert-emoji",
-                                       NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
-                                       GDK_KEY_semicolon, GDK_CONTROL_MASK,
-                                       "insert-emoji",
-                                       NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_period, GDK_CONTROL_MASK,
+                                "misc.insert-emoji",
+                                NULL);
+  gtk_widget_class_bind_action (widget_class,
+                                GDK_KEY_semicolon, GDK_CONTROL_MASK,
+                                "misc.insert-emoji",
+                                NULL);
 
   gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_ACCESSIBLE);
   gtk_widget_class_set_css_name (widget_class, I_("text"));
-
-  gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
-                                   gtk_text_activate_clipboard_cut);
-  gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
-                                   gtk_text_activate_clipboard_copy);
-  gtk_widget_class_install_action (widget_class, "clipboard.paste", NULL,
-                                   gtk_text_activate_clipboard_paste);
-  gtk_widget_class_install_action (widget_class, "selection.delete", NULL,
-                                   gtk_text_activate_selection_delete);
-  gtk_widget_class_install_action (widget_class, "selection.select-all", NULL,
-                                   gtk_text_activate_selection_select_all);
-  gtk_widget_class_install_action (widget_class, "misc.insert-emoji", NULL,
-                                   gtk_text_activate_misc_insert_emoji);
-  gtk_widget_class_install_property_action (widget_class,
-                                            "misc.toggle-visibility",
-                                            "visibility");
 }
 
 static void


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