[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 203/473: Refactor command button.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:56:13 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 1917692c8df898933ad0686a8cdb0e8d960e77b8
Author: Graeme Gott <graeme at gottcode.org>
Date:   Wed Oct 30 16:06:07 2013 -0400

    Refactor command button.
---
 src/CMakeLists.txt           |    1 +
 src/command_button.cpp       |   82 ++++++++++++++++++++++
 src/command_button.hpp       |   76 +++++++++++++++++++++
 src/configuration_dialog.cpp |   12 ++--
 src/menu.cpp                 |  153 ++++++++++++------------------------------
 src/menu.hpp                 |   67 ++++--------------
 src/panel_plugin.cpp         |   13 ++--
 src/panel_plugin.hpp         |    5 ++
 8 files changed, 234 insertions(+), 175 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e60e6f9..c1bfc8d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -64,6 +64,7 @@ endif()
 add_library(whiskermenu MODULE
     applications_page.cpp
     category.cpp
+    command_button.cpp
     configuration_dialog.cpp
     favorites_page.cpp
     icon_size.cpp
diff --git a/src/command_button.cpp b/src/command_button.cpp
new file mode 100644
index 0000000..68299e6
--- /dev/null
+++ b/src/command_button.cpp
@@ -0,0 +1,82 @@
+// Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+//
+// This library is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
+
+#include "command_button.hpp"
+
+extern "C"
+{
+#include <libxfce4ui/libxfce4ui.h>
+}
+
+using namespace WhiskerMenu;
+
+//-----------------------------------------------------------------------------
+
+CommandButton::CommandButton(const gchar* icon, const gchar* text, const std::string& command, const std::string& error_text) :
+	m_command(command),
+	m_error_text(error_text),
+	m_status(Unchecked)
+{
+	m_button = GTK_BUTTON(gtk_button_new());
+	gtk_button_set_relief(m_button, GTK_RELIEF_NONE);
+	gtk_widget_set_tooltip_text(GTK_WIDGET(m_button), text);
+	g_signal_connect(m_button, "clicked", G_CALLBACK(CommandButton::clicked_slot), this);
+
+	GtkWidget* image = gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	gtk_container_add(GTK_CONTAINER(m_button), GTK_WIDGET(image));
+}
+
+//-----------------------------------------------------------------------------
+
+CommandButton::~CommandButton()
+{
+	gtk_widget_destroy(GTK_WIDGET(m_button));
+}
+
+//-----------------------------------------------------------------------------
+
+void CommandButton::set_command(const std::string& command)
+{
+	m_command = command;
+	m_status = Unchecked;
+}
+
+//-----------------------------------------------------------------------------
+
+void CommandButton::check()
+{
+	if (m_status == Unchecked)
+	{
+		gchar* path = g_find_program_in_path(m_command.c_str());
+		m_status = path ? Valid : Invalid;
+		g_free(path);
+	}
+	gtk_widget_set_sensitive(GTK_WIDGET(m_button), m_status == Valid);
+}
+
+//-----------------------------------------------------------------------------
+
+void CommandButton::clicked()
+{
+	GError* error = NULL;
+	if (g_spawn_command_line_async(m_command.c_str(), &error) == false)
+	{
+		xfce_dialog_show_error(NULL, error, m_error_text.c_str());
+		g_error_free(error);
+	}
+}
+
+//-----------------------------------------------------------------------------
diff --git a/src/command_button.hpp b/src/command_button.hpp
new file mode 100644
index 0000000..4f0bde3
--- /dev/null
+++ b/src/command_button.hpp
@@ -0,0 +1,76 @@
+// Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+//
+// This library is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
+
+#ifndef WHISKERMENU_COMMAND_BUTTON_HPP
+#define WHISKERMENU_COMMAND_BUTTON_HPP
+
+#include <string>
+
+extern "C"
+{
+#include <gtk/gtk.h>
+}
+
+namespace WhiskerMenu
+{
+
+class CommandButton
+{
+	enum Status
+	{
+		Unchecked = -1,
+		Invalid,
+		Valid
+	};
+
+public:
+	CommandButton(const gchar* icon, const gchar* text, const std::string& command, const std::string& error_text);
+	~CommandButton();
+
+	GtkWidget* get_widget() const
+	{
+		return GTK_WIDGET(m_button);
+	}
+
+	std::string get_command() const
+	{
+		return m_command;
+	}
+
+	void set_command(const std::string& command);
+
+	void check();
+
+private:
+	void clicked();
+
+private:
+	GtkButton* m_button;
+	std::string m_command;
+	std::string m_error_text;
+	Status m_status;
+
+
+private:
+	static void clicked_slot(GtkButton*, CommandButton* obj)
+	{
+		obj->clicked();
+	}
+};
+
+}
+
+#endif // WHISKERMENU_COMMAND_BUTTON_HPP
diff --git a/src/configuration_dialog.cpp b/src/configuration_dialog.cpp
index 21268d2..7438994 100644
--- a/src/configuration_dialog.cpp
+++ b/src/configuration_dialog.cpp
@@ -214,7 +214,7 @@ void ConfigurationDialog::toggle_display_recent(GtkToggleButton* button)
 void ConfigurationDialog::settings_command_changed()
 {
 	const gchar* text = gtk_entry_get_text(GTK_ENTRY(m_settings_command));
-	Menu::set_settings_command(text ? text : "");
+	m_plugin->get_menu()->set_settings_command(text ? text : "");
 }
 
 //-----------------------------------------------------------------------------
@@ -222,7 +222,7 @@ void ConfigurationDialog::settings_command_changed()
 void ConfigurationDialog::lockscreen_command_changed()
 {
 	const gchar* text = gtk_entry_get_text(GTK_ENTRY(m_lockscreen_command));
-	Menu::set_lockscreen_command(text ? text : "");
+	m_plugin->get_menu()->set_lockscreen_command(text ? text : "");
 }
 
 //-----------------------------------------------------------------------------
@@ -230,7 +230,7 @@ void ConfigurationDialog::lockscreen_command_changed()
 void ConfigurationDialog::logout_command_changed()
 {
 	const gchar* text = gtk_entry_get_text(GTK_ENTRY(m_logout_command));
-	Menu::set_logout_command(text ? text : "");
+	m_plugin->get_menu()->set_logout_command(text ? text : "");
 }
 
 //-----------------------------------------------------------------------------
@@ -455,7 +455,7 @@ GtkWidget* ConfigurationDialog::init_commands_tab()
 	gtk_size_group_add_widget(label_size_group, label);
 
 	m_settings_command = gtk_entry_new();
-	gtk_entry_set_text(GTK_ENTRY(m_settings_command), Menu::get_settings_command().c_str());
+	gtk_entry_set_text(GTK_ENTRY(m_settings_command), m_plugin->get_menu()->get_settings_command().c_str());
 	gtk_box_pack_start(hbox, m_settings_command, true, true, 0);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_settings_command);
 	g_signal_connect(m_settings_command, "changed", G_CALLBACK(ConfigurationDialog::settings_command_changed_slot), this);
@@ -470,7 +470,7 @@ GtkWidget* ConfigurationDialog::init_commands_tab()
 	gtk_size_group_add_widget(label_size_group, label);
 
 	m_lockscreen_command = gtk_entry_new();
-	gtk_entry_set_text(GTK_ENTRY(m_lockscreen_command), Menu::get_lockscreen_command().c_str());
+	gtk_entry_set_text(GTK_ENTRY(m_lockscreen_command), m_plugin->get_menu()->get_lockscreen_command().c_str());
 	gtk_box_pack_start(hbox, m_lockscreen_command, true, true, 0);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_lockscreen_command);
 	g_signal_connect(m_lockscreen_command, "changed", G_CALLBACK(ConfigurationDialog::lockscreen_command_changed_slot), this);
