[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 26/28: Fix excessive menu reloading when apps are installed.
noreply at xfce.org
noreply at xfce.org
Sat Aug 20 18:33:22 CEST 2016
This is an automated email from the git hooks/post-receive script.
gottcode pushed a commit to annotated tag v1.0.1
in repository panel-plugins/xfce4-whiskermenu-plugin.
commit 90fbff3e1a51edff631452e945e199e7b29d79e0
Author: Graeme Gott <graeme at gottcode.org>
Date: Thu Jun 27 12:34:16 2013 -0400
Fix excessive menu reloading when apps are installed.
---
src/applications_page.cpp | 29 ++++++++++++++++++++++-------
src/applications_page.hpp | 8 ++++++--
src/menu.cpp | 5 ++++-
src/panel_plugin.cpp | 2 +-
4 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/src/applications_page.cpp b/src/applications_page.cpp
index 86f5b9d..9482940 100644
--- a/src/applications_page.cpp
+++ b/src/applications_page.cpp
@@ -48,7 +48,8 @@ ApplicationsPage::Category::Category(GarconMenuDirectory* directory)
ApplicationsPage::ApplicationsPage(Menu* menu) :
FilterPage(menu),
m_garcon_menu(nullptr),
- m_current_category(nullptr)
+ m_current_category(nullptr),
+ m_loaded(false)
{
// Set desktop environment for applications
const gchar* desktop = g_getenv("XDG_CURRENT_DESKTOP");
@@ -115,8 +116,13 @@ bool ApplicationsPage::on_filter(GtkTreeModel* model, GtkTreeIter* iter)
//-----------------------------------------------------------------------------
-void ApplicationsPage::reload_applications()
+void ApplicationsPage::load_applications()
{
+ if (m_loaded)
+ {
+ return;
+ }
+
// Remove previous menu data
clear_applications();
@@ -125,7 +131,7 @@ void ApplicationsPage::reload_applications()
g_object_ref(m_garcon_menu);
if (garcon_menu_load(m_garcon_menu, nullptr, nullptr))
{
- g_signal_connect_swapped(m_garcon_menu, "reload-required", SLOT_CALLBACK(ApplicationsPage::reload_applications), this);
+ g_signal_connect_swapped(m_garcon_menu, "reload-required", SLOT_CALLBACK(ApplicationsPage::invalidate_applications), this);
load_menu(m_garcon_menu);
}
@@ -149,10 +155,19 @@ void ApplicationsPage::reload_applications()
set_model(model.get_model());
// Update filters
- reload_categories();
+ load_categories();
// Update menu items of other panels
get_menu()->set_items(m_items);
+
+ m_loaded = true;
+}
+
+//-----------------------------------------------------------------------------
+
+void ApplicationsPage::invalidate_applications()
+{
+ m_loaded = false;
}
//-----------------------------------------------------------------------------
@@ -256,7 +271,7 @@ void ApplicationsPage::load_menu(GarconMenu* menu)
}
// Listen for menu changes
- g_signal_connect_swapped(menu, "directory-changed", SLOT_CALLBACK(ApplicationsPage::reload_applications), this);
+ g_signal_connect_swapped(menu, "directory-changed", SLOT_CALLBACK(ApplicationsPage::invalidate_applications), this);
}
//-----------------------------------------------------------------------------
@@ -284,12 +299,12 @@ void ApplicationsPage::load_menu_item(const gchar* desktop_id, GarconMenuItem* m
}
// Listen for menu changes
- g_signal_connect_swapped(menu_item, "changed", SLOT_CALLBACK(ApplicationsPage::reload_applications), page);
+ g_signal_connect_swapped(menu_item, "changed", SLOT_CALLBACK(ApplicationsPage::invalidate_applications), page);
}
//-----------------------------------------------------------------------------
-void ApplicationsPage::reload_categories()
+void ApplicationsPage::load_categories()
{
std::vector<GtkRadioButton*> category_buttons;
diff --git a/src/applications_page.hpp b/src/applications_page.hpp
index 990799d..345e64c 100644
--- a/src/applications_page.hpp
+++ b/src/applications_page.hpp
@@ -62,7 +62,10 @@ public:
ApplicationsPage(Menu* menu);
~ApplicationsPage();
- SLOT_0(void, ApplicationsPage, reload_applications);
+ void load_applications();
+
+public:
+ SLOT_0(void, ApplicationsPage, invalidate_applications);
private:
SLOT_1(void, ApplicationsPage, apply_filter, GtkToggleButton*);
@@ -72,7 +75,7 @@ private:
void clear_applications();
void load_menu(GarconMenu* menu);
static void load_menu_item(const gchar* desktop_id, GarconMenuItem* menu_item, ApplicationsPage* page);
- void reload_categories();
+ void load_categories();
private:
GarconMenu* m_garcon_menu;
@@ -80,6 +83,7 @@ private:
std::unordered_map<GtkRadioButton*, Category*> m_category_buttons;
std::unordered_map<Category*, std::vector<Launcher*>> m_categories;
std::unordered_map<std::string, Launcher*> m_items;
+ bool m_loaded;
};
}
diff --git a/src/menu.cpp b/src/menu.cpp
index 0d3dde4..38a088d 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -162,7 +162,7 @@ Menu::Menu(XfceRc* settings) :
gtk_box_pack_start(m_sidebar_box, gtk_hseparator_new(), false, true, 0);
// Populate app menu
- m_applications->reload_applications();
+ m_applications->load_applications();
// Show widgets
gtk_widget_show_all(GTK_WIDGET(m_vbox));
@@ -216,6 +216,9 @@ void Menu::hide()
void Menu::show(GtkWidget* parent, bool horizontal)
{
+ // Make sure applications list is current; does nothing unless list has changed
+ m_applications->load_applications();
+
// Reset mouse cursor by forcing favorites to hide
gtk_widget_show(m_favorites->get_widget());
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index c5967c8..b29ca41 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -101,7 +101,7 @@ PanelPlugin::~PanelPlugin()
void PanelPlugin::reload()
{
m_menu->hide();
- m_menu->get_applications()->reload_applications();
+ m_menu->get_applications()->invalidate_applications();
}
//-----------------------------------------------------------------------------
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list