[devhelp/wip/swilmet/various-code-improvements] sidebar: disconnect the hitlist_model during a new filtering



commit 1b55f062217bdb43baca1ec0e99a04d60afe7c09
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Nov 12 20:46:34 2015 +0100

    sidebar: disconnect the hitlist_model during a new filtering
    
    See the comment in the code for the rationale. The following behavior
    was strange:
    
    1. launch devhelp, search something -> nothing is selected in the
       hitlist.
    2. select something in the results.
    3. edit the search (or oven clear the search and begin a new search)
       -> the same row is kept selected.
    
    Now as soon as we edit the search, the selection is cleared, which feels
    natural to me.

 src/dh-sidebar.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/dh-sidebar.c b/src/dh-sidebar.c
index be16855..d0e02c8 100644
--- a/src/dh-sidebar.c
+++ b/src/dh-sidebar.c
@@ -80,11 +80,20 @@ sidebar_filter_idle_cb (DhSidebar *sidebar)
         book_link = dh_sidebar_get_selected_book (sidebar);
         book_id = book_link != NULL ? dh_link_get_book_id (book_link) : NULL;
 
+        /* Disconnect the model during the filter, for:
+         * 1. better performances.
+         * 2. clearing the selection.
+         */
+        gtk_tree_view_set_model (priv->hitlist_view, NULL);
+
         link = dh_keyword_model_filter (priv->hitlist_model,
                                         search_text,
                                         book_id,
                                         NULL);
 
+        gtk_tree_view_set_model (priv->hitlist_view,
+                                 GTK_TREE_MODEL (priv->hitlist_model));
+
         if (link != NULL)
                 g_signal_emit (sidebar, signals[LINK_SELECTED], 0, link);
 


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