3c4174
diff -up gtk+-2.19.7/gtk/gtkstatusicon.c.icon-padding gtk+-2.19.7/gtk/gtkstatusicon.c
3c4174
--- gtk+-2.19.7/gtk/gtkstatusicon.c.icon-padding	2010-03-08 08:42:22.000000000 -0500
3c4174
+++ gtk+-2.19.7/gtk/gtkstatusicon.c	2010-03-10 00:40:11.165527903 -0500
3c4174
@@ -170,6 +170,7 @@ static void     gtk_status_icon_screen_c
3c4174
 						  GdkScreen      *old_screen);
3c4174
 static void     gtk_status_icon_embedded_changed (GtkStatusIcon *status_icon);
3c4174
 static void     gtk_status_icon_orientation_changed (GtkStatusIcon *status_icon);
3c4174
+static void     gtk_status_icon_padding_changed  (GtkStatusIcon *status_icon);
3c4174
 static gboolean gtk_status_icon_scroll           (GtkStatusIcon  *status_icon,
3c4174
 						  GdkEventScroll *event);
3c4174
 static gboolean gtk_status_icon_query_tooltip    (GtkStatusIcon *status_icon,
3c4174
@@ -850,6 +851,8 @@ gtk_status_icon_init (GtkStatusIcon *sta
3c4174
 			    G_CALLBACK (gtk_status_icon_embedded_changed), status_icon);
3c4174
   g_signal_connect_swapped (priv->tray_icon, "notify::orientation",
3c4174
 			    G_CALLBACK (gtk_status_icon_orientation_changed), status_icon);
3c4174
+  g_signal_connect_swapped (priv->tray_icon, "notify::padding",
3c4174
+			    G_CALLBACK (gtk_status_icon_padding_changed), status_icon);
3c4174
   g_signal_connect_swapped (priv->tray_icon, "button-press-event",
3c4174
 			    G_CALLBACK (gtk_status_icon_button_press), status_icon);
3c4174
   g_signal_connect_swapped (priv->tray_icon, "button-release-event",
3c4174
@@ -975,6 +978,8 @@ gtk_status_icon_finalize (GObject *objec
3c4174
   g_signal_handlers_disconnect_by_func (priv->tray_icon,
3c4174
 			                gtk_status_icon_orientation_changed, status_icon);
3c4174
   g_signal_handlers_disconnect_by_func (priv->tray_icon,
3c4174
+			                gtk_status_icon_padding_changed, status_icon);
3c4174
+  g_signal_handlers_disconnect_by_func (priv->tray_icon,
3c4174
 			                gtk_status_icon_button_press, status_icon);
3c4174
   g_signal_handlers_disconnect_by_func (priv->tray_icon,
3c4174
 			                gtk_status_icon_button_release, status_icon);
3c4174
@@ -1679,14 +1684,32 @@ gtk_status_icon_screen_changed (GtkStatu
3c4174
 #ifdef GDK_WINDOWING_X11
3c4174
 
3c4174
 static void
3c4174
+gtk_status_icon_padding_changed (GtkStatusIcon *status_icon)
3c4174
+{
3c4174
+  GtkStatusIconPrivate *priv = status_icon->priv;
3c4174
+  GtkOrientation orientation;
3c4174
+  gint padding;
3c4174
+
3c4174
+  orientation = _gtk_tray_icon_get_orientation (GTK_TRAY_ICON (priv->tray_icon));
3c4174
+  padding = _gtk_tray_icon_get_padding (GTK_TRAY_ICON (priv->tray_icon));
3c4174
+
3c4174
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
3c4174
+    gtk_misc_set_padding (GTK_MISC (priv->image), padding, 0);
3c4174
+  else
3c4174
+    gtk_misc_set_padding (GTK_MISC (priv->image), 0, padding);
3c4174
+}
3c4174
+
3c4174
+static void
3c4174
 gtk_status_icon_embedded_changed (GtkStatusIcon *status_icon)
3c4174
 {
3c4174
+  gtk_status_icon_padding_changed (status_icon);
3c4174
   g_object_notify (G_OBJECT (status_icon), "embedded");
3c4174
 }
3c4174
 
3c4174
 static void
3c4174
 gtk_status_icon_orientation_changed (GtkStatusIcon *status_icon)
3c4174
 {
3c4174
+  gtk_status_icon_padding_changed (status_icon);
3c4174
   g_object_notify (G_OBJECT (status_icon), "orientation");
3c4174
 }
3c4174
 
3c4174
@@ -1804,7 +1827,7 @@ gtk_status_icon_reset_image_data (GtkSta
3c4174
 
3c4174
       g_object_notify (G_OBJECT (status_icon), "stock");
3c4174
       break;
3c4174
-      
3c4174
+
3c4174
     case GTK_IMAGE_ICON_NAME:
3c4174
       g_free (priv->image_data.icon_name);
3c4174
       priv->image_data.icon_name = NULL;
3c4174
diff -up gtk+-2.19.7/gtk/gtktrayicon.h.icon-padding gtk+-2.19.7/gtk/gtktrayicon.h
3c4174
--- gtk+-2.19.7/gtk/gtktrayicon.h.icon-padding	2009-10-18 01:35:45.000000000 -0400
3c4174
+++ gtk+-2.19.7/gtk/gtktrayicon.h	2010-03-10 00:40:11.169528392 -0500
3c4174
@@ -69,7 +69,8 @@ void           _gtk_tray_icon_cancel_mes
3c4174
 					       guint        id);
3c4174
 
3c4174
 GtkOrientation _gtk_tray_icon_get_orientation (GtkTrayIcon *icon);
3c4174
-					    
3c4174
+gint           _gtk_tray_icon_get_padding     (GtkTrayIcon *icon);
3c4174
+
3c4174
 G_END_DECLS
3c4174
 
3c4174
 #endif /* __GTK_TRAY_ICON_H__ */
3c4174
diff -up gtk+-2.19.7/gtk/gtktrayicon-x11.c.icon-padding gtk+-2.19.7/gtk/gtktrayicon-x11.c
3c4174
--- gtk+-2.19.7/gtk/gtktrayicon-x11.c.icon-padding	2010-03-08 21:01:28.000000000 -0500
3c4174
+++ gtk+-2.19.7/gtk/gtktrayicon-x11.c	2010-03-10 00:49:48.229509604 -0500
3c4174
@@ -43,23 +43,26 @@
3c4174
 
3c4174
 enum {
3c4174
   PROP_0,
3c4174
-  PROP_ORIENTATION
3c4174
+  PROP_ORIENTATION,
3c4174
+  PROP_PADDING
3c4174
 };
3c4174
 
3c4174
 struct _GtkTrayIconPrivate
3c4174
 {
3c4174
   guint stamp;
3c4174
-  
3c4174
+
3c4174
   Atom selection_atom;
3c4174
   Atom manager_atom;
3c4174
   Atom system_tray_opcode_atom;
3c4174
   Atom orientation_atom;
3c4174
   Atom visual_atom;
3c4174
+  Atom padding_atom;
3c4174
   Window manager_window;
3c4174
   GdkVisual *manager_visual;
3c4174
   gboolean manager_visual_rgba;
3c4174
 
3c4174
   GtkOrientation orientation;
3c4174
+  gint padding;
3c4174
 };
3c4174
 
3c4174
 static void gtk_tray_icon_constructed   (GObject     *object);
3c4174
@@ -113,6 +116,16 @@ gtk_tray_icon_class_init (GtkTrayIconCla
3c4174
 						      GTK_ORIENTATION_HORIZONTAL,
3c4174
 						      GTK_PARAM_READABLE));
3c4174
 
3c4174
+  g_object_class_install_property (gobject_class,
3c4174
+				   PROP_PADDING,
3c4174
+				   g_param_spec_int ("padding",
3c4174
+						     P_("Padding"),
3c4174
+						     P_("Padding that should be put around icons in the tray"),
3c4174
+						     0,
3c4174
+                                                     G_MAXINT,
3c4174
+                                                     0,
3c4174
+						     GTK_PARAM_READABLE));
3c4174
+
3c4174
   g_type_class_add_private (class, sizeof (GtkTrayIconPrivate));
3c4174
 }
3c4174
 
3c4174
@@ -124,6 +137,7 @@ gtk_tray_icon_init (GtkTrayIcon *icon)
3c4174
   
3c4174
   icon->priv->stamp = 1;
3c4174
   icon->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
3c4174
+  icon->priv->padding = 0;
3c4174
 
3c4174
   gtk_widget_set_app_paintable (GTK_WIDGET (icon), TRUE);
3c4174
   gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
3c4174
@@ -161,6 +175,10 @@ gtk_tray_icon_constructed (GObject *obje
3c4174
 					 "_NET_SYSTEM_TRAY_VISUAL",
3c4174
 					 False);
3c4174
 
3c4174
+  icon->priv->padding_atom = XInternAtom (xdisplay,
3c4174
+					 "_NET_SYSTEM_TRAY_PADDING",
3c4174
+					 False);
3c4174
+
3c4174
   /* Add a root window filter so that we get changes on MANAGER */
3c4174
   gdk_window_add_filter (root_window,
3c4174
 			 gtk_tray_icon_manager_filter, icon);
3c4174
@@ -212,6 +230,9 @@ gtk_tray_icon_get_property (GObject    *
3c4174
     case PROP_ORIENTATION:
3c4174
       g_value_set_enum (value, icon->priv->orientation);
3c4174
       break;
3c4174
+    case PROP_PADDING:
3c4174
+      g_value_set_int (value, icon->priv->padding);
3c4174
+      break;
3c4174
     default:
3c4174
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3c4174
       break;
3c4174
@@ -372,9 +393,58 @@ gtk_tray_icon_get_visual_property (GtkTr
3c4174
     XFree (prop.prop);
3c4174
 }
3c4174
 
3c4174
+static void
3c4174
+gtk_tray_icon_get_padding_property (GtkTrayIcon *icon)
3c4174
+{
3c4174
+  GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (icon));
3c4174
+  GdkDisplay *display = gdk_screen_get_display (screen);
3c4174
+  Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
3c4174
+
3c4174
+  Atom type;
3c4174
+  int format;
3c4174
+  union {
3c4174
+	gulong *prop;
3c4174
+	guchar *prop_ch;
3c4174
+  } prop = { NULL };
3c4174
+  gulong nitems;
3c4174
+  gulong bytes_after;
3c4174
+  int error, result;
3c4174
+
3c4174
+  g_assert (icon->priv->manager_window != None);
3c4174
+
3c4174
+  gdk_error_trap_push ();
3c4174
+  type = None;
3c4174
+  result = XGetWindowProperty (xdisplay,
3c4174
+			       icon->priv->manager_window,
3c4174
+			       icon->priv->padding_atom,
3c4174
+			       0, G_MAXLONG, FALSE,
3c4174
+			       XA_CARDINAL,
3c4174
+			       &type, &format, &nitems,
3c4174
+			       &bytes_after, &(prop.prop_ch));
3c4174
+  error = gdk_error_trap_pop ();
3c4174
+
3c4174
+  if (!error && result == Success &&
3c4174
+      type == XA_CARDINAL && nitems == 1 && format == 32)
3c4174
+    {
3c4174
+      gint padding;
3c4174
+
3c4174
+      padding = prop.prop[0];
3c4174
+
3c4174
+      if (icon->priv->padding != padding)
3c4174
+	{
3c4174
+	  icon->priv->padding = padding;
3c4174
+
3c4174
+	  g_object_notify (G_OBJECT (icon), "padding");
3c4174
+	}
3c4174
+    }
3c4174
+
3c4174
+  if (type != None)
3c4174
+    XFree (prop.prop);
3c4174
+}
3c4174
+
3c4174
 static GdkFilterReturn
3c4174
-gtk_tray_icon_manager_filter (GdkXEvent *xevent, 
3c4174
-			      GdkEvent  *event, 
3c4174
+gtk_tray_icon_manager_filter (GdkXEvent *xevent,
3c4174
+			      GdkEvent  *event,
3c4174
 			      gpointer   user_data)
3c4174
 {
3c4174
   GtkTrayIcon *icon = user_data;
3c4174
@@ -399,6 +469,11 @@ gtk_tray_icon_manager_filter (GdkXEvent 
3c4174
 
3c4174
 	  gtk_tray_icon_get_orientation_property (icon);
3c4174
 	}
3c4174
+      else if (xev->xany.type == PropertyNotify &&
3c4174
+               xev->xproperty.atom == icon->priv->padding_atom)
3c4174
+        {
3c4174
+          gtk_tray_icon_get_padding_property (icon);
3c4174
+        }
3c4174
       else if (xev->xany.type == DestroyNotify)
3c4174
 	{
3c4174
           GTK_NOTE (PLUGSOCKET,
3c4174
@@ -504,6 +579,7 @@ gtk_tray_icon_update_manager_window (Gtk
3c4174
 
3c4174
       gtk_tray_icon_get_orientation_property (icon);
3c4174
       gtk_tray_icon_get_visual_property (icon);
3c4174
+      gtk_tray_icon_get_padding_property (icon);
3c4174
 
3c4174
       if (gtk_widget_get_realized (GTK_WIDGET (icon)))
3c4174
 	{
3c4174
@@ -740,6 +816,14 @@ _gtk_tray_icon_get_orientation (GtkTrayI
3c4174
   return icon->priv->orientation;
3c4174
 }
3c4174
 
3c4174
+gint
3c4174
+_gtk_tray_icon_get_padding (GtkTrayIcon *icon)
3c4174
+{
3c4174
+  g_return_val_if_fail (GTK_IS_TRAY_ICON (icon), 0);
3c4174
+
3c4174
+  return icon->priv->padding;
3c4174
+}
3c4174
+
3c4174
 
3c4174
 #define __GTK_TRAY_ICON_X11_C__
3c4174
 #include "gtkaliasdef.c"