--- /gnome/cvs/libegg/libegg/tray/eggtraymanager.c	2003-04-09 03:05:44.000000000 +0200
+++ myeggtraymanager.c	2004-12-23 14:07:29.000000000 +0100
@@ -23,6 +23,7 @@
 
 #include "eggtraymanager.h"
 
+#include <glib/gi18n.h>
 #include <gdk/gdkx.h>
 #include <gtk/gtkinvisible.h>
 #include <gtk/gtksocket.h>
@@ -31,16 +32,6 @@
 
 #include "eggmarshalers.h"
 
-#ifndef EGG_COMPILATION
-#ifndef _
-#define _(x) dgettext (GETTEXT_PACKAGE, x)
-#define N_(x) x
-#endif
-#else
-#define _(x) x
-#define N_(x) x
-#endif
-
 /* Signals */
 enum
 {
@@ -124,6 +115,7 @@ egg_tray_manager_get_type (void)
 static void
 egg_tray_manager_init (EggTrayManager *manager)
 {
+  manager->invisible = NULL;
   manager->socket_table = g_hash_table_new (NULL, NULL);
 }
 
@@ -208,6 +200,9 @@ egg_tray_manager_finalize (GObject *obje
   manager = EGG_TRAY_MANAGER (object);
 
   egg_tray_manager_unmanage (manager);
+
+  g_list_free (manager->messages);
+  g_hash_table_destroy (manager->socket_table);
   
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -284,7 +279,14 @@ egg_tray_manager_handle_dock_request (Eg
 {
   GtkWidget *socket;
   Window *window;
+    GtkRequisition req;
   
+  if (g_hash_table_lookup (tray->sockets, GINT_TO_POINTER (xev->data.l[2])))
+    {
+        /* We already got this notification earlier, ignore this one */
+        return;
+    }
+
   socket = gtk_socket_new ();
   
   /* We need to set the child window here
@@ -306,9 +308,26 @@ egg_tray_manager_handle_dock_request (Eg
       g_signal_connect (socket, "plug_removed",
 			G_CALLBACK (egg_tray_manager_plug_removed), manager);
       
-      gtk_socket_add_id (GTK_SOCKET (socket), xevent->data.l[2]);
+      gtk_socket_add_id (GTK_SOCKET (socket), *window);
+
+      g_hash_table_insert (manager->socket_table, GINT_TO_POINTER (*window), socket);
 
-      g_hash_table_insert (manager->socket_table, GINT_TO_POINTER (xevent->data.l[2]), socket);
+        /*
+         * Make sure the icons have a meaningfull size ...
+         */ 
+        req.width = req.height = 1;
+        gtk_widget_size_request (socket, &req);
+        /*
+        if ((req.width < 16) || (req.height < 16))
+        {
+            gint nw = MAX (24, req.width);
+            gint nh = MAX (24, req.height);
+            g_warning (_("tray icon has requested a size of (%i x %i), resizing to (%i x %i)"), 
+                        req.width, req.height, nw, nh);
+            gtk_widget_set_size_request(icon, nw,  nh);
+        }
+        */
+        gtk_widget_show(icon);
     }
   else
     gtk_widget_destroy (socket);
@@ -628,7 +647,7 @@ egg_tray_manager_check_running_xscreen (
   selection_atom = XInternAtom (DisplayOfScreen (xscreen), selection_atom_name, False);
   g_free (selection_atom_name);
 
-  if (XGetSelectionOwner (DisplayOfScreen (xscreen), selection_atom))
+  if (XGetSelectionOwner (DisplayOfScreen (xscreen), selection_atom) != None)
     return TRUE;
   else
     return FALSE;
