[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 222/473: Add command to launch menu editor.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:56:32 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 9622124adff690021e9260eb9446a52d055339de
Author: Graeme Gott <graeme at gottcode.org>
Date:   Thu Nov 7 06:43:17 2013 -0500

    Add command to launch menu editor.
---
 panel-plugin/command.cpp              |   31 +++++++++++++++++++++++++++++++
 panel-plugin/command.h                |    2 ++
 panel-plugin/configuration-dialog.cpp |   24 ++++++++++++++++++++++++
 panel-plugin/configuration-dialog.h   |    7 +++++++
 panel-plugin/plugin.cpp               |    3 +++
 panel-plugin/settings.cpp             |    5 +++++
 panel-plugin/settings.h               |    1 +
 7 files changed, 73 insertions(+)

diff --git a/panel-plugin/command.cpp b/panel-plugin/command.cpp
index 02222ca..b10c866 100644
--- a/panel-plugin/command.cpp
+++ b/panel-plugin/command.cpp
@@ -37,6 +37,7 @@ enum
 
 Command::Command(const gchar* icon, const gchar* text, const gchar* command, const gchar* error_text) :
 	m_button(NULL),
+	m_menuitem(NULL),
 	m_icon(g_strdup(icon)),
 	m_text(g_strdup(text)),
 	m_command(g_strdup(command)),
@@ -54,6 +55,10 @@ Command::~Command()
 	{
 		g_object_unref(m_button);
 	}
+	if (m_menuitem)
+	{
+		g_object_unref(m_menuitem);
+	}
 
 	g_free(m_icon);
 	g_free(m_text);
@@ -88,6 +93,28 @@ GtkWidget* Command::get_button()
 
 //-----------------------------------------------------------------------------
 
+GtkWidget* Command::get_menuitem()
+{
+	if (m_menuitem)
+	{
+		return m_menuitem;
+	}
+
+	m_menuitem = gtk_image_menu_item_new_with_mnemonic(m_text);
+	GtkWidget* image = gtk_image_new_from_icon_name(m_icon, GTK_ICON_SIZE_MENU);
+	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m_menuitem), image);
+	g_signal_connect(m_menuitem, "activate", G_CALLBACK(Command::activated_slot), this);
+
+	gtk_widget_show(m_menuitem);
+	gtk_widget_set_sensitive(m_menuitem, m_status == WHISKERMENU_COMMAND_VALID);
+
+	g_object_ref_sink(m_menuitem);
+
+	return m_menuitem;
+}
+
+//-----------------------------------------------------------------------------
+
 void Command::set(const gchar* command)
 {
 	if (command != m_command)
@@ -113,6 +140,10 @@ void Command::check()
 	{
 		gtk_widget_set_sensitive(m_button, m_status == WHISKERMENU_COMMAND_VALID);
 	}
+	if (m_menuitem)
+	{
+		gtk_widget_set_sensitive(m_menuitem, m_status == WHISKERMENU_COMMAND_VALID);
+	}
 }
 
 //-----------------------------------------------------------------------------
diff --git a/panel-plugin/command.h b/panel-plugin/command.h
index 9903d8a..1e4b697 100644
--- a/panel-plugin/command.h
+++ b/panel-plugin/command.h
@@ -33,6 +33,7 @@ public:
 	~Command();
 
 	GtkWidget* get_button();
+	GtkWidget* get_menuitem();
 
 	const gchar* get() const
 	{
@@ -48,6 +49,7 @@ private:
 
 private:
 	GtkWidget* m_button;
+	GtkWidget* m_menuitem;
 	gchar* m_icon;
 	gchar* m_text;
 	gchar* m_command;
diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp
index 0cde867..5d549f4 100644
--- a/panel-plugin/configuration-dialog.cpp
+++ b/panel-plugin/configuration-dialog.cpp
@@ -227,6 +227,14 @@ void ConfigurationDialog::logout_command_changed()
 
 //-----------------------------------------------------------------------------
 
+void ConfigurationDialog::menueditor_command_changed()
+{
+	const gchar* text = gtk_entry_get_text(GTK_ENTRY(m_menueditor_command));
+	wm_settings->command_menueditor->set(text);
+}
+
+//-----------------------------------------------------------------------------
+
 void ConfigurationDialog::response(int response_id)
 {
 	if ((m_plugin->get_button_style() == Plugin::ShowText) && m_plugin->get_button_title().empty())
@@ -237,6 +245,7 @@ void ConfigurationDialog::response(int response_id)
 	wm_settings->command_settings->check();
 	wm_settings->command_lockscreen->check();
 	wm_settings->command_logout->check();
+	wm_settings->command_menueditor->check();
 
 	if (response_id == GTK_RESPONSE_CLOSE)
 	{
@@ -486,6 +495,21 @@ GtkWidget* ConfigurationDialog::init_commands_tab()
 	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);
 
+	// Add menu editor 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(_("Edit _Applications:"));
+	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_menueditor_command = gtk_entry_new();
+	gtk_entry_set_text(GTK_ENTRY(m_menueditor_command), wm_settings->command_menueditor->get());
+	gtk_box_pack_start(hbox, m_menueditor_command, true, true, 0);
+	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_menueditor_command);
+	g_signal_connect(m_menueditor_command, "changed", G_CALLBACK(ConfigurationDialog::menueditor_command_changed_slot), this);
+
 	return page;
 }
 
