[gnome-builder] plugins/xml-pack: Enable autocompletion
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/xml-pack: Enable autocompletion
- Date: Sat, 23 Jul 2022 22:33:54 +0000 (UTC)
commit d6280e49498740ce582ae24aadbf60d3a26bf51c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Jul 23 09:53:02 2022 -0300
plugins/xml-pack: Enable autocompletion
A rather straightforward enablement. The major change is the usage
of GtkSourceCompletionCell API instead of the now non-existant
GtkSourceCompletionRow.
src/plugins/xml-pack/ide-xml-completion-provider.c | 35 ++++++++++++++--------
src/plugins/xml-pack/meson.build | 2 +-
src/plugins/xml-pack/xml-pack-plugin.c | 2 --
3 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/src/plugins/xml-pack/ide-xml-completion-provider.c
b/src/plugins/xml-pack/ide-xml-completion-provider.c
index c04b015e7..74982cab3 100644
--- a/src/plugins/xml-pack/ide-xml-completion-provider.c
+++ b/src/plugins/xml-pack/ide-xml-completion-provider.c
@@ -1032,7 +1032,7 @@ ide_xml_completion_provider_populate_async (GtkSourceCompletionProvider *provide
{
IdeXmlCompletionProvider *self = (IdeXmlCompletionProvider *)provider;
g_autoptr(IdeTask) task = NULL;
- GtkTextBuffer *buffer;
+ GtkSourceBuffer *buffer;
IdeXmlService *service;
PopulateState *state;
IdeContext *ide_context;
@@ -1079,7 +1079,7 @@ ide_xml_completion_provider_populate_finish (GtkSourceCompletionProvider *provi
return ide_task_propagate_object (IDE_TASK (result), error);
}
-static gboolean
+static void
ide_xml_completion_provider_refilter (GtkSourceCompletionProvider *provider,
GtkSourceCompletionContext *context,
GListModel *model)
@@ -1109,8 +1109,6 @@ ide_xml_completion_provider_refilter (GtkSourceCompletionProvider *provider,
if (!gtk_source_completion_fuzzy_match (label, casefold, &priority))
g_list_store_remove (G_LIST_STORE (model), i - 1);
}
-
- return TRUE;
}
static void
@@ -1120,19 +1118,30 @@ ide_xml_completion_provider_display (GtkSourceCompletionProvider *provider,
GtkSourceCompletionCell *cell)
{
IdeXmlProposal *item = (IdeXmlProposal *)proposal;
- const gchar *label;
g_assert (IDE_IS_XML_COMPLETION_PROVIDER (provider));
- g_assert (GTK_SOURCE_IS_COMPLETION_LIST_BOX_ROW (row));
+ g_assert (GTK_SOURCE_IS_COMPLETION_CELL (cell));
g_assert (GTK_SOURCE_IS_COMPLETION_CONTEXT (context));
g_assert (GTK_SOURCE_IS_COMPLETION_PROPOSAL (proposal));
- label = ide_xml_proposal_get_label (item);
+ switch (gtk_source_completion_cell_get_column (cell))
+ {
+ case GTK_SOURCE_COMPLETION_COLUMN_ICON:
+ gtk_source_completion_cell_set_icon_name (cell, "text-xml-symbolic");
+ break;
- gtk_source_completion_list_box_row_set_icon_name (row, NULL);
- gtk_source_completion_list_box_row_set_left (row, NULL);
- gtk_source_completion_list_box_row_set_right (row, NULL);
- gtk_source_completion_list_box_row_set_center_markup (row, label);
+ case GTK_SOURCE_COMPLETION_COLUMN_TYPED_TEXT:
+ gtk_source_completion_cell_set_markup (cell, ide_xml_proposal_get_label (item));
+ break;
+
+ case GTK_SOURCE_COMPLETION_COLUMN_COMMENT:
+ case GTK_SOURCE_COMPLETION_COLUMN_DETAILS:
+ case GTK_SOURCE_COMPLETION_COLUMN_BEFORE:
+ case GTK_SOURCE_COMPLETION_COLUMN_AFTER:
+ default:
+ gtk_source_completion_cell_set_text (cell, NULL);
+ break;
+ }
}
static void
@@ -1141,6 +1150,7 @@ ide_xml_completion_provider_activate (GtkSourceCompletionProvider *provider,
GtkSourceCompletionProposal *proposal)
{
IdeXmlProposal *item = (IdeXmlProposal *)proposal;
+ GtkSourceBuffer *source_buffer;
GtkTextBuffer *buffer;
GtkTextIter begin, end;
const gchar *text;
@@ -1151,9 +1161,10 @@ ide_xml_completion_provider_activate (GtkSourceCompletionProvider *provider,
text = ide_xml_proposal_get_text (item);
- buffer = gtk_source_completion_context_get_buffer (context);
+ source_buffer = gtk_source_completion_context_get_buffer (context);
gtk_source_completion_context_get_bounds (context, &begin, &end);
+ buffer = GTK_TEXT_BUFFER (source_buffer);
gtk_text_buffer_begin_user_action (buffer);
gtk_text_buffer_delete (buffer, &begin, &end);
gtk_text_buffer_insert (buffer, &begin, text, -1);
diff --git a/src/plugins/xml-pack/meson.build b/src/plugins/xml-pack/meson.build
index 08986e341..4c0610f38 100644
--- a/src/plugins/xml-pack/meson.build
+++ b/src/plugins/xml-pack/meson.build
@@ -4,7 +4,7 @@ plugins_sources += files([
'ide-xml-analysis.c',
'ide-xml-completion-attributes.c',
'ide-xml-completion-values.c',
- # 'ide-xml-completion-provider.c',
+ 'ide-xml-completion-provider.c',
'ide-xml-diagnostic-provider.c',
'ide-xml-hash-table.c',
'ide-xml-highlighter.c',
diff --git a/src/plugins/xml-pack/xml-pack-plugin.c b/src/plugins/xml-pack/xml-pack-plugin.c
index 097c7aa1b..2e3fd2f5b 100644
--- a/src/plugins/xml-pack/xml-pack-plugin.c
+++ b/src/plugins/xml-pack/xml-pack-plugin.c
@@ -34,11 +34,9 @@
_IDE_EXTERN void
_ide_xml_register_types (PeasObjectModule *module)
{
-#if 0
peas_object_module_register_extension_type (module,
GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
IDE_TYPE_XML_COMPLETION_PROVIDER);
-#endif
peas_object_module_register_extension_type (module,
IDE_TYPE_DIAGNOSTIC_PROVIDER,
IDE_TYPE_XML_DIAGNOSTIC_PROVIDER);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]