[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 46/473: Add option to switch categories by hovering.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:53:36 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 8ca71d69d761e9364eeb8b9c26daa1bf4212d5cf
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sun Jun 30 19:48:35 2013 -0400

    Add option to switch categories by hovering.
---
 src/configuration_dialog.cpp |   20 ++++++++++++++++++++
 src/configuration_dialog.hpp |    2 ++
 src/panel_plugin.cpp         |    3 +++
 src/section_button.cpp       |   37 +++++++++++++++++++++++++++++++++++++
 src/section_button.hpp       |    2 ++
 5 files changed, 64 insertions(+)

diff --git a/src/configuration_dialog.cpp b/src/configuration_dialog.cpp
index 92725ad..96739a9 100644
--- a/src/configuration_dialog.cpp
+++ b/src/configuration_dialog.cpp
@@ -18,6 +18,7 @@
 
 #include "launcher.hpp"
 #include "panel_plugin.hpp"
+#include "section_button.hpp"
 
 extern "C"
 {
@@ -96,6 +97,18 @@ ConfigurationDialog::ConfigurationDialog(PanelPlugin* plugin) :
 	xfce_panel_image_set_size(XFCE_PANEL_IMAGE(m_icon), 48);
 	gtk_container_add(GTK_CONTAINER(m_icon_button), m_icon);
 
+	// Create behavior section
+	GtkBox* behavior_vbox = GTK_BOX(gtk_vbox_new(false, 8));
+	GtkWidget* behavior_frame = xfce_gtk_frame_box_new_with_content(_("Behavior"), GTK_WIDGET(behavior_vbox));
+	gtk_box_pack_start(contents_vbox, behavior_frame, false, false, 0);
+	gtk_container_set_border_width(GTK_CONTAINER(behavior_frame), 6);
+
+	// Add option to use generic names
+	m_hover_switch_category = gtk_check_button_new_with_mnemonic(_("Switch categories by _hovering"));
+	gtk_box_pack_start(behavior_vbox, m_hover_switch_category, true, true, 0);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_hover_switch_category), section_button_get_hover_activate());
+	g_signal_connect(m_hover_switch_category, "toggled", SLOT_CALLBACK(ConfigurationDialog::toggle_hover_switch_category), this);
+
 	// Show GTK window
 	gtk_widget_show_all(m_window);
 
@@ -138,6 +151,13 @@ void ConfigurationDialog::choose_icon()
 
 //-----------------------------------------------------------------------------
 
+void ConfigurationDialog::toggle_hover_switch_category(GtkToggleButton* button)
+{
+	section_button_set_hover_activate(gtk_toggle_button_get_active(button));
+}
+
+//-----------------------------------------------------------------------------
+
 void ConfigurationDialog::toggle_show_name(GtkToggleButton*)
 {
 	Launcher::set_show_name(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_show_names)));
diff --git a/src/configuration_dialog.hpp b/src/configuration_dialog.hpp
index f35e69e..3ba3320 100644
--- a/src/configuration_dialog.hpp
+++ b/src/configuration_dialog.hpp
@@ -37,6 +37,7 @@ public:
 
 private:
 	SLOT_0(void, ConfigurationDialog, choose_icon);
+	SLOT_1(void, ConfigurationDialog, toggle_hover_switch_category, GtkToggleButton*);
 	SLOT_1(void, ConfigurationDialog, toggle_show_name, GtkToggleButton*);
 	SLOT_1(void, ConfigurationDialog, toggle_show_description, GtkToggleButton*);
 	SLOT_2(void, ConfigurationDialog, response, GtkDialog*, gint);
@@ -49,6 +50,7 @@ private:
 	GtkWidget* m_icon_button;
 	GtkWidget* m_show_names;
 	GtkWidget* m_show_descriptions;
+	GtkWidget* m_hover_switch_category;
 };
 
 }
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index 4e6f2bb..1d78c8c 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -20,6 +20,7 @@
 #include "configuration_dialog.hpp"
 #include "launcher.hpp"
 #include "menu.hpp"
