[gtksourceview/gtksourcecompletion] Changed can_auto_complete API to get_interactive and get_automatic



commit 092cd6ed870c0f673c090abcf93ac06e62ac7de3
Author: Jesse van den Kieboom <jesse icecrew nl>
Date:   Fri Apr 17 21:51:21 2009 +0200

    Changed can_auto_complete API to get_interactive and get_automatic
    
    gtk_source_completion_provider_get_interactive indicates that a provider provides proposals that are interactively autocompleted (e.g. while typing).
    
    gtk_source_completion_provider_get_automatic indicates that a provider will be automatically included in the list with completions (e.g. on pressing Ctrl+space)
---
 gtksourceview/gtksourcecompletion.c         |   45 ++++++++++++++++++---------
 gtksourceview/gtksourcecompletionprovider.c |   41 +++++++++++++++++++-----
 gtksourceview/gtksourcecompletionprovider.h |    7 +++-
 tests/gsc-provider-devhelp.c                |    4 +-
 tests/gsc-provider-test.c                   |    4 +-
 5 files changed, 71 insertions(+), 30 deletions(-)

diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index d708d2b..8ef37ca 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -101,7 +101,8 @@ struct _GtkSourceCompletionPrivate
 	GtkSourceView *view;
 
 	GList *providers;
-	GList *auto_providers;
+	GList *automatic_providers;
+	GList *interactive_providers;
 	GList *active_providers;
 	
 	guint show_timed_out_id;
@@ -1105,7 +1106,7 @@ show_auto_completion (GtkSourceCompletion *completion)
 	/* Check minimum amount of characters */
 	if (g_utf8_strlen (word, -1) >= completion->priv->minimum_auto_complete_length)
 	{
-		gtk_source_completion_popup (completion, completion->priv->auto_providers, word);
+		gtk_source_completion_popup (completion, completion->priv->interactive_providers, word);
 	}
 
 	g_free (word);
