[gnome-builder] completion: drop use of :context and add load vfunc



commit 7cd2a992319f978bdb0efa6691bfe6528ccdd27e
Author: Christian Hergert <chergert redhat com>
Date:   Sat Mar 11 01:55:27 2017 -0800

    completion: drop use of :context and add load vfunc
    
    Instead of requiring the :context property (which causes weird conflicts
    with vala), use a load vfunc and ensure it gets used.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779891

 libide/sourceview/ide-completion-provider.c        |   16 +++++-----------
 libide/sourceview/ide-completion-provider.h        |   10 ++++------
 .../vala-pack/ide-vala-completion-provider.vala    |   12 ++++--------
 3 files changed, 13 insertions(+), 25 deletions(-)
---
diff --git a/libide/sourceview/ide-completion-provider.c b/libide/sourceview/ide-completion-provider.c
index 9b17993..b0737e2 100644
--- a/libide/sourceview/ide-completion-provider.c
+++ b/libide/sourceview/ide-completion-provider.c
@@ -19,19 +19,11 @@
 #include "ide-completion-provider.h"
 #include "ide-context.h"
 
-G_DEFINE_INTERFACE (IdeCompletionProvider,
-                    ide_completion_provider,
-                    GTK_SOURCE_TYPE_COMPLETION_PROVIDER)
+G_DEFINE_INTERFACE (IdeCompletionProvider, ide_completion_provider, GTK_SOURCE_TYPE_COMPLETION_PROVIDER)
 
 static void
 ide_completion_provider_default_init (IdeCompletionProviderInterface *iface)
 {
-  g_object_interface_install_property (iface,
-                                       g_param_spec_object ("context",
-                                                            "Context",
-                                                            "Context",
-                                                            IDE_TYPE_CONTEXT,
-                                                            (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | 
G_PARAM_STATIC_STRINGS)));
 }
 
 gboolean
@@ -115,10 +107,12 @@ ide_completion_provider_context_current_word (GtkSourceCompletionContext *contex
 }
 
 void
-ide_completion_provider_load (IdeCompletionProvider *self)
+ide_completion_provider_load (IdeCompletionProvider *self,
+                              IdeContext            *context)
 {
   g_return_if_fail (IDE_IS_COMPLETION_PROVIDER (self));
+  g_return_if_fail (IDE_IS_CONTEXT (context));
 
   if (IDE_COMPLETION_PROVIDER_GET_IFACE (self)->load)
-    IDE_COMPLETION_PROVIDER_GET_IFACE (self)->load (self);
+    IDE_COMPLETION_PROVIDER_GET_IFACE (self)->load (self, context);
 }
diff --git a/libide/sourceview/ide-completion-provider.h b/libide/sourceview/ide-completion-provider.h
index 2818830..0af958e 100644
--- a/libide/sourceview/ide-completion-provider.h
+++ b/libide/sourceview/ide-completion-provider.h
@@ -37,18 +37,16 @@ struct _IdeCompletionProviderInterface
 {
   GtkSourceCompletionProviderIface parent_interface;
 
-  /* Pacify Vala */
-  void (*set_context) (IdeCompletionProvider *self,
-                       IdeContext            *context);
-
-  void (*load)        (IdeCompletionProvider *self);
+  void (*load) (IdeCompletionProvider *self,
+                IdeContext            *context);
 };
 
 GType     ide_completion_provider_get_type                     (void);
 gboolean  ide_completion_provider_context_in_comment           (GtkSourceCompletionContext *context);
 gboolean  ide_completion_provider_context_in_comment_or_string (GtkSourceCompletionContext *context);
 gchar    *ide_completion_provider_context_current_word         (GtkSourceCompletionContext *context);
-void      ide_completion_provider_load                         (IdeCompletionProvider      *self);
+void      ide_completion_provider_load                         (IdeCompletionProvider      *self,
+                                                                IdeContext                 *context);
 
 G_END_DECLS
 
diff --git a/plugins/vala-pack/ide-vala-completion-provider.vala 
b/plugins/vala-pack/ide-vala-completion-provider.vala
index 3fef3cf..af08e05 100644
--- a/plugins/vala-pack/ide-vala-completion-provider.vala
+++ b/plugins/vala-pack/ide-vala-completion-provider.vala
@@ -30,6 +30,7 @@ namespace Ide
                int line = -1;
                int column = -1;
                Ide.CompletionResults? results;
+               Ide.Context? _context;
 
                public void populate (Gtk.SourceCompletionContext context)
                {
@@ -146,13 +147,8 @@ namespace Ide
                        return 200;
                }
 
-               public void load () {}
-
-               // This code shouldn't have to exist.
-               // If we can fixup libide+vala to not have such weird interaction that
-               // would be great.
-               Ide.Context? _context;
-               public Ide.Context context { construct { _context = value; } }
-               public void set_context (Ide.Context context) { _context = context; }
+               public void load (Ide.Context context) {
+                       this._context = context;
+               }
        }
 }


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