[Xfce4-commits] [apps/xfce4-notifyd] 01/04: panel-plugin: Ensure the icon resizes with Xfce 4.12

noreply at xfce.org noreply at xfce.org
Tue Nov 7 23:47:14 CET 2017


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

o   c   h   o   s   i       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 apps/xfce4-notifyd.

commit c4aa5b0b77840a3796c5082943ac27b23262e194
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Fri Nov 3 00:48:23 2017 +0100

    panel-plugin: Ensure the icon resizes with Xfce 4.12
---
 panel-plugin/notification-plugin.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/panel-plugin/notification-plugin.c b/panel-plugin/notification-plugin.c
index 3e20f8d..d672846 100644
--- a/panel-plugin/notification-plugin.c
+++ b/panel-plugin/notification-plugin.c
@@ -265,15 +265,49 @@ notification_plugin_size_changed (XfcePanelPlugin       *plugin,
                                   gint                   size,
                                   NotificationPlugin    *notification_plugin)
 {
+#if !LIBXFCE4PANEL_CHECK_VERSION (4, 13, 0)
+  GtkStyleContext *context;
+  GtkBorder padding, border;
+  gint width;
+  gint xthickness;
+  gint ythickness;
+#endif
   gint icon_size;
 
   size /= xfce_panel_plugin_get_nrows (notification_plugin->plugin);
   gtk_widget_set_size_request (GTK_WIDGET (notification_plugin->button), size, size);
 #if LIBXFCE4PANEL_CHECK_VERSION (4,13,0)
   icon_size = xfce_panel_plugin_get_icon_size (XFCE_PANEL_PLUGIN (plugin));
+#else
+  /* Calculate the size of the widget because the theme can override it */
+  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;
+
+  /* Calculate the size of the space left for the icon */
+  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)
+    button->priv->panel_icon_width = 16;
+  else if (width >=22 && width <= 29)
+    button->priv->panel_icon_width = 24;
+  else if (width >= 30 && width <= 40)
+    button->priv->panel_icon_width = 32;
+  else
+    button->priv->panel_icon_width = width;
 #endif
+
+  /* resize the plugin */
+  gtk_widget_set_size_request (GTK_WIDGET (plugin), size, size);
   gtk_image_set_pixel_size (GTK_IMAGE (notification_plugin->image), icon_size);
 
+  /* resize the plugin button too */
+  gtk_widget_set_size_request (GTK_WIDGET (notification_plugin), -1, -1);
+
   return TRUE;
 }
 

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


More information about the Xfce4-commits mailing list