@@ -1129,7 +1130,7 @@ buffer_insert_text_cb (GtkTextBuffer       *buffer,
 	
 	if (!GTK_WIDGET_VISIBLE (completion->priv->window))
 	{
-		if (completion->priv->auto_providers != NULL)
+		if (completion->priv->interactive_providers != NULL)
 		{
 			update_typing_offsets (completion);
 		
@@ -1247,11 +1248,11 @@ gtk_source_completion_finalize (GObject *object)
 		g_source_remove (completion->priv->show_timed_out_id);
 	}
 	
-	if (completion->priv->providers != NULL)
-	{
-		g_list_foreach (completion->priv->providers, (GFunc)g_object_unref, NULL);
-		g_list_free (completion->priv->providers);
-	}
+	g_list_free (completion->priv->automatic_providers);
+	g_list_free (completion->priv->interactive_providers);
+	
+	g_list_foreach (completion->priv->providers, (GFunc)g_object_unref, NULL);
+	g_list_free (completion->priv->providers);
 	
 	g_free (completion->priv->filter_criteria);
 	
@@ -1869,7 +1870,7 @@ gtk_source_completion_popup (GtkSourceCompletion *completion,
 	/* Use all registered providers if no providers were specified */
 	if (providers == NULL)
 	{
-		providers = completion->priv->providers;
+		providers = completion->priv->automatic_providers;
 	}
 	
 	if (providers == NULL)
@@ -1979,10 +1980,17 @@ 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_can_auto_complete (provider))
+	if (gtk_source_completion_provider_get_interactive (provider))
 	{
-		completion->priv->auto_providers = 
-			g_list_append (completion->priv->auto_providers,
+		completion->priv->interactive_providers = 
+			g_list_append (completion->priv->interactive_providers,
+			               provider);
+	}
+	
+	if (gtk_source_completion_provider_get_automatic (provider))
+	{
+		completion->priv->automatic_providers = 
+			g_list_append (completion->priv->automatic_providers,
 			               provider);
 	}
 	                                              
@@ -2011,10 +2019,17 @@ gtk_source_completion_remove_provider (GtkSourceCompletion         *completion,
 
 	if (item != NULL)
 	{
-		if (gtk_source_completion_provider_can_auto_complete (provider))
+		if (gtk_source_completion_provider_get_interactive (provider))
+		{
+			completion->priv->interactive_providers = 
+				g_list_remove (completion->priv->interactive_providers,
+				               provider);
+		}
+		
+		if (gtk_source_completion_provider_get_automatic (provider))
 		{
-			completion->priv->auto_providers = 
-				g_list_remove (completion->priv->auto_providers,
+			completion->priv->automatic_providers = 
+				g_list_remove (completion->priv->automatic_providers,
 				               provider);
 		}
 
diff --git a/gtksourceview/gtksourcecompletionprovider.c b/gtksourceview/gtksourcecompletionprovider.c
index fb3df9c..b0494c0 100644
--- a/gtksourceview/gtksourcecompletionprovider.c
+++ b/gtksourceview/gtksourcecompletionprovider.c
@@ -61,7 +61,13 @@ gtk_source_completion_provider_filter_proposal_default (GtkSourceCompletionProvi
 }
 
 static gboolean
-gtk_source_completion_provider_can_auto_complete_default (GtkSourceCompletionProvider *provider)
+gtk_source_completion_provider_get_automatic_default (GtkSourceCompletionProvider *provider)
+{
+	return TRUE;
+}
+
+static gboolean
+gtk_source_completion_provider_get_interactive_default (GtkSourceCompletionProvider *provider)
 {
 	return FALSE;
 }
@@ -90,8 +96,10 @@ gtk_source_completion_provider_base_init (GtkSourceCompletionProviderIface *ifac
 
 	iface->get_proposals = gtk_source_completion_provider_get_proposals_default;
 	iface->filter_proposal = gtk_source_completion_provider_filter_proposal_default;
-	iface->can_auto_complete = gtk_source_completion_provider_can_auto_complete_default;
-
+	
+	iface->get_automatic = gtk_source_completion_provider_get_automatic_default;
+	iface->get_interactive = gtk_source_completion_provider_get_interactive_default;
+	
 	iface->get_info_widget = gtk_source_completion_provider_get_info_widget_default;
 	iface->update_info = gtk_source_completion_provider_update_info_default;
 	
@@ -101,7 +109,6 @@ gtk_source_completion_provider_base_init (GtkSourceCompletionProviderIface *ifac
 	}
 }
 
-
 GType 
 gtk_source_completion_provider_get_type ()
 {
@@ -196,18 +203,34 @@ gtk_source_completion_provider_filter_proposal (GtkSourceCompletionProvider *pro
 }
 
 /**
- * gtk_source_completion_provider_can_auto_complete:
+ * gtk_source_completion_provider_get_interactive:
+ * @provider: The #GtkSourceCompletionProvider
+ *
+ * Get whether @provider responds to interactive completion (e.g. completion
+ * when typing)
+ *
+ * Returns: %TRUE if @provider can be used interactively, or %FALSE otherwise
+ */
+gboolean
+gtk_source_completion_provider_get_interactive (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);
+}
+
+/**
+ * gtk_source_completion_provider_get_automatic:
  * @provider: The #GtkSourceCompletionProvider
  *
- * Get whether @provider can be used to auto complete typed words
+ * Get whether @provider is automatically included in the list of completions
  *
- * Returns: %TRUE if @provider can be used to auto complete, or %FALSE otherwise
+ * Returns: %TRUE if @provider is automatically included, or %FALSE otherwise
  */
 gboolean
-gtk_source_completion_provider_can_auto_complete (GtkSourceCompletionProvider *provider)
+gtk_source_completion_provider_get_automatic (GtkSourceCompletionProvider *provider)
 {
 	g_return_val_if_fail (GTK_IS_SOURCE_COMPLETION_PROVIDER (provider), FALSE);
-	return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->can_auto_complete (provider);
+	return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_automatic (provider);
 }
 
 /**
diff --git a/gtksourceview/gtksourcecompletionprovider.h b/gtksourceview/gtksourcecompletionprovider.h
index 6d222a8..039f8df 100644
--- a/gtksourceview/gtksourcecompletionprovider.h
+++ b/gtksourceview/gtksourcecompletionprovider.h
@@ -50,7 +50,9 @@ struct _GtkSourceCompletionProviderIface
 	gboolean 	 (*filter_proposal) 	(GtkSourceCompletionProvider *provider,
 						 GtkSourceCompletionProposal *proposal,
 						 const gchar                 *criteria);
-	gboolean         (*can_auto_complete)	(GtkSourceCompletionProvider *provider);
+
+	gboolean         (*get_automatic)	(GtkSourceCompletionProvider *provider);
+	gboolean         (*get_interactive)	(GtkSourceCompletionProvider *provider);
 						 
 	GtkWidget 	*(*get_info_widget)	(GtkSourceCompletionProvider *provider,
 						 GtkSourceCompletionProposal *proposal);
@@ -72,7 +74,8 @@ gboolean	 gtk_source_completion_provider_filter_proposal	(GtkSourceCompletionPro
 								 GtkSourceCompletionProposal *proposal,
 								 const gchar                 *criteria);
 
-gboolean 	 gtk_source_completion_provider_can_auto_complete (GtkSourceCompletionProvider *provider);
+gboolean 	 gtk_source_completion_provider_get_automatic	(GtkSourceCompletionProvider *provider);
+gboolean 	 gtk_source_completion_provider_get_interactive	(GtkSourceCompletionProvider *provider);
 
 GtkWidget	*gtk_source_completion_provider_get_info_widget	(GtkSourceCompletionProvider *provider,
 								 GtkSourceCompletionProposal *proposal);
diff --git a/tests/gsc-provider-devhelp.c b/tests/gsc-provider-devhelp.c
index ef14f89..e1649ff 100644
--- a/tests/gsc-provider-devhelp.c
+++ b/tests/gsc-provider-devhelp.c
@@ -51,7 +51,7 @@ gsc_provider_devhelp_filter_proposal (GtkSourceCompletionProvider *provider,
 }
 
 static gboolean
-gsc_provider_devhelp_can_auto_complete (GtkSourceCompletionProvider *provider)
+gsc_provider_devhelp_get_interactive(GtkSourceCompletionProvider *provider)
 {
 	return TRUE;
 }
@@ -81,7 +81,7 @@ gsc_provider_devhelp_iface_init (GtkSourceCompletionProviderIface *iface)
 {
 	iface->get_name = gsc_provider_devhelp_get_name;
 	iface->get_proposals = gsc_provider_devhelp_get_proposals;
-	iface->can_auto_complete = gsc_provider_devhelp_can_auto_complete;
+	iface->get_interactive = gsc_provider_devhelp_get_interactive;
 	iface->filter_proposal = gsc_provider_devhelp_filter_proposal;
 	
 	iface->get_info_widget = gsc_provider_devhelp_get_info_widget;
diff --git a/tests/gsc-provider-test.c b/tests/gsc-provider-test.c
index 96d64c4..690c9e0 100644
--- a/tests/gsc-provider-test.c
+++ b/tests/gsc-provider-test.c
@@ -85,7 +85,7 @@ gsc_provider_test_filter_proposal (GtkSourceCompletionProvider *provider,
 }
 
 static gboolean
-gsc_provider_test_can_auto_complete (GtkSourceCompletionProvider *provider)
+gsc_provider_test_get_interactive (GtkSourceCompletionProvider *provider)
 {
 	return TRUE;
 }
@@ -129,7 +129,7 @@ gsc_provider_test_iface_init (GtkSourceCompletionProviderIface *iface)
 
 	iface->get_proposals = gsc_provider_test_get_proposals;
 	iface->filter_proposal = gsc_provider_test_filter_proposal;
-	iface->can_auto_complete = gsc_provider_test_can_auto_complete;
+	iface->get_interactive = gsc_provider_test_get_interactive;
 }
 
 static void 



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