[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 01/44: Add option to hide category names.

noreply at xfce.org noreply at xfce.org
Wed Feb 1 15:12:47 CET 2017


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to annotated tag v1.7.0
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit d5691a1b07fe197853f68e93669931bb6e0d4ac1
Author: Graeme Gott <graeme at gottcode.org>
Date:   Wed Oct 19 11:44:28 2016 -0400

    Add option to hide category names.
---
 panel-plugin/configuration-dialog.cpp | 40 +++++++++++++++++++++++++++--------
 panel-plugin/configuration-dialog.h   |  2 ++
 panel-plugin/section-button.cpp       | 27 +++++++++++++++++------
 panel-plugin/section-button.h         |  4 +++-
 panel-plugin/settings.cpp             |  3 +++
 panel-plugin/settings.h               |  1 +
 panel-plugin/window.cpp               | 20 +++++++++---------
 7 files changed, 71 insertions(+), 26 deletions(-)

diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp
index aa850bc..b254731 100644
--- a/panel-plugin/configuration-dialog.cpp
+++ b/panel-plugin/configuration-dialog.cpp
@@ -145,6 +145,13 @@ void ConfigurationDialog::category_icon_size_changed(GtkComboBox* combo)
 {
 	wm_settings->category_icon_size = gtk_combo_box_get_active(combo) - 1;
 	wm_settings->set_modified();
+
+	bool active = wm_settings->category_icon_size != -1;
+	gtk_widget_set_sensitive(m_show_category_names, active);
+	if (!active)
+	{
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_category_names), true);
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -198,6 +205,15 @@ void ConfigurationDialog::toggle_show_generic_name(GtkToggleButton* button)
 
 //-----------------------------------------------------------------------------
 
+void ConfigurationDialog::toggle_show_category_name(GtkToggleButton* button)
+{
+	wm_settings->category_show_name = gtk_toggle_button_get_active(button);
+	wm_settings->set_modified();
+	m_plugin->reload();
+}
+
+//-----------------------------------------------------------------------------
+
 void ConfigurationDialog::toggle_show_description(GtkToggleButton* button)
 {
 	wm_settings->launcher_show_description = gtk_toggle_button_get_active(button);
@@ -583,28 +599,34 @@ GtkWidget* ConfigurationDialog::init_appearance_tab()
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_generic_names), !wm_settings->launcher_show_name);
 	g_signal_connect_slot(m_show_generic_names, "toggled", &ConfigurationDialog::toggle_show_generic_name, this);
 
+	// Add option to hide category names
+	m_show_category_names = gtk_check_button_new_with_mnemonic(_("Show cate_gory names"));
+	gtk_table_attach_defaults(menu_table, m_show_category_names, 0, 2, 1, 2);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_category_names), wm_settings->category_show_name);
+	g_signal_connect_slot(m_show_category_names, "toggled", &ConfigurationDialog::toggle_show_category_name, this);
+
 	// Add option to hide descriptions
 	m_show_descriptions = gtk_check_button_new_with_mnemonic(_("Show application _descriptions"));
-	gtk_table_attach_defaults(menu_table, m_show_descriptions, 0, 2, 1, 2);
+	gtk_table_attach_defaults(menu_table, m_show_descriptions, 0, 2, 2, 3);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_descriptions), wm_settings->launcher_show_description);
 	g_signal_connect_slot(m_show_descriptions, "toggled", &ConfigurationDialog::toggle_show_description, this);
 
 	// Add option to hide tooltips
 	m_show_tooltips = gtk_check_button_new_with_mnemonic(_("Show application too_ltips"));
-	gtk_table_attach_defaults(menu_table, m_show_tooltips, 0, 2, 2, 3);
+	gtk_table_attach_defaults(menu_table, m_show_tooltips, 0, 2, 3, 4);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_tooltips), wm_settings->launcher_show_tooltip);
 	g_signal_connect_slot(m_show_tooltips, "toggled", &ConfigurationDialog::toggle_show_tooltip, this);
 
 	// Add option to show menu hierarchy
 	m_show_hierarchy = gtk_check_button_new_with_mnemonic(_("Show menu hie_rarchy"));
