[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 06/08: Fix changes to favorites not always saved.

noreply at xfce.org noreply at xfce.org
Sat Aug 20 18:33:41 CEST 2016


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

gottcode pushed a commit to annotated tag v1.0.3
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 243b32cfb128cabcbe9edc6dbc5269213a1377d4
Author: Graeme Gott <graeme at gottcode.org>
Date:   Fri Jul 5 14:34:48 2013 -0400

    Fix changes to favorites not always saved.
---
 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 f35e69e..7d3bdd5 100644
--- a/src/configuration_dialog.hpp
+++ b/src/configuration_dialog.hpp
@@ -35,6 +35,11 @@ public:
 	ConfigurationDialog(PanelPlugin* plugin);
 	~ConfigurationDialog();
 
+	GtkWidget* get_widget() const
+	{
+		return m_window;
+	}
+
 private:
 	SLOT_0(void, ConfigurationDialog, choose_icon);
 	SLOT_1(void, ConfigurationDialog, toggle_show_name, GtkToggleButton*);
diff --git a/src/list_page.cpp b/src/list_page.cpp
index 2f39c0a..af823dc 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 8c6d23b..df6cd3c 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -54,7 +54,8 @@ Menu::Menu(XfceRc* settings) :
 	m_window(nullptr),
 	m_geometry{0,0,400,500},
 	m_layout_left(true),
-	m_layout_bottom(true)
+	m_layout_bottom(true),
+	m_modified(false)
 {
 	// Create the window
 	m_window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
@@ -378,6 +379,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;
 	}
 }
 
@@ -411,6 +413,13 @@ void Menu::set_items(std::unordered_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 6fc00ad..ca89557 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(std::vector<GtkRadioButton*> categories);
 	void set_items(std::unordered_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 a3a093e..e7f0678 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 7a11289..e348afa 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -156,6 +156,10 @@ 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();
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -169,7 +173,8 @@ void PanelPlugin::menu_shown()
 
 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