[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 167/473: Add options to set custom commands. Closes #25.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:55:37 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 0f21215a649543292d24130cc103edf18194ec1b
Author: Graeme Gott <graeme at gottcode.org>
Date:   Tue Oct 8 13:54:22 2013 -0400

    Add options to set custom commands. Closes #25.
---
 src/configuration_dialog.cpp |   87 ++++++++++++++++++++++++++++++++++++++++++
 src/configuration_dialog.hpp |   22 +++++++++++
 src/menu.cpp                 |   52 +++++++++++++++++++++++--
 src/menu.hpp                 |   11 ++++++
 4 files changed, 169 insertions(+), 3 deletions(-)

diff --git a/src/configuration_dialog.cpp b/src/configuration_dialog.cpp
index 09255e3..f6dd478 100644
--- a/src/configuration_dialog.cpp
+++ b/src/configuration_dialog.cpp
@@ -21,6 +21,7 @@
 #include "icon_size.hpp"
 #include "launcher.hpp"
 #include "launcher_view.hpp"
+#include "menu.hpp"
 #include "panel_plugin.hpp"
 #include "section_button.hpp"
 
@@ -64,6 +65,7 @@ ConfigurationDialog::ConfigurationDialog(PanelPlugin* plugin) :
 	gtk_notebook_append_page(notebook, init_appearance_tab(), gtk_label_new_with_mnemonic("_Appearance"));
 	gtk_notebook_append_page(notebook, init_panel_button_tab(), gtk_label_new_with_mnemonic("_Panel Button"));
 	gtk_notebook_append_page(notebook, init_behavior_tab(), gtk_label_new_with_mnemonic("_Behavior"));
+	gtk_notebook_append_page(notebook, init_commands_tab(), gtk_label_new_with_mnemonic("_Commands"));
 
 	// Add tabs to dialog
 	GtkBox* vbox = GTK_BOX(gtk_vbox_new(false, 8));
@@ -183,6 +185,30 @@ void ConfigurationDialog::toggle_remember_favorites(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 : "");
+}
+
+//-----------------------------------------------------------------------------
+
+void ConfigurationDialog::lockscreen_command_changed()
+{
+	const gchar* text = gtk_entry_get_text(GTK_ENTRY(m_lockscreen_command));
+	Menu::set_lockscreen_command(text ? text : "");
+}
+
+//-----------------------------------------------------------------------------
+
+void ConfigurationDialog::logout_command_changed()
+{
+	const gchar* text = gtk_entry_get_text(GTK_ENTRY(m_logout_command));
+	Menu::set_logout_command(text ? text : "");
+}
+
+//-----------------------------------------------------------------------------
+
 void ConfigurationDialog::response(int response_id)
 {
 	if ((m_plugin->get_button_style() == PanelPlugin::ShowText) && m_plugin->get_button_title().empty())
@@ -362,3 +388,64 @@ GtkWidget* ConfigurationDialog::init_behavior_tab()
 }
 
 //-----------------------------------------------------------------------------
+
+GtkWidget* ConfigurationDialog::init_commands_tab()
+{
+	// Create size group for labels
+	GtkSizeGroup* label_size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+
+	// Create commands section
+	GtkWidget* page = gtk_alignment_new(0, 0, 1, 0);
+	gtk_container_set_border_width(GTK_CONTAINER(page), 8);
+	GtkBox* panel_vbox = GTK_BOX(gtk_vbox_new(false, 8));
+	gtk_container_add(GTK_CONTAINER(page), GTK_WIDGET(panel_vbox));
+
+	// Add settings command entry
+	GtkBox* hbox = GTK_BOX(gtk_hbox_new(false, 12));
+	gtk_box_pack_start(panel_vbox, GTK_WIDGET(hbox), false, false, 0);
+
+	GtkWidget* label = gtk_label_new_with_mnemonic(_("_Settings:"));
+	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+	gtk_box_pack_start(hbox, label, false, false, 0);
+	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_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);
+
+	// Add lock screen command entry
+	hbox = GTK_BOX(gtk_hbox_new(false, 12));
+	gtk_box_pack_start(panel_vbox, GTK_WIDGET(hbox), false, false, 0);
+
+	label = gtk_label_new_with_mnemonic(_("Lock _Screen:"));
+	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+	gtk_box_pack_start(hbox, label, false, false, 0);
+	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_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);
+
+	// Add log out command entry
+	hbox = GTK_BOX(gtk_hbox_new(false, 12));
+	gtk_box_pack_start(panel_vbox, GTK_WIDGET(hbox), false, false, 0);
+
+	label = gtk_label_new_with_mnemonic(_("Log _Out:"));
+	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+	gtk_box_pack_start(hbox, label, false, false, 0);
+	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_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);
+
+	return page;
+}
+
+//-----------------------------------------------------------------------------
diff --git a/src/configuration_dialog.hpp b/src/configuration_dialog.hpp
index 02403b9..ed189d4 100644
--- a/src/configuration_dialog.hpp
+++ b/src/configuration_dialog.hpp
@@ -49,10 +49,14 @@ private:
 	void toggle_show_description(GtkToggleButton* button);
 	void toggle_load_hierarchy(GtkToggleButton* button);
 	void toggle_remember_favorites(GtkToggleButton* button);