-	gtk_table_attach_defaults(menu_table, m_show_hierarchy, 0, 2, 3, 4);
+	gtk_table_attach_defaults(menu_table, m_show_hierarchy, 0, 2, 4, 5);
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_show_hierarchy), wm_settings->load_hierarchy);
 	g_signal_connect_slot(m_show_hierarchy, "toggled", &ConfigurationDialog::toggle_show_hierarchy, this);
 
 	// Add item icon size selector
 	label = gtk_label_new_with_mnemonic(_("Ite_m icon size:"));
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-	gtk_table_attach(menu_table, label, 0, 1, 4, 5, GTK_FILL, GtkAttachOptions(GTK_EXPAND | GTK_FILL), 0, 0);
+	gtk_table_attach(menu_table, label, 0, 1, 5, 6, GTK_FILL, GtkAttachOptions(GTK_EXPAND | GTK_FILL), 0, 0);
 
 	m_item_icon_size = gtk_combo_box_text_new();
 	std::vector<std::string> icon_sizes = IconSize::get_strings();
@@ -613,14 +635,14 @@ GtkWidget* ConfigurationDialog::init_appearance_tab()
 		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_item_icon_size), i->c_str());
 	}
 	gtk_combo_box_set_active(GTK_COMBO_BOX(m_item_icon_size), wm_settings->launcher_icon_size + 1);
-	gtk_table_attach_defaults(menu_table, m_item_icon_size, 1, 2, 4, 5);
+	gtk_table_attach_defaults(menu_table, m_item_icon_size, 1, 2, 5, 6);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_item_icon_size);
 	g_signal_connect_slot(m_item_icon_size, "changed", &ConfigurationDialog::item_icon_size_changed, this);
 
 	// Add category icon size selector
 	label = gtk_label_new_with_mnemonic(_("Categ_ory icon size:"));
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-	gtk_table_attach(menu_table, label, 0, 1, 5, 6, GTK_FILL, GtkAttachOptions(GTK_EXPAND | GTK_FILL), 0, 0);
+	gtk_table_attach(menu_table, label, 0, 1, 6, 7, GTK_FILL, GtkAttachOptions(GTK_EXPAND | GTK_FILL), 0, 0);
 
 	m_category_icon_size = gtk_combo_box_text_new();
 	for (std::vector<std::string>::const_iterator i = icon_sizes.begin(), end = icon_sizes.end(); i != end; ++i)
@@ -628,17 +650,17 @@ GtkWidget* ConfigurationDialog::init_appearance_tab()
 		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_category_icon_size), i->c_str());
 	}
 	gtk_combo_box_set_active(GTK_COMBO_BOX(m_category_icon_size), wm_settings->category_icon_size + 1);
-	gtk_table_attach_defaults(menu_table, m_category_icon_size, 1, 2, 5, 6);
+	gtk_table_attach_defaults(menu_table, m_category_icon_size, 1, 2, 6, 7);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_category_icon_size);
 	g_signal_connect_slot(m_category_icon_size, "changed", &ConfigurationDialog::category_icon_size_changed, this);
 
 	// Add option to control background opacity
 	label = gtk_label_new_with_mnemonic(_("Background opacit_y:"));
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-	gtk_table_attach(menu_table, label, 0, 1, 6, 7, GTK_FILL, GtkAttachOptions(GTK_EXPAND | GTK_FILL), 0, 0);
+	gtk_table_attach(menu_table, label, 0, 1, 7, 8, GTK_FILL, GtkAttachOptions(GTK_EXPAND | GTK_FILL), 0, 0);
 
 	m_background_opacity = gtk_hscale_new_with_range(0.0, 100.0, 1.0);
