[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 213/473: Use a category for all applications.
noreply at xfce.org
noreply at xfce.org
Mon Feb 16 23:56:23 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 1038f86e56bb987f1ea873f0d71be3342c00e094
Author: Graeme Gott <graeme at gottcode.org>
Date: Fri Nov 1 17:06:19 2013 -0400
Use a category for all applications.
---
panel-plugin/applications-page.cpp | 68 ++++++++----------------------------
panel-plugin/applications-page.h | 8 -----
panel-plugin/category.cpp | 26 ++++++++------
panel-plugin/window.cpp | 2 +-
4 files changed, 30 insertions(+), 74 deletions(-)
diff --git a/panel-plugin/applications-page.cpp b/panel-plugin/applications-page.cpp
index c6bca3c..9dd0766 100644
--- a/panel-plugin/applications-page.cpp
+++ b/panel-plugin/applications-page.cpp
@@ -19,18 +19,12 @@
#include "category.h"
#include "launcher.h"
-#include "launcher-model.h"
#include "launcher-view.h"
#include "section-button.h"
#include "window.h"
#include <algorithm>
-extern "C"
-{
-#include <libxfce4util/libxfce4util.h>
-}
-
using namespace WhiskerMenu;
//-----------------------------------------------------------------------------
@@ -42,8 +36,6 @@ static bool f_load_hierarchy = false;
ApplicationsPage::ApplicationsPage(Window* window) :
Page(window),
m_garcon_menu(NULL),
- m_all_button(NULL),
- m_model(NULL),
m_loaded(false)
{
// Set desktop environment for applications
@@ -94,20 +86,15 @@ void ApplicationsPage::apply_filter(GtkToggleButton* togglebutton)
break;
}
}
-
- // Apply filter
- if (category)
- {
- get_view()->unset_model();
- get_view()->set_fixed_height_mode(!category->has_separators());
- get_view()->set_model(category->get_model());
- }
- else
+ if (!category)
{
- get_view()->unset_model();
- get_view()->set_fixed_height_mode(true);
- get_view()->set_model(m_model);
+ return;
}
+
+ // Apply filter
+ get_view()->unset_model();
+ get_view()->set_fixed_height_mode(!category->has_separators());
+ get_view()->set_model(category->get_model());
}
//-----------------------------------------------------------------------------
@@ -151,25 +138,17 @@ void ApplicationsPage::load_applications()
std::sort(m_categories.begin(), m_categories.end(), &Element::less_than);
}
- // Create sorted list of menu items
- std::vector<Launcher*> sorted_items;
- sorted_items.reserve(m_items.size());
+ // Create all items category
+ Category* category = new Category(NULL);
for (std::map<std::string, Launcher*>::const_iterator i = m_items.begin(), end = m_items.end(); i != end; ++i)
{
- sorted_items.push_back(i->second);
+ category->append_item(i->second);
}
- std::sort(sorted_items.begin(), sorted_items.end(), &Element::less_than);
+ category->sort();
+ m_categories.insert(m_categories.begin(), category);
- // Add all items to model
- LauncherModel model;
- for (std::vector<Launcher*>::const_iterator i = sorted_items.begin(), end = sorted_items.end(); i != end; ++i)
- {
- model.append_item(*i);
- }
- m_model = model.get_model();
- g_object_ref(m_model);
get_view()->set_fixed_height_mode(true);
- get_view()->set_model(m_model);
+ get_view()->set_model(category->get_model());
// Update filters
load_categories();
@@ -185,9 +164,6 @@ void ApplicationsPage::load_applications()
void ApplicationsPage::clear_applications()
{
// Free categories
- delete m_all_button;
- m_all_button = NULL;
-
for (std::vector<Category*>::iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
{
delete *i;
@@ -196,7 +172,7 @@ void ApplicationsPage::clear_applications()
// Free menu items
get_window()->unset_items();
- unset_model();
+ get_view()->unset_model();
for (std::map<std::string, Launcher*>::iterator i = m_items.begin(), end = m_items.end(); i != end; ++i)
{
@@ -309,11 +285,6 @@ void ApplicationsPage::load_categories()
{
std::vector<SectionButton*> category_buttons;
- // Add button for all applications
- m_all_button = new SectionButton("applications-other", _("All"));
- g_signal_connect(m_all_button->get_button(), "toggled", G_CALLBACK(ApplicationsPage::apply_filter_slot), this);
- category_buttons.push_back(m_all_button);
-
// Add buttons for categories
for (std::vector<Category*>::const_iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
{
@@ -328,17 +299,6 @@ void ApplicationsPage::load_categories()
//-----------------------------------------------------------------------------
-void ApplicationsPage::unset_model()
-{
- if (m_model)
- {
- g_object_unref(m_model);
- m_model = NULL;
- }
-}
-
-//-----------------------------------------------------------------------------
-
bool ApplicationsPage::get_load_hierarchy()
{
return f_load_hierarchy;
diff --git a/panel-plugin/applications-page.h b/panel-plugin/applications-page.h
index 5035dc6..dfb3485 100644
--- a/panel-plugin/applications-page.h
+++ b/panel-plugin/applications-page.h
@@ -46,11 +46,6 @@ public:
Launcher* get_application(const std::string& desktop_id) const;
- GtkTreeModel* get_model() const
- {
- return m_model;
- }
-
void invalidate_applications();
void load_applications();
@@ -64,14 +59,11 @@ private:
void load_menu(GarconMenu* menu, Category* parent_category);
void load_menu_item(GarconMenuItem* menu_item, Category* category);
void load_categories();
- void unset_model();
private:
GarconMenu* m_garcon_menu;
- 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/panel-plugin/category.cpp b/panel-plugin/category.cpp
index 3ce50c1..4b6d12a 100644
--- a/panel-plugin/category.cpp
+++ b/panel-plugin/category.cpp
@@ -22,6 +22,11 @@
#include <algorithm>
+extern "C"
+{
+#include <glib/gi18n.h>
+}
+
using namespace WhiskerMenu;
//-----------------------------------------------------------------------------
@@ -44,21 +49,20 @@ Category::Category(GarconMenuDirectory* directory) :
m_has_separators(false),
m_has_subcategories(false)
{
- // Fetch icon
- const gchar* icon = garcon_menu_directory_get_icon_name(directory);
- if (G_UNLIKELY(!icon))
+ const gchar* icon = NULL;
+ const gchar* text = NULL;
+ if (directory)
{
- icon = "";
+ icon = garcon_menu_directory_get_icon_name(directory);
+ text = garcon_menu_directory_get_name(directory);
}
- set_icon(icon);
-
- // Fetch text
- const gchar* text = garcon_menu_directory_get_name(directory);
- if (G_UNLIKELY(!text))
+ else
{
- text = "";
+ icon = "applications-other";
+ text = _("All");
}
- set_text(text);
+ set_icon(icon ? icon : "");
+ set_text(text ? text : "");
}
//-----------------------------------------------------------------------------
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index 6617425..33cefcd 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -571,7 +571,7 @@ void Window::set_categories(const std::vector<SectionButton*>& categories)
void Window::set_items()
{
- m_search_results->set_menu_items(m_applications->get_model());
+ m_search_results->set_menu_items(m_applications->get_view()->get_model());
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