[gnome-builder] give completion access to the sourceview
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] give completion access to the sourceview
- Date: Tue, 24 Mar 2015 00:33:11 +0000 (UTC)
commit dadb7b259141e0ae9c73e3a0113645de384a0226
Author: Christian Hergert <christian hergert me>
Date: Sat Mar 21 16:02:25 2015 -0700
give completion access to the sourceview
src/commands/gb-command-vim-provider.c | 29 ++++++++++++++++++++++-------
src/vim/gb-vim.c | 3 ++-
src/vim/gb-vim.h | 3 ++-
3 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/src/commands/gb-command-vim-provider.c b/src/commands/gb-command-vim-provider.c
index b34c452..e12484a 100644
--- a/src/commands/gb-command-vim-provider.c
+++ b/src/commands/gb-command-vim-provider.c
@@ -36,16 +36,14 @@ struct _GbCommandVimProvider
G_DEFINE_TYPE (GbCommandVimProvider, gb_command_vim_provider, GB_TYPE_COMMAND_PROVIDER)
-static GbCommand *
-gb_command_vim_provider_lookup (GbCommandProvider *provider,
- const gchar *command_text)
+GtkWidget *
+get_source_view (GbCommandProvider *provider)
{
- IdeSourceView *source_view;
GbWorkbench *workbench;
GbView *active_view;
+ IdeSourceView *source_view;
- g_return_val_if_fail (GB_IS_COMMAND_VIM_PROVIDER (provider), NULL);
- g_return_val_if_fail (command_text, NULL);
+ g_assert (GB_IS_COMMAND_VIM_PROVIDER (provider));
/* Make sure we have a workbench */
workbench = gb_command_provider_get_workbench (provider);
@@ -62,6 +60,20 @@ gb_command_vim_provider_lookup (GbCommandProvider *provider,
if (!IDE_IS_SOURCE_VIEW (source_view))
return NULL;
+ return GTK_WIDGET (source_view);
+}
+
+static GbCommand *
+gb_command_vim_provider_lookup (GbCommandProvider *provider,
+ const gchar *command_text)
+{
+ GtkWidget *source_view;
+
+ g_return_val_if_fail (GB_IS_COMMAND_VIM_PROVIDER (provider), NULL);
+ g_return_val_if_fail (command_text, NULL);
+
+ source_view = get_source_view (provider);
+
return g_object_new (GB_TYPE_COMMAND_VIM,
"command-text", command_text,
"source-view", source_view,
@@ -73,6 +85,7 @@ gb_command_vim_provider_complete (GbCommandProvider *provider,
GPtrArray *completions,
const gchar *initial_command_text)
{
+ GtkWidget *source_view;
gchar **results;
gsize i;
@@ -80,7 +93,9 @@ gb_command_vim_provider_complete (GbCommandProvider *provider,
g_return_if_fail (completions);
g_return_if_fail (initial_command_text);
- results = gb_vim_complete (initial_command_text);
+ source_view = get_source_view (provider);
+
+ results = gb_vim_complete (GTK_SOURCE_VIEW (source_view), initial_command_text);
for (i = 0; results [i]; i++)
g_ptr_array_add (completions, results [i]);
g_free (results);
diff --git a/src/vim/gb-vim.c b/src/vim/gb-vim.c
index 7b63fe7..424e246 100644
--- a/src/vim/gb-vim.c
+++ b/src/vim/gb-vim.c
@@ -690,7 +690,8 @@ gb_vim_complete_command (const gchar *line,
}
gchar **
-gb_vim_complete (const gchar *line)
+gb_vim_complete (GtkSourceView *source_view,
+ const gchar *line)
{
GPtrArray *ar;
diff --git a/src/vim/gb-vim.h b/src/vim/gb-vim.h
index 54d4678..e28499d 100644
--- a/src/vim/gb-vim.h
+++ b/src/vim/gb-vim.h
@@ -40,7 +40,8 @@ GQuark gb_vim_error_quark (void);
gboolean gb_vim_execute (GtkSourceView *source_view,
const gchar *line,
GError **error);
-gchar **gb_vim_complete (const gchar *line);
+gchar **gb_vim_complete (GtkSourceView *source_view,
+ const gchar *line);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]