[gtksourceview] completion: add GtkSourceCompletionContext::provider-model-changed



commit d3480174c31c98d7717b84f3cdd8d368b2f870a2
Author: Christian Hergert <chergert redhat com>
Date:   Fri Sep 2 23:27:29 2022 -0700

    completion: add GtkSourceCompletionContext::provider-model-changed
    
    This signal is emitted when a model is changed for a particular provider.

 gtksourceview/gtksourcecompletioncontext.c | 34 ++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
---
diff --git a/gtksourceview/gtksourcecompletioncontext.c b/gtksourceview/gtksourcecompletioncontext.c
index 3a31ba66..1cfa0414 100644
--- a/gtksourceview/gtksourcecompletioncontext.c
+++ b/gtksourceview/gtksourcecompletioncontext.c
@@ -96,7 +96,13 @@ enum {
        N_PROPS
 };
 
+enum {
+       PROVIDER_MODEL_CHANGED,
+       N_SIGNALS
+};
+
 static GParamSpec *properties [N_PROPS];
+static guint signals [N_SIGNALS];
 
 static void
 clear_provider_info (gpointer data)
@@ -315,6 +321,32 @@ gtk_source_completion_context_class_init (GtkSourceCompletionContextClass *klass
                                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
 
        g_object_class_install_properties (object_class, N_PROPS, properties);
+
+       /**
+        * GtkSourceCompletionContext::provider-model-changed:
+        * @self: a #GtkSourceCompletionContext
+        * @provider: a #GtkSourceCompletionProvider
+        * @model: (nullable): a #GListModel
+        *
+        * Emitted when a provider changes a model.
+        *
+        * This signal is primarily useful for #GtkSourceCompletionProvider's
+        * that want to track other providers in context. For example, it can
+        * be used to create a "top results" provider.
+        *
+        * Since: 5.6
+        */
+       signals [PROVIDER_MODEL_CHANGED] =
+               g_signal_new ("provider-model-changed",
+                             G_TYPE_FROM_CLASS (klass),
+                             G_SIGNAL_RUN_LAST,
+                             0,
+                             NULL, NULL,
+                             NULL,
+                             G_TYPE_NONE,
+                             2,
+                             GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
+                             G_TYPE_LIST_MODEL);
 }
 
 static void
@@ -683,6 +715,8 @@ gtk_source_completion_context_set_proposals_for_provider (GtkSourceCompletionCon
 
                        g_list_model_items_changed (G_LIST_MODEL (self), position, n_removed, n_added);
 
+                       g_signal_emit (self, signals [PROVIDER_MODEL_CHANGED], 0, provider, results);
+
                        break;
                }
 


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