Index: lib/gui/gmtray/gmtray-gtk.c
===================================================================
--- lib/gui/gmtray/gmtray-gtk.c	(révision 4882)
+++ lib/gui/gmtray/gmtray-gtk.c	(copie de travail)
@@ -30,7 +30,7 @@
  */
 
 /*
- *                         gmtray-x11.c  -  description
+ *                         gmtray-gtk.c  -  description
  *                         ------------------------
  *   begin                : Sat Jan 7 2002
  *   copyright            : (C) 2000-2006 by Damien Sandras
@@ -42,103 +42,53 @@
 #include "../../../config.h"
 
 #include "gmtray-internal.h"
-#include "eggtrayicon.h"
 
 struct _GmTraySpecific
 {
-  GtkWidget *eggtray; /* the eggtray */
-  GtkImage *image; /* eggtray's image (ie : what we really show) */
+  GtkStatusIcon *status_icon; /* the status icon of the system tray */
 };
 
-/* declaration of some helpers */
-static void init_tray_with_image (GmTray *tray,
-				  GtkWidget *image);
 
-static gint clicked_cb (GtkWidget *unused,
-			GdkEventButton *event,
-			gpointer data);
 
-static void destroyed_cb (GtkWidget *widget,
-			  gpointer data);
-
-/* definition of the helper functions */
-
 static void
-init_tray_with_image (GmTray *tray, GtkWidget *image)
+left_click_cb (GtkStatusIcon *si,
+		gpointer user_data)
 {
-  GtkWidget *event_box = NULL;
-  GtkWidget *eggtray   = NULL;
+  GmTray *tray = user_data;
 
-  eggtray = GTK_WIDGET (egg_tray_icon_new (PACKAGE_NAME));
-  event_box = gtk_event_box_new ();
+  g_return_if_fail (tray != NULL);
 
-  gtk_container_add (GTK_CONTAINER (event_box), image);
-  gtk_container_add (GTK_CONTAINER (eggtray), event_box);
-
-  gtk_widget_show_all (eggtray);
-
-  g_signal_connect (G_OBJECT (event_box), "button_press_event",
-		    G_CALLBACK (clicked_cb), tray);
-  g_signal_connect (G_OBJECT (event_box), "destroy",
-		    G_CALLBACK (destroyed_cb), tray);
-
-  /* FIXME if (tray->specific->eggtray)
-     g_object_unref (G_OBJECT (tray->specific->eggtray));*/
-
-  tray->specific->eggtray = eggtray;
-  tray->specific->image = GTK_IMAGE (image);
+  if (tray->left_clicked_callback)
+    tray->left_clicked_callback (tray->left_clicked_callback_data);
 }
 
-/* this function is the one which receives the clicks on the tray, and will
- * decide whether to call the click callback, show the menu, or ignore
- */
-static gint
-clicked_cb (GtkWidget *unused,
-	    GdkEventButton *event,
-	    gpointer data)
-{
-  GmTray *tray = data;
 
-  g_return_val_if_fail (tray != NULL, FALSE);
+/* FIXME: the callback for middle click is missing, but as of GTK 2.10, it's 
+ * not supported by GtkStatusIcon. */
 
-  if (event->type == GDK_BUTTON_PRESS) {
 
-    if (event->button == 1) {
-
-      if (tray->left_clicked_callback)
-	tray->left_clicked_callback (tray->left_clicked_callback_data);
-      return TRUE;
-    } else if (event->button == 2) {
-
-      if (tray->middle_clicked_callback)
-	tray->middle_clicked_callback (tray->middle_clicked_callback_data);
-      return TRUE;
-    } else if (event->button == 3) {
-
-      gmtray_menu (tray);
-      return TRUE;
-    }
-  }
-
-  return FALSE;
-}
-
 static void
