[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/02: Fix large size button

noreply at xfce.org noreply at xfce.org
Sun May 21 16:04:08 CEST 2017


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

a   n   d   r   z   e   j   r       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-pulseaudio-plugin.

commit bee333f6ecd6e89d89ef68bf880d93b1fe5fff7a
Author: Matthieu Mota <matthieumota at gmail.com>
Date:   Sun May 21 15:30:26 2017 +0200

    Fix large size button
---
 panel-plugin/pulseaudio-plugin.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/panel-plugin/pulseaudio-plugin.c b/panel-plugin/pulseaudio-plugin.c
index ff2c254..6a756c3 100644
--- a/panel-plugin/pulseaudio-plugin.c
+++ b/panel-plugin/pulseaudio-plugin.c
@@ -241,13 +241,38 @@ pulseaudio_plugin_size_changed (XfcePanelPlugin *plugin,
 {
   PulseaudioPlugin *pulseaudio_plugin = PULSEAUDIO_PLUGIN (plugin);
   gint              icon_size;
+  GtkStyleContext  *context;
+  GtkBorder         padding;
+  GtkBorder         border;
+  gint              width;
+  gint              xthickness;
+  gint              ythickness;
 
   /* The plugin only occupies a single row */
   size /= xfce_panel_plugin_get_nrows (plugin);
 #if LIBXFCE4PANEL_CHECK_VERSION (4,13,0)
   icon_size = xfce_panel_plugin_get_icon_size (plugin);
 #else
-  icon_size = size - 2; // fall-back for older panel versions
+  // fall-back for older panel versions
+  /* Get widget's padding and border to correctly calculate the button's icon size */
+  context = gtk_widget_get_style_context (GTK_WIDGET (pulseaudio_plugin->button));
+  gtk_style_context_get_padding (context, gtk_widget_get_state_flags (GTK_WIDGET (pulseaudio_plugin->button)), &padding);
+  gtk_style_context_get_border (context, gtk_widget_get_state_flags (GTK_WIDGET (pulseaudio_plugin->button)), &border);
+  xthickness = padding.left+padding.right+border.left+border.right;
+  ythickness = padding.top+padding.bottom+border.top+border.bottom;
+
+  width = size - 2 * MAX (xthickness, ythickness);
+  /* Since symbolic icons are usually only provided in 16px we
+   * try to be clever and use size steps */
+
+  if (width <= 21)
+      icon_size = 16;
+  else if (width >=22 && width <= 29)
+      icon_size = 24;
+  else if (width >= 30 && width <= 40)
+      icon_size = 32;
+  else
+      icon_size = width;
 #endif
 
   pulseaudio_button_set_size (pulseaudio_plugin->button, size, icon_size);

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


More information about the Xfce4-commits mailing list