[gnome-builder/wip/gtk4-port: 671/1774] plugins/pygi: actually insert the proposal
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 671/1774] plugins/pygi: actually insert the proposal
- Date: Mon, 11 Jul 2022 22:31:19 +0000 (UTC)
commit fb87423a260813f0fd6033542f90ccb0eb226351
Author: Christian Hergert <chergert redhat com>
Date: Wed Apr 20 16:15:50 2022 -0700
plugins/pygi: actually insert the proposal
src/plugins/pygi/gbp-pygi-completion-provider.c | 13 +++++++++++++
src/plugins/pygi/gbp-pygi-proposal.c | 8 ++++++++
src/plugins/pygi/gbp-pygi-proposal.h | 9 +++++----
3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/pygi/gbp-pygi-completion-provider.c b/src/plugins/pygi/gbp-pygi-completion-provider.c
index abdf5a987..72c3a6018 100644
--- a/src/plugins/pygi/gbp-pygi-completion-provider.c
+++ b/src/plugins/pygi/gbp-pygi-completion-provider.c
@@ -106,10 +106,23 @@ gbp_pygi_completion_provider_activate (GtkSourceCompletionProvider *provider,
GtkSourceCompletionContext *context,
GtkSourceCompletionProposal *proposal)
{
+ GtkSourceBuffer *buffer;
+ GtkTextIter begin, end;
+
g_assert (GBP_IS_PYGI_COMPLETION_PROVIDER (provider));
g_assert (GTK_SOURCE_IS_COMPLETION_CONTEXT (context));
g_assert (GBP_IS_PYGI_PROPOSAL (proposal));
+ buffer = gtk_source_completion_context_get_buffer (context);
+
+ gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (buffer));
+ if (gtk_source_completion_context_get_bounds (context, &begin, &end))
+ gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &begin, &end);
+ gtk_text_buffer_insert (GTK_TEXT_BUFFER (buffer),
+ &begin,
+ gbp_pygi_proposal_get_name (GBP_PYGI_PROPOSAL (proposal)),
+ -1);
+ gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (buffer));
}
static void
diff --git a/src/plugins/pygi/gbp-pygi-proposal.c b/src/plugins/pygi/gbp-pygi-proposal.c
index b9a090f45..46c6b8c4e 100644
--- a/src/plugins/pygi/gbp-pygi-proposal.c
+++ b/src/plugins/pygi/gbp-pygi-proposal.c
@@ -82,3 +82,11 @@ gbp_pygi_proposal_display (GbpPygiProposal *self,
gtk_source_completion_cell_set_text (cell, NULL);
}
}
+
+const char *
+gbp_pygi_proposal_get_name (GbpPygiProposal *self)
+{
+ g_return_val_if_fail (GBP_IS_PYGI_PROPOSAL (self), NULL);
+
+ return self->name;
+}
diff --git a/src/plugins/pygi/gbp-pygi-proposal.h b/src/plugins/pygi/gbp-pygi-proposal.h
index c34320035..fb437b61b 100644
--- a/src/plugins/pygi/gbp-pygi-proposal.h
+++ b/src/plugins/pygi/gbp-pygi-proposal.h
@@ -28,9 +28,10 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpPygiProposal, gbp_pygi_proposal, GBP, PYGI_PROPOSAL, GObject)
-GbpPygiProposal *gbp_pygi_proposal_new (const char *name);
-void gbp_pygi_proposal_display (GbpPygiProposal *self,
- GtkSourceCompletionContext *context,
- GtkSourceCompletionCell *cell);
+GbpPygiProposal *gbp_pygi_proposal_new (const char *name);
+const char *gbp_pygi_proposal_get_name (GbpPygiProposal *self);
+void gbp_pygi_proposal_display (GbpPygiProposal *self,
+ GtkSourceCompletionContext *context,
+ GtkSourceCompletionCell *cell);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]