[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 171/473: Add option to position command buttons next to search entry.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:55: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 48300ac080bd34848026ce57d5c3130cae4f11da
Author: Graeme Gott <graeme at gottcode.org>
Date:   Wed Oct 9 13:38:51 2013 -0400

    Add option to position command buttons next to search entry.
---
 src/configuration_dialog.cpp |   17 ++++++
 src/configuration_dialog.hpp |    7 +++
 src/menu.cpp                 |  129 ++++++++++++++++++++++++++++++++++++------
 src/menu.hpp                 |   10 +++-
 src/panel_plugin.cpp         |    2 +
 5 files changed, 146 insertions(+), 19 deletions(-)

diff --git a/src/configuration_dialog.cpp b/src/configuration_dialog.cpp
index 0dea0ce..62cd201 100644
--- a/src/configuration_dialog.cpp
+++ b/src/configuration_dialog.cpp
@@ -172,7 +172,17 @@ void ConfigurationDialog::toggle_show_description(GtkToggleButton* button)
 
 void ConfigurationDialog::toggle_position_search_alternate(GtkToggleButton* button)
 {
+	bool active = gtk_toggle_button_get_active(button);
 	Menu::set_position_search_alternate(gtk_toggle_button_get_active(button));
+	gtk_widget_set_sensitive(GTK_WIDGET(m_position_commands_alternate), active);
+	m_plugin->reload();
+}
+
+//-----------------------------------------------------------------------------
+
+void ConfigurationDialog::toggle_position_commands_alternate(GtkToggleButton* button)
+{
+	Menu::set_position_commands_alternate(gtk_toggle_button_get_active(button));
 	m_plugin->reload();
 }
 
@@ -269,6 +279,13 @@ GtkWidget* ConfigurationDialog::init_appearance_tab()
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_position_search_alternate), Menu::get_position_search_alternate());
 	g_signal_connect(m_position_search_alternate, "toggled", G_CALLBACK(ConfigurationDialog::toggle_position_search_alternate_slot), this);
 
+	// Add option to use alternate commands position
+	m_position_commands_alternate = gtk_check_button_new_with_mnemonic(_("Position commands next to search _entry"));
+	gtk_box_pack_start(appearance_vbox, m_position_commands_alternate, true, true, 0);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_position_commands_alternate), Menu::get_position_commands_alternate());
+	gtk_widget_set_sensitive(GTK_WIDGET(m_position_commands_alternate), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_position_search_alternate)));
+	g_signal_connect(m_position_commands_alternate, "toggled", G_CALLBACK(ConfigurationDialog::toggle_position_commands_alternate_slot), this);
+
 	// Add item icon size selector
 	GtkBox* hbox = GTK_BOX(gtk_hbox_new(false, 12));
 	gtk_box_pack_start(appearance_vbox, GTK_WIDGET(hbox), false, false, 0);
diff --git a/src/configuration_dialog.hpp b/src/configuration_dialog.hpp
index 5f4fe83..888e163 100644
--- a/src/configuration_dialog.hpp
+++ b/src/configuration_dialog.hpp
@@ -42,6 +42,7 @@ private:
 	void toggle_show_name(GtkToggleButton* button);
 	void toggle_show_description(GtkToggleButton* button);
 	void toggle_position_search_alternate(GtkToggleButton* button);
+	void toggle_position_commands_alternate(GtkToggleButton* button);
 	void category_icon_size_changed(GtkComboBox* combo);
 	void item_icon_size_changed(GtkComboBox* combo);
 
@@ -71,6 +72,7 @@ private:
 	GtkWidget* m_show_names;
 	GtkWidget* m_show_descriptions;
 	GtkWidget* m_position_search_alternate;
+	GtkWidget* m_position_commands_alternate;
 	GtkWidget* m_category_icon_size;
 	GtkWidget* m_item_icon_size;
 
@@ -135,6 +137,11 @@ private:
 		obj->toggle_position_search_alternate(button);
 	}
 
