[gtksourceview/wip/chergert/gsv-gtk4] words: implement activate for word completion
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/gsv-gtk4] words: implement activate for word completion
- Date: Tue, 1 Sep 2020 22:33:14 +0000 (UTC)
commit 15998fe750f501848cb5b0765a0bba98e16d810b
Author: Christian Hergert <chergert redhat com>
Date: Tue Sep 1 15:26:19 2020 -0700
words: implement activate for word completion
.../words/gtksourcecompletionwords.c | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
index 644936e1..21e91c71 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
@@ -474,6 +474,30 @@ gtk_source_completion_words_display (GtkSourceCompletionProvider *provider,
}
}
+static void
+gtk_source_completion_words_activate (GtkSourceCompletionProvider *provider,
+ GtkSourceCompletionContext *context,
+ GtkSourceCompletionProposal *proposal)
+{
+ GtkSourceCompletionWordsProposal *p = (GtkSourceCompletionWordsProposal *)proposal;
+ GtkTextIter begin, end;
+
+ 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));
+
+ if (gtk_source_completion_context_get_bounds (context, &begin, &end))
+ {
+ GtkTextBuffer *buffer = gtk_text_iter_get_buffer (&begin);
+ const char *word = gtk_source_completion_words_proposal_get_word (p);
+
+ gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (buffer));
+ gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &begin, &end);
+ gtk_text_buffer_insert (GTK_TEXT_BUFFER (buffer), &begin, word, -1);
+ gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (buffer));
+ }
+}
+
static void
gtk_source_completion_words_iface_init (GtkSourceCompletionProviderInterface *iface)
{
@@ -482,6 +506,7 @@ gtk_source_completion_words_iface_init (GtkSourceCompletionProviderInterface *if
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;
+ iface->activate = gtk_source_completion_words_activate;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]