[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 231/473: Add support for hiding commands.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:56:41 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 8870e2e2e4dcc908737713ce69dc41331fc9dcca
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sun Nov 10 14:51:31 2013 -0500

    Add support for hiding commands.
---
 panel-plugin/command.cpp  |    9 ++++++---
 panel-plugin/command.h    |   11 +++++++++++
 panel-plugin/settings.cpp |   10 ++++++++++
 panel-plugin/window.cpp   |    6 ++++++
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/command.cpp b/panel-plugin/command.cpp
index 1f3a4be..c889207 100644
--- a/panel-plugin/command.cpp
+++ b/panel-plugin/command.cpp
@@ -44,7 +44,8 @@ Command::Command(const gchar* icon, const gchar* text, const gchar* command, con
 	m_text(g_strdup(text)),
 	m_command(g_strdup(command)),
 	m_error_text(g_strdup(error_text)),
-	m_status(WHISKERMENU_COMMAND_UNCHECKED)
+	m_status(WHISKERMENU_COMMAND_UNCHECKED),
+	m_shown(true)
 {
 	check();
 }
@@ -96,7 +97,7 @@ GtkWidget* Command::get_button()
 	GtkWidget* image = gtk_image_new_from_icon_name(m_icon, GTK_ICON_SIZE_LARGE_TOOLBAR);
 	gtk_container_add(GTK_CONTAINER(m_button), GTK_WIDGET(image));
 
-	gtk_widget_show(m_button);
+	gtk_widget_set_visible(m_button, m_shown);
 	gtk_widget_set_sensitive(m_button, m_status == WHISKERMENU_COMMAND_VALID);
 
 	g_object_ref_sink(m_button);
@@ -118,7 +119,7 @@ GtkWidget* Command::get_menuitem()
 	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_visible(m_menuitem, m_shown);
 	gtk_widget_set_sensitive(m_menuitem, m_status == WHISKERMENU_COMMAND_VALID);
 
 	g_object_ref_sink(m_menuitem);
@@ -151,10 +152,12 @@ void Command::check()
 
 	if (m_button)
 	{
+		gtk_widget_set_visible(m_button, m_shown);
 		gtk_widget_set_sensitive(m_button, m_status == WHISKERMENU_COMMAND_VALID);
 	}
 	if (m_menuitem)
 	{
+		gtk_widget_set_visible(m_menuitem, m_shown);
 		gtk_widget_set_sensitive(m_menuitem, m_status == WHISKERMENU_COMMAND_VALID);
 	}
 }
diff --git a/panel-plugin/command.h b/panel-plugin/command.h
index 1e4b697..a3d276c 100644
--- a/panel-plugin/command.h
+++ b/panel-plugin/command.h
@@ -40,8 +40,18 @@ public:
 		return m_command;
 	}
 
+	bool get_shown() const
+	{
+		return m_shown;
+	}
+
 	void set(const gchar* command);
 
+	void set_shown(bool shown)
+	{
+		m_shown = shown;
+	}
+
 	void check();
 
 private:
@@ -55,6 +65,7 @@ private:
 	gchar* m_command;
 	gchar* m_error_text;
 	gint m_status;
+	bool m_shown;
 
 
 private:
diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp
index 8cc78fe..b81bca4 100644
--- a/panel-plugin/settings.cpp
+++ b/panel-plugin/settings.cpp
@@ -157,6 +157,11 @@ void Settings::load(char* file)
 	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()));
 
+	command_settings->set_shown(xfce_rc_read_bool_entry(rc, "show-command-settings", command_settings->get_shown()));
+	command_lockscreen->set_shown(xfce_rc_read_bool_entry(rc, "show-command-lockscreen", command_lockscreen->get_shown()));
+	command_logout->set_shown(xfce_rc_read_bool_entry(rc, "show-command-logout", command_logout->get_shown()));
+	command_menueditor->set_shown(xfce_rc_read_bool_entry(rc, "show-command-menueditor", command_menueditor->get_shown()));
+
 	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));
 
@@ -211,6 +216,11 @@ void Settings::save(char* file)
 	xfce_rc_write_entry(rc, "command-logout", command_logout->get());
 	xfce_rc_write_entry(rc, "command-menueditor", command_menueditor->get());
 
+	xfce_rc_write_bool_entry(rc, "show-command-settings", command_settings->get_shown());
+	xfce_rc_write_bool_entry(rc, "show-command-lockscreen", command_lockscreen->get_shown());
+	xfce_rc_write_bool_entry(rc, "show-command-logout", command_logout->get_shown());
+	xfce_rc_write_bool_entry(rc, "show-command-menueditor", command_menueditor->get_shown());
+
 	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/window.cpp b/panel-plugin/window.cpp
index 3a05d34..b9a9c76 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -263,6 +263,12 @@ void Window::show(GtkWidget* parent, bool horizontal)
 	m_recent->get_view()->reload_icon_size();
 	m_applications->get_view()->reload_icon_size();
 
+	// Make sure commands are valid and visible
+	wm_settings->command_settings->check();
+	wm_settings->command_lockscreen->check();
+	wm_settings->command_logout->check();
+	wm_settings->command_menueditor->check();
+
 	// Make sure applications list is current; does nothing unless list has changed
 	if (m_applications->load_applications())
 	{

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


More information about the Xfce4-commits mailing list