+	static void toggle_position_commands_alternate_slot(GtkToggleButton* button, ConfigurationDialog* obj)
+	{
+		obj->toggle_position_commands_alternate(button);
+	}
+
 	static void toggle_load_hierarchy_slot(GtkToggleButton* button, ConfigurationDialog* obj)
 	{
 		obj->toggle_load_hierarchy(button);
diff --git a/src/menu.cpp b/src/menu.cpp
index 11fbe32..933b2ed 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -54,6 +54,7 @@ std::string Menu::m_lockscreen_command = "xflock4";
 std::string Menu::m_logout_command = "xfce4-session-logout";
 bool Menu::m_display_recent = false;
 bool Menu::m_position_search_alternate = false;
+bool Menu::m_position_commands_alternate = false;
 
 //-----------------------------------------------------------------------------
 
@@ -62,6 +63,7 @@ Menu::Menu(XfceRc* settings) :
 	m_layout_left(true),
 	m_layout_bottom(true),
 	m_layout_search_alternate(false),
+	m_layout_commands_alternate(false),
 	m_modified(false)
 {
 	m_geometry.x = 0;
@@ -158,17 +160,25 @@ Menu::Menu(XfceRc* settings) :
 	gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(m_vbox));
 	gtk_container_set_border_width(GTK_CONTAINER(m_vbox), 2);
 
-	// Create box for packing username and action buttons
+	// Create box for packing commands
+	m_commands_align = GTK_ALIGNMENT(gtk_alignment_new(1, 0, 0, 0));
+	m_commands_box = GTK_BOX(gtk_hbox_new(false, 0));
+	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_settings_button), false, false, 0);
+	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_lock_screen_button), false, false, 0);
+	gtk_box_pack_start(m_commands_box, GTK_WIDGET(m_log_out_button), false, false, 0);
+	gtk_container_add(GTK_CONTAINER(m_commands_align), GTK_WIDGET(m_commands_box));
+
+	// Create box for packing username, commands, and resize widget
 	m_title_box = GTK_BOX(gtk_hbox_new(false, 0));
 	gtk_box_pack_start(m_vbox, GTK_WIDGET(m_title_box), false, false, 0);
 	gtk_box_pack_start(m_title_box, GTK_WIDGET(m_username), true, true, 0);
-	gtk_box_pack_start(m_title_box, GTK_WIDGET(m_settings_button), false, false, 0);
-	gtk_box_pack_start(m_title_box, GTK_WIDGET(m_lock_screen_button), false, false, 0);
-	gtk_box_pack_start(m_title_box, GTK_WIDGET(m_log_out_button), false, false, 0);
+	gtk_box_pack_start(m_title_box, GTK_WIDGET(m_commands_align), false, false, 0);
 	gtk_box_pack_start(m_title_box, GTK_WIDGET(m_resizer->get_widget()), false, false, 0);
 
 	// Add search to layout
-	gtk_box_pack_start(m_vbox, GTK_WIDGET(m_search_entry), false, true, 0);
+	m_search_box = GTK_BOX(gtk_hbox_new(false, 6));
+	gtk_box_pack_start(m_vbox, GTK_WIDGET(m_search_box), false, true, 0);
+	gtk_box_pack_start(m_search_box, GTK_WIDGET(m_search_entry), true, true, 0);
 
 	// Create box for packing launcher pages and sidebar
 	m_contents_box = GTK_BOX(gtk_hbox_new(false, 6));
@@ -199,6 +209,10 @@ Menu::Menu(XfceRc* settings) :
 	gtk_container_add(GTK_CONTAINER(m_sidebar), viewport);
 	gtk_container_add(GTK_CONTAINER(viewport), GTK_WIDGET(m_sidebar_box));
 
+	GtkSizeGroup* sidebar_size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+	gtk_size_group_add_widget(sidebar_size_group, GTK_WIDGET(m_sidebar));
+	gtk_size_group_add_widget(sidebar_size_group, GTK_WIDGET(m_commands_align));
+
 	// Populate app menu
 	m_applications->load_applications();
 
@@ -401,18 +415,76 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 	{
 		layout_left = !layout_left;
 	}
