[gtksourceview] Completion: remove model from TreeView during move-page



commit 085f5cd32c19ff9047c972268fa54022e6235384
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Feb 27 14:05:38 2013 +0100

    Completion: remove model from TreeView during move-page
    
    The row-inserted and row-deleted signals are now useless, so it
    simplifies the code of the model. And it is also more efficient.

 gtksourceview/gtksourcecompletion.c      |   12 ++---
 gtksourceview/gtksourcecompletionmodel.c |   64 +-----------------------------
 2 files changed, 6 insertions(+), 70 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 62b2fbf..f911841 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -962,7 +962,6 @@ gtk_source_completion_move_page (GtkSourceCompletion *completion,
                                  GtkScrollStep        step,
                                  gint                 num)
 {
-       GtkTreeSelection *selection;
        GList *visible_providers = NULL;
 
        if (step == GTK_SCROLL_ENDS)
@@ -993,16 +992,15 @@ gtk_source_completion_move_page (GtkSourceCompletion *completion,
                }
        }
 
+       gtk_tree_view_set_model (completion->priv->tree_view_proposals, NULL);
+
        gtk_source_completion_model_set_visible_providers (completion->priv->model_proposals,
                                                           visible_providers);
 
-       update_selection_label (completion);
-
-       selection = gtk_tree_view_get_selection (completion->priv->tree_view_proposals);
-
-       /* Unselect all, so the first proposal is selected if needed. */
-       gtk_tree_selection_unselect_all (selection);
+       gtk_tree_view_set_model (completion->priv->tree_view_proposals,
+                                GTK_TREE_MODEL (completion->priv->model_proposals));
 
+       update_selection_label (completion);
        check_first_selected (completion);
 
        g_list_free (visible_providers);
diff --git a/gtksourceview/gtksourcecompletionmodel.c b/gtksourceview/gtksourcecompletionmodel.c
index d465c6e..0e28615 100644
--- a/gtksourceview/gtksourcecompletionmodel.c
+++ b/gtksourceview/gtksourcecompletionmodel.c
@@ -857,68 +857,6 @@ gtk_source_completion_model_add_proposals (GtkSourceCompletionModel    *model,
 
 /* Get/set visible providers */
 
-static void
-show_provider (GtkSourceCompletionModel *model,
-              ProviderInfo             *provider_info)
-{
-       GtkTreePath *path;
-       GList *l;
-
-       path = get_proposal_path (model, provider_info->proposals->head);
-
-       for (l = provider_info->proposals->head; l != NULL; l = l->next)
-       {
-               GtkTreeIter iter;
-               iter.user_data = l;
-
-               gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
-
-               gtk_tree_path_next (path);
-       }
-
-       gtk_tree_path_free (path);
-}
-
-static void
-hide_provider (GtkSourceCompletionModel *model,
-              ProviderInfo             *provider_info)
-{
-       GtkTreePath *path;
-       gint i;
-
-       path = get_proposal_path (model, provider_info->proposals->head);
-
-       for (i = 0; i < provider_info->proposals->length; i++)
-       {
-               gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
-       }
-
-       gtk_tree_path_free (path);
-}
-
-static void
-update_provider_visibility (GtkSourceCompletionModel *model,
-                           ProviderInfo             *provider_info)
-{
-       gboolean new_visible = is_provider_visible (model, provider_info->completion_provider);
-
-       if (new_visible == provider_info->visible)
-       {
-               return;
-       }
-
-       if (new_visible)
-       {
-               provider_info->visible = TRUE;
-               show_provider (model, provider_info);
-       }
-       else
-       {
-               hide_provider (model, provider_info);
-               provider_info->visible = FALSE;
-       }
-}
-
 void
 gtk_source_completion_model_set_visible_providers (GtkSourceCompletionModel *model,
                                                    GList                    *providers)
@@ -941,7 +879,7 @@ gtk_source_completion_model_set_visible_providers (GtkSourceCompletionModel *mod
        for (l = model->priv->providers; l != NULL; l = l->next)
        {
                ProviderInfo *provider_info = l->data;
-               update_provider_visibility (model, provider_info);
+               provider_info->visible = is_provider_visible (model, provider_info->completion_provider);
        }
 }
 


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