[gtksourceview/wip/chergert/gsv-gtk4] words: implement display interface for completion words



commit 4fc8effc246d1a5ac62a68cf55a336ea5cdeb198
Author: Christian Hergert <chergert redhat com>
Date:   Tue Sep 1 14:02:46 2020 -0700

    words: implement display interface for completion words

 .../words/gtksourcecompletionwords.c               | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
index be268eea..a0884dae 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
@@ -447,6 +447,29 @@ gtk_source_completion_words_get_priority (GtkSourceCompletionProvider *provider,
        return priv->priority;
 }
 
+static void
+gtk_source_completion_words_display (GtkSourceCompletionProvider *provider,
+                                     GtkSourceCompletionContext  *context,
+                                     GtkSourceCompletionProposal *proposal,
+                                     GtkSourceCompletionCell     *cell)
+{
+       GtkSourceCompletionWordsProposal *p = (GtkSourceCompletionWordsProposal *)proposal;
+       GtkSourceCompletionColumn column;
+
+       g_assert (GTK_SOURCE_IS_COMPLETION_WORDS (provider));
+       g_assert (GTK_SOURCE_IS_COMPLETION_CONTEXT (context));
+       g_assert (GTK_SOURCE_IS_COMPLETION_WORDS_PROPOSAL (p));
+       g_assert (GTK_SOURCE_IS_COMPLETION_CELL (cell));
+
+       column = gtk_source_completion_cell_get_column (cell);
+
+       if (column == GTK_SOURCE_COMPLETION_COLUMN_TYPED_TEXT)
+       {
+               const char *word = gtk_source_completion_words_proposal_get_word (p);
+               gtk_source_completion_cell_set_text (cell, word);
+       }
+}
+
 static void
 gtk_source_completion_words_iface_init (GtkSourceCompletionProviderInterface *iface)
 {
@@ -454,6 +477,7 @@ gtk_source_completion_words_iface_init (GtkSourceCompletionProviderInterface *if
        iface->populate_async = gtk_source_completion_words_populate_async;
        iface->populate_finish = gtk_source_completion_words_populate_finish;
        iface->get_priority = gtk_source_completion_words_get_priority;
+       iface->display = gtk_source_completion_words_display;
 }
 
 static void


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