@@ -485,7 +485,7 @@ GtkWidget* ConfigurationDialog::init_commands_tab()
 	gtk_size_group_add_widget(label_size_group, label);
 
 	m_logout_command = gtk_entry_new();
-	gtk_entry_set_text(GTK_ENTRY(m_logout_command), Menu::get_logout_command().c_str());
+	gtk_entry_set_text(GTK_ENTRY(m_logout_command), m_plugin->get_menu()->get_logout_command().c_str());
 	gtk_box_pack_start(hbox, m_logout_command, true, true, 0);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_logout_command);
 	g_signal_connect(m_logout_command, "changed", G_CALLBACK(ConfigurationDialog::logout_command_changed_slot), this);
diff --git a/src/menu.cpp b/src/menu.cpp
index 19fbe55..e3ed2d0 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -17,6 +17,7 @@
 #include "menu.hpp"
 
 #include "applications_page.hpp"
+#include "command_button.hpp"
 #include "favorites_page.hpp"
 #include "launcher_view.hpp"
 #include "recent_page.hpp"
@@ -37,21 +38,6 @@ using namespace WhiskerMenu;
 
 //-----------------------------------------------------------------------------
 
-static GtkButton* new_action_button(const gchar* icon, const gchar* text)
-{
-	GtkButton* button = GTK_BUTTON(gtk_button_new());
-	gtk_button_set_relief(button, GTK_RELIEF_NONE);
-	gtk_widget_set_tooltip_text(GTK_WIDGET(button), text);
-
-	GtkWidget* image = gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_LARGE_TOOLBAR);
-	gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(image));
-
-	return button;
-}
-
-Menu::Command Menu::m_settings_command = "xfce4-settings-manager";
-Menu::Command Menu::m_lockscreen_command = "xflock4";
-Menu::Command Menu::m_logout_command = "xfce4-session-logout";
 bool Menu::m_display_recent = false;
 bool Menu::m_position_search_alternate = false;
 bool Menu::m_position_commands_alternate = false;
