[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 450/473: Recreate window when opaqueness changes.

noreply at xfce.org noreply at xfce.org
Tue Feb 17 00:00:20 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 9c9c325b83619d9458c5cf4faac334e0ef6c1986
Author: Graeme Gott <graeme at gottcode.org>
Date:   Mon Feb 9 06:39:18 2015 -0500

    Recreate window when opaqueness changes.
---
 panel-plugin/plugin.cpp |   25 ++++++++++++++++++++++---
 panel-plugin/plugin.h   |    3 +++
 panel-plugin/window.cpp |   23 ++++++++++++-----------
 panel-plugin/window.h   |    2 +-
 4 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/panel-plugin/plugin.cpp b/panel-plugin/plugin.cpp
index 649bfef..73d2d05 100644
--- a/panel-plugin/plugin.cpp
+++ b/panel-plugin/plugin.cpp
@@ -96,13 +96,15 @@ static bool panel_utils_grab_available()
 
 Plugin::Plugin(XfcePanelPlugin* plugin) :
 	m_plugin(plugin),
-	m_window(NULL)
+	m_window(NULL),
+	m_opacity(100)
 {
 	// Load settings
 	wm_settings = new Settings;
 	wm_settings->button_title = get_button_title_default();
 	wm_settings->load(g_strconcat(DATADIR, "/xfce4/whiskermenu/defaults.rc", NULL));
 	wm_settings->load(xfce_panel_plugin_lookup_rc_file(m_plugin));
+	m_opacity = wm_settings->menu_opacity;
 
 	// Prevent empty panel button
 	if (!wm_settings->button_icon_visible)
@@ -304,7 +306,7 @@ void Plugin::button_toggled(GtkToggleButton* button)
 	else
 	{
 		xfce_panel_plugin_block_autohide(m_plugin, true);
-		m_window->show(m_button, xfce_panel_plugin_get_orientation(m_plugin) == GTK_ORIENTATION_HORIZONTAL);
+		show_menu(m_button, xfce_panel_plugin_get_orientation(m_plugin) == GTK_ORIENTATION_HORIZONTAL);
 	}
 }
 
@@ -355,7 +357,7 @@ gboolean Plugin::remote_event(XfcePanelPlugin*, gchar* name, GValue* value)
 	}
 	else if (value && G_VALUE_HOLDS_BOOLEAN(value) && g_value_get_boolean(value))
 	{
-		m_window->show(NULL, true);
+		show_menu(NULL, true);
 	}
 	else
 	{
@@ -494,3 +496,20 @@ void Plugin::update_size()
 }
 
 //-----------------------------------------------------------------------------
+
+void Plugin::show_menu(GtkWidget* parent, bool horizontal)
+{
+	if (wm_settings->menu_opacity != m_opacity)
+	{
+		if ((m_opacity == 100) || (wm_settings->menu_opacity == 100))
+		{
+			delete m_window;
+			m_window = new Window;
+			g_signal_connect_slot<GtkWidget*>(m_window->get_widget(), "unmap", &Plugin::menu_hidden, this);
+		}
+		m_opacity = wm_settings->menu_opacity;
+	}
+	m_window->show(parent, horizontal);
+}
+
+//-----------------------------------------------------------------------------
diff --git a/panel-plugin/plugin.h b/panel-plugin/plugin.h
index ee27e67..f81d70e 100644
--- a/panel-plugin/plugin.h
+++ b/panel-plugin/plugin.h
@@ -71,6 +71,7 @@ private:
 	void show_about();
 	gboolean size_changed(XfcePanelPlugin*, gint size);
 	void update_size();
+	void show_menu(GtkWidget* parent, bool horizontal);
 
 private:
 	XfcePanelPlugin* m_plugin;
@@ -80,6 +81,8 @@ private:
 	GtkBox* m_button_box;
 	GtkLabel* m_button_label;
 	GtkImage* m_button_icon;
+
+	int m_opacity;
 };
 
 }
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index e5fada4..da53e09 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -45,8 +45,7 @@ WhiskerMenu::Window::Window() :
 	m_layout_bottom(true),
 	m_layout_search_alternate(false),
 	m_layout_commands_alternate(false),
-	m_supports_alpha(false),
-	m_opacity(wm_settings->menu_opacity)
+	m_supports_alpha(false)
 {
 	m_geometry.x = 0;
 	m_geometry.y = 0;
@@ -115,7 +114,7 @@ WhiskerMenu::Window::Window() :
 	m_commands_button[3] = wm_settings->command[Settings::CommandLogOut]->get_button();
 	for (int i = 0; i < 4; ++i)
 	{
-		g_signal_connect_slot<GtkButton*>(m_commands_button[i], "clicked", &Window::hide, this);
+		m_command_slots[i] = g_signal_connect_slot<GtkButton*>(m_commands_button[i], "clicked", &Window::hide, this);
 	}
 
 	m_resizer = new ResizerWidget(m_window);
@@ -249,6 +248,12 @@ WhiskerMenu::Window::Window() :
 
 WhiskerMenu::Window::~Window()
 {
+	for (int i = 0; i < 4; ++i)
+	{
+		g_signal_handler_disconnect(m_commands_button[i], m_command_slots[i]);
+		gtk_container_remove(GTK_CONTAINER(m_commands_box), m_commands_button[i]);
+	}
+
 	delete m_applications;
 	delete m_search_results;
 	delete m_recent;
@@ -257,6 +262,9 @@ WhiskerMenu::Window::~Window()
 	delete m_profilepic;
 	delete m_resizer;
 
+	delete m_favorites_button;
+	delete m_recent_button;
+
 	g_object_unref(m_window);
 }
 
@@ -280,13 +288,6 @@ void WhiskerMenu::Window::hide()
 
 void WhiskerMenu::Window::show(GtkWidget* parent, bool horizontal)
 {
-	// Handle change in opacity
-	if (wm_settings->menu_opacity != m_opacity)
-	{
-		m_opacity = wm_settings->menu_opacity;
-		on_screen_changed_event(GTK_WIDGET(m_window), NULL);
-	}
-
 	// Make sure icon sizes are correct
 	m_favorites_button->reload_icon_size();
 	m_recent_button->reload_icon_size();
@@ -830,7 +831,7 @@ void WhiskerMenu::Window::on_screen_changed_event(GtkWidget* widget, GdkScreen*)
 {
 	GdkScreen* screen = gtk_widget_get_screen(widget);
 	GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen);
-	if (!colormap || (m_opacity == 100))
+	if (!colormap || (wm_settings->menu_opacity == 100))
 	{
 		colormap = gdk_screen_get_system_colormap(screen);
 		m_supports_alpha = false;
diff --git a/panel-plugin/window.h b/panel-plugin/window.h
index 68dfc84..bfaec1f 100644
--- a/panel-plugin/window.h
+++ b/panel-plugin/window.h
@@ -113,6 +113,7 @@ private:
 
 	GtkAlignment* m_commands_align;
 	GtkWidget* m_commands_button[4];
+	gulong m_command_slots[4];
 
 	GtkEntry* m_search_entry;
 
@@ -133,7 +134,6 @@ private:
 	bool m_layout_search_alternate;
 	bool m_layout_commands_alternate;
 	bool m_supports_alpha;
-	int m_opacity;
 };
 
 }

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


More information about the Xfce4-commits mailing list