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

noreply at xfce.org noreply at xfce.org
Thu Oct 20 14:28:27 CEST 2016


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 3c4fdbd06d12428314be0b4119a0b777aaf6dfe1
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 | 39 +++++++++++++++++++++++++++--------
 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, 70 insertions(+), 26 deletions(-)

diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp
index 264884c..e0200d5 100644
--- a/panel-plugin/configuration-dialog.cpp
+++ b/panel-plugin/configuration-dialog.cpp
@@ -142,6 +142,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);
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -195,6 +202,14 @@ 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();
+}
+
+//-----------------------------------------------------------------------------
+
 void ConfigurationDialog::toggle_show_description(GtkToggleButton* button)
 {
 	wm_settings->launcher_show_description = gtk_toggle_button_get_active(button);
@@ -578,28 +593,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_grid_attach(menu_table, m_show_category_names, 0, 1, 2, 1);
+	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_grid_attach(menu_table, m_show_descriptions, 0, 1, 2, 1);
+	gtk_grid_attach(menu_table, m_show_descriptions, 0, 2, 2, 1);
 	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_grid_attach(menu_table, m_show_tooltips, 0, 2, 3, 1);
+	gtk_grid_attach(menu_table, m_show_tooltips, 0, 3, 3, 1);
 	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_grid_attach(menu_table, m_show_hierarchy, 0, 3, 2, 1);
+	gtk_grid_attach(menu_table, m_show_hierarchy, 0, 4, 2, 1);
 	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_widget_set_halign(label, GTK_ALIGN_START);
-	gtk_grid_attach(menu_table, label, 0, 4, 1, 1);
+	gtk_grid_attach(menu_table, label, 0, 5, 1, 1);
 
 	m_item_icon_size = gtk_combo_box_text_new();
 	std::vector<std::string> icon_sizes = IconSize::get_strings();
@@ -608,14 +629,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_grid_attach(menu_table, m_item_icon_size, 1, 4, 1, 1);
+	gtk_grid_attach(menu_table, m_item_icon_size, 1, 5, 1, 1);
 	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_widget_set_halign(label, GTK_ALIGN_START);
-	gtk_grid_attach(menu_table, label, 0, 5, 1, 1);
+	gtk_grid_attach(menu_table, label, 0, 6, 1, 1);
 
 	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)
@@ -623,18 +644,18 @@ 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_grid_attach(menu_table, m_category_icon_size, 1, 5, 1, 1);
+	gtk_grid_attach(menu_table, m_category_icon_size, 1, 6, 1, 1);
 	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_widget_set_halign(label, GTK_ALIGN_START);
-	gtk_grid_attach(menu_table, label, 0, 6, 1, 1);
+	gtk_grid_attach(menu_table, label, 0, 7, 1, 1);
 
 	m_background_opacity = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1.0);
 	gtk_widget_set_hexpand(GTK_WIDGET(m_background_opacity), true);
-	gtk_grid_attach(menu_table, m_background_opacity, 1, 6, 1, 1);
+	gtk_grid_attach(menu_table, m_background_opacity, 1, 7, 1, 1);
 	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 f8d96d9..095e10b 100644
--- a/panel-plugin/section-button.cpp
+++ b/panel-plugin/section-button.cpp
@@ -51,6 +51,7 @@ 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);
 #if GTK_CHECK_VERSION(3,20,0)
 	gtk_widget_set_focus_on_click(GTK_WIDGET(m_button), false);
 #else
@@ -58,15 +59,16 @@ SectionButton::SectionButton(const gchar* icon, const gchar* text) :
 #endif
 	g_signal_connect(m_button, "enter-notify-event", G_CALLBACK(on_enter_notify_event), GTK_TOGGLE_BUTTON(m_button));
 
-	GtkBox* box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4));
-	gtk_container_add(GTK_CONTAINER(m_button), GTK_WIDGET(box));
+	m_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 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();
 }
 
 //-----------------------------------------------------------------------------
@@ -88,6 +90,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 cfd8706..8224722 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -313,16 +313,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)
 	{
@@ -370,6 +360,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