[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 146/473: Derive applications page from page.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:55:16 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 5f911c32b00fcf44073b38c75d43194e78098ee4
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sat Jul 20 08:19:27 2013 -0400

    Derive applications page from page.
---
 src/applications_page.cpp |   53 ++++++++++++++++++++-------------------------
 src/applications_page.hpp |   11 ++++++++--
 src/category.hpp          |    6 -----
 src/filter_page.cpp       |    7 ------
 src/filter_page.hpp       |    2 --
 5 files changed, 32 insertions(+), 47 deletions(-)

diff --git a/src/applications_page.cpp b/src/applications_page.cpp
index 46da7de..5b58fff 100644
--- a/src/applications_page.cpp
+++ b/src/applications_page.cpp
@@ -23,6 +23,8 @@
 #include "menu.hpp"
 #include "section_button.hpp"
 
+#include <algorithm>
+
 extern "C"
 {
 #include <libxfce4util/libxfce4util.h>
@@ -33,10 +35,11 @@ using namespace WhiskerMenu;
 //-----------------------------------------------------------------------------
 
 ApplicationsPage::ApplicationsPage(Menu* menu) :
-	FilterPage(menu),
+	Page(menu),
 	m_garcon_menu(NULL),
 	m_current_category(NULL),
 	m_all_button(NULL),
+	m_model(NULL),
 	m_loaded(false)
 {
 	// Set desktop environment for applications
@@ -78,46 +81,25 @@ void ApplicationsPage::apply_filter(GtkToggleButton* togglebutton)
 	}
 
 	// Find category matching button
-	m_current_category = NULL;
+	Category* category = NULL;
 	for (std::vector<Category*>::const_iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
 	{
 		if (GTK_TOGGLE_BUTTON((*i)->get_button()->get_button()) == togglebutton)
 		{
-			m_current_category = *i;
+			category = *i;
 			break;
 		}
 	}
 
 	// Apply filter
-	if (m_current_category)
+	if (category)
 	{
-		get_view()->set_model(m_current_category->get_model());
+		get_view()->set_model(category->get_model());
 	}
 	else
 	{
-		get_view()->set_model(get_model());
-		refilter();
+		get_view()->set_model(m_model);
 	}
-	m_current_category = NULL;
-}
-
-//-----------------------------------------------------------------------------
-
-bool ApplicationsPage::on_filter(GtkTreeModel* model, GtkTreeIter* iter)
-{
-	if (!m_current_category)
-	{
-		return true;
-	}
-
-	Launcher* launcher = NULL;
-	gtk_tree_model_get(model, iter, LauncherModel::COLUMN_LAUNCHER, &launcher, -1);
-	if (!launcher)
-	{
-		return false;
-	}
-
-	return m_current_category->contains(launcher);
 }
 
 //-----------------------------------------------------------------------------
@@ -163,9 +145,9 @@ void ApplicationsPage::load_applications()
 	{
 		model.append_item(i->second);
 	}
-
-	// Create filter model and pass ownership to view, do not delete!
-	set_model(model.get_model());
+	m_model = model.get_model();
+	g_object_ref(m_model);
+	get_view()->set_model(m_model);
 
 	// Update filters
 	load_categories();
@@ -322,3 +304,14 @@ void ApplicationsPage::load_categories()
 }
 
 //-----------------------------------------------------------------------------
+
+void ApplicationsPage::unset_model()
+{
+	if (m_model)
+	{
+		g_object_unref(m_model);
+		m_model = NULL;
+	}
+}
+
+//-----------------------------------------------------------------------------
diff --git a/src/applications_page.hpp b/src/applications_page.hpp
index 78cc349..2d8ce7c 100644
--- a/src/applications_page.hpp
+++ b/src/applications_page.hpp
@@ -17,7 +17,7 @@
 #ifndef WHISKERMENU_APPLICATIONS_PAGE_HPP
 #define WHISKERMENU_APPLICATIONS_PAGE_HPP
 
-#include "filter_page.hpp"
+#include "page.hpp"
 
 #include <map>
 #include <string>
@@ -37,7 +37,7 @@ class LauncherView;
 class Menu;
 class SectionButton;
 
-class ApplicationsPage : public FilterPage
+class ApplicationsPage : public Page
 {
 
 public:
@@ -46,6 +46,11 @@ public:
 
 	Launcher* get_application(const std::string& desktop_id) const;
 
+	GtkTreeModel* get_model() const
+	{
+		return m_model;
+	}
+
 	void invalidate_applications();
 	void load_applications();
 
@@ -56,6 +61,7 @@ private:
 	void load_menu(GarconMenu* menu);
 	void load_menu_item(GarconMenuItem* menu_item);
 	void load_categories();
+	void unset_model();
 
 private:
 	GarconMenu* m_garcon_menu;
@@ -63,6 +69,7 @@ private:
 	SectionButton* m_all_button;
 	std::vector<Category*> m_categories;
 	std::map<std::string, Launcher*> m_items;
+	GtkTreeModel* m_model;
 	bool m_loaded;
 
 
diff --git a/src/category.hpp b/src/category.hpp
index 1238a59..e47f465 100644
--- a/src/category.hpp
+++ b/src/category.hpp
@@ -17,7 +17,6 @@
 #ifndef WHISKERMENU_CATEGORY_HPP
 #define WHISKERMENU_CATEGORY_HPP
 
-#include <algorithm>
 #include <vector>
 
 extern "C"
@@ -45,11 +44,6 @@ public:
 		return m_button;
 	}
 
-	bool contains(Launcher* launcher) const
-	{
-		return std::find(m_items.begin(), m_items.end(), launcher) != m_items.end();
-	}
-
 	bool empty() const
 	{
 		return m_items.empty();
diff --git a/src/filter_page.cpp b/src/filter_page.cpp
index 5cbdfb9..6738541 100644
--- a/src/filter_page.cpp
+++ b/src/filter_page.cpp
@@ -37,13 +37,6 @@ FilterPage::~FilterPage()
 
 //-----------------------------------------------------------------------------
 
-GtkTreeModel* FilterPage::get_model() const
-{
-	return GTK_TREE_MODEL(m_filter_model);
-}
-
-//-----------------------------------------------------------------------------
-
 void FilterPage::refilter()
 {
 	if (m_filter_model)
diff --git a/src/filter_page.hpp b/src/filter_page.hpp
index fc8753d..1bbe71b 100644
--- a/src/filter_page.hpp
+++ b/src/filter_page.hpp
@@ -28,8 +28,6 @@ public:
 	explicit FilterPage(Menu* menu);
 	~FilterPage();
 
-	GtkTreeModel* get_model() const;
-
 protected:
 	GtkTreePath* convert_child_path_to_path(GtkTreePath* path) const;
 	virtual bool on_filter(GtkTreeModel* model, GtkTreeIter* iter)=0;

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


More information about the Xfce4-commits mailing list