[gtksourceview] signalgroup: port to GSignalGroup



commit 8f27e65ce5de58a7a66728c910a21c5a5bca1f23
Author: Christian Hergert <chergert redhat com>
Date:   Tue Sep 6 12:39:12 2022 -0700

    signalgroup: port to GSignalGroup
    
    Now that we have GSignalGroup in GObject directly, we no longer need to
    carry our copy of the implementation in-tree. Just use GObject's directly.

 gtksourceview/gtksourcecompletion.c          | 103 ++--
 gtksourceview/gtksourcegutter.c              |  27 +-
 gtksourceview/gtksourcehover.c               |   1 -
 gtksourceview/gtksourcesignalgroup-private.h |  62 --
 gtksourceview/gtksourcesignalgroup.c         | 849 ---------------------------
 gtksourceview/gtksourceview-private.h        |   3 +-
 gtksourceview/gtksourceview-snippets.c       |  22 +-
 gtksourceview/meson.build                    |   1 -
 8 files changed, 76 insertions(+), 992 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index b8c5ac5a..a699c058 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -30,7 +30,6 @@
 #include "gtksourcecompletionproposal.h"
 #include "gtksourcecompletionprovider.h"
 #include "gtksourcebuffer.h"
-#include "gtksourcesignalgroup-private.h"
 #include "gtksourceview-private.h"
 
 /**
@@ -105,17 +104,17 @@ struct _GtkSourceCompletion
         * our current context. That includes handling notification of the first
         * result so that we can show the window, etc.
         */
-       GtkSourceSignalGroup *context_signals;
+       GSignalGroup *context_signals;
 
        /* Signals to changes in the underlying GtkTextBuffer that we use to
         * determine where and how we can do completion.
         */
-       GtkSourceSignalGroup *buffer_signals;
+       GSignalGroup *buffer_signals;
 
        /* We need to track various events on the view to ensure that we don't
         * activate at incorrect times.
         */
-       GtkSourceSignalGroup *view_signals;
+       GSignalGroup *view_signals;
 
        /* The display popover for results */
        GtkSourceCompletionList *display;
@@ -403,7 +402,7 @@ _gtk_source_completion_set_context (GtkSourceCompletion        *self,
        if (g_set_object (&self->context, context))
        {
                g_clear_handle_id (&self->queued_update, g_source_remove);
-               gtk_source_signal_group_set_target (self->context_signals, context);
+               g_signal_group_set_target (self->context_signals, context);
        }
 }
 