@@ -107,14 +93,14 @@ Menu::Menu(XfceRc* settings) :
 	g_free(username);
 
 	// Create action buttons
-	m_settings_button = new_action_button("preferences-desktop", _("All Settings"));
-	g_signal_connect(m_settings_button, "clicked", G_CALLBACK(Menu::launch_settings_manager_slot), this);
+	m_settings_button = new CommandButton("preferences-desktop", _("All Settings"), "xfce4-settings-manager", _("Failed to open settings manager."));
+	g_signal_connect_swapped(m_settings_button->get_widget(), "clicked", G_CALLBACK(Menu::hide_slot), this);
 
-	m_lock_screen_button = new_action_button("system-lock-screen", _("Lock Screen"));
-	g_signal_connect(m_lock_screen_button, "clicked", G_CALLBACK(Menu::lock_screen_slot), this);
+	m_lockscreen_button = new CommandButton("system-lock-screen", _("Lock Screen"), "xflock4", _("Failed to lock screen."));
+	g_signal_connect_swapped(m_lockscreen_button->get_widget(), "clicked", G_CALLBACK(Menu::hide_slot), this);
 
-	m_log_out_button = new_action_button("system-log-out", _("Log Out"));
-	g_signal_connect(m_log_out_button, "clicked", G_CALLBACK(Menu::log_out_slot), this);
+	m_logout_button = new CommandButton("system-log-out", _("Log Out"), "xfce4-session-logout", _("Failed to log out."));
+	g_signal_connect_swapped(m_logout_button->get_widget(), "clicked", G_CALLBACK(Menu::hide_slot), this);
 
 	m_resizer = new ResizerWidget(m_window);
 
@@ -163,9 +149,9 @@ Menu::Menu(XfceRc* settings) :
 	// Create box for packing commands
 	m_commands_align = GTK_ALIGNMENT(gtk_alignment_new(1, 0, 0, 0));
 	m_commands_box = GTK_BOX(gtk_hbox_new(false, 0));
-	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_settings_button), false, false, 0);
-	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_lock_screen_button), false, false, 0);
-	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_log_out_button), false, false, 0);
+	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_settings_button->get_widget()), false, false, 0);
+	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_lockscreen_button->get_widget()), false, false, 0);
+	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_logout_button->get_widget()), false, false, 0);
 	gtk_container_add(GTK_CONTAINER(m_commands_align), GTK_WIDGET(m_commands_box));
 
 	// Create box for packing username, commands, and resize widget
@@ -245,6 +231,10 @@ Menu::~Menu()
 	delete m_recent;
 	delete m_favorites;
 
+	delete m_settings_button;
+	delete m_lockscreen_button;
+	delete m_logout_button;
+
 	delete m_resizer;
 	g_object_unref(m_window);
 }
@@ -291,9 +281,9 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 	m_applications->get_view()->reload_icon_size();
 
 	// Make sure commands are valid
