[gtksourceview/wip/chergert/gsv-gtk4: 175/194] completion: track changes to shortcut activation



commit d413eeedea67e370e53f17d4843dfea6621c9ba4
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 6 11:55:18 2020 -0700

    completion: track changes to shortcut activation
    
    There will be further followup work here, but one of the big side-effects
    is that we'll have to redesign event propagation for completion. It might
    make sense to just overhaul completion at the same time given how much
    the end APIs will change from things like:
    
     - Window placement with new GDK APIs
     - Icon changes from GTK icon theme
     - Shortcut and keyboard activation
     - List model usage for reduced overhead
     - Removal of treeview

 gtksourceview/gtksourcecompletion.c |  11 +-
 gtksourceview/gtksourceview.c       | 323 +++++++++++++++++++-----------------
 2 files changed, 182 insertions(+), 152 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index feac1f26..f3e7147a 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -1253,6 +1253,7 @@ view_key_press_event_cb (GtkEventController  *key,
                          GdkModifierType      state,
                          GtkSourceCompletion *completion)
 {
+#if 0
        static gboolean mnemonic_keyval_set = FALSE;
        static guint mnemonic_keyval = GDK_KEY_VoidSymbol;
        GdkModifierType mod;
@@ -1306,6 +1307,7 @@ view_key_press_event_cb (GtkEventController  *key,
        {
                return TRUE;
        }
+#endif
 
        return FALSE;
 }
@@ -2229,7 +2231,6 @@ static void
 gtk_source_completion_class_init (GtkSourceCompletionClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       GtkBindingSet *binding_set;
 
        object_class->get_property = gtk_source_completion_get_property;
        object_class->set_property = gtk_source_completion_set_property;
@@ -2541,6 +2542,13 @@ gtk_source_completion_class_init (GtkSourceCompletionClass *klass)
                                            G_CALLBACK (gtk_source_completion_activate_proposal),
                                            NULL, NULL, NULL, G_TYPE_NONE, 0);
 
+#if 0
+
+       /* XXX: We cannot do keybindings with GObject's any more. This will
+        * need to be redesigned to keep events happening either from the
+        * completion info class or from the sourceview itself.
+        */
+
        /* Key bindings */
        binding_set = gtk_binding_set_by_class (klass);
 
@@ -2641,6 +2649,7 @@ gtk_source_completion_class_init (GtkSourceCompletionClass *klass)
                                      2,
                                      GTK_TYPE_SCROLL_STEP, GTK_SCROLL_ENDS,
                                      G_TYPE_INT, 1);
+#endif
 
        g_type_ensure (GTK_SOURCE_TYPE_COMPLETION_INFO);
 }
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index d85c836f..ae1fe6d0 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -478,7 +478,6 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
 {
        GObjectClass *object_class;
        GtkTextViewClass *textview_class;
-       GtkBindingSet *binding_set;
        GtkWidgetClass *widget_class;
 
        object_class = G_OBJECT_CLASS (klass);
@@ -939,156 +938,178 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
        gtk_widget_class_install_action (widget_class, "source.change-case", "s",
                                         gtk_source_view_activate_change_case);
 
-       binding_set = gtk_binding_set_by_class (klass);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_space,
-                                     GDK_CONTROL_MASK,
-                                     "show-completion", 0);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Up,
-                                     GDK_MOD1_MASK,
-                                     "move-lines", 1,
-                                     G_TYPE_BOOLEAN, FALSE);
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Up,
-                                     GDK_MOD1_MASK,
-                                     "move-lines", 1,
-                                     G_TYPE_BOOLEAN, FALSE);
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Down,
-                                     GDK_MOD1_MASK,
-                                     "move-lines", 1,
-                                     G_TYPE_BOOLEAN, TRUE);
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Down,
-                                     GDK_MOD1_MASK,
-                                     "move-lines", 1,
-                                     G_TYPE_BOOLEAN, TRUE);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Left,
-                                     GDK_MOD1_MASK,
-                                     "move-words", 1,
-                                     G_TYPE_INT, -1);
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Left,
-                                     GDK_MOD1_MASK,
-                                     "move-words", 1,
-                                     G_TYPE_INT, -1);
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Right,
-                                     GDK_MOD1_MASK,
-                                     "move-words", 1,
-                                     G_TYPE_INT, 1);
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Right,
-                                     GDK_MOD1_MASK,
-                                     "move-words", 1,
-                                     G_TYPE_INT, 1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Up,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_STEPS,
-                                     G_TYPE_INT, -1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Up,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_STEPS,
-                                     G_TYPE_INT, -1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Down,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_STEPS,
-                                     G_TYPE_INT, 1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Down,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_STEPS,
-                                     G_TYPE_INT, 1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Page_Up,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_PAGES,
-                                     G_TYPE_INT, -1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Page_Up,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_PAGES,
-                                     G_TYPE_INT, -1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Page_Down,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_PAGES,
-                                     G_TYPE_INT, 1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Page_Down,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_PAGES,
-                                     G_TYPE_INT, 1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_Home,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_ENDS,
-                                     G_TYPE_INT, -1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_Home,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_ENDS,
-                                     G_TYPE_INT, -1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_End,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_ENDS,
-                                     G_TYPE_INT, 1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_KP_End,
-                                     GDK_MOD1_MASK | GDK_SHIFT_MASK,
-                                     "move-viewport", 2,
-                                     GTK_TYPE_SCROLL_STEP, GTK_SCROLL_ENDS,
-                                     G_TYPE_INT, 1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_percent,
-                                     GDK_CONTROL_MASK,
-                                     "move-to-matching-bracket", 1,
-                                     G_TYPE_BOOLEAN, FALSE);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_a,
-                                     GDK_CONTROL_MASK | GDK_SHIFT_MASK,
-                                     "change-number", 1,
-                                     G_TYPE_INT, 1);
-
-       gtk_binding_entry_add_signal (binding_set,
-                                     GDK_KEY_x,
-                                     GDK_CONTROL_MASK | GDK_SHIFT_MASK,
-                                     "change-number", 1,
-                                     G_TYPE_INT, -1);
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_CONTROL_MASK,
+                                            GDK_KEY_space,
+                                            "show-completion",
+                                            NULL);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK,
+                                            GDK_KEY_Up,
+                                            "move-lines",
+                                            "(b)",
+                                            FALSE);
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK,
+                                            GDK_KEY_KP_Up,
+                                            "move-lines",
+                                            "(b)",
+                                            FALSE);
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK,
+                                            GDK_KEY_Down,
+                                            "move-lines",
+                                            "(b)",
+                                            TRUE);
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK,
+                                            GDK_KEY_KP_Down,
+                                            "move-lines",
+                                            "(b)",
+                                            TRUE);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK,
+                                            GDK_KEY_Left,
+                                            "move-words",
+                                            "(i)",
+                                            -1);
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK,
+                                            GDK_KEY_KP_Left,
+                                            "move-words",
+                                            "(i)",
+                                            -1);
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK,
+                                            GDK_KEY_Right,
+                                            "move-words",
+                                            "(i)",
+                                            1);
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK,
+                                            GDK_KEY_KP_Right,
+                                            "move-words",
+                                            "(i)",
+                                            1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_Up,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_STEPS,
+                                            -1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_KP_Up,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_STEPS,
+                                            -1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_Down,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_STEPS,
+                                            1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_KP_Down,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_STEPS,
+                                            1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_Page_Up,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_PAGES,
+                                            -1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_KP_Page_Up,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_PAGES,
+                                            -1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_Page_Down,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_PAGES,
+                                            1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_KP_Page_Down,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_PAGES,
+                                            1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_Home,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_ENDS,
+                                            -1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_KP_Home,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_ENDS,
+                                            -1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_End,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_ENDS,
+                                            1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_MOD1_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_KP_End,
+                                            "move-viewport",
+                                            "(ii)",
+                                            GTK_SCROLL_ENDS,
+                                            1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_CONTROL_MASK,
+                                            GDK_KEY_percent,
+                                            "move-to-matching-bracket",
+                                            "(b)",
+                                            FALSE);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_a,
+                                            "change-number",
+                                            "(i)",
+                                            1);
+
+       gtk_widget_class_add_binding_signal (widget_class,
+                                            GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+                                            GDK_KEY_x,
+                                            "change-number",
+                                            "(i)",
+                                            -1);
 }
 
 static GObject *


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