+#include "section_button.hpp"
 
 using namespace WhiskerMenu;
 
@@ -54,6 +55,7 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
 		m_button_icon_name = xfce_rc_read_entry(settings, "button-icon", m_button_icon_name.c_str());
 		Launcher::set_show_name(xfce_rc_read_bool_entry(settings, "launcher-show-name", true));
 		Launcher::set_show_description(xfce_rc_read_bool_entry(settings, "launcher-show-description", true));
+		section_button_set_hover_activate(xfce_rc_read_bool_entry(settings, "hover-switch-category", false));
 		m_menu = new Menu(settings);
 
 		xfce_rc_close(settings);
@@ -200,6 +202,7 @@ void PanelPlugin::save()
 	xfce_rc_write_entry(settings, "button-icon", m_button_icon_name.c_str());
 	xfce_rc_write_bool_entry(settings, "launcher-show-name", Launcher::get_show_name());
 	xfce_rc_write_bool_entry(settings, "launcher-show-description", Launcher::get_show_description());
+	xfce_rc_write_bool_entry(settings, "hover-switch-category", section_button_get_hover_activate());
 	m_menu->save(settings);
 
 	xfce_rc_close(settings);
diff --git a/src/section_button.cpp b/src/section_button.cpp
index e5c966f..cd33770 100644
--- a/src/section_button.cpp
+++ b/src/section_button.cpp
@@ -18,12 +18,35 @@
 
 //-----------------------------------------------------------------------------
 
+static bool f_hover_activate = false;
+
+static gboolean hover_timeout(GtkToggleButton* button)
+{
+	if (gtk_widget_get_state(GTK_WIDGET(button)) == GTK_STATE_PRELIGHT)
+	{
+		gtk_toggle_button_set_active(button, true);
+	}
+	return false;
+}
+
+static gboolean on_enter_notify_event(GtkWidget*, GdkEventCrossing*, GtkToggleButton* button)
+{
+	if (f_hover_activate && !gtk_toggle_button_get_active(button))
+	{
+		g_timeout_add(150, (GSourceFunc)hover_timeout, button);
+	}
+	return false;
+}
+
+//-----------------------------------------------------------------------------
+
 GtkRadioButton* WhiskerMenu::new_section_button(const gchar* icon, const gchar* text)
 {
 	GtkWidget* button = gtk_radio_button_new(NULL);
 	gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), false);
 	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
 	gtk_button_set_focus_on_click(GTK_BUTTON(button), false);
+	g_signal_connect(button, "enter-notify-event", G_CALLBACK(on_enter_notify_event), GTK_TOGGLE_BUTTON(button));
 
 	GtkBox* box = GTK_BOX(gtk_hbox_new(false, 4));
 	gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(box));
@@ -38,3 +61,17 @@ GtkRadioButton* WhiskerMenu::new_section_button(const gchar* icon, const gchar*
 }
 
 //-----------------------------------------------------------------------------
+
+bool WhiskerMenu::section_button_get_hover_activate()
+{
+	return f_hover_activate;
+}
+
+//-----------------------------------------------------------------------------
+
+void WhiskerMenu::section_button_set_hover_activate(bool hover_activate)
+{
+	f_hover_activate = hover_activate;
+}
+
+//-----------------------------------------------------------------------------
diff --git a/src/section_button.hpp b/src/section_button.hpp
index 33a3c4c..bcb6cd2 100644
--- a/src/section_button.hpp
+++ b/src/section_button.hpp
@@ -26,6 +26,8 @@ namespace WhiskerMenu
 {
 
 GtkRadioButton* new_section_button(const gchar* icon, const gchar* text);
+bool section_button_get_hover_activate();
+void section_button_set_hover_activate(bool hover_activate);
 
 }
 

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


More information about the Xfce4-commits mailing list