[gtksourceview] Completion: remove interactive_providers struct field
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] Completion: remove interactive_providers struct field
- Date: Sat, 16 Mar 2013 15:44:29 +0000 (UTC)
commit bda88baae296564407f99ce1a5b8375f98f9bda2
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Mar 16 15:46:52 2013 +0100
Completion: remove interactive_providers struct field
When a provider is added to Completion, it is added in the list of all
providers, in the 'providers' struct field. It was also added to the list
of interactive providers if the provider supports the interactive
activation.
The problem is that if the provider wants to change its mind and wants
to add or drop support of interactive activation, _after_ it has been
added to the Completion, this didn't work as expected.
A workaround was to remove and re-add the provider to the Completion,
but it is really a hack.
So it's better, when starting an interactive completion, to always check
all the providers.
Example of use:
https://git.gnome.org/browse/latexila/commit/?id=69449d1b00e1d980a36ec64e7024bc2a6d4bf31a
gtksourceview/gtksourcecompletion.c | 35 +++++++++--------------------------
1 files changed, 9 insertions(+), 26 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 1c711bb..667fbfd 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -155,7 +155,6 @@ struct _GtkSourceCompletionPrivate
GtkSourceCompletionModel *model_proposals;
GList *providers;
- GList *interactive_providers;
GtkSourceCompletionContext *context;
GList *active_providers;
@@ -295,17 +294,20 @@ select_providers (GList *providers,
GtkSourceCompletionContext *context)
{
GList *selection = NULL;
+ GList *l;
- while (providers != NULL)
+ for (l = providers; l != NULL; l = l->next)
{
- GtkSourceCompletionProvider *provider = providers->data;
+ GtkSourceCompletionProvider *provider = l->data;
+
+ gboolean good_activation = (gtk_source_completion_provider_get_activation (provider) &
+ gtk_source_completion_context_get_activation (context)) != 0;
- if (gtk_source_completion_provider_match (provider, context))
+ if (good_activation &&
+ gtk_source_completion_provider_match (provider, context))
{
selection = g_list_prepend (selection, provider);
}
-
- providers = g_list_next (providers);
}
return g_list_reverse (selection);
@@ -1261,7 +1263,7 @@ start_interactive_completion (GtkSourceCompletion *completion,
g_signal_emit (completion, signals[POPULATE_CONTEXT], 0, context);
/* Select providers */
- providers = select_providers (completion->priv->interactive_providers, context);
+ providers = select_providers (completion->priv->providers, context);
if (providers == NULL)
{
@@ -1388,9 +1390,6 @@ gtk_source_completion_dispose (GObject *object)
completion->priv->main_window = NULL;
}
- g_list_free (completion->priv->interactive_providers);
- completion->priv->interactive_providers = NULL;
-
g_list_free_full (completion->priv->providers, g_object_unref);
completion->priv->providers = NULL;
@@ -2385,14 +2384,6 @@ gtk_source_completion_add_provider (GtkSourceCompletion *completion,
completion->priv->providers = g_list_append (completion->priv->providers,
g_object_ref (provider));
- if (gtk_source_completion_provider_get_activation (provider) &
- GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE)
- {
- completion->priv->interactive_providers =
- g_list_append (completion->priv->interactive_providers,
- provider);
- }
-
if (error != NULL)
{
*error = NULL;
@@ -2439,14 +2430,6 @@ gtk_source_completion_remove_provider (GtkSourceCompletion *completion,
completion->priv->providers = g_list_remove_link (completion->priv->providers, item);
- if (gtk_source_completion_provider_get_activation (provider) &
- GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE)
- {
- completion->priv->interactive_providers =
- g_list_remove (completion->priv->interactive_providers,
- provider);
- }
-
g_object_unref (provider);
if (error != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]