[gtksourceview/wip/chergert/gsv-gtk4: 206/259] view: integrate assistants better with key presses and dispose




commit afa1d3b31077c4442e04728051cda7ddbf205e85
Author: Christian Hergert <chergert redhat com>
Date:   Sun Aug 30 14:39:18 2020 -0700

    view: integrate assistants better with key presses and dispose

 gtksourceview/gtksourceview.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index d8aa6460..310c3f40 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -1399,7 +1399,12 @@ gtk_source_view_dispose (GObject *object)
        GtkSourceView *view = GTK_SOURCE_VIEW (object);
        GtkSourceViewPrivate *priv = gtk_source_view_get_instance_private (view);
 
-       g_clear_object (&priv->completion);
+       if (priv->completion != NULL)
+       {
+               g_object_run_dispose (G_OBJECT (priv->completion));
+               g_clear_object (&priv->completion);
+       }
+
        g_clear_object (&priv->style_scheme);
        g_clear_object (&priv->space_drawer);
 
@@ -1413,6 +1418,8 @@ gtk_source_view_dispose (GObject *object)
         */
        g_signal_handlers_disconnect_by_func (view, notify_buffer_cb, NULL);
 
+       _gtk_source_view_assistants_shutdown (&priv->assistants);
+
        G_OBJECT_CLASS (gtk_source_view_parent_class)->dispose (object);
 }
 
@@ -3879,10 +3886,10 @@ do_ctrl_backspace (GtkSourceView *view)
 
 static gboolean
 gtk_source_view_key_pressed (GtkSourceView         *view,
-                            guint                  key,
-                            guint                  keycode,
-                            guint                  state,
-                            GtkEventControllerKey *controller)
+                             guint                  key,
+                             guint                  keycode,
+                             guint                  state,
+                             GtkEventControllerKey *controller)
 {
        GtkSourceViewPrivate *priv = gtk_source_view_get_instance_private (view);
        GtkTextBuffer *buf;
@@ -3891,6 +3898,11 @@ gtk_source_view_key_pressed (GtkSourceView         *view,
        guint modifiers;
        gboolean editable;
 
+       if (_gtk_source_view_assistants_handle_key (&priv->assistants, key, state))
+       {
+               return TRUE;
+       }
+
        buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
 
        editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (view));


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