-	check_command(m_settings_command, GTK_WIDGET(m_settings_button));
-	check_command(m_lockscreen_command, GTK_WIDGET(m_lock_screen_button));
-	check_command(m_logout_command, GTK_WIDGET(m_log_out_button));
+	m_settings_button->check();
+	m_lockscreen_button->check();
+	m_logout_button->check();
 
 	// Make sure applications list is current; does nothing unless list has changed
 	m_applications->load_applications();
@@ -447,9 +437,9 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 			gtk_misc_set_alignment(GTK_MISC(m_username), 0.0f, 0.5f);
 
 			gtk_alignment_set(m_commands_align, 1, 0, 0, 0);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button), 0);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lock_screen_button), 1);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_log_out_button), 2);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button->get_widget()), 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lockscreen_button->get_widget()), 1);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_logout_button->get_widget()), 2);
 
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 0);
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_resizer->get_widget()), 1);
@@ -465,9 +455,9 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 			gtk_misc_set_alignment(GTK_MISC(m_username), 1.0f, 0.5f);
 
 			gtk_alignment_set(m_commands_align, 0, 0, 0, 0);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button), 2);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lock_screen_button), 1);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_log_out_button), 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button->get_widget()), 2);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lockscreen_button->get_widget()), 1);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_logout_button->get_widget()), 0);
 
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 1);
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_resizer->get_widget()), 0);
@@ -483,9 +473,9 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 			gtk_misc_set_alignment(GTK_MISC(m_username), 0.0f, 0.5f);
 
 			gtk_alignment_set(m_commands_align, 1, 0, 0, 0);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button), 0);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lock_screen_button), 1);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_log_out_button), 2);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button->get_widget()), 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lockscreen_button->get_widget()), 1);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_logout_button->get_widget()), 2);
 
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 0);
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_commands_align), 1);
@@ -499,9 +489,9 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 			gtk_misc_set_alignment(GTK_MISC(m_username), 1.0f, 0.5f);
 
 			gtk_alignment_set(m_commands_align, 0, 0, 0, 0);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button), 2);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lock_screen_button), 1);
-			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_log_out_button), 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button->get_widget()), 2);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lockscreen_button->get_widget()), 1);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_logout_button->get_widget()), 0);
 
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 2);
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_commands_align), 1);
@@ -633,63 +623,63 @@ bool Menu::on_enter_notify_event(GdkEventCrossing* event)
 
 std::string Menu::get_settings_command()
 {
-	return m_settings_command.m_exec;
+	return m_settings_button->get_command();
 }
 
 //-----------------------------------------------------------------------------
 
 std::string Menu::get_lockscreen_command()
 {
-	return m_lockscreen_command.m_exec;
+	return m_lockscreen_button->get_command();
 }
 
 //-----------------------------------------------------------------------------
 
 std::string Menu::get_logout_command()
 {
-	return m_logout_command.m_exec;
+	return m_logout_button->get_command();
 }
 
 //-----------------------------------------------------------------------------
 
-bool Menu::get_display_recent()
+void Menu::set_settings_command(const std::string& command)
 {
-	return m_display_recent;
+	m_settings_button->set_command(command);
 }
 
 //-----------------------------------------------------------------------------
 
-bool Menu::get_position_search_alternate()
+void Menu::set_lockscreen_command(const std::string& command)
 {
-	return m_position_search_alternate;
+	m_lockscreen_button->set_command(command);
 }
 
 //-----------------------------------------------------------------------------
 
-bool Menu::get_position_commands_alternate()
+void Menu::set_logout_command(const std::string& command)
 {
-	return m_position_commands_alternate;
+	m_logout_button->set_command(command);
 }
 
 //-----------------------------------------------------------------------------
 
-void Menu::set_settings_command(const std::string& command)
+bool Menu::get_display_recent()
 {
-	m_settings_command = command;
+	return m_display_recent;
 }
 
 //-----------------------------------------------------------------------------
 
-void Menu::set_lockscreen_command(const std::string& command)
+bool Menu::get_position_search_alternate()
 {
-	m_lockscreen_command = command;
+	return m_position_search_alternate;
 }
 
 //-----------------------------------------------------------------------------
 
