[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 05/06: Create search model more efficiently.

noreply at xfce.org noreply at xfce.org
Fri Feb 7 01:56:26 CET 2020


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

g   o   t   t   c   o   d   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 1110cf78bd5a9bc87970623c8ea07ba813514685
Author: Graeme Gott <graeme at gottcode.org>
Date:   Thu Feb 6 15:47:26 2020 -0500

    Create search model more efficiently.
---
 panel-plugin/applications-page.cpp | 13 +++++++++++++
 panel-plugin/applications-page.h   |  1 +
 panel-plugin/search-page.cpp       | 17 +++--------------
 panel-plugin/search-page.h         |  2 +-
 panel-plugin/window.cpp            |  2 +-
 5 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/panel-plugin/applications-page.cpp b/panel-plugin/applications-page.cpp
index 2584000..d9f8a63 100644
--- a/panel-plugin/applications-page.cpp
+++ b/panel-plugin/applications-page.cpp
@@ -114,6 +114,19 @@ Launcher* ApplicationsPage::find(const std::string& desktop_id) const
 
 //-----------------------------------------------------------------------------
 
+std::vector<Launcher*> ApplicationsPage::find_all() const
+{
+	std::vector<Launcher*> launchers;
+	launchers.reserve(m_items.size());
+	for (const auto& i : m_items)
+	{
+		launchers.push_back(i.second);
+	}
+	return launchers;
+}
+
+//-----------------------------------------------------------------------------
+
 void ApplicationsPage::apply_filter(GtkToggleButton* togglebutton)
 {
 	// Only apply filter for active button
diff --git a/panel-plugin/applications-page.h b/panel-plugin/applications-page.h
index df22855..724bd8b 100644
--- a/panel-plugin/applications-page.h
+++ b/panel-plugin/applications-page.h
@@ -40,6 +40,7 @@ public:
 
 	GtkTreeModel* create_launcher_model(std::vector<std::string>& desktop_ids) const;
 	Launcher* find(const std::string& desktop_id) const;
+	std::vector<Launcher*> find_all() const;
 
 	void invalidate();
 	bool load();
diff --git a/panel-plugin/search-page.cpp b/panel-plugin/search-page.cpp
index 778496b..15501f8 100644
--- a/panel-plugin/search-page.cpp
+++ b/panel-plugin/search-page.cpp
@@ -17,6 +17,7 @@
 
 #include "search-page.h"
 
+#include "applications-page.h"
 #include "launcher.h"
 #include "launcher-view.h"
 #include "search-action.h"
@@ -154,21 +155,9 @@ void SearchPage::set_filter(const gchar* filter)
 
 //-----------------------------------------------------------------------------
 
-void SearchPage::set_menu_items(GtkTreeModel* model)
+void SearchPage::set_menu_items()
 {
-	// loop over every single item in model
-	GtkTreeIter iter;
-	bool valid = gtk_tree_model_get_iter_first(model, &iter);
-	while (valid)
-	{
-		Launcher* launcher = nullptr;
-		gtk_tree_model_get(model, &iter, LauncherView::COLUMN_LAUNCHER, &launcher, -1);
-		if (launcher)
-		{
-			m_launchers.push_back(launcher);
-		}
-		valid = gtk_tree_model_iter_next(model, &iter);
-	}
+	m_launchers = get_window()->get_applications()->find_all();
 
 	get_view()->unset_model();
 
diff --git a/panel-plugin/search-page.h b/panel-plugin/search-page.h
index bb5aac9..e4e67db 100644
--- a/panel-plugin/search-page.h
+++ b/panel-plugin/search-page.h
@@ -35,7 +35,7 @@ public:
 	~SearchPage();
 
 	void set_filter(const gchar* filter);
-	void set_menu_items(GtkTreeModel* model);
+	void set_menu_items();
 	void unset_menu_items();
 
 private:
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index 433cf8a..26ecc09 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -566,7 +566,7 @@ void WhiskerMenu::Window::set_categories(const std::vector<CategoryButton*>& cat
 
 void WhiskerMenu::Window::set_items()
 {
-	m_search_results->set_menu_items(m_applications->get_view()->get_model());
+	m_search_results->set_menu_items();
 	m_favorites->set_menu_items();
 	m_recent->set_menu_items();
 

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


More information about the Xfce4-commits mailing list