+	if (m_layout_commands_alternate != m_position_commands_alternate)
+	{
+		m_layout_left = !layout_left;
+		m_layout_commands_alternate = m_position_commands_alternate;
+		if (m_layout_commands_alternate)
+		{
+			g_object_ref(m_commands_align);
+			gtk_container_remove(GTK_CONTAINER(m_title_box), GTK_WIDGET(m_commands_align));
+			gtk_box_pack_start(m_search_box, GTK_WIDGET(m_commands_align), false, false, 0);
+			g_object_unref(m_commands_align);
+		}
+		else
+		{
+			g_object_ref(m_commands_align);
+			gtk_container_remove(GTK_CONTAINER(m_search_box), GTK_WIDGET(m_commands_align));
+			gtk_box_pack_start(m_title_box, GTK_WIDGET(m_commands_align), false, false, 0);
+			g_object_unref(m_commands_align);
+		}
+	}
 	if (layout_left != m_layout_left)
 	{
 		m_layout_left = layout_left;
-		if (m_layout_left)
+		if (m_layout_left && m_layout_commands_alternate)
 		{
 			gtk_misc_set_alignment(GTK_MISC(m_username), 0.0f, 0.5f);
 
+			gtk_alignment_set(m_commands_align, 1, 0, 0, 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button), 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lock_screen_button), 1);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_log_out_button), 2);
+
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 0);
-			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_settings_button), 1);
-			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_lock_screen_button), 2);
-			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_log_out_button), 3);
-			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_resizer->get_widget()), 4);
+			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_resizer->get_widget()), 1);
+
+			gtk_box_reorder_child(m_search_box, GTK_WIDGET(m_search_entry), 0);
+			gtk_box_reorder_child(m_search_box, GTK_WIDGET(m_commands_align), 1);
+
+			gtk_box_reorder_child(m_contents_box, GTK_WIDGET(m_panels_box), 1);
+			gtk_box_reorder_child(m_contents_box, GTK_WIDGET(m_sidebar), 2);
+		}
+		else if (m_layout_commands_alternate)
+		{
+			gtk_misc_set_alignment(GTK_MISC(m_username), 1.0f, 0.5f);
+
+			gtk_alignment_set(m_commands_align, 0, 0, 0, 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button), 2);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lock_screen_button), 1);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_log_out_button), 0);
+
+			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 1);
+			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_resizer->get_widget()), 0);
+
+			gtk_box_reorder_child(m_search_box, GTK_WIDGET(m_search_entry), 1);
+			gtk_box_reorder_child(m_search_box, GTK_WIDGET(m_commands_align), 0);
+
+			gtk_box_reorder_child(m_contents_box, GTK_WIDGET(m_panels_box), 2);
+			gtk_box_reorder_child(m_contents_box, GTK_WIDGET(m_sidebar), 1);
+		}
+		else if (m_layout_left)
+		{
+			gtk_misc_set_alignment(GTK_MISC(m_username), 0.0f, 0.5f);
+
+			gtk_alignment_set(m_commands_align, 1, 0, 0, 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button), 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lock_screen_button), 1);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_log_out_button), 2);
+
+			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 0);
+			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_commands_align), 1);
+			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_resizer->get_widget()), 2);
 
 			gtk_box_reorder_child(m_contents_box, GTK_WIDGET(m_panels_box), 1);
 			gtk_box_reorder_child(m_contents_box, GTK_WIDGET(m_sidebar), 2);
@@ -421,10 +493,13 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 		{
 			gtk_misc_set_alignment(GTK_MISC(m_username), 1.0f, 0.5f);
 
-			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 4);
-			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_settings_button), 3);
-			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_lock_screen_button), 2);
-			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_log_out_button), 1);
+			gtk_alignment_set(m_commands_align, 0, 0, 0, 0);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_settings_button), 2);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_lock_screen_button), 1);
+			gtk_box_reorder_child(m_commands_box, GTK_WIDGET(m_log_out_button), 0);
+
+			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_username), 2);
+			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_commands_align), 1);
 			gtk_box_reorder_child(m_title_box, GTK_WIDGET(m_resizer->get_widget()), 0);
 
 			gtk_box_reorder_child(m_contents_box, GTK_WIDGET(m_panels_box), 2);
@@ -440,24 +515,24 @@ void Menu::show(GtkWidget* parent, bool horizontal)
 		{
 			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_title_box), 0);
 			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_contents_box), 1);
-			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_search_entry), 2);
+			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_search_box), 2);
 		}
 		else if (m_layout_search_alternate)
 		{
 			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_title_box), 2);
 			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_contents_box), 1);
-			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_search_entry), 0);
+			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_search_box), 0);
 		}
 		else if (m_layout_bottom)
 		{
 			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_title_box), 0);
-			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_search_entry), 1);
+			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_search_box), 1);
 			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_contents_box), 2);
 		}
 		else
 		{
 			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_title_box), 2);
-			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_search_entry), 1);
+			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_search_box), 1);
 			gtk_box_reorder_child(m_vbox, GTK_WIDGET(m_contents_box), 0);
 		}
 	}
@@ -586,6 +661,13 @@ bool Menu::get_position_search_alternate()
 
 //-----------------------------------------------------------------------------
 