-void Menu::set_logout_command(const std::string& command)
+bool Menu::get_position_commands_alternate()
 {
-	m_logout_command = command;
+	return m_position_commands_alternate;
 }
 
 //-----------------------------------------------------------------------------
@@ -957,58 +947,3 @@ void Menu::search()
 }
 
 //-----------------------------------------------------------------------------
-
-void Menu::launch_settings_manager()
-{
-	hide();
-
-	GError* error = NULL;
-	if (g_spawn_command_line_async(m_settings_command.m_exec.c_str(), &error) == false)
-	{
-		xfce_dialog_show_error(NULL, error, _("Failed to open settings manager."));
-		g_error_free(error);
-	}
-}
-
-//-----------------------------------------------------------------------------
-
-void Menu::lock_screen()
-{
-	hide();
-
-	GError* error = NULL;
-	if (g_spawn_command_line_async(m_lockscreen_command.m_exec.c_str(), &error) == false)
-	{
-		xfce_dialog_show_error(NULL, error, _("Failed to lock screen."));
-		g_error_free(error);
-	}
-}
-
-//-----------------------------------------------------------------------------
-
-void Menu::log_out()
-{
-	hide();
-
-	GError* error = NULL;
-	if (g_spawn_command_line_async(m_logout_command.m_exec.c_str(), &error) == false)
-	{
-		xfce_dialog_show_error(NULL, error, _("Failed to log out."));
-		g_error_free(error);
-	}
-}
-
-//-----------------------------------------------------------------------------
-
-void Menu::check_command(Command& command, GtkWidget* button)
-{
-	if (command.m_status == Unchecked)
-	{
-		gchar* path = g_find_program_in_path(command.m_exec.c_str());
-		command.m_status = path ? Valid : Invalid;
-		g_free(path);
-	}
-	gtk_widget_set_sensitive(button, command.m_status == Valid);
-}
-
-//-----------------------------------------------------------------------------
diff --git a/src/menu.hpp b/src/menu.hpp
index ae17c3a..86b16df 100644
--- a/src/menu.hpp
+++ b/src/menu.hpp
@@ -31,6 +31,7 @@ namespace WhiskerMenu
 {
 
 class ApplicationsPage;
+class CommandButton;
 class FavoritesPage;
 class Launcher;
 class Page;
@@ -41,32 +42,6 @@ class SectionButton;
 
 class Menu
 {
-	enum CommandStatus
-	{
-		Unchecked = -1,
-		Invalid,
-		Valid
-	};
-
-	struct Command
-	{
-		std::string m_exec;
-		CommandStatus m_status;
-
-		Command(const char* exec = NULL) :
-			m_exec(exec ? exec : ""),
-			m_status(Unchecked)
-		{
-		}
-
-		Command& operator=(const std::string& exec)
-		{
-			m_exec = exec;
-			m_status = Unchecked;
-			return *this;
-		}
-	};
-
 public:
 	explicit Menu(XfceRc* settings);
 	~Menu();
@@ -109,15 +84,16 @@ public:
 	void set_modified();
 	void unset_items();
 
-	static std::string get_settings_command();
-	static std::string get_lockscreen_command();
-	static std::string get_logout_command();
+	std::string get_settings_command();
+	std::string get_lockscreen_command();
+	std::string get_logout_command();
+	void set_settings_command(const std::string& command);
+	void set_lockscreen_command(const std::string& command);
+	void set_logout_command(const std::string& command);
+
 	static bool get_display_recent();
 	static bool get_position_search_alternate();
 	static bool get_position_commands_alternate();
-	static void set_settings_command(const std::string& command);
-	static void set_lockscreen_command(const std::string& command);
-	static void set_logout_command(const std::string& command);
 	static void set_display_recent(bool display);
 	static void set_position_search_alternate(bool alternate);
 	static void set_position_commands_alternate(bool alternate);
@@ -137,10 +113,6 @@ private:
 	void show_favorites();
 	void show_default_page();
 	void search();
-	void launch_settings_manager();
-	void lock_screen();
-	void log_out();
-	static void check_command(Command& command, GtkWidget* button);
 
 private:
 	GtkWindow* m_window;
@@ -157,9 +129,9 @@ private:
 	ResizerWidget* m_resizer;
 
 	GtkAlignment* m_commands_align;
-	GtkButton* m_settings_button;
-	GtkButton* m_lock_screen_button;
-	GtkButton* m_log_out_button;
+	CommandButton* m_settings_button;
+	CommandButton* m_lockscreen_button;
+	CommandButton* m_logout_button;
 
 	GtkEntry* m_search_entry;
 
@@ -181,9 +153,6 @@ private:
 	bool m_layout_commands_alternate;
 	bool m_modified;
 
-	static Command m_settings_command;
-	static Command m_lockscreen_command;
-	static Command m_logout_command;
 	static bool m_display_recent;
 	static bool m_position_search_alternate;
 	static bool m_position_commands_alternate;
@@ -255,19 +224,9 @@ private:
 		obj->search();
 	}
 
-	static void launch_settings_manager_slot(GtkButton*, Menu* obj)
-	{
-		obj->launch_settings_manager();
-	}
-
-	static void lock_screen_slot(GtkButton*, Menu* obj)
-	{
-		obj->lock_screen();
-	}
-
-	static void log_out_slot(GtkButton*, Menu* obj)
+	static void hide_slot(Menu* obj)
 	{
-		obj->log_out();
+		obj->hide();
 	}
 };
 
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index a65054b..af4e4ec 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -72,10 +72,11 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
 		Menu::set_display_recent(xfce_rc_read_bool_entry(settings, "display-recent-default", Menu::get_display_recent()));
 		Menu::set_position_search_alternate(xfce_rc_read_bool_entry(settings, "position-search-alternate", Menu::get_position_search_alternate()));
 		Menu::set_position_commands_alternate(xfce_rc_read_bool_entry(settings, "position-commands-alternate", Menu::get_position_commands_alternate()));
