[gtksourceview] Move gsc_provider_get_interactive/default to get_activation
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtksourceview] Move gsc_provider_get_interactive/default to get_activation
- Date: Tue, 29 Sep 2009 21:06:51 +0000 (UTC)
commit d649b6374b100ee2e203d1419651192feb34f0a3
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Tue Sep 29 22:51:54 2009 +0200
Move gsc_provider_get_interactive/default to get_activation
Instead of having two functions with booleans for the two types of
activation, there now is a single flag on the provider, accessible through
gtk_source_completion_provider_get_activation.
gtksourceview/gtksourcecompletion.c | 14 +++-
gtksourceview/gtksourcecompletioncontext.c | 81 +++++++--------------------
gtksourceview/gtksourcecompletioncontext.h | 18 +++++-
gtksourceview/gtksourcecompletionprovider.c | 50 ++++-------------
gtksourceview/gtksourcecompletionprovider.h | 8 +-
gtksourceview/gtksourceview.c | 12 +++-
6 files changed, 71 insertions(+), 112 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 5874007..96efa92 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -1407,7 +1407,10 @@ show_auto_completion (GtkSourceCompletion *completion)
}
context = gtk_source_completion_create_context (completion, &iter);
- g_object_set (context, "interactive", TRUE, NULL);
+ g_object_set (context,
+ "activation",
+ GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE,
+ NULL);
gtk_source_completion_show (completion,
completion->priv->interactive_providers,
@@ -1450,7 +1453,8 @@ update_interactive_completion (GtkSourceCompletion *completion,
completion->priv->show_timed_out_id = 0;
}
}
- else if (gtk_source_completion_context_get_interactive (completion->priv->context) &&
+ else if ((gtk_source_completion_context_get_activation (completion->priv->context) &
+ GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE) &&
gtk_text_iter_get_line (iter) != completion->priv->typing_line)
{
gtk_source_completion_hide (completion);
@@ -3102,7 +3106,8 @@ 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_interactive (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);
@@ -3143,7 +3148,8 @@ gtk_source_completion_remove_provider (GtkSourceCompletion *completion,
{
completion->priv->providers = g_list_remove_link (completion->priv->providers, item);
- if (gtk_source_completion_provider_get_interactive (provider))
+ 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);
diff --git a/gtksourceview/gtksourcecompletioncontext.c b/gtksourceview/gtksourcecompletioncontext.c
index b6fa504..2d14487 100644
--- a/gtksourceview/gtksourcecompletioncontext.c
+++ b/gtksourceview/gtksourcecompletioncontext.c
@@ -32,8 +32,7 @@ struct _GtkSourceCompletionContextPrivate
GtkSourceCompletion *completion;
GtkTextIter iter;
- gboolean interactive_mode;
- gboolean default_mode;
+ GtkSourceCompletionActivation activation;
};
/* Properties */
@@ -44,8 +43,7 @@ enum
PROP_COMPLETION,
PROP_VIEW,
PROP_ITER,
- PROP_INTERACTIVE,
- PROP_DEFAULT
+ PROP_ACTIVATION
};
/* Signals */
@@ -89,11 +87,8 @@ gtk_source_completion_context_set_property (GObject *object,
case PROP_ITER:
self->priv->iter = *((GtkTextIter *)g_value_get_pointer (value));
break;
- case PROP_INTERACTIVE:
- self->priv->interactive_mode = g_value_get_boolean (value);
- break;
- case PROP_DEFAULT:
- self->priv->default_mode = g_value_get_boolean (value);
+ case PROP_ACTIVATION:
+ self->priv->activation = g_value_get_flags (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -119,11 +114,9 @@ gtk_source_completion_context_get_property (GObject *object,
case PROP_ITER:
g_value_set_pointer (value, &(self->priv->iter));
break;
- case PROP_INTERACTIVE:
- g_value_set_boolean (value, self->priv->interactive_mode);
+ case PROP_ACTIVATION:
+ g_value_set_flags (value, self->priv->activation);
break;
- case PROP_DEFAULT:
- g_value_set_boolean (value, self->priv->default_mode);
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -195,30 +188,18 @@ gtk_source_completion_context_class_init (GtkSourceCompletionContextClass *klass
G_PARAM_READWRITE));
/**
- * GtkSourceCompletionContext:interactive:
+ * GtkSourceCompletionContext:activation:
*
- * Whether the completion is in 'interactive' mode.
+ * The completion activation
**/
g_object_class_install_property (object_class,
- PROP_INTERACTIVE,
- g_param_spec_boolean ("interactive",
- _("Interactive"),
- _("Whether the completion was invoked in interactive mode"),
- FALSE,
- G_PARAM_READWRITE));
-
- /**
- * GtkSourceCompletionContext:default:
- *
- * Whether the completion is in 'default' mode.
- **/
- g_object_class_install_property (object_class,
- PROP_DEFAULT,
- g_param_spec_boolean ("default",
- _("Default"),
- _("Whether completion was invoked in default mode"),
- FALSE,
- G_PARAM_READWRITE));
+ PROP_ACTIVATION,
+ g_param_spec_flags ("activation",
+ _("Activation"),
+ _("The type of activation"),
+ GTK_TYPE_SOURCE_COMPLETION_ACTIVATION,
+ GTK_SOURCE_COMPLETION_ACTIVATION_NONE,
+ G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof(GtkSourceCompletionContextPrivate));
}
@@ -294,39 +275,19 @@ gtk_source_completion_context_get_iter (GtkSourceCompletionContext *context,
}
/**
- * gtk_source_completion_context_get_interactive:
- * @context: A #GtkSourceCompletionContext
- *
- * Get whether the context is targeting 'interactive' mode providers. The
- * interactive mode is used by #GtkSourceCompletion to indicate a completion
- * that was started interactively (i.e. when typing).
- *
- * Returns: %TRUE if the context is in 'interactive' mode, %FALSE otherwise
- */
-gboolean
-gtk_source_completion_context_get_interactive (GtkSourceCompletionContext *context)
-{
- g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_CONTEXT (context), FALSE);
-
- return context->priv->interactive_mode;
-}
-
-/**
- * gtk_source_completion_context_get_default:
+ * gtk_source_completion_context_get_activation:
* @context: A #GtkSourceCompletionContext
*
- * Get whether the context is targeting 'default' mode providers. The default
- * mode is used by the #GtkSourceView completion binding to invoke the
- * completion with providers that support default mode.
+ * Get the context activation
*
- * Returns: %TRUE if the context is in 'default' mode, %FALSE otherwise
+ * Returns: The context activation
*/
-gboolean
-gtk_source_completion_context_get_default (GtkSourceCompletionContext *context)
+GtkSourceCompletionActivation
+gtk_source_completion_context_get_activation (GtkSourceCompletionContext *context)
{
g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_CONTEXT (context), FALSE);
- return context->priv->default_mode;
+ return context->priv->activation;
}
void
diff --git a/gtksourceview/gtksourcecompletioncontext.h b/gtksourceview/gtksourcecompletioncontext.h
index 6fd4a1c..512c115 100644
--- a/gtksourceview/gtksourcecompletioncontext.h
+++ b/gtksourceview/gtksourcecompletioncontext.h
@@ -39,6 +39,20 @@ typedef struct _GtkSourceCompletionContext GtkSourceCompletionContext;
typedef struct _GtkSourceCompletionContextClass GtkSourceCompletionContextClass;
typedef struct _GtkSourceCompletionContextPrivate GtkSourceCompletionContextPrivate;
+/**
+ * GtkSourceCompletionActivation:
+ * @GTK_SOURCE_COMPLETION_ACTIVATION_NONE: none.
+ * @GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE: interactive activation
+ * @GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED: user requested activation
+ * (e.g. through a keyboard accelerator from the view)
+ **/
+typedef enum
+{
+ GTK_SOURCE_COMPLETION_ACTIVATION_NONE = 0,
+ GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE = 1 << 0,
+ GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED = 1 << 1
+} GtkSourceCompletionActivation;
+
/* Forward declaration */
struct _GtkSourceCompletionProvider;
struct _GtkSourceCompletion;
@@ -73,8 +87,8 @@ struct _GtkSourceView *
void gtk_source_completion_context_get_iter (GtkSourceCompletionContext *context,
GtkTextIter *iter);
-gboolean gtk_source_completion_context_get_interactive (GtkSourceCompletionContext *context);
-gboolean gtk_source_completion_context_get_default (GtkSourceCompletionContext *context);
+GtkSourceCompletionActivation
+ gtk_source_completion_context_get_activation (GtkSourceCompletionContext *context);
void _gtk_source_completion_context_cancel (GtkSourceCompletionContext *context);
diff --git a/gtksourceview/gtksourcecompletionprovider.c b/gtksourceview/gtksourcecompletionprovider.c
index 7a6fab4..b03e003 100644
--- a/gtksourceview/gtksourcecompletionprovider.c
+++ b/gtksourceview/gtksourcecompletionprovider.c
@@ -51,16 +51,11 @@ gtk_source_completion_provider_populate_default (GtkSourceCompletionProvider *pr
gtk_source_completion_context_add_proposals (context, provider, NULL, TRUE);
}
-static gboolean
-gtk_source_completion_provider_get_interactive_default (GtkSourceCompletionProvider *provider)
-{
- return TRUE;
-}
-
-static gboolean
-gtk_source_completion_provider_get_default_default (GtkSourceCompletionProvider *provider)
+static GtkSourceCompletionActivation
+gtk_source_completion_provider_get_activation_default (GtkSourceCompletionProvider *provider)
{
- return TRUE;
+ return GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE |
+ GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED;
}
static gboolean
@@ -111,8 +106,7 @@ gtk_source_completion_provider_base_init (GtkSourceCompletionProviderIface *ifac
iface->populate = gtk_source_completion_provider_populate_default;
iface->match = gtk_source_completion_provider_match_default;
- iface->get_interactive = gtk_source_completion_provider_get_interactive_default;
- iface->get_default = gtk_source_completion_provider_get_default_default;
+ iface->get_activation = gtk_source_completion_provider_get_activation_default;
iface->get_info_widget = gtk_source_completion_provider_get_info_widget_default;
iface->update_info = gtk_source_completion_provider_update_info_default;
@@ -208,39 +202,19 @@ gtk_source_completion_provider_populate (GtkSourceCompletionProvider *provider,
}
/**
- * gtk_source_completion_provider_get_default:
- * @provider: A #GtkSourceCompletionProvider
- *
- * Get whether the provider can be activated in default mode. Default mode
- * is a special mode which corresponds to the keybinding on #GtkSourceView
- * with which a completion can be invoked.
- *
- * Returns: %TRUE if the provider should be activated in default mode.
- *
- **/
-gboolean
-gtk_source_completion_provider_get_default (GtkSourceCompletionProvider *provider)
-{
- g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_PROVIDER (provider), FALSE);
- return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_default (provider);
-}
-
-/**
- * gtk_source_completion_provider_get_interactive:
+ * gtk_source_completion_provider_get_activation:
* @provider: A #GtkSourceCompletionProvider
*
- * Get whether the provider can be activated in interactive mode. Interactive
- * mode is a special completion mode which is invoked automatically when
- * typing.
+ * Get with what kind of activation the provider should be activated.
*
- * Returns: %TRUE if the provider should be activated in interactive mode.
+ * Returns: a combination of #GtkSourceCompletionActivation.
*
**/
-gboolean
-gtk_source_completion_provider_get_interactive (GtkSourceCompletionProvider *provider)
+GtkSourceCompletionActivation
+gtk_source_completion_provider_get_activation (GtkSourceCompletionProvider *provider)
{
- g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_PROVIDER (provider), FALSE);
- return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_interactive (provider);
+ g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_PROVIDER (provider), GTK_SOURCE_COMPLETION_ACTIVATION_NONE);
+ return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_activation (provider);
}
/**
diff --git a/gtksourceview/gtksourcecompletionprovider.h b/gtksourceview/gtksourcecompletionprovider.h
index c08bd5d..148fadc 100644
--- a/gtksourceview/gtksourcecompletionprovider.h
+++ b/gtksourceview/gtksourcecompletionprovider.h
@@ -58,8 +58,8 @@ struct _GtkSourceCompletionProviderIface
gboolean (*match) (GtkSourceCompletionProvider *provider,
GtkSourceCompletionContext *context);
- gboolean (*get_interactive) (GtkSourceCompletionProvider *provider);
- gboolean (*get_default) (GtkSourceCompletionProvider *provider);
+ GtkSourceCompletionActivation
+ (*get_activation) (GtkSourceCompletionProvider *provider);
GtkWidget *(*get_info_widget) (GtkSourceCompletionProvider *provider,
GtkSourceCompletionProposal *proposal);
@@ -85,8 +85,8 @@ GdkPixbuf *gtk_source_completion_provider_get_icon (GtkSourceCompletionProvider
void gtk_source_completion_provider_populate (GtkSourceCompletionProvider *provider,
GtkSourceCompletionContext *context);
-gboolean gtk_source_completion_provider_get_interactive (GtkSourceCompletionProvider *provider);
-gboolean gtk_source_completion_provider_get_default (GtkSourceCompletionProvider *provider);
+GtkSourceCompletionActivation
+ gtk_source_completion_provider_get_activation (GtkSourceCompletionProvider *provider);
gboolean gtk_source_completion_provider_match (GtkSourceCompletionProvider *provider,
GtkSourceCompletionContext *context);
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 05a7618..7999d88 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -1760,7 +1760,7 @@ gtk_source_view_redo (GtkSourceView *view)
}
static GList *
-get_default_providers (GtkSourceCompletion *completion)
+get_user_requested_providers (GtkSourceCompletion *completion)
{
GList *item;
GList *ret = NULL;
@@ -1773,7 +1773,8 @@ get_default_providers (GtkSourceCompletion *completion)
provider = GTK_SOURCE_COMPLETION_PROVIDER (item->data);
- if (gtk_source_completion_provider_get_default (provider))
+ if (gtk_source_completion_provider_get_activation (provider) &
+ GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED)
{
ret = g_list_prepend (ret, provider);
}
@@ -1794,9 +1795,12 @@ gtk_source_view_show_completion_real (GtkSourceView *view)
completion = gtk_source_view_get_completion (view);
context = gtk_source_completion_create_context (completion, NULL);
- g_object_set (context, "default", TRUE, NULL);
+ g_object_set (context,
+ "activation",
+ GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED,
+ NULL);
- providers = get_default_providers (completion);
+ providers = get_user_requested_providers (completion);
gtk_source_completion_show (completion,
providers,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]