Truncated systray icons

Jasper Huijsmans jasper at xfce.org
Mon Feb 27 21:40:26 CET 2006


Olivier Fourdan schreef:
...
> I dunno, maybe you're right, but setting a size there clearly introduces 
> a race condition between (maybe broken implementations of the) systray 
> icon and the panel systray.
> 
> I'm not sure how to fix that in a clean way. BTW, your patch enlarge the 
> panel too, it doesn't bound the icon size, does it?
> 

I don't know, but is the patch below any better?

I couldn't set the size conditionally, because 
gtk_widget_get_size_request() and gtk_widget_size_request() return -1 
and 1, respectively. No idea how gtk does the size allocation...


Index: plugins/systray/systray.c
===================================================================
--- plugins/systray/systray.c	(revision 20124)
+++ plugins/systray/systray.c	(working copy)
@@ -78,21 +78,38 @@
      return TRUE;
  }

+static gboolean
+set_icon_size (GtkWidget *icon)
+{
+
+    if (GTK_IS_WIDGET (icon))
+    {
+        int size =
+            GPOINTER_TO_INT (g_object_get_data (G_OBJECT (icon), "size"));
+
+        gtk_widget_set_size_request (icon, size, size);
+    }
+
+    return FALSE;
+}
+
  static void
  icon_docked (XfceSystemTray * tray, GtkWidget * icon, Systray * systray)
  {
      if (systray->tray_registered)
      {
-        int size = MIN (systray->iconbox->allocation.width,
-                        systray->iconbox->allocation.height);
+        int size = xfce_panel_plugin_get_size (systray->plugin);
+        int border = size > 26 ? 2 : 0;

-        gtk_widget_hide (systray->iconbox);
+        size = size - border - 2 - MAX (systray->frame->style->xthickness,
+                                        systray->frame->style->ythickness);
+
+        gtk_widget_show (icon);
          gtk_box_pack_start (GTK_BOX (systray->iconbox), icon,
                              FALSE, FALSE, 0);
-        gtk_widget_show (icon);
-        gtk_widget_set_size_request (icon, size, size);
-        gtk_widget_show (systray->iconbox);
-        gtk_widget_queue_draw (systray->iconbox);
+
+        g_object_set_data (G_OBJECT (icon), "size", GINT_TO_POINTER 
(size));
+        g_idle_add ((GSourceFunc)set_icon_size, icon);
      }
  }

@@ -172,8 +189,8 @@

      gtk_container_set_border_width (GTK_CONTAINER (systray->frame), 
border);

-    size = size - border - MAX (systray->frame->style->xthickness,
-                                systray->frame->style->ythickness);
+    size = size - border - 2 - MAX (systray->frame->style->xthickness,
+                                    systray->frame->style->ythickness);

      list = gtk_container_get_children (GTK_CONTAINER (systray->iconbox));
      for (l = list; l != NULL; l = l->next)




More information about the Xfce4-dev mailing list