-destroyed_cb (GtkWidget *widget,
-	      gpointer data)
+right_click_cb (GtkStatusIcon *si,
+		guint button,
+		guint activate_time,
+		gpointer user_data)
 {
-  GmTray     *tray  = data;
-  GtkWidget  *image = NULL;
-  gchar      *stock_id = NULL;
-  GtkIconSize size;
-
+  GmTray *tray = user_data;
+  GtkMenu *menu;
+  
   g_return_if_fail (tray != NULL);
 
-  gtk_image_get_stock (GTK_IMAGE (tray->specific->image), &stock_id, &size);
+  if (tray->menu_callback == NULL)
+    return;
 
-  image = gtk_image_new_from_stock (stock_id, size);
+  menu = tray->menu_callback (tray->menu_callback_data);
 
-  init_tray_with_image (tray, GTK_WIDGET (image));
+  gtk_widget_show_all (GTK_WIDGET (menu));
+
+  gtk_menu_popup (menu, 
+		  NULL, NULL, NULL, NULL,
+		  button, 
+		  activate_time);
 }
 
 
@@ -148,17 +98,24 @@
 GmTray *
 gmtray_new (const gchar *image)
 {
-  GmTray    *result    = NULL;
-  GtkWidget *my_image  = NULL;
+  GmTray *tray;
+  GtkStatusIcon *si;
 
-  result = gmtray_new_common (image);
-  result->specific = g_new0 (GmTraySpecific, 1);
+  tray = gmtray_new_common (image);
+  tray->specific = g_new0 (GmTraySpecific, 1);
+  
+  si = tray->specific->status_icon = gtk_status_icon_new_from_stock (image);
+  gtk_status_icon_set_visible (si, TRUE);
 
-  my_image = gtk_image_new_from_stock (image, GTK_ICON_SIZE_MENU);
+  g_signal_connect (G_OBJECT (si), "activate", 
+		  G_CALLBACK (left_click_cb), tray);
+  
+  /* FIXME: add here the missing middle click signal */
 
-  init_tray_with_image (result, my_image);
+  g_signal_connect (G_OBJECT (si), "popup-menu", 
+		  G_CALLBACK (right_click_cb), tray);
 
-  return result;
+  return tray;
 }
 
 
@@ -167,6 +124,7 @@
 {
   g_return_if_fail (tray != NULL);
 
+  g_object_unref (tray->specific->status_icon);
   g_free (tray->specific);
   gmtray_delete_common (tray);
 }
@@ -176,10 +134,13 @@
 gmtray_show_image (GmTray *tray,
 		   const gchar *image)
 {
+  GtkStatusIcon *si;
   g_return_if_fail (tray != NULL);
 
-  gtk_image_set_from_stock (tray->specific->image, image,
-			    GTK_ICON_SIZE_MENU);
+  si = tray->specific->status_icon;
+
+  gtk_status_icon_set_from_stock (si, image);
+  gtk_status_icon_set_visible (si, TRUE);
 }
 
 
@@ -190,13 +151,8 @@
 
   g_return_if_fail (tray != NULL);
 
-  if (tray->menu_callback == NULL)
-    return;
-
-  menu = tray->menu_callback (tray->menu_callback_data);
-
-  gtk_widget_show_all (GTK_WIDGET (menu));
-
-  gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
-		  0, gtk_get_current_event_time ());
+  right_click_cb (tray->specific->status_icon,
+		0,
+		gtk_get_current_event_time(),
+		tray);
 }
Index: lib/gui/gmtray/Makefile.am
===================================================================
--- lib/gui/gmtray/Makefile.am	(révision 4882)
+++ lib/gui/gmtray/Makefile.am	(copie de travail)
@@ -5,16 +5,19 @@
 	gmtray-internal.h	\
 	gmtray-common.c
 
-if WIN32
 libgmtray_la_SOURCES +=		\
-	gmtray-win32.c		\
-	pixbuf_to_hicon.h	\
-	pixbuf_to_hicon.c
-else
-libgmtray_la_SOURCES +=		\
-	gmtray-x11.c		\
-	eggtrayicon.c		\
-	eggtrayicon.h
-endif
+	gmtray-gtk.c
 
+#if WIN32
+#libgmtray_la_SOURCES +=		\
+#	gmtray-win32.c		\
+#	pixbuf_to_hicon.h	\
+#	pixbuf_to_hicon.c
+#else
+#libgmtray_la_SOURCES +=		\
+#	gmtray-x11.c		\
+#	eggtrayicon.c		\
+#	eggtrayicon.h
+#endif
+
 INCLUDES = $(EKIGA_LIB_CFLAGS)