-	gtk_table_attach_defaults(menu_table, m_background_opacity, 1, 2, 6, 7);
+	gtk_table_attach_defaults(menu_table, m_background_opacity, 1, 2, 7, 8);
 	gtk_scale_set_value_pos(GTK_SCALE(m_background_opacity), GTK_POS_RIGHT);
 	gtk_range_set_value(GTK_RANGE(m_background_opacity), wm_settings->menu_opacity);
 	g_signal_connect_slot(m_background_opacity, "value-changed", &ConfigurationDialog::background_opacity_changed, this);
diff --git a/panel-plugin/configuration-dialog.h b/panel-plugin/configuration-dialog.h
index d14b630..c5d65fd 100644
--- a/panel-plugin/configuration-dialog.h
+++ b/panel-plugin/configuration-dialog.h
@@ -42,6 +42,7 @@ public:
 
 private:
 	void toggle_show_generic_name(GtkToggleButton* button);
+	void toggle_show_category_name(GtkToggleButton* button);
 	void toggle_show_description(GtkToggleButton* button);
 	void toggle_show_tooltip(GtkToggleButton* button);
 	void toggle_show_hierarchy(GtkToggleButton* button);
@@ -85,6 +86,7 @@ private:
 
 	GtkWidget* m_button_single_row;
 	GtkWidget* m_show_generic_names;
+	GtkWidget* m_show_category_names;
 	GtkWidget* m_show_descriptions;
 	GtkWidget* m_show_tooltips;
 	GtkWidget* m_show_hierarchy;
diff --git a/panel-plugin/section-button.cpp b/panel-plugin/section-button.cpp
index 13ea3bc..30ed6b2 100644
--- a/panel-plugin/section-button.cpp
+++ b/panel-plugin/section-button.cpp
@@ -51,18 +51,20 @@ SectionButton::SectionButton(const gchar* icon, const gchar* text) :
 	m_button = GTK_RADIO_BUTTON(gtk_radio_button_new(NULL));
 	gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(m_button), false);
 	gtk_button_set_relief(GTK_BUTTON(m_button), GTK_RELIEF_NONE);
+	gtk_widget_set_tooltip_text(GTK_WIDGET(m_button), text);
 	gtk_button_set_focus_on_click(GTK_BUTTON(m_button), false);
 	g_signal_connect(m_button, "enter-notify-event", G_CALLBACK(on_enter_notify_event), GTK_TOGGLE_BUTTON(m_button));
 
-	GtkBox* box = GTK_BOX(gtk_hbox_new(false, 4));
-	gtk_container_add(GTK_CONTAINER(m_button), GTK_WIDGET(box));
+	m_box = GTK_BOX(gtk_hbox_new(false, 4));
+	gtk_container_add(GTK_CONTAINER(m_button), GTK_WIDGET(m_box));
 
 	m_icon = xfce_panel_image_new();
-	reload_icon_size();
-	gtk_box_pack_start(box, m_icon, false, false, 0);
+	gtk_box_pack_start(m_box, m_icon, false, false, 0);
+
+	m_label = gtk_label_new(text);
+	gtk_box_pack_start(m_box, m_label, false, true, 0);
 
-	GtkWidget* label = gtk_label_new(text);
-	gtk_box_pack_start(box, label, false, true, 0);
+	reload_icon_size();
 }
 
 //-----------------------------------------------------------------------------
@@ -84,6 +86,19 @@ void SectionButton::reload_icon_size()
 	{
 		xfce_panel_image_set_from_source(XFCE_PANEL_IMAGE(m_icon), m_icon_name);
 	}
+
+	if (wm_settings->category_show_name)
+	{
+		gtk_widget_set_has_tooltip(GTK_WIDGET(m_button), false);
+		gtk_box_set_child_packing(m_box, m_icon, false, false, 0, GTK_PACK_START);
+		gtk_widget_show(m_label);
+	}
+	else
+	{
+		gtk_widget_set_has_tooltip(GTK_WIDGET(m_button), true);
+		gtk_widget_hide(m_label);
+		gtk_box_set_child_packing(m_box, m_icon, true, true, 0, GTK_PACK_START);
+	}
 }
 
 //-----------------------------------------------------------------------------