+bool Menu::get_position_commands_alternate()
+{
+	return m_position_commands_alternate;
+}
+
+//-----------------------------------------------------------------------------
+
 void Menu::set_settings_command(const std::string& command)
 {
 	m_settings_command = command;
@@ -617,6 +699,17 @@ void Menu::set_display_recent(bool display)
 void Menu::set_position_search_alternate(bool alternate)
 {
 	m_position_search_alternate = alternate;
+	if (!alternate)
+	{
+		m_position_commands_alternate = false;
+	}
+}
+
+//-----------------------------------------------------------------------------
+
+void Menu::set_position_commands_alternate(bool alternate)
+{
+	m_position_commands_alternate = alternate && m_position_search_alternate;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/src/menu.hpp b/src/menu.hpp
index 6244172..4d89403 100644
--- a/src/menu.hpp
+++ b/src/menu.hpp
@@ -88,11 +88,13 @@ public:
 	static std::string get_logout_command();
 	static bool get_display_recent();
 	static bool get_position_search_alternate();
+	static bool get_position_commands_alternate();
 	static void set_settings_command(const std::string& command);
 	static void set_lockscreen_command(const std::string& command);
 	static void set_logout_command(const std::string& command);
 	static void set_display_recent(bool display);
 	static void set_position_search_alternate(bool alternate);
+	static void set_position_commands_alternate(bool alternate);
 
 private:
 	bool on_enter_notify_event(GdkEventCrossing* event);
@@ -118,15 +120,19 @@ private:
 
 	GtkBox* m_vbox;
 	GtkBox* m_title_box;
+	GtkBox* m_commands_box;
+	GtkBox* m_search_box;
 	GtkBox* m_contents_box;
 	GtkBox* m_panels_box;
 	GtkBox* m_sidebar_box;
 
 	GtkLabel* m_username;
+	ResizerWidget* m_resizer;
+
+	GtkAlignment* m_commands_align;
 	GtkButton* m_settings_button;
 	GtkButton* m_lock_screen_button;
 	GtkButton* m_log_out_button;
-	ResizerWidget* m_resizer;
 
 	GtkEntry* m_search_entry;
 
@@ -145,6 +151,7 @@ private:
 	bool m_layout_left;
 	bool m_layout_bottom;
 	bool m_layout_search_alternate;
+	bool m_layout_commands_alternate;
 	bool m_modified;
 
 	static std::string m_settings_command;
@@ -152,6 +159,7 @@ private:
 	static std::string m_logout_command;
 	static bool m_display_recent;
 	static bool m_position_search_alternate;
+	static bool m_position_commands_alternate;
 
 
 private:
diff --git a/src/panel_plugin.cpp b/src/panel_plugin.cpp
index 4879dd6..a65054b 100644
--- a/src/panel_plugin.cpp
+++ b/src/panel_plugin.cpp
@@ -71,6 +71,7 @@ PanelPlugin::PanelPlugin(XfcePanelPlugin* plugin) :
 		FavoritesPage::set_remember_favorites(xfce_rc_read_bool_entry(settings, "favorites-in-recent", FavoritesPage::get_remember_favorites()));
 		Menu::set_display_recent(xfce_rc_read_bool_entry(settings, "display-recent-default", Menu::get_display_recent()));
 		Menu::set_position_search_alternate(xfce_rc_read_bool_entry(settings, "position-search-alternate", Menu::get_position_search_alternate()));
+		Menu::set_position_commands_alternate(xfce_rc_read_bool_entry(settings, "position-commands-alternate", Menu::get_position_commands_alternate()));
 		Menu::set_settings_command(xfce_rc_read_entry(settings, "command-settings", Menu::get_settings_command().c_str()));
 		Menu::set_lockscreen_command(xfce_rc_read_entry(settings, "command-lockscreen", Menu::get_lockscreen_command().c_str()));
 		Menu::set_logout_command(xfce_rc_read_entry(settings, "command-logout", Menu::get_logout_command().c_str()));
@@ -322,6 +323,7 @@ void PanelPlugin::save()
 	xfce_rc_write_bool_entry(settings, "favorites-in-recent", FavoritesPage::get_remember_favorites());
 	xfce_rc_write_bool_entry(settings, "display-recent-default", Menu::get_display_recent());
 	xfce_rc_write_bool_entry(settings, "position-search-alternate", Menu::get_position_search_alternate());
+	xfce_rc_write_bool_entry(settings, "position-commands-alternate", Menu::get_position_commands_alternate());
 	xfce_rc_write_entry(settings, "command-settings", Menu::get_settings_command().c_str());
 	xfce_rc_write_entry(settings, "command-lockscreen", Menu::get_lockscreen_command().c_str());
 	xfce_rc_write_entry(settings, "command-logout", Menu::get_logout_command().c_str());

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


More information about the Xfce4-commits mailing list