[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/02: Correctly calculate the icon's size

noreply at xfce.org noreply at xfce.org
Thu Mar 5 09:06:19 CET 2015


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

andrzejr pushed a commit to branch master
in repository panel-plugins/xfce4-pulseaudio-plugin.

commit cf836c87a5f422bd572405ecc2e5ccfcaf09e620
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Thu Mar 5 08:48:14 2015 +0100

    Correctly calculate the icon's size
    
    based on the widget's padding and border instead of
    an relying on an arbitrary value.
---
 panel-plugin/pulseaudio-button.c |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/panel-plugin/pulseaudio-button.c b/panel-plugin/pulseaudio-button.c
index 7fea918..759dc60 100644
--- a/panel-plugin/pulseaudio-button.c
+++ b/panel-plugin/pulseaudio-button.c
@@ -266,10 +266,9 @@ pulseaudio_button_menu_deactivate (PulseaudioButton *button,
 static void
 pulseaudio_button_update_icons (PulseaudioButton *button)
 {
-  guint           i;
-  GtkIconInfo    *info;
-  GtkStyleContext *context;
-  gboolean is_symbolic;
+  guint             i;
+  GtkIconInfo      *info;
+  GtkStyleContext  *context;
 
   g_return_if_fail (IS_PULSEAUDIO_BUTTON (button));
 
@@ -332,10 +331,23 @@ void
 pulseaudio_button_set_size (PulseaudioButton *button,
                             gint              size)
 {
+  GtkStyleContext  *context;
+  GtkBorder         padding;
+  GtkBorder         border;
+  gint              xthickness;
+  gint              ythickness;
+
   g_return_if_fail (IS_PULSEAUDIO_BUTTON (button));
   g_return_if_fail (size > 0);
 
-  button->icon_size = size - 4;
+  /* Get widget's padding and border to correctly calculate the button's icon size */
+  context = gtk_widget_get_style_context (GTK_WIDGET (button));
+  gtk_style_context_get_padding (context, gtk_widget_get_state_flags (GTK_WIDGET (button)), &padding);
+  gtk_style_context_get_border (context, gtk_widget_get_state_flags (GTK_WIDGET (button)), &border);
+  xthickness = padding.left+padding.right+border.left+border.right;
+  ythickness = padding.top+padding.bottom+border.top+border.bottom;
+
+  button->icon_size = size - 2* MAX (xthickness, ythickness);
   gtk_widget_set_size_request (GTK_WIDGET (button), size, size);
   pulseaudio_button_update_icons (button);
 }

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


More information about the Xfce4-commits mailing list