diff --git a/panel-plugin/section-button.h b/panel-plugin/section-button.h
index 32b7511..ae2c46d 100644
--- a/panel-plugin/section-button.h
+++ b/panel-plugin/section-button.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2016 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -58,7 +58,9 @@ public:
 
 private:
 	GtkRadioButton* m_button;
+	GtkBox* m_box;
 	GtkWidget* m_icon;
+	GtkWidget* m_label;
 	gchar* m_icon_name;
 };
 
diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp
index 13f7e6e..e8b4784 100644
--- a/panel-plugin/settings.cpp
+++ b/panel-plugin/settings.cpp
@@ -94,6 +94,7 @@ Settings::Settings() :
 	launcher_icon_size(IconSize::Small),
 
 	category_hover_activate(false),
+	category_show_name(true),
 	category_icon_size(IconSize::Smaller),
 
 	load_hierarchy(false),
@@ -179,6 +180,7 @@ void Settings::load(char* file)
 
 	category_hover_activate = xfce_rc_read_bool_entry(rc, "hover-switch-category", category_hover_activate);
 	category_icon_size = xfce_rc_read_int_entry(rc, "category-icon-size", category_icon_size);
+	category_show_name = xfce_rc_read_bool_entry(rc, "category-show-name", category_show_name) && (category_icon_size != -1);
 
 	load_hierarchy = xfce_rc_read_bool_entry(rc, "load-hierarchy", load_hierarchy);
 
@@ -275,6 +277,7 @@ void Settings::save(char* file)
 	xfce_rc_write_int_entry(rc, "item-icon-size", launcher_icon_size);
 
 	xfce_rc_write_bool_entry(rc, "hover-switch-category", category_hover_activate);
+	xfce_rc_write_bool_entry(rc, "category-show-name", category_show_name);
 	xfce_rc_write_int_entry(rc, "category-icon-size", category_icon_size);
 
 	xfce_rc_write_bool_entry(rc, "load-hierarchy", load_hierarchy);
diff --git a/panel-plugin/settings.h b/panel-plugin/settings.h
index e3c9724..46d934d 100644
--- a/panel-plugin/settings.h
+++ b/panel-plugin/settings.h
@@ -71,6 +71,7 @@ public:
 	IconSize launcher_icon_size;
 
 	bool category_hover_activate;
+	bool category_show_name;
 	IconSize category_icon_size;
 
 	bool load_hierarchy;
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index 3a6b909..eb482c2 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -272,16 +272,6 @@ void WhiskerMenu::Window::hide()
 
 void WhiskerMenu::Window::show(GtkWidget* parent, bool horizontal)
 {
-	// Make sure icon sizes are correct
-	m_favorites_button->reload_icon_size();
-	m_recent_button->reload_icon_size();
-	m_applications->reload_category_icon_size();
-
-	m_search_results->get_view()->reload_icon_size();
-	m_favorites->get_view()->reload_icon_size();
-	m_recent->get_view()->reload_icon_size();
-	m_applications->get_view()->reload_icon_size();
-
 	// Handle showing tooltips
 	if (wm_settings->launcher_show_tooltip)
 	{
@@ -329,6 +319,16 @@ void WhiskerMenu::Window::show(GtkWidget* parent, bool horizontal)
 	}
 	show_default_page();
 
+	// Make sure icon sizes are correct
+	m_favorites_button->reload_icon_size();
+	m_recent_button->reload_icon_size();
+	m_applications->reload_category_icon_size();
+
+	m_search_results->get_view()->reload_icon_size();
+	m_favorites->get_view()->reload_icon_size();
+	m_recent->get_view()->reload_icon_size();
+	m_applications->get_view()->reload_icon_size();
+
 	GdkScreen* screen = NULL;
 	int parent_x = 0, parent_y = 0, parent_w = 0, parent_h = 0;
 	if (parent != NULL)

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


More information about the Xfce4-commits mailing list