[gtksourceview/wip/completion-model: 10/19] Completion: remove model_{begin, end}_populate()



commit 66ce74e2813c683384560b13d98465ef01ca3d92
Author: SÃbastien Wilmet <swilmet gnome org>
Date:   Mon Jan 21 19:38:47 2013 +0100

    Completion: remove model_{begin,end}_populate()
    
    Remove also the tests for multiple populations in the same model. It is
    not used anymore.

 gtksourceview/gtksourcecompletion.c      |    7 --
 gtksourceview/gtksourcecompletionmodel.c |   17 +-----
 gtksourceview/gtksourcecompletionmodel.h |    8 ---
 tests/test-completion-model.c            |   96 ------------------------------
 4 files changed, 1 insertions(+), 127 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index b714c6a..90954be 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -3157,9 +3157,6 @@ update_completion (GtkSourceCompletion        *completion,
 	gtk_source_completion_model_set_show_headers (completion->priv->model_proposals,
 						      completion->priv->show_headers);
 
-	gtk_source_completion_model_begin_populate (completion->priv->model_proposals,
-						    completion->priv->active_providers);
-
 	for (item = providers; item != NULL; item = g_list_next (item))
 	{
 		GtkSourceCompletionProvider *provider =
@@ -3263,10 +3260,6 @@ _gtk_source_completion_add_proposals (GtkSourceCompletion         *completion,
 
 	if (finished)
 	{
-		/* Let the model know this provider is done */
-		gtk_source_completion_model_end_populate (completion->priv->model_proposals,
-							  provider);
-
 		/* Remove provider from list of running providers */
 		completion->priv->running_providers =
 			g_list_delete_link (completion->priv->running_providers,
diff --git a/gtksourceview/gtksourcecompletionmodel.c b/gtksourceview/gtksourcecompletionmodel.c
index 69bbf2f..df15e3f 100644
--- a/gtksourceview/gtksourcecompletionmodel.c
+++ b/gtksourceview/gtksourcecompletionmodel.c
@@ -730,22 +730,7 @@ gtk_source_completion_model_init (GtkSourceCompletionModel *self)
 	self->priv->visible_providers = NULL;
 }
 
-/* Population: begin/end populate, add proposals, cancel */
-
-void
-gtk_source_completion_model_begin_populate (GtkSourceCompletionModel *model,
-					    GList                    *providers)
-{
-	g_return_if_fail (GTK_SOURCE_IS_COMPLETION_MODEL (model));
-}
-
-void
-gtk_source_completion_model_end_populate (GtkSourceCompletionModel    *model,
-					  GtkSourceCompletionProvider *provider)
-{
-	g_return_if_fail (GTK_SOURCE_IS_COMPLETION_MODEL (model));
-	g_return_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider));
-}
+/* Population: add proposals */
 
 /* Returns the newly-created provider node */
 static GList *
diff --git a/gtksourceview/gtksourcecompletionmodel.h b/gtksourceview/gtksourcecompletionmodel.h
index af4b599..4804066 100644
--- a/gtksourceview/gtksourcecompletionmodel.h
+++ b/gtksourceview/gtksourcecompletionmodel.h
@@ -69,19 +69,11 @@ GtkSourceCompletionModel *
          gtk_source_completion_model_new			(void);
 
 G_GNUC_INTERNAL
-void     gtk_source_completion_model_begin_populate             (GtkSourceCompletionModel    *model,
-								 GList                       *providers);
-
-G_GNUC_INTERNAL
 void     gtk_source_completion_model_add_proposals              (GtkSourceCompletionModel    *model,
 								 GtkSourceCompletionProvider *provider,
 								 GList                       *proposals);
 
 G_GNUC_INTERNAL
-void     gtk_source_completion_model_end_populate               (GtkSourceCompletionModel    *model,
-								 GtkSourceCompletionProvider *provider);
-
-G_GNUC_INTERNAL
 gboolean gtk_source_completion_model_is_empty			(GtkSourceCompletionModel    *model,
 								 gboolean                     only_visible);
 
diff --git a/tests/test-completion-model.c b/tests/test-completion-model.c
index acba596..c858b87 100644
--- a/tests/test-completion-model.c
+++ b/tests/test-completion-model.c
@@ -134,8 +134,6 @@ populate_model (GtkSourceCompletionModel *model,
 	GList *cur_provider;
 	GList *cur_list_proposals;
 
-	gtk_source_completion_model_begin_populate (model, all_providers);
-
 	for (cur_provider = all_providers,
 	     cur_list_proposals = all_list_proposals;
 	     cur_provider != NULL;
@@ -145,9 +143,6 @@ populate_model (GtkSourceCompletionModel *model,
 		gtk_source_completion_model_add_proposals (model,
 							   GTK_SOURCE_COMPLETION_PROVIDER (cur_provider->data),
 							   cur_list_proposals->data);
-
-		gtk_source_completion_model_end_populate (model,
-							  GTK_SOURCE_COMPLETION_PROVIDER (cur_provider->data));
 	}
 }
 
@@ -321,15 +316,10 @@ test_is_empty (void)
 	list_providers = g_list_append (list_providers, provider);
 	list_proposals = create_proposals ();
 
-	gtk_source_completion_model_begin_populate (model, list_providers);
-
 	gtk_source_completion_model_add_proposals (model,
 						   GTK_SOURCE_COMPLETION_PROVIDER (provider),
 						   list_proposals);
 
-	gtk_source_completion_model_end_populate (model,
-						  GTK_SOURCE_COMPLETION_PROVIDER (provider));
-
 	g_assert (!gtk_source_completion_model_is_empty (model, FALSE));
 	g_assert (!gtk_source_completion_model_is_empty (model, TRUE));
 
@@ -445,82 +435,6 @@ test_set_visible_providers (void)
 	g_list_free (subset_list_proposals);
 }
 
-/* Do a first populate, and then a second populate with another set of
- * proposals. The proposals in common between the two populates are inserted in
- * the same order.
- */
-static void
-test_second_populate_same_order (void)
-{
-	GtkSourceCompletionModel *model;
-	GList *all_providers = NULL;
-	GList *all_list_proposals = NULL;
-	GList *list_proposals = NULL;
-
-	/* First populate with two providers */
-	model = gtk_source_completion_model_new ();
-	create_providers (&all_providers, &all_list_proposals);
-	populate_model (model, all_providers, all_list_proposals);
-
-	/* Remove the second provider and its associated proposals */
-	g_object_unref (all_providers->next->data);
-	all_providers = g_list_delete_link (all_providers, all_providers->next);
-
-	g_list_free_full (all_list_proposals->next->data, g_object_unref);
-	all_list_proposals = g_list_delete_link (all_list_proposals, all_list_proposals->next);
-
-	/* Alter the proposals of the remaining provider */
-	list_proposals = all_list_proposals->data;
-	g_object_unref (list_proposals->data);
-	list_proposals = g_list_delete_link (list_proposals, list_proposals);
-	list_proposals = g_list_concat (list_proposals, create_proposals ());
-	all_list_proposals->data = list_proposals;
-
-	/* Second populate */
-	populate_model (model, all_providers, all_list_proposals);
-	check_all_providers_with_and_without_headers (model, all_providers, all_list_proposals);
-
-	g_object_unref (model);
-	free_providers (all_providers, all_list_proposals);
-}
-
-/* Same as test_second_populate_same_order() but with a different insertion
- * order of the common proposals for the second populate.
- */
-static void
-test_second_populate_different_order (void)
-{
-	GtkSourceCompletionModel *model;
-	GList *all_providers = NULL;
-	GList *all_list_proposals = NULL;
-	GList *list_proposals = NULL;
-
-	/* First populate with two providers */
-	model = gtk_source_completion_model_new ();
-	create_providers (&all_providers, &all_list_proposals);
-	populate_model (model, all_providers, all_list_proposals);
-
-	/* Remove the second provider and its associated proposals */
-	g_object_unref (all_providers->next->data);
-	all_providers = g_list_delete_link (all_providers, all_providers->next);
-
-	g_list_free_full (all_list_proposals->next->data, g_object_unref);
-	all_list_proposals = g_list_delete_link (all_list_proposals, all_list_proposals->next);
-
-	/* Alter the proposals of the remaining provider */
-	list_proposals = all_list_proposals->data;
-	list_proposals = g_list_reverse (list_proposals);
-	list_proposals = g_list_concat (list_proposals, create_proposals ());
-	all_list_proposals->data = list_proposals;
-
-	/* Second populate */
-	populate_model (model, all_providers, all_list_proposals);
-	check_all_providers_with_and_without_headers (model, all_providers, all_list_proposals);
-
-	g_object_unref (model);
-	free_providers (all_providers, all_list_proposals);
-}
-
 static void
 test_populate_several_batches (void)
 {
@@ -533,7 +447,6 @@ test_populate_several_batches (void)
 	GtkTreeIter iter;
 
 	gtk_source_completion_model_set_show_headers (model, TRUE);
-	gtk_source_completion_model_begin_populate (model, list_providers);
 
 	/* First batch */
 	gtk_source_completion_model_add_proposals (model, provider, first_proposals);
@@ -544,7 +457,6 @@ test_populate_several_batches (void)
 
 	/* Second batch */
 	gtk_source_completion_model_add_proposals (model, provider, second_proposals);
-	gtk_source_completion_model_end_populate (model, provider);
 
 	all_proposals = g_list_copy (first_proposals);
 	all_proposals = g_list_concat (all_proposals, g_list_copy (second_proposals));
@@ -601,9 +513,7 @@ test_n_proposals (void)
 	list_providers = g_list_append (NULL, provider);
 	list_proposals = create_proposals ();
 
-	gtk_source_completion_model_begin_populate (model, list_providers);
 	gtk_source_completion_model_add_proposals (model, provider, list_proposals);
-	gtk_source_completion_model_end_populate (model, provider);
 
 	g_assert (gtk_source_completion_model_n_proposals (model, other_provider) == 0);
 
@@ -710,12 +620,6 @@ main (int argc, char **argv)
 	g_test_add_func ("/CompletionModel/set-visible-providers",
 			 test_set_visible_providers);
 
-	g_test_add_func ("/CompletionModel/second-populate-same-order",
-			 test_second_populate_same_order);
-
-	g_test_add_func ("/CompletionModel/second-populate-different-order",
-			 test_second_populate_different_order);
-
 	g_test_add_func ("/CompletionModel/populate-several-batches",
 			 test_populate_several_batches);
 



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