@@ -896,7 +895,7 @@ gtk_source_completion_set_view (GtkSourceCompletion *self,
 
        if (g_set_weak_pointer (&self->view, view))
        {
-               gtk_source_signal_group_set_target (self->view_signals, view);
+               g_signal_group_set_target (self->view_signals, view);
                g_object_bind_property (view, "buffer",
                                        self->buffer_signals, "target",
                                        G_BINDING_SYNC_CREATE);
@@ -904,15 +903,15 @@ gtk_source_completion_set_view (GtkSourceCompletion *self,
 }
 
 static void
-on_buffer_signals_bind (GtkSourceCompletion  *self,
-                        GtkSourceBuffer      *buffer,
-                        GtkSourceSignalGroup *signals_)
+on_buffer_signals_bind (GtkSourceCompletion *self,
+                        GtkSourceBuffer     *buffer,
+                        GSignalGroup        *signals_)
 {
        GtkTextIter where;
 
        g_assert (GTK_SOURCE_IS_COMPLETION (self));
        g_assert (GTK_SOURCE_IS_BUFFER (buffer));
-       g_assert (GTK_SOURCE_IS_SIGNAL_GROUP (signals_));
+       g_assert (G_IS_SIGNAL_GROUP (signals_));
 
        if (self->disposed)
                return;
@@ -950,9 +949,9 @@ gtk_source_completion_dispose (GObject *object)
                self->hide_tick_handler = 0;
        }
 
-       gtk_source_signal_group_set_target (self->context_signals, NULL);
-       gtk_source_signal_group_set_target (self->buffer_signals, NULL);
-       gtk_source_signal_group_set_target (self->view_signals, NULL);
+       g_signal_group_set_target (self->context_signals, NULL);
+       g_signal_group_set_target (self->buffer_signals, NULL);
+       g_signal_group_set_target (self->view_signals, NULL);
 
        g_clear_pointer ((GtkSourceAssistant **)&self->display, _gtk_source_assistant_destroy);
 
@@ -1229,9 +1228,9 @@ gtk_source_completion_init (GtkSourceCompletion *self)
 {
        self->cancellable = g_cancellable_new ();
        self->providers = g_ptr_array_new_with_free_func (g_object_unref);
-       self->buffer_signals = gtk_source_signal_group_new (GTK_TYPE_TEXT_BUFFER);
-       self->context_signals = gtk_source_signal_group_new (GTK_SOURCE_TYPE_COMPLETION_CONTEXT);
-       self->view_signals = gtk_source_signal_group_new (GTK_SOURCE_TYPE_VIEW);
+       self->buffer_signals = g_signal_group_new (GTK_TYPE_TEXT_BUFFER);
+       self->context_signals = g_signal_group_new (GTK_SOURCE_TYPE_COMPLETION_CONTEXT);
+       self->view_signals = g_signal_group_new (GTK_SOURCE_TYPE_VIEW);
        self->page_size = DEFAULT_PAGE_SIZE;
        self->show_icons = TRUE;
 
@@ -1240,11 +1239,11 @@ gtk_source_completion_init (GtkSourceCompletion *self)
         * having results (or vice-versa, when we've filtered to the point of
         * no results).
         */
-       gtk_source_signal_group_connect_object (self->context_signals,
-                                               "notify::empty",
-                                               G_CALLBACK (gtk_source_completion_notify_context_empty_cb),
-                                               self,
-                                               G_CONNECT_SWAPPED);
+       g_signal_group_connect_object (self->context_signals,
+                                      "notify::empty",
+                                      G_CALLBACK (gtk_source_completion_notify_context_empty_cb),
+                                      self,
+                                      G_CONNECT_SWAPPED);
 
        /*
         * We need to know when the buffer inserts or deletes text so that we
@@ -1256,41 +1255,41 @@ gtk_source_completion_init (GtkSourceCompletion *self)
                                 G_CALLBACK (on_buffer_signals_bind),
                                 self,
                                 G_CONNECT_SWAPPED);
-       gtk_source_signal_group_connect_object (self->buffer_signals,
-                                               "delete-range",
-                                               G_CALLBACK 
(gtk_source_completion_buffer_delete_range_after_cb),
-                                               self,
-                                               G_CONNECT_AFTER | G_CONNECT_SWAPPED);
-       gtk_source_signal_group_connect_object (self->buffer_signals,
-                                               "insert-text",
-                                               G_CALLBACK 
(gtk_source_completion_buffer_insert_text_after_cb),
-                                               self,
-                                               G_CONNECT_AFTER | G_CONNECT_SWAPPED);
-       gtk_source_signal_group_connect_object (self->buffer_signals,
-                                               "mark-set",
-                                               G_CALLBACK (gtk_source_completion_buffer_mark_set_cb),
-                                               self,
-                                               G_CONNECT_SWAPPED);
+       g_signal_group_connect_object (self->buffer_signals,
+                                      "delete-range",
+                                      G_CALLBACK (gtk_source_completion_buffer_delete_range_after_cb),
+                                      self,
+                                      G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+       g_signal_group_connect_object (self->buffer_signals,
+                                      "insert-text",
+                                      G_CALLBACK (gtk_source_completion_buffer_insert_text_after_cb),
+                                      self,
+                                      G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+       g_signal_group_connect_object (self->buffer_signals,
+                                      "mark-set",
+                                      G_CALLBACK (gtk_source_completion_buffer_mark_set_cb),
+                                      self,
+                                      G_CONNECT_SWAPPED);
 
        /*
         * We track some events on the view that owns our GtkSourceCompletion instance so
         * that we can hide the window when it definitely should not be displayed.
         */
-       gtk_source_signal_group_connect_object (self->view_signals,
-                                               "move-cursor",
-                                               G_CALLBACK (gtk_source_completion_view_move_cursor_cb),
-                                               self,
-                                               G_CONNECT_AFTER | G_CONNECT_SWAPPED);
-       gtk_source_signal_group_connect_object (self->view_signals,
-                                               "paste-clipboard",
-                                               G_CALLBACK (gtk_source_completion_block_interactive),
-                                               self,
-                                               G_CONNECT_SWAPPED);
-       gtk_source_signal_group_connect_object (self->view_signals,
-                                               "paste-clipboard",
-                                               G_CALLBACK (gtk_source_completion_unblock_interactive),
-                                               self,
-                                               G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+       g_signal_group_connect_object (self->view_signals,
+                                      "move-cursor",
+                                      G_CALLBACK (gtk_source_completion_view_move_cursor_cb),
+                                      self,
+                                      G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+       g_signal_group_connect_object (self->view_signals,
+                                      "paste-clipboard",
+                                      G_CALLBACK (gtk_source_completion_block_interactive),
+                                      self,
+                                      G_CONNECT_SWAPPED);
+       g_signal_group_connect_object (self->view_signals,
+                                      "paste-clipboard",
+                                      G_CALLBACK (gtk_source_completion_unblock_interactive),
+                                      self,
+                                      G_CONNECT_AFTER | G_CONNECT_SWAPPED);
 }
 
 /**
@@ -1505,7 +1504,7 @@ _gtk_source_completion_get_display (GtkSourceCompletion *self)
  * @priority: (out) (allow-none): An optional location for the score of the match
  *
  * This helper function can do a fuzzy match for you giving a haystack and
- * casefolded needle. 
+ * casefolded needle.
  *
  * Casefold your needle using [func@GLib.utf8_casefold] before
  * running the query.
diff --git a/gtksourceview/gtksourcegutter.c b/gtksourceview/gtksourcegutter.c
index 3324325d..84851727 100644
--- a/gtksourceview/gtksourcegutter.c
+++ b/gtksourceview/gtksourcegutter.c
@@ -24,7 +24,6 @@
 #include "gtksourcegutter-private.h"
 #include "gtksourcegutterlines.h"
 #include "gtksourcegutterlines-private.h"
-#include "gtksourcesignalgroup-private.h"
 #include "gtksourcestylescheme-private.h"
 #include "gtksourceview-private.h"
 #include "gtksourcegutterrenderer.h"
@@ -74,7 +73,7 @@ struct _GtkSourceGutter
        GtkSourceView        *view;
        GList                *renderers;
        GtkSourceGutterLines *lines;
-       GtkSourceSignalGroup *signals;
+       GSignalGroup         *signals;
        GBinding             *target_binding;
 
        GtkTextWindowType     window_type;
@@ -426,7 +425,7 @@ gtk_source_gutter_dispose (GObject *object)
 
        if (gutter->signals != NULL)
        {
-               gtk_source_signal_group_set_target (gutter->signals, NULL);
+               g_signal_group_set_target (gutter->signals, NULL);
                g_clear_object (&gutter->signals);
        }
 
@@ -488,17 +487,17 @@ gtk_source_gutter_init (GtkSourceGutter *gutter)
 
        gutter->window_type = GTK_TEXT_WINDOW_LEFT;
 
-       gutter->signals = gtk_source_signal_group_new (GTK_TYPE_ADJUSTMENT);
-       gtk_source_signal_group_connect_object (gutter->signals,
-                                               "value-changed",
-                                               G_CALLBACK (on_adjustment_value_changed),
-                                               gutter,
-                                               0);
-       gtk_source_signal_group_connect_object (gutter->signals,
-                                               "notify::upper",
-                                               G_CALLBACK (on_adjustment_upper_changed),
-                                               gutter,
-                                               0);
+       gutter->signals = g_signal_group_new (GTK_TYPE_ADJUSTMENT);
+       g_signal_group_connect_object (gutter->signals,
+                                      "value-changed",
+                                      G_CALLBACK (on_adjustment_value_changed),
+                                      gutter,
+                                      0);
+       g_signal_group_connect_object (gutter->signals,
+                                      "notify::upper",
+                                      G_CALLBACK (on_adjustment_upper_changed),
+                                      gutter,
+                                      0);
 
        /* Setup fallback click handling */
        click = gtk_gesture_click_new ();
diff --git a/gtksourceview/gtksourcehover.c b/gtksourceview/gtksourcehover.c
index b7125813..21b46b66 100644
--- a/gtksourceview/gtksourcehover.c
+++ b/gtksourceview/gtksourcehover.c
@@ -28,7 +28,6 @@
 #include "gtksourcehovercontext.h"
 #include "gtksourcehoverprovider.h"
 #include "gtksourceiter-private.h"
-#include "gtksourcesignalgroup-private.h"
 #include "gtksourceview-private.h"
 
 #define DEFAULT_HOVER_DELAY 500
diff --git a/gtksourceview/gtksourceview-private.h b/gtksourceview/gtksourceview-private.h
index 72d0ba14..1f5ad0b2 100644
--- a/gtksourceview/gtksourceview-private.h
+++ b/gtksourceview/gtksourceview-private.h
@@ -25,7 +25,6 @@
 
 #include "gtksourceinformative-private.h"
 #include "gtksourceassistant-private.h"
-#include "gtksourcesignalgroup-private.h"
 
 G_BEGIN_DECLS
 
@@ -39,7 +38,7 @@ typedef struct _GtkSourceViewSnippets
 {
        GtkSourceView        *view;
        GtkSourceBuffer      *buffer;
-       GtkSourceSignalGroup *snippet_signals;
+       GSignalGroup         *snippet_signals;
        GtkSourceInformative *informative;
        GQueue                queue;
        gulong                buffer_insert_text_handler;
diff --git a/gtksourceview/gtksourceview-snippets.c b/gtksourceview/gtksourceview-snippets.c
index 55195d37..60490e6f 100644
--- a/gtksourceview/gtksourceview-snippets.c
+++ b/gtksourceview/gtksourceview-snippets.c
@@ -392,7 +392,7 @@ gtk_source_view_snippets_notify_position_cb (GtkSourceViewSnippets *snippets,
 }
 
 static void
-gtk_source_view_snippets_bind_cb (GtkSourceSignalGroup  *signals,
+gtk_source_view_snippets_bind_cb (GSignalGroup          *signals,
                                   GtkSourceSnippet      *snippet,
                                   GtkSourceViewSnippets *snippets)
 {
@@ -416,19 +416,19 @@ _gtk_source_view_snippets_init (GtkSourceViewSnippets *snippets,
        memset (snippets, 0, sizeof *snippets);
        snippets->view = view;
 
-       snippets->snippet_signals = gtk_source_signal_group_new (GTK_SOURCE_TYPE_SNIPPET);
+       snippets->snippet_signals = g_signal_group_new (GTK_SOURCE_TYPE_SNIPPET);
 
        g_signal_connect (snippets->snippet_signals,
                          "bind",
                          G_CALLBACK (gtk_source_view_snippets_bind_cb),
                          snippets);
 
-       gtk_source_signal_group_connect_data (snippets->snippet_signals,
-                                             "notify::focus-position",
-                                             G_CALLBACK (gtk_source_view_snippets_notify_position_cb),
-                                             snippets,
-                                             NULL,
-                                             G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+       g_signal_group_connect_data (snippets->snippet_signals,
+                                    "notify::focus-position",
+                                    G_CALLBACK (gtk_source_view_snippets_notify_position_cb),
+                                    snippets,
+                                    NULL,
+                                    G_CONNECT_SWAPPED | G_CONNECT_AFTER);
 
        if (GTK_SOURCE_IS_BUFFER (buffer))
        {
@@ -464,7 +464,7 @@ _gtk_source_view_snippets_shutdown (GtkSourceViewSnippets *snippets)
 
        if (snippets->snippet_signals != NULL)
        {
-               gtk_source_signal_group_set_target (snippets->snippet_signals, NULL);
+               g_signal_group_set_target (snippets->snippet_signals, NULL);
                g_clear_object (&snippets->snippet_signals);
        }
 
@@ -679,7 +679,7 @@ _gtk_source_view_snippets_push (GtkSourceViewSnippets *snippets,
        }
        else
        {
-               gtk_source_signal_group_set_target (snippets->snippet_signals, snippet);
+               g_signal_group_set_target (snippets->snippet_signals, snippet);
        }
 }
 
@@ -721,7 +721,7 @@ _gtk_source_view_snippets_pop (GtkSourceViewSnippets *snippets)
        }
 
        snippet = g_queue_peek_head (&snippets->queue);
-       gtk_source_signal_group_set_target (snippets->snippet_signals, snippet);
+       g_signal_group_set_target (snippets->snippet_signals, snippet);
 
        if (snippet == NULL)
        {
diff --git a/gtksourceview/meson.build b/gtksourceview/meson.build
index 61b9b7b5..5ba8f20e 100644
--- a/gtksourceview/meson.build
+++ b/gtksourceview/meson.build
@@ -131,7 +131,6 @@ core_private_c = files([
   'gtksourcemarkssequence.c',
   'gtksourcepixbufhelper.c',
   'gtksourceregex.c',
-  'gtksourcesignalgroup.c',
   'gtksourceview-assistants.c',
   'gtksourcesnippetbundle.c',
   'gtksourcesnippetbundle-parser.c',


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