[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 69/473: Fix changes to favorites not always saved. Closes #9.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:53:59 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 13110181b8c5400cf474085819ee554932960e7c
Author: Graeme Gott <graeme at gottcode.org>
Date:   Fri Jul 5 14:34:48 2013 -0400

    Fix changes to favorites not always saved. Closes #9.
---
 src/configuration_dialog.hpp |    5 +++++
 src/list_page.cpp            |    2 ++
 src/menu.cpp                 |   11 ++++++++++-
 src/menu.hpp                 |    7 +++++++
 src/page.cpp                 |    2 ++
 src/panel_plugin.cpp         |    7 ++++++-
 6 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/configuration_dialog.hpp b/src/configuration_dialog.hpp
index 5462414..b518997 100644
--- a/src/configuration_dialog.hpp
+++ b/src/configuration_dialog.hpp
@@ -35,6 +35,11 @@ public:
 	explicit ConfigurationDialog(PanelPlugin* plugin);
 	~ConfigurationDialog();
 
+	GtkWidget* get_widget() const
+	{
+		return m_window;
+	}
+
 private:
 	SLOT_0(void, ConfigurationDialog, choose_icon);
 	SLOT_1(void, ConfigurationDialog, toggle_hover_switch_category, GtkToggleButton*);
diff --git a/src/list_page.cpp b/src/list_page.cpp
index 4886b0c..06e0beb 100644
--- a/src/list_page.cpp
+++ b/src/list_page.cpp
@@ -19,6 +19,7 @@
 #include "launcher.hpp"
 #include "launcher_model.hpp"
 #include "launcher_view.hpp"
+#include "menu.hpp"
 
 #include <algorithm>
 
@@ -144,6 +145,7 @@ void ListPage::on_row_changed(GtkTreeModel* model, GtkTreePath* path, GtkTreeIte
 	if (launcher)
 	{
 		m_desktop_ids[pos] = garcon_menu_item_get_desktop_id(launcher->get_item());
+		get_menu()->set_modified(); // Handle favorites being rearranged
 	}
 }
 
diff --git a/src/menu.cpp b/src/menu.cpp
index 6ac7fc3..5de79b7 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -55,7 +55,8 @@ static GtkButton* new_action_button(const gchar* icon, const gchar* text)
 Menu::Menu(XfceRc* settings) :
 	m_window(NULL),
 	m_layout_left(true),
-	m_layout_bottom(true)
+	m_layout_bottom(true),
+	m_modified(false)
 {
 	m_geometry.x = 0;
 	m_geometry.y = 0;
@@ -410,6 +411,7 @@ void Menu::save(XfceRc* settings)
 		m_recent->save(settings);
 		xfce_rc_write_int_entry(settings, "menu-width", m_geometry.width);
 		xfce_rc_write_int_entry(settings, "menu-height", m_geometry.height);
+		m_modified = false;
 	}
 }
 
@@ -443,6 +445,13 @@ void Menu::set_items(const std::map<std::string, Launcher*>& items)
 
 //-----------------------------------------------------------------------------
 
+void Menu::set_modified()
+{
+	m_modified = true;
+}
+
+//-----------------------------------------------------------------------------
+
 void Menu::unset_items()
 {
 	m_search_results->unset_menu_items();
diff --git a/src/menu.hpp b/src/menu.hpp
index 6cee971..f6ac5ef 100644
--- a/src/menu.hpp
+++ b/src/menu.hpp
@@ -70,11 +70,17 @@ public:
 		return m_recent;
 	}
 
+	bool get_modified() const
+	{
+		return m_modified;
+	}
+
 	void hide();
 	void show(GtkWidget* parent, bool horizontal);
 	void save(XfceRc* settings);
 	void set_categories(const std::vector<GtkRadioButton*>& categories);
 	void set_items(const std::map<std::string, Launcher*>& items);
+	void set_modified();
 	void unset_items();
 
 private:
@@ -121,6 +127,7 @@ private:
 	GdkRectangle m_geometry;
 	bool m_layout_left;
 	bool m_layout_bottom;
+	bool m_modified;
 };
 
 }
diff --git a/src/page.cpp b/src/page.cpp
index 93c9e71..6e3159f 100644
--- a/src/page.cpp
+++ b/src/page.cpp
@@ -319,6 +319,7 @@ void Page::add_selected_to_favorites()
 {
 	Launcher* launcher = get_selected_launcher();
 	m_menu->get_favorites()->add(launcher);
+	m_menu->set_modified();
 }
 
 //-----------------------------------------------------------------------------
@@ -327,6 +328,7 @@ void Page::remove_selected_from_favorites()
 {
 	Launcher* launcher = get_selected_launcher();
 	m_menu->get_favorites()->remove(launcher);
+	m_menu->set_modified();
 }
 
 //-----------------------------------------------------------------------------
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index 980b0eb..b6140f5 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -157,13 +157,18 @@ void PanelPlugin::menu_hidden()
 {
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_button), false);
 	xfce_panel_plugin_block_autohide(m_plugin, false);
+	if (m_menu->get_modified())
+	{
+		save();
+	}
 }
 
 //-----------------------------------------------------------------------------
 
 void PanelPlugin::configure()
 {
-	new ConfigurationDialog(this);
+	ConfigurationDialog* dialog = new ConfigurationDialog(this);
+	g_signal_connect_swapped(dialog->get_widget(), "destroy", SLOT_CALLBACK(PanelPlugin::save), this);
 }
 
 //-----------------------------------------------------------------------------

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


More information about the Xfce4-commits mailing list