diff --git a/panel-plugin/configuration-dialog.h b/panel-plugin/configuration-dialog.h
index 66e8576..e449e4c 100644
--- a/panel-plugin/configuration-dialog.h
+++ b/panel-plugin/configuration-dialog.h
@@ -59,6 +59,7 @@ private:
 	void settings_command_changed();
 	void lockscreen_command_changed();
 	void logout_command_changed();
+	void menueditor_command_changed();
 
 	void response(int response_id);
 	GtkWidget* init_appearance_tab();
@@ -90,6 +91,7 @@ private:
 	GtkWidget* m_settings_command;
 	GtkWidget* m_lockscreen_command;
 	GtkWidget* m_logout_command;
+	GtkWidget* m_menueditor_command;
 
 
 private:
@@ -177,6 +179,11 @@ private:
 	{
 		obj->logout_command_changed();
 	}
+
+	static void menueditor_command_changed_slot(GtkEditable*, ConfigurationDialog* obj)
+	{
+		obj->menueditor_command_changed();
+	}
 };
 
 }
diff --git a/panel-plugin/plugin.cpp b/panel-plugin/plugin.cpp
index 9e82097..f24187b 100644
--- a/panel-plugin/plugin.cpp
+++ b/panel-plugin/plugin.cpp
@@ -18,6 +18,7 @@
 #include "plugin.h"
 
 #include "applications-page.h"
+#include "command.h"
 #include "configuration-dialog.h"
 #include "settings.h"
 #include "window.h"
@@ -108,6 +109,8 @@ Plugin::Plugin(XfcePanelPlugin* plugin) :
 	g_signal_connect_swapped(plugin, "save", G_CALLBACK(Plugin::save_slot), this);
 	g_signal_connect(plugin, "size-changed", G_CALLBACK(Plugin::size_changed_slot), this);
 	xfce_panel_plugin_menu_show_configure(plugin);
+
+	xfce_panel_plugin_menu_insert_item(plugin, GTK_MENU_ITEM(wm_settings->command_menueditor->get_menuitem()));
 }
 
 //-----------------------------------------------------------------------------
diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp
index 02a633c..5950496 100644
--- a/panel-plugin/settings.cpp
+++ b/panel-plugin/settings.cpp
@@ -101,6 +101,7 @@ Settings::Settings() :
 	command_settings = new Command("preferences-desktop", _("All Settings"), "xfce4-settings-manager", _("Failed to open settings manager."));
 	command_lockscreen = new Command("system-lock-screen", _("Lock Screen"), "xflock4", _("Failed to lock screen."));
 	command_logout = new Command("system-log-out", _("Log Out"), "xfce4-session-logout", _("Failed to log out."));
+	command_menueditor = new Command("xfce4-menueditor", _("Edit _Applications"), "menulibre", _("Failed to launch menu editor."));
 }
 
 //-----------------------------------------------------------------------------
@@ -110,6 +111,7 @@ Settings::~Settings()
 	delete command_settings;
 	delete command_lockscreen;
 	delete command_logout;
+	delete command_menueditor;
 }
 
 //-----------------------------------------------------------------------------
@@ -153,6 +155,7 @@ void Settings::load(char* file)
 	command_settings->set(xfce_rc_read_entry(rc, "command-settings", command_settings->get()));
 	command_lockscreen->set(xfce_rc_read_entry(rc, "command-lockscreen", command_lockscreen->get()));
 	command_logout->set(xfce_rc_read_entry(rc, "command-logout", command_logout->get()));
+	command_menueditor->set(xfce_rc_read_entry(rc, "command-menueditor", command_menueditor->get()));
 
 	menu_width = std::max(300, xfce_rc_read_int_entry(rc, "menu-width", menu_width));
 	menu_height = std::max(400, xfce_rc_read_int_entry(rc, "menu-height", menu_height));
@@ -162,6 +165,7 @@ void Settings::load(char* file)
 	command_settings->check();
 	command_lockscreen->check();
 	command_logout->check();
+	command_menueditor->check();
 }
 
 //-----------------------------------------------------------------------------
@@ -205,6 +209,7 @@ void Settings::save(char* file)
 	xfce_rc_write_entry(rc, "command-settings", command_settings->get());
 	xfce_rc_write_entry(rc, "command-lockscreen", command_lockscreen->get());
 	xfce_rc_write_entry(rc, "command-logout", command_logout->get());
+	xfce_rc_write_entry(rc, "command-menueditor", command_menueditor->get());
 
 	xfce_rc_write_int_entry(rc, "menu-width", menu_width);
 	xfce_rc_write_int_entry(rc, "menu-height", menu_height);
diff --git a/panel-plugin/settings.h b/panel-plugin/settings.h
index fe6a2e2..05f3eba 100644
--- a/panel-plugin/settings.h
+++ b/panel-plugin/settings.h
@@ -65,6 +65,7 @@ public:
 	Command* command_settings;
 	Command* command_lockscreen;
 	Command* command_logout;
+	Command* command_menueditor;
 
 	int menu_width;
 	int menu_height;

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


More information about the Xfce4-commits mailing list