+	void settings_command_changed();
+	void lockscreen_command_changed();
+	void logout_command_changed();
 	void response(int response_id);
 	GtkWidget* init_appearance_tab();
 	GtkWidget* init_panel_button_tab();
 	GtkWidget* init_behavior_tab();
+	GtkWidget* init_commands_tab();
 
 private:
 	PanelPlugin* m_plugin;
@@ -69,6 +73,9 @@ private:
 	GtkWidget* m_hover_switch_category;
 	GtkWidget* m_load_hierarchy;
 	GtkWidget* m_remember_favorites;
+	GtkWidget* m_settings_command;
+	GtkWidget* m_lockscreen_command;
+	GtkWidget* m_logout_command;
 
 
 private:
@@ -126,6 +133,21 @@ private:
 	{
 		obj->response(response_id);
 	}
+
+	static void settings_command_changed_slot(GtkEditable*, ConfigurationDialog* obj)
+	{
+		obj->settings_command_changed();
+	}
+
+	static void lockscreen_command_changed_slot(GtkEditable*, ConfigurationDialog* obj)
+	{
+		obj->lockscreen_command_changed();
+	}
+
+	static void logout_command_changed_slot(GtkEditable*, ConfigurationDialog* obj)
+	{
+		obj->logout_command_changed();
+	}
 };
 
 }
diff --git a/src/menu.cpp b/src/menu.cpp
index c3d1468..863e9ea 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -49,6 +49,10 @@ static GtkButton* new_action_button(const gchar* icon, const gchar* text)
 	return button;
 }
 
+std::string Menu::m_settings_command = "xfce4-settings-manager";
+std::string Menu::m_lockscreen_command = "xflock4";
+std::string Menu::m_logout_command = "xfce4-session-logout";
+
 //-----------------------------------------------------------------------------
 
 Menu::Menu(XfceRc* settings) :
@@ -506,6 +510,48 @@ bool Menu::on_enter_notify_event(GdkEventCrossing* event)
 
 //-----------------------------------------------------------------------------
 
+std::string Menu::get_settings_command()
+{
+	return m_settings_command;
+}
+
+//-----------------------------------------------------------------------------
+
+std::string Menu::get_lockscreen_command()
+{
+	return m_lockscreen_command;
+}
+
+//-----------------------------------------------------------------------------
+
+std::string Menu::get_logout_command()
+{
+	return m_logout_command;
+}
+
+//-----------------------------------------------------------------------------
+
+void Menu::set_settings_command(const std::string& command)
+{
+	m_settings_command = command;
+}
+
+//-----------------------------------------------------------------------------
+
+void Menu::set_lockscreen_command(const std::string& command)
+{
+	m_lockscreen_command = command;
+}
+
+//-----------------------------------------------------------------------------
+
+void Menu::set_logout_command(const std::string& command)
+{
+	m_logout_command = command;
+}
+
+//-----------------------------------------------------------------------------
+
 bool Menu::on_leave_notify_event(GdkEventCrossing* event)
 {
 	if ( (event->detail == GDK_NOTIFY_INFERIOR)
@@ -738,7 +784,7 @@ void Menu::launch_settings_manager()
 	hide();
 
 	GError* error = NULL;
-	if (g_spawn_command_line_async("xfce4-settings-manager", &error) == false)
+	if (g_spawn_command_line_async(m_settings_command.c_str(), &error) == false)
 	{
 		xfce_dialog_show_error(NULL, error, _("Failed to open settings manager."));
 		g_error_free(error);
@@ -752,7 +798,7 @@ void Menu::lock_screen()
 	hide();
 
 	GError* error = NULL;
-	if (g_spawn_command_line_async("xflock4", &error) == false)
+	if (g_spawn_command_line_async(m_lockscreen_command.c_str(), &error) == false)
 	{
 		xfce_dialog_show_error(NULL, error, _("Failed to lock screen."));
 		g_error_free(error);
@@ -766,7 +812,7 @@ void Menu::log_out()
 	hide();
 
 	GError* error = NULL;
-	if (g_spawn_command_line_async("xfce4-session-logout", &error) == false)
+	if (g_spawn_command_line_async(m_logout_command.c_str(), &error) == false)
 	{
 		xfce_dialog_show_error(NULL, error, _("Failed to log out."));
 		g_error_free(error);
diff --git a/src/menu.hpp b/src/menu.hpp
index 85a57a5..4742c7b 100644
--- a/src/menu.hpp
+++ b/src/menu.hpp
@@ -82,6 +82,13 @@ 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();
+	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);
+
 private:
 	bool on_enter_notify_event(GdkEventCrossing* event);
 	bool on_leave_notify_event(GdkEventCrossing* event);
@@ -131,6 +138,10 @@ private:
 	bool m_layout_bottom;
 	bool m_modified;
 
+	static std::string m_settings_command;
+	static std::string m_lockscreen_command;
+	static std::string m_logout_command;
+
 
 private:
 	static gboolean on_enter_notify_event_slot(GtkWidget*, GdkEventCrossing* event, Menu* obj)

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


More information about the Xfce4-commits mailing list