-		Menu::set_settings_command(xfce_rc_read_entry(settings, "command-settings", Menu::get_settings_command().c_str()));
-		Menu::set_lockscreen_command(xfce_rc_read_entry(settings, "command-lockscreen", Menu::get_lockscreen_command().c_str()));
-		Menu::set_logout_command(xfce_rc_read_entry(settings, "command-logout", Menu::get_logout_command().c_str()));
+
 		m_menu = new Menu(settings);
+		m_menu->set_settings_command(xfce_rc_read_entry(settings, "command-settings", m_menu->get_settings_command().c_str()));
+		m_menu->set_lockscreen_command(xfce_rc_read_entry(settings, "command-lockscreen", m_menu->get_lockscreen_command().c_str()));
+		m_menu->set_logout_command(xfce_rc_read_entry(settings, "command-logout", m_menu->get_logout_command().c_str()));
 
 		xfce_rc_close(settings);
 	}
@@ -324,9 +325,9 @@ void PanelPlugin::save()
 	xfce_rc_write_bool_entry(settings, "display-recent-default", Menu::get_display_recent());
 	xfce_rc_write_bool_entry(settings, "position-search-alternate", Menu::get_position_search_alternate());
 	xfce_rc_write_bool_entry(settings, "position-commands-alternate", Menu::get_position_commands_alternate());
-	xfce_rc_write_entry(settings, "command-settings", Menu::get_settings_command().c_str());
-	xfce_rc_write_entry(settings, "command-lockscreen", Menu::get_lockscreen_command().c_str());
-	xfce_rc_write_entry(settings, "command-logout", Menu::get_logout_command().c_str());
+	xfce_rc_write_entry(settings, "command-settings", m_menu->get_settings_command().c_str());
+	xfce_rc_write_entry(settings, "command-lockscreen", m_menu->get_lockscreen_command().c_str());
+	xfce_rc_write_entry(settings, "command-logout", m_menu->get_logout_command().c_str());
 	m_menu->save(settings);
 
 	xfce_rc_close(settings);
diff --git a/src/panel_plugin.hpp b/src/panel_plugin.hpp
index ce0df66..f9f571d 100644
--- a/src/panel_plugin.hpp
+++ b/src/panel_plugin.hpp
@@ -48,6 +48,11 @@ public:
 		ShowIconAndText = ShowIcon | ShowText
 	};
 
+	Menu* get_menu() const
+	{
+		return m_menu;
+	}
+
 	ButtonStyle get_button_style() const
 	{
 		return ButtonStyle(m_button_icon_visible | (m_button_title_visible << 1));

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


More information about the Xfce4-commits mailing list