[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 440/473: Fix panel button border not shown when pressed.

noreply at xfce.org noreply at xfce.org
Tue Feb 17 00:00:10 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 f2f4978824149ed215fa1788a031973d4b75e296
Author: Graeme Gott <graeme at gottcode.org>
Date:   Thu Dec 11 16:03:47 2014 -0500

    Fix panel button border not shown when pressed.
---
 panel-plugin/plugin.cpp |   44 +++++++++++---------------------------------
 panel-plugin/plugin.h   |    3 +--
 2 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/panel-plugin/plugin.cpp b/panel-plugin/plugin.cpp
index b7f451a..649bfef 100644
--- a/panel-plugin/plugin.cpp
+++ b/panel-plugin/plugin.cpp
@@ -126,7 +126,7 @@ Plugin::Plugin(XfcePanelPlugin* plugin) :
 	gtk_widget_set_name(m_button, "whiskermenu-button");
 	gtk_button_set_relief(GTK_BUTTON(m_button), GTK_RELIEF_NONE);
 	gtk_button_set_focus_on_click(GTK_BUTTON(m_button), false);
-	g_signal_connect_slot(m_button, "button-press-event", &Plugin::button_clicked, this);
+	g_signal_connect_slot(m_button, "toggled", &Plugin::button_toggled, this);
 	g_signal_connect_slot<GtkWidget*,GtkStyle*>(m_button, "style-set", &Plugin::update_size, this);
 	g_signal_connect_slot<GtkWidget*,GdkScreen*>(m_button, "screen-changed", &Plugin::update_size, this);
 	gtk_widget_show(m_button);
@@ -294,24 +294,18 @@ void Plugin::set_configure_enabled(bool enabled)
 
 //-----------------------------------------------------------------------------
 
-gboolean Plugin::button_clicked(GtkWidget*, GdkEvent* event)
+void Plugin::button_toggled(GtkToggleButton* button)
 {
-	GdkEventButton* event_button = reinterpret_cast<GdkEventButton*>(event);
-	if (event_button->button != 1 || event_button->state & GDK_CONTROL_MASK)
-	{
-		return false;
-	}
-
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_button)) == true)
+	if (gtk_toggle_button_get_active(button) == false)
 	{
 		m_window->hide();
+		xfce_panel_plugin_block_autohide(m_plugin, false);
 	}
 	else
 	{
-		popup_menu(false, false);
+		xfce_panel_plugin_block_autohide(m_plugin, true);
+		m_window->show(m_button, xfce_panel_plugin_get_orientation(m_plugin) == GTK_ORIENTATION_HORIZONTAL);
 	}
-
-	return true;
 }
 
 //-----------------------------------------------------------------------------
@@ -319,7 +313,6 @@ gboolean Plugin::button_clicked(GtkWidget*, GdkEvent* event)
 void Plugin::menu_hidden()
 {
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_button), false);
-	xfce_panel_plugin_block_autohide(m_plugin, false);
 	save();
 }
 
@@ -360,9 +353,13 @@ gboolean Plugin::remote_event(XfcePanelPlugin*, gchar* name, GValue* value)
 	{
 		m_window->hide();
 	}
+	else if (value && G_VALUE_HOLDS_BOOLEAN(value) && g_value_get_boolean(value))
+	{
+		m_window->show(NULL, true);
+	}
 	else
 	{
-		popup_menu(value && G_VALUE_HOLDS_BOOLEAN(value) && g_value_get_boolean(value), true);
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_button), true);
 	}
 
 	return true;
@@ -497,22 +494,3 @@ void Plugin::update_size()
 }
 
 //-----------------------------------------------------------------------------
-
-void Plugin::popup_menu(bool at_cursor, bool activate_button)
-{
-	if (!at_cursor)
-	{
-		xfce_panel_plugin_block_autohide(m_plugin, true);
-		if (activate_button)
-		{
-			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_button), true);
-		}
-		m_window->show(m_button, xfce_panel_plugin_get_orientation(m_plugin) == GTK_ORIENTATION_HORIZONTAL);
-	}
-	else
-	{
-		m_window->show(NULL, true);
-	}
-}
-
-//-----------------------------------------------------------------------------
diff --git a/panel-plugin/plugin.h b/panel-plugin/plugin.h
index a9d03ee..ee27e67 100644
--- a/panel-plugin/plugin.h
+++ b/panel-plugin/plugin.h
@@ -58,7 +58,7 @@ public:
 	void set_configure_enabled(bool enabled);
 
 private:
-	gboolean button_clicked(GtkWidget*, GdkEvent* event);
+	void button_toggled(GtkToggleButton* button);
 	void menu_hidden();
 	void configure();
 #if (LIBXFCE4PANEL_CHECK_VERSION(4,9,0))
@@ -71,7 +71,6 @@ private:
 	void show_about();
 	gboolean size_changed(XfcePanelPlugin*, gint size);
 	void update_size();
-	void popup_menu(bool at_cursor, bool activate_button);
 
 private:
 	XfcePanelPlugin* m_plugin;

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


More information about the Xfce4-commits mailing list