[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 73/473: Optimize showing search results.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:54:03 CET 2015


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 23df6dd6a1b93a145399dd18941d480a783907bd
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sat Jul 6 07:03:34 2013 -0400

    Optimize showing search results.
---
 src/search_page.cpp |   30 +++++++++++++-----------------
 src/search_page.hpp |    1 -
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/search_page.cpp b/src/search_page.cpp
index 9a7788d..cace7e2 100644
--- a/src/search_page.cpp
+++ b/src/search_page.cpp
@@ -59,20 +59,22 @@ void SearchPage::set_filter(const gchar* filter)
 	}
 	m_query.set(query);
 
+	// Remove previous search results
+	g_object_freeze_notify(G_OBJECT(get_view()->get_widget()));
+	get_view()->unset_model();
+	gtk_tree_model_sort_reset_default_sort_func(m_sort_model);
+
 	// Create search results
 	for (std::vector<Launcher*>::iterator i = m_launchers.begin(), end = m_launchers.end(); i != end; ++i)
 	{
 		(*i)->search(m_query);
 	}
-
-	// Apply filter
-	GtkTreeModel* filter_model = gtk_tree_model_sort_get_model(m_sort_model);
-	get_view()->set_model(filter_model);
-	unset_search_model();
-
 	refilter();
 
-	set_search_model(filter_model);
+	// Show search results
+	gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(m_sort_model), (GtkTreeIterCompareFunc)&SearchPage::on_sort, this, NULL);
+	get_view()->set_model(GTK_TREE_MODEL(m_sort_model));
+	g_object_thaw_notify(G_OBJECT(get_view()->get_widget()));
 
 	// Find first result
 	GtkTreeIter iter;
@@ -105,7 +107,9 @@ void SearchPage::set_menu_items(GtkTreeModel* model)
 
 	unset_search_model();
 	set_model(model);
-	set_search_model(get_view()->get_model());
+	m_sort_model = GTK_TREE_MODEL_SORT(gtk_tree_model_sort_new_with_model(get_view()->get_model()));
+	gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(m_sort_model), (GtkTreeIterCompareFunc)&SearchPage::on_sort, this, NULL);
+	get_view()->unset_model();
 }
 
 //-----------------------------------------------------------------------------
@@ -147,15 +151,6 @@ gint SearchPage::on_sort(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, Se
 
 //-----------------------------------------------------------------------------
 
-void SearchPage::set_search_model(GtkTreeModel* child_model)
-{
-	m_sort_model = GTK_TREE_MODEL_SORT(gtk_tree_model_sort_new_with_model(child_model));
-	gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(m_sort_model), (GtkTreeIterCompareFunc)&SearchPage::on_sort, this, NULL);
-	get_view()->set_model(GTK_TREE_MODEL(m_sort_model));
-}
-
-//-----------------------------------------------------------------------------
-
 void SearchPage::unset_search_model()
 {
 	if (m_sort_model)
@@ -163,6 +158,7 @@ void SearchPage::unset_search_model()
 		g_object_unref(m_sort_model);
 		m_sort_model = NULL;
 	}
+	get_view()->unset_model();
 }
 
 //-----------------------------------------------------------------------------
diff --git a/src/search_page.hpp b/src/search_page.hpp
index 047ce9a..e12e677 100644
--- a/src/search_page.hpp
+++ b/src/search_page.hpp
@@ -46,7 +46,6 @@ private:
 private:
 	bool on_filter(GtkTreeModel* model, GtkTreeIter* iter);
 	static gint on_sort(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, SearchPage* page);
-	void set_search_model(GtkTreeModel* child_model);
 	void unset_search_model();
 
 private:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list