[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 02/02: Fix panel icon size not following theme.
noreply at xfce.org
noreply at xfce.org
Sun May 20 18:32:42 CEST 2018
This is an automated email from the git hooks/post-receive script.
g o t t c o d e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository panel-plugins/xfce4-whiskermenu-plugin.
commit 3e3f0175a0145dc96d06ad6ff915ee39f11f783b
Author: Graeme Gott <graeme at gottcode.org>
Date: Sun May 20 12:30:43 2018 -0400
Fix panel icon size not following theme.
---
panel-plugin/plugin.cpp | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/panel-plugin/plugin.cpp b/panel-plugin/plugin.cpp
index bc673a9..49cb665 100644
--- a/panel-plugin/plugin.cpp
+++ b/panel-plugin/plugin.cpp
@@ -117,8 +117,6 @@ Plugin::Plugin(XfcePanelPlugin* plugin) :
gtk_widget_set_name(m_button, "whiskermenu-button");
#if !LIBXFCE4PANEL_CHECK_VERSION(4,13,0)
widget_add_css(m_button, ".xfce4-panel button { padding: 1px; }");
- gtk_button_set_relief(GTK_BUTTON(m_button), GTK_RELIEF_NONE);
- gtk_widget_set_focus_on_click(GTK_WIDGET(m_button), false);
#endif
g_signal_connect_slot(m_button, "toggled", &Plugin::button_toggled, this);
gtk_widget_show(m_button);
@@ -129,7 +127,6 @@ Plugin::Plugin(XfcePanelPlugin* plugin) :
gtk_widget_show(GTK_WIDGET(m_button_box));
m_button_icon = GTK_IMAGE(gtk_image_new());
- widget_add_css(GTK_WIDGET(m_button_icon), "image { padding: 3px; }");
icon_changed(wm_settings->button_icon_name.c_str());
gtk_box_pack_start(m_button_box, GTK_WIDGET(m_button_icon), true, false, 0);
if (wm_settings->button_icon_visible)
@@ -428,25 +425,32 @@ gboolean Plugin::size_changed(XfcePanelPlugin*, gint size)
0, GTK_PACK_START);
// Resize icon
+ if (wm_settings->button_single_row)
+ {
+ size /= xfce_panel_plugin_get_nrows(m_plugin);
+ }
#if LIBXFCE4PANEL_CHECK_VERSION(4,13,0)
gint icon_size = xfce_panel_plugin_get_icon_size(m_plugin);
#else
- gint icon_size = size / xfce_panel_plugin_get_nrows(m_plugin);
- icon_size -= 4;
- if (icon_size < 24)
- {
- icon_size = 16;
- }
- else if (icon_size < 32)
+ GtkBorder padding, border;
+ GtkStyleContext* context = gtk_widget_get_style_context(m_button);
+ GtkStateFlags flags = gtk_widget_get_state_flags(m_button);
+ gtk_style_context_get_padding(context, flags, &padding);
+ gtk_style_context_get_border(context, flags, &border);
+ gint xthickness = padding.left + padding.right + border.left + border.right;
+ gint ythickness = padding.top + padding.bottom + border.top + border.bottom;
+ gint icon_size = size - 2 * std::max(xthickness, ythickness);
+#endif
+ gtk_image_set_pixel_size(m_button_icon, icon_size);
+
+ if (wm_settings->button_title_visible)
{
- icon_size = 24;
+ gtk_widget_set_size_request(m_button, -1, -1);
}
- else if (icon_size < 36)
+ else
{
- icon_size = 32;
+ gtk_widget_set_size_request(m_button, size, size);
}
-#endif
- gtk_image_set_pixel_size(m_button_icon, icon_size);
if (wm_settings->button_title_visible || !wm_settings->button_single_row)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list