[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 224/473: Add options to hide category and launcher icons.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:56:34 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 359118dd5f563db11ea32ad1f840a0a7e8eb7ae9
Author: Graeme Gott <graeme at gottcode.org>
Date:   Thu Nov 7 07:41:47 2013 -0500

    Add options to hide category and launcher icons.
---
 panel-plugin/configuration-dialog.cpp |    8 ++++----
 panel-plugin/icon-size.cpp            |    2 ++
 panel-plugin/icon-size.h              |    5 +++--
 panel-plugin/launcher-view.cpp        |   20 ++++++++++++--------
 panel-plugin/launcher-view.h          |    2 +-
 panel-plugin/section-button.cpp       |   16 ++++++++++++----
 panel-plugin/section-button.h         |    1 +
 7 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp
index 5d549f4..8b4d849 100644
--- a/panel-plugin/configuration-dialog.cpp
+++ b/panel-plugin/configuration-dialog.cpp
@@ -115,14 +115,14 @@ void ConfigurationDialog::choose_icon()
 
 void ConfigurationDialog::category_icon_size_changed(GtkComboBox* combo)
 {
-	wm_settings->category_icon_size = gtk_combo_box_get_active(combo);
+	wm_settings->category_icon_size = gtk_combo_box_get_active(combo) - 1;
 }
 
 //-----------------------------------------------------------------------------
 
 void ConfigurationDialog::item_icon_size_changed(GtkComboBox* combo)
 {
-	wm_settings->launcher_icon_size = gtk_combo_box_get_active(combo);
+	wm_settings->launcher_icon_size = gtk_combo_box_get_active(combo) - 1;
 }
 
 //-----------------------------------------------------------------------------
@@ -306,7 +306,7 @@ 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);
+	gtk_combo_box_set_active(GTK_COMBO_BOX(m_item_icon_size), wm_settings->launcher_icon_size + 1);
 	gtk_box_pack_start(hbox, m_item_icon_size, false, false, 0);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_item_icon_size);
 	g_signal_connect(m_item_icon_size, "changed", G_CALLBACK(ConfigurationDialog::item_icon_size_changed_slot), this);
@@ -325,7 +325,7 @@ 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);
+	gtk_combo_box_set_active(GTK_COMBO_BOX(m_category_icon_size), wm_settings->category_icon_size + 1);
 	gtk_box_pack_start(hbox, m_category_icon_size, false, false, 0);
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label), m_category_icon_size);
 	g_signal_connect(m_category_icon_size, "changed", G_CALLBACK(ConfigurationDialog::category_icon_size_changed_slot), this);
diff --git a/panel-plugin/icon-size.cpp b/panel-plugin/icon-size.cpp
index 94ee09b..11fd185 100644
--- a/panel-plugin/icon-size.cpp
+++ b/panel-plugin/icon-size.cpp
@@ -31,6 +31,7 @@ int IconSize::get_size() const
 	int size = 0;
 	switch (m_size)
 	{
+		case NONE:     size =   1; break;
 		case Smallest: size =  16; break;
 		case Smaller:  size =  24; break;
 		case Small:    size =  32; break;
@@ -48,6 +49,7 @@ int IconSize::get_size() const
 std::vector<std::string> IconSize::get_strings()
 {
 	std::vector<std::string> strings;
+	strings.push_back(_("None"));
 	strings.push_back(_("Very Small"));
 	strings.push_back(_("Smaller"));
 	strings.push_back(_("Small"));
diff --git a/panel-plugin/icon-size.h b/panel-plugin/icon-size.h
index de9c694..d5ad158 100644
--- a/panel-plugin/icon-size.h
+++ b/panel-plugin/icon-size.h
@@ -29,7 +29,8 @@ class IconSize
 public:
 	enum Size
 	{
-		Smallest = 0,
+		NONE = -1,
+		Smallest,
 		Smaller,
 		Small,
 		Normal,
@@ -39,7 +40,7 @@ public:
 	};
 
 	IconSize(const int size) :
-		m_size(size > int(Smallest) ? (size < int(Largest) ? size : int(Largest)) : int(Smallest))
+		m_size(size > int(NONE) ? (size < int(Largest) ? size : int(Largest)) : int(NONE))
 	{
 	}
 
diff --git a/panel-plugin/launcher-view.cpp b/panel-plugin/launcher-view.cpp
index 53d7ec7..c708589 100644
--- a/panel-plugin/launcher-view.cpp
+++ b/panel-plugin/launcher-view.cpp
@@ -41,7 +41,8 @@ static gboolean is_separator(GtkTreeModel* model, GtkTreeIter* iter, gpointer)
 //-----------------------------------------------------------------------------
 
 LauncherView::LauncherView() :
-	m_model(NULL)
+	m_model(NULL),
+	m_icon_size(0)
 {
 	// Create the view
 	m_view = GTK_TREE_VIEW(exo_tree_view_new());
@@ -177,9 +178,7 @@ void LauncherView::unset_model()
 void LauncherView::reload_icon_size()
 {
 	// Force exo to reload SVG icons
-	int size = 0;
-	g_object_get(m_icon_renderer, "size", &size, NULL);
-	if (size != wm_settings->launcher_icon_size.get_size())
+	if (m_icon_size != wm_settings->launcher_icon_size.get_size())
 	{
 		gtk_tree_view_remove_column(m_view, m_column);
 		create_column();
@@ -190,14 +189,19 @@ void LauncherView::reload_icon_size()
 
 void LauncherView::create_column()
 {
+	m_icon_size = wm_settings->launcher_icon_size.get_size();
+
 	m_column = gtk_tree_view_column_new();
 	gtk_tree_view_column_set_expand(m_column, true);
 	gtk_tree_view_column_set_visible(m_column, true);
 
-	m_icon_renderer = exo_cell_renderer_icon_new();
-	g_object_set(m_icon_renderer, "size", wm_settings->launcher_icon_size.get_size(), NULL);
-	gtk_tree_view_column_pack_start(m_column, m_icon_renderer, false);
-	gtk_tree_view_column_add_attribute(m_column, m_icon_renderer, "icon", LauncherView::COLUMN_ICON);
+	if (m_icon_size > 1)
+	{
+		GtkCellRenderer* icon_renderer = exo_cell_renderer_icon_new();
+		g_object_set(icon_renderer, "size", m_icon_size, NULL);
+		gtk_tree_view_column_pack_start(m_column, icon_renderer, false);
+		gtk_tree_view_column_add_attribute(m_column, icon_renderer, "icon", LauncherView::COLUMN_ICON);
+	}
 
 	GtkCellRenderer* text_renderer = gtk_cell_renderer_text_new();
 	g_object_set(text_renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
diff --git a/panel-plugin/launcher-view.h b/panel-plugin/launcher-view.h
index f2784a9..70cc4cb 100644
--- a/panel-plugin/launcher-view.h
+++ b/panel-plugin/launcher-view.h
@@ -79,7 +79,7 @@ private:
 	GtkTreeModel* m_model;
 	GtkTreeView* m_view;
 	GtkTreeViewColumn* m_column;
-	GtkCellRenderer* m_icon_renderer;
+	int m_icon_size;
 
 
 private:
diff --git a/panel-plugin/section-button.cpp b/panel-plugin/section-button.cpp
index 690371a..3725d9d 100644
--- a/panel-plugin/section-button.cpp
+++ b/panel-plugin/section-button.cpp
@@ -48,7 +48,8 @@ static gboolean on_enter_notify_event(GtkWidget*, GdkEventCrossing*, GtkToggleBu
 
 //-----------------------------------------------------------------------------
 
-SectionButton::SectionButton(const gchar* icon, const gchar* text)
+SectionButton::SectionButton(const gchar* icon, const gchar* text) :
+	m_icon_name(g_strdup(icon))
 {
 	m_button = GTK_RADIO_BUTTON(gtk_radio_button_new(NULL));
 	gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(m_button), false);
@@ -59,9 +60,9 @@ SectionButton::SectionButton(const gchar* icon, const gchar* text)
 	GtkBox* box = GTK_BOX(gtk_hbox_new(false, 4));
 	gtk_container_add(GTK_CONTAINER(m_button), GTK_WIDGET(box));
 
-	m_icon = xfce_panel_image_new_from_source(icon);
+	m_icon = xfce_panel_image_new();
 	reload_icon_size();
-	gtk_box_pack_start(box, GTK_WIDGET(m_icon), false, false, 0);
+	gtk_box_pack_start(box, m_icon, false, false, 0);
 
 	GtkWidget* label = gtk_label_new(text);
 	gtk_box_pack_start(box, label, false, true, 0);
@@ -71,6 +72,7 @@ SectionButton::SectionButton(const gchar* icon, const gchar* text)
 
 SectionButton::~SectionButton()
 {
+	g_free(m_icon_name);
 	gtk_widget_destroy(GTK_WIDGET(m_button));
 }
 
@@ -78,7 +80,13 @@ SectionButton::~SectionButton()
 
 void SectionButton::reload_icon_size()
 {
-	xfce_panel_image_set_size(XFCE_PANEL_IMAGE(m_icon), wm_settings->category_icon_size.get_size());
+	xfce_panel_image_clear(XFCE_PANEL_IMAGE(m_icon));
+	int size = wm_settings->category_icon_size.get_size();
+	xfce_panel_image_set_size(XFCE_PANEL_IMAGE(m_icon), size);
+	if (size > 1)
+	{
+		xfce_panel_image_set_from_source(XFCE_PANEL_IMAGE(m_icon), m_icon_name);
+	}
 }
 
 //-----------------------------------------------------------------------------
diff --git a/panel-plugin/section-button.h b/panel-plugin/section-button.h
index 921e8c6..d91fc98 100644
--- a/panel-plugin/section-button.h
+++ b/panel-plugin/section-button.h
@@ -62,6 +62,7 @@ public:
 private:
 	GtkRadioButton* m_button;
 	GtkWidget* m_icon;
+	gchar* m_icon_name;
 };
 
 }

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


More information about the Xfce4-commits mailing list