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



commit 34b64738cc50f5b17e8ac82a1dc467ab8a9c8029
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.

 gtk/gtktext.c | 112 ++++++++++++++++++++++++++++------------------------------
 1 file changed, 55 insertions(+), 57 deletions(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 3c8d152069..f3c7da3767 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1182,9 +1182,27 @@ gtk_text_class_init (GtkTextClass *class)
                   NULL,
                   G_TYPE_NONE, 0);
 
-  /*
-   * Key bindings
-   */
+  /* Actions */
+
+  gtk_widget_class_install_action (widget_class, "clipboard.cut",
+                                   gtk_text_activate_clipboard_cut);
+  gtk_widget_class_install_action (widget_class, "clipboard.copy",
+                                   gtk_text_activate_clipboard_copy);
+  gtk_widget_class_install_action (widget_class, "clipboard.paste",
+                                   gtk_text_activate_clipboard_paste);
+  gtk_widget_class_install_action (widget_class, "selection.delete",
+                                   gtk_text_activate_selection_delete);
+  gtk_widget_class_install_action (widget_class, "selection.select-all",
+                                   gtk_text_activate_selection_select_all);
+  gtk_widget_class_install_action (widget_class, "misc.insert-emoji",
+                                   gtk_text_activate_misc_insert_emoji);
+  gtk_widget_class_install_stateful_action (widget_class, "misc.toggle-visibility",
+                                            gtk_text_activate_misc_toggle_visibility,
+                                            NULL,
+                                            gtk_text_set_misc_toggle_visibility,
+                                            gtk_text_get_misc_toggle_visibility);
+
+  /* Key bindings */
 
   /* Moving the insertion point */
   add_move_binding (widget_class, GDK_KEY_Right, 0,
@@ -1235,17 +1253,15 @@ 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,
-                                GDK_KEY_a, GDK_CONTROL_MASK,
-                                (GtkShortcutFunc) gtk_text_select_all,
-                                NULL);
+  gtk_widget_class_add_binding_action (widget_class,
+                                       GDK_KEY_a, GDK_CONTROL_MASK,
+                                       "selection.select-all",
+                                       NULL);
 
-  gtk_widget_class_add_binding (widget_class,
-                                GDK_KEY_slash, GDK_CONTROL_MASK,
-                                (GtkShortcutFunc) gtk_text_select_all,
-                                NULL);
+  gtk_widget_class_add_binding_action (widget_class,
+                                       GDK_KEY_slash, GDK_CONTROL_MASK,
+                                       "selection.select-all",
+                                       NULL);
 
   /* Unselect all 
    */
@@ -1313,85 +1329,67 @@ gtk_text_class_init (GtkTextClass *class)
                                        "(ii)", GTK_DELETE_WORD_ENDS, -1);
 
   /* Cut/copy/paste */
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_x, GDK_CONTROL_MASK,
-                                       "cut-clipboard",
+                                       "clipboard.cut",
                                        NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_c, GDK_CONTROL_MASK,
-                                       "copy-clipboard",
+                                       "clipboard.copy",
                                        NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_v, GDK_CONTROL_MASK,
-                                       "paste-clipboard",
+                                       "clipboard.paste",
                                        NULL);
 
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_Delete, GDK_SHIFT_MASK,
-                                       "cut-clipboard",
+                                       "clipboard.cut",
                                        NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_Insert, GDK_CONTROL_MASK,
-                                       "copy-clipboard",
+                                       "clipboard.copy",
                                        NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_Insert, GDK_SHIFT_MASK,
-                                       "paste-clipboard",
+                                       "clipboard.paste",
                                        NULL);
 
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
-                                       "cut-clipboard",
+                                       "clipboard.cut",
                                        NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_KP_Insert, GDK_CONTROL_MASK,
-                                       "copy-clipboard",
+                                       "clipboard.copy",
                                        NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_KP_Insert, GDK_SHIFT_MASK,
-                                       "paste-clipboard",
+                                       "clipboard.paste",
                                        NULL);
 
   /* Overwrite */
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_Insert, 0,
-                                       "toggle-overwrite",
+                                       "misc.toggle-overwrite",
                                        NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_KP_Insert, 0,
-                                       "toggle-overwrite",
+                                       "misc.toggle-overwrite",
                                        NULL);
 
   /* Emoji */
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_period, GDK_CONTROL_MASK,
-                                       "insert-emoji",
+                                       "misc.insert-emoji",
                                        NULL);
-  gtk_widget_class_add_binding_signal (widget_class,
+  gtk_widget_class_add_binding_action (widget_class,
                                        GDK_KEY_semicolon, GDK_CONTROL_MASK,
-                                       "insert-emoji",
+                                       "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",
-                                   gtk_text_activate_clipboard_cut);
-  gtk_widget_class_install_action (widget_class, "clipboard.copy",
-                                   gtk_text_activate_clipboard_copy);
-  gtk_widget_class_install_action (widget_class, "clipboard.paste",
-                                   gtk_text_activate_clipboard_paste);
-  gtk_widget_class_install_action (widget_class, "selection.delete",
-                                   gtk_text_activate_selection_delete);
-  gtk_widget_class_install_action (widget_class, "selection.select-all",
-                                   gtk_text_activate_selection_select_all);
-  gtk_widget_class_install_action (widget_class, "misc.insert-emoji",
-                                   gtk_text_activate_misc_insert_emoji);
-  gtk_widget_class_install_stateful_action (widget_class, "misc.toggle-visibility",
-                                            gtk_text_activate_misc_toggle_visibility,
-                                            NULL,
-                                            gtk_text_set_misc_toggle_visibility,
-                                            gtk_text_get_misc_toggle_visibility);
 }
 
 static void


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