[gtksourceview] completion: add gtk_source_completion_context_list_providers()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] completion: add gtk_source_completion_context_list_providers()
- Date: Sat, 3 Sep 2022 06:29:41 +0000 (UTC)
commit 71b0891595052a92545499391d9f832db4cc5fed
Author: Christian Hergert <chergert redhat com>
Date: Fri Sep 2 23:29:01 2022 -0700
completion: add gtk_source_completion_context_list_providers()
This API can be used to retrieve the list of providers that are found
within a completion context. You might use this to make a filtered list
of models and prioritize some items into a high-priority model.
gtksourceview/gtksourcecompletioncontext.c | 29 +++++++++++++++++++++++++++++
gtksourceview/gtksourcecompletioncontext.h | 2 ++
2 files changed, 31 insertions(+)
---
diff --git a/gtksourceview/gtksourcecompletioncontext.c b/gtksourceview/gtksourcecompletioncontext.c
index 1cfa0414..d051ba99 100644
--- a/gtksourceview/gtksourcecompletioncontext.c
+++ b/gtksourceview/gtksourcecompletioncontext.c
@@ -1106,3 +1106,32 @@ gtk_source_completion_context_get_language (GtkSourceCompletionContext *self)
return NULL;
}
+
+/**
+ * gtk_source_completion_context_list_providers:
+ * @self: a #GtkSourceCompletionContext
+ *
+ * Gets the providers that are associated with the context.
+ *
+ * Returns: (transfer full): a #GListModel of #GtkSourceCompletionProvider
+ *
+ * Since: 5.6
+ */
+GListModel *
+gtk_source_completion_context_list_providers (GtkSourceCompletionContext *self)
+{
+ GListStore *store;
+
+ g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_CONTEXT (self), NULL);
+
+ store = g_list_store_new (GTK_SOURCE_TYPE_COMPLETION_PROVIDER);
+
+ for (guint i = 0; i < self->providers->len; i++)
+ {
+ const ProviderInfo *info = &g_array_index (self->providers, ProviderInfo, i);
+
+ g_list_store_append (store, info->provider);
+ }
+
+ return G_LIST_MODEL (store);
+}
diff --git a/gtksourceview/gtksourcecompletioncontext.h b/gtksourceview/gtksourcecompletioncontext.h
index 7f3fe8c2..acafa2de 100644
--- a/gtksourceview/gtksourcecompletioncontext.h
+++ b/gtksourceview/gtksourcecompletioncontext.h
@@ -66,5 +66,7 @@ void gtk_source_completion_context_set_proposals_for_p
GTK_SOURCE_AVAILABLE_IN_5_6
GListModel *gtk_source_completion_context_get_proposals_for_provider
(GtkSourceCompletionContext *self,
GtkSourceCompletionProvider *provider);
+GTK_SOURCE_AVAILABLE_IN_5_6
+GListModel *gtk_source_completion_context_list_providers
(GtkSourceCompletionContext *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]