Commit 22d2c012 authored by Christian Hergert's avatar Christian Hergert
Browse files

ctags: use load vfunc to initialize context

Now that we cannot guarantee that :context will be set before constructed
we need to use the load vfunc to attach things. This is much better/safer
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=779891
parent 6f80f473
......@@ -1495,6 +1495,7 @@ ide_source_view__completion_provider_added (IdeExtensionSetAdapter *adapter,
PeasExtension *extension,
IdeSourceView *self)
{
IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
GtkSourceCompletion *completion;
g_assert (IDE_IS_SOURCE_VIEW (self));
......@@ -1508,7 +1509,8 @@ ide_source_view__completion_provider_added (IdeExtensionSetAdapter *adapter,
GTK_SOURCE_COMPLETION_PROVIDER (extension),
NULL);
ide_completion_provider_load (IDE_COMPLETION_PROVIDER (extension));
ide_completion_provider_load (IDE_COMPLETION_PROVIDER (extension),
ide_buffer_get_context (priv->buffer));
}
static void
......
......@@ -28,14 +28,15 @@
#include "ide-ctags-service.h"
#include "ide-ctags-util.h"
static void provider_iface_init (GtkSourceCompletionProviderIface *iface);
static void provider_iface_init (GtkSourceCompletionProviderIface *iface);
static void provider2_iface_init (IdeCompletionProviderInterface *iface);
G_DEFINE_DYNAMIC_TYPE_EXTENDED (IdeCtagsCompletionProvider,
ide_ctags_completion_provider,
IDE_TYPE_OBJECT,
0,
G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER, provider_iface_init)
G_IMPLEMENT_INTERFACE (IDE_TYPE_COMPLETION_PROVIDER, NULL))
G_IMPLEMENT_INTERFACE (IDE_TYPE_COMPLETION_PROVIDER, provider2_iface_init))
void
ide_ctags_completion_provider_add_index (IdeCtagsCompletionProvider *self,
......@@ -72,15 +73,15 @@ ide_ctags_completion_provider_add_index (IdeCtagsCompletionProvider *self,
}
static void
ide_ctags_completion_provider_constructed (GObject *object)
ide_ctags_completion_provider_load (IdeCompletionProvider *provider,
IdeContext *context)
{
IdeCtagsCompletionProvider *self = (IdeCtagsCompletionProvider *)object;
IdeContext *context;
IdeCtagsCompletionProvider *self = (IdeCtagsCompletionProvider *)provider;
IdeCtagsService *service;
G_OBJECT_CLASS (ide_ctags_completion_provider_parent_class)->constructed (object);
g_assert (IDE_IS_CTAGS_COMPLETION_PROVIDER (self));
g_assert (IDE_IS_CONTEXT (context));
context = ide_object_get_context (IDE_OBJECT (self));
service = ide_context_get_service_typed (context, IDE_TYPE_CTAGS_SERVICE);
ide_ctags_service_register_completion (service, self);
}
......@@ -117,7 +118,6 @@ ide_ctags_completion_provider_class_init (IdeCtagsCompletionProviderClass *klass
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = ide_ctags_completion_provider_constructed;
object_class->dispose = ide_ctags_completion_provider_dispose;
object_class->finalize = ide_ctags_completion_provider_finalize;
}
......@@ -366,6 +366,12 @@ provider_iface_init (GtkSourceCompletionProviderIface *iface)
iface->activate_proposal = ide_ctags_completion_provider_activate_proposal;
}
static void
provider2_iface_init (IdeCompletionProviderInterface *iface)
{
iface->load = ide_ctags_completion_provider_load;
}
void
_ide_ctags_completion_provider_register_type (GTypeModule *module)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment