Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-cups-manager/configure.in,v
retrieving revision 1.94
diff -p -u -B -r1.94 configure.in
--- configure.in	18 Nov 2006 19:56:37 -0000	1.94
+++ configure.in	10 Dec 2006 15:25:46 -0000
@@ -14,11 +14,14 @@ AC_SUBST(LT_VERSION_INFO)
 
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 
+GNOME_COMMON_INIT
+GNOME_DEBUG_CHECK
 GNOME_COMPILE_WARNINGS(maximum)
+GNOME_MAINTAINER_MODE_DEFINES
 
 AC_PROG_CXX
 
-GTK_REQUIRED=2.3.1
+GTK_REQUIRED=2.10.0
 GLIB_REQUIRED=2.3.1
 LIBGNOME_REQUIRED=2.0.0
 LIBGNOMEUI_REQUIRED=2.0.0
Index: po/POTFILES.in
===================================================================
RCS file: /cvs/gnome/gnome-cups-manager/po/POTFILES.in,v
retrieving revision 1.13
diff -p -u -B -r1.13 POTFILES.in
--- po/POTFILES.in	10 Nov 2006 12:42:34 -0000	1.13
+++ po/POTFILES.in	10 Dec 2006 15:25:46 -0000
@@ -2,7 +2,6 @@
 # Please keep this file sorted alphabetically.
 gnome-cups-add/add-printer.c
 gnome-cups-add/gnome-cups-add.glade
-gnome-cups-manager/eggtrayicon.c
 gnome-cups-manager.desktop.in
 gnome-cups-manager/gnome-cups-icon.c
 gnome-cups-manager/gnome-cups-manager.c
Index: gnome-cups-manager/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-cups-manager/gnome-cups-manager/Makefile.am,v
retrieving revision 1.16
diff -p -u -B -r1.16 Makefile.am
--- gnome-cups-manager/Makefile.am	27 Sep 2004 19:41:14 -0000	1.16
+++ gnome-cups-manager/Makefile.am	10 Dec 2006 15:25:46 -0000
@@ -29,9 +29,7 @@ BUILT_SOURCES =			\
 	eggmarshalers.c
 
 cut_and_paste_sources =		\
-	$(BUILT_SOURCES)	\
-	eggtrayicon.c		\
-	eggtrayicon.h
+	$(BUILT_SOURCES)
 
 gnome_cups_icon_SOURCES= \
 	$(cut_and_paste_sources) \
Index: gnome-cups-manager/eggtrayicon.c
===================================================================
RCS file: gnome-cups-manager/eggtrayicon.c
diff -N gnome-cups-manager/eggtrayicon.c
--- gnome-cups-manager/eggtrayicon.c	24 Jun 2004 18:15:57 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,468 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* eggtrayicon.c
- * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <string.h>
-#include <libintl.h>
-
-#include "eggtrayicon.h"
-
-#include <gdk/gdkx.h>
-#include <X11/Xatom.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
-
-#define SYSTEM_TRAY_REQUEST_DOCK    0
-#define SYSTEM_TRAY_BEGIN_MESSAGE   1
-#define SYSTEM_TRAY_CANCEL_MESSAGE  2
-
-#define SYSTEM_TRAY_ORIENTATION_HORZ 0
-#define SYSTEM_TRAY_ORIENTATION_VERT 1
-
-enum {
-  PROP_0,
-  PROP_ORIENTATION
-};
-         
-static GtkPlugClass *parent_class = NULL;
-
-static void egg_tray_icon_init (EggTrayIcon *icon);
-static void egg_tray_icon_class_init (EggTrayIconClass *klass);
-
-static void egg_tray_icon_get_property (GObject    *object,
-					guint       prop_id,
-					GValue     *value,
-					GParamSpec *pspec);
-
-static void egg_tray_icon_realize   (GtkWidget *widget);
-static void egg_tray_icon_unrealize (GtkWidget *widget);
-
-static void egg_tray_icon_update_manager_window (EggTrayIcon *icon);
-
-GType
-egg_tray_icon_get_type (void)
-{
-  static GType our_type = 0;
-
-  if (our_type == 0)
-    {
-      static const GTypeInfo our_info =
-      {
-	sizeof (EggTrayIconClass),
-	(GBaseInitFunc) NULL,
-	(GBaseFinalizeFunc) NULL,
-	(GClassInitFunc) egg_tray_icon_class_init,
-	NULL, /* class_finalize */
-	NULL, /* class_data */
-	sizeof (EggTrayIcon),
-	0,    /* n_preallocs */
-	(GInstanceInitFunc) egg_tray_icon_init
-      };
-
-      our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0);
-    }
-
-  return our_type;
-}
-
-static void
-egg_tray_icon_init (EggTrayIcon *icon)
-{
-  icon->stamp = 1;
-  icon->orientation = GTK_ORIENTATION_HORIZONTAL;
-  
-  gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
-}
-
-static void
-egg_tray_icon_class_init (EggTrayIconClass *klass)
-{
-  GObjectClass *gobject_class = (GObjectClass *)klass;
-  GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
-
-  parent_class = g_type_class_peek_parent (klass);
-
-  gobject_class->get_property = egg_tray_icon_get_property;
-
-  widget_class->realize   = egg_tray_icon_realize;
-  widget_class->unrealize = egg_tray_icon_unrealize;
-
-  g_object_class_install_property (gobject_class,
-				   PROP_ORIENTATION,
-				   g_param_spec_enum ("orientation",
-						      _("Orientation"),
-						      _("The orientation of the tray."),
-						      GTK_TYPE_ORIENTATION,
-						      GTK_ORIENTATION_HORIZONTAL,
-						      G_PARAM_READABLE));
-}
-
-static void
-egg_tray_icon_get_property (GObject    *object,
-			    guint       prop_id,
-			    GValue     *value,
-			    GParamSpec *pspec)
-{
-  EggTrayIcon *icon = EGG_TRAY_ICON (object);
-
-  switch (prop_id)
-    {
-    case PROP_ORIENTATION:
-      g_value_set_enum (value, icon->orientation);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-static void
-egg_tray_icon_get_orientation_property (EggTrayIcon *icon)
-{
-  Display *xdisplay;
-  Atom type;
-  int format;
-  union {
-	gulong *prop;
-	guchar *prop_ch;
-  } prop = { NULL };
-  gulong nitems;
-  gulong bytes_after;
-  int error, result;
-
-  g_assert (icon->manager_window != None);
-  
-  xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-
-  gdk_error_trap_push ();
-  type = None;
-  result = XGetWindowProperty (xdisplay,
-			       icon->manager_window,
-			       icon->orientation_atom,
-			       0, G_MAXLONG, FALSE,
-			       XA_CARDINAL,
-			       &type, &format, &nitems,
-			       &bytes_after, &(prop.prop_ch));
-  error = gdk_error_trap_pop ();
-
-  if (error || result != Success)
-    return;
-
-  if (type == XA_CARDINAL)
-    {
-      GtkOrientation orientation;
-
-      orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
-					GTK_ORIENTATION_HORIZONTAL :
-					GTK_ORIENTATION_VERTICAL;
-
-      if (icon->orientation != orientation)
-	{
-	  icon->orientation = orientation;
-
-	  g_object_notify (G_OBJECT (icon), "orientation");
-	}
-    }
-
-  if (prop.prop)
-    XFree (prop.prop);
-}
-
-static GdkFilterReturn
-egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data)
-{
-  EggTrayIcon *icon = user_data;
-  XEvent *xev = (XEvent *)xevent;
-
-  if (xev->xany.type == ClientMessage &&
-      xev->xclient.message_type == icon->manager_atom &&
-      xev->xclient.data.l[1] == icon->selection_atom)
-    {
-      egg_tray_icon_update_manager_window (icon);
-    }
-  else if (xev->xany.window == icon->manager_window)
-    {
-      if (xev->xany.type == PropertyNotify &&
-	  xev->xproperty.atom == icon->orientation_atom)
-	{
-	  egg_tray_icon_get_orientation_property (icon);
-	}
-      if (xev->xany.type == DestroyNotify)
-	{
-	  egg_tray_icon_update_manager_window (icon);
-	}
-    }
-  
-  return GDK_FILTER_CONTINUE;
-}
-
-static void
-egg_tray_icon_unrealize (GtkWidget *widget)
-{
-  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
-  GdkWindow *root_window;
-
-  if (icon->manager_window != None)
-    {
-      GdkWindow *gdkwin;
-
-      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
-                                              icon->manager_window);
-
-      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
-    }
-
-  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
-
-  gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);
-
-  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
-    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-static void
-egg_tray_icon_send_manager_message (EggTrayIcon *icon,
-				    long         message,
-				    Window       window,
-				    long         data1,
-				    long         data2,
-				    long         data3)
-{
-  XClientMessageEvent ev;
-  Display *display;
-  
-  ev.type = ClientMessage;
-  ev.window = window;
-  ev.message_type = icon->system_tray_opcode_atom;
-  ev.format = 32;
-  ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window);
-  ev.data.l[1] = message;
-  ev.data.l[2] = data1;
-  ev.data.l[3] = data2;
-  ev.data.l[4] = data3;
-
-  display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-  
-  gdk_error_trap_push ();
-  XSendEvent (display,
-	      icon->manager_window, False, NoEventMask, (XEvent *)&ev);
-  XSync (display, False);
-  gdk_error_trap_pop ();
-}
-
-static void
-egg_tray_icon_send_dock_request (EggTrayIcon *icon)
-{
-  egg_tray_icon_send_manager_message (icon,
-				      SYSTEM_TRAY_REQUEST_DOCK,
-				      icon->manager_window,
-				      gtk_plug_get_id (GTK_PLUG (icon)),
-				      0, 0);
-}
-
-static void
-egg_tray_icon_update_manager_window (EggTrayIcon *icon)
-{
-  Display *xdisplay;
-  
-  xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-  
-  if (icon->manager_window != None)
-    {
-      GdkWindow *gdkwin;
-
-      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
-					      icon->manager_window);
-      
-      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
-    }
-  
-  XGrabServer (xdisplay);
-  
-  icon->manager_window = XGetSelectionOwner (xdisplay,
-					     icon->selection_atom);
-
-  if (icon->manager_window != None)
-    XSelectInput (xdisplay,
-		  icon->manager_window, StructureNotifyMask|PropertyChangeMask);
-
-  XUngrabServer (xdisplay);
-  XFlush (xdisplay);
-  
-  if (icon->manager_window != None)
-    {
-      GdkWindow *gdkwin;
-
-      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
-					      icon->manager_window);
-      
-      gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);
-
-      /* Send a request that we'd like to dock */
-      egg_tray_icon_send_dock_request (icon);
-
-      egg_tray_icon_get_orientation_property (icon);
-    }
-}
-
-static void
-egg_tray_icon_realize (GtkWidget *widget)
-{
-  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
-  GdkScreen *screen;
-  GdkDisplay *display;
-  Display *xdisplay;
-  char buffer[256];
-  GdkWindow *root_window;
-
-  if (GTK_WIDGET_CLASS (parent_class)->realize)
-    GTK_WIDGET_CLASS (parent_class)->realize (widget);
-
-  screen = gtk_widget_get_screen (widget);
-  display = gdk_screen_get_display (screen);
-  xdisplay = gdk_x11_display_get_xdisplay (display);
-
-  /* Now see if there's a manager window around */
-  g_snprintf (buffer, sizeof (buffer),
-	      "_NET_SYSTEM_TRAY_S%d",
-	      gdk_screen_get_number (screen));
-
-  icon->selection_atom = XInternAtom (xdisplay, buffer, False);
-  
-  icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
-  
-  icon->system_tray_opcode_atom = XInternAtom (xdisplay,
-						   "_NET_SYSTEM_TRAY_OPCODE",
-						   False);
-
-  icon->orientation_atom = XInternAtom (xdisplay,
-					"_NET_SYSTEM_TRAY_ORIENTATION",
-					False);
-
-  egg_tray_icon_update_manager_window (icon);
-
-  root_window = gdk_screen_get_root_window (screen);
-  
-  /* Add a root window filter so that we get changes on MANAGER */
-  gdk_window_add_filter (root_window,
-			 egg_tray_icon_manager_filter, icon);
-}
-
-EggTrayIcon *
-egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
-{
-  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
-
-  return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL);
-}
-
-EggTrayIcon*
-egg_tray_icon_new (const gchar *name)
-{
-  return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
-}
-
-guint
-egg_tray_icon_send_message (EggTrayIcon *icon,
-			    gint         timeout,
-			    const gchar *message,
-			    gint         len)
-{
-  guint stamp;
-  
-  g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
-  g_return_val_if_fail (timeout >= 0, 0);
-  g_return_val_if_fail (message != NULL, 0);
-		     
-  if (icon->manager_window == None)
-    return 0;
-
-  if (len < 0)
-    len = strlen (message);
-
-  stamp = icon->stamp++;
-  
-  /* Get ready to send the message */
-  egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
-				      (Window)gtk_plug_get_id (GTK_PLUG (icon)),
-				      timeout, len, stamp);
-
-  /* Now to send the actual message */
-  gdk_error_trap_push ();
-  while (len > 0)
-    {
-      XClientMessageEvent ev;
-      Display *xdisplay;
-
-      xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-      
-      ev.type = ClientMessage;
-      ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
-      ev.format = 8;
-      ev.message_type = XInternAtom (xdisplay,
-				     "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
-      if (len > 20)
-	{
-	  memcpy (&ev.data, message, 20);
-	  len -= 20;
-	  message += 20;
-	}
-      else
-	{
-	  memcpy (&ev.data, message, len);
-	  len = 0;
-	}
-
-      XSendEvent (xdisplay,
-		  icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
-      XSync (xdisplay, False);
-    }
-  gdk_error_trap_pop ();
-
-  return stamp;
-}
-
-void
-egg_tray_icon_cancel_message (EggTrayIcon *icon,
-			      guint        id)
-{
-  g_return_if_fail (EGG_IS_TRAY_ICON (icon));
-  g_return_if_fail (id > 0);
-  
-  egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
-				      (Window)gtk_plug_get_id (GTK_PLUG (icon)),
-				      id, 0, 0);
-}
-
-GtkOrientation
-egg_tray_icon_get_orientation (EggTrayIcon *icon)
-{
-  g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL);
-
-  return icon->orientation;
-}
Index: gnome-cups-manager/eggtrayicon.h
===================================================================
RCS file: gnome-cups-manager/eggtrayicon.h
diff -N gnome-cups-manager/eggtrayicon.h
--- gnome-cups-manager/eggtrayicon.h	24 Jun 2004 18:15:57 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* eggtrayicon.h
- * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __EGG_TRAY_ICON_H__
-#define __EGG_TRAY_ICON_H__
-
-#include <gtk/gtkplug.h>
-#include <gdk/gdkx.h>
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_TRAY_ICON		(egg_tray_icon_get_type ())
-#define EGG_TRAY_ICON(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon))
-#define EGG_TRAY_ICON_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass))
-#define EGG_IS_TRAY_ICON(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TRAY_ICON))
-#define EGG_IS_TRAY_ICON_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON))
-#define EGG_TRAY_ICON_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass))
-	
-typedef struct _EggTrayIcon	  EggTrayIcon;
-typedef struct _EggTrayIconClass  EggTrayIconClass;
-
-struct _EggTrayIcon
-{
-  GtkPlug parent_instance;
-
-  guint stamp;
-  
-  Atom selection_atom;
-  Atom manager_atom;
-  Atom system_tray_opcode_atom;
-  Atom orientation_atom;
-  Window manager_window;
-
-  GtkOrientation orientation;
-};
-
-struct _EggTrayIconClass
-{
-  GtkPlugClass parent_class;
-};
-
-GType        egg_tray_icon_get_type       (void);
-
-EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen   *screen,
-					   const gchar *name);
-
-EggTrayIcon *egg_tray_icon_new            (const gchar *name);
-
-guint        egg_tray_icon_send_message   (EggTrayIcon *icon,
-					   gint         timeout,
-					   const char  *message,
-					   gint         len);
-void         egg_tray_icon_cancel_message (EggTrayIcon *icon,
-					   guint        id);
-
-GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon);
-					    
-G_END_DECLS
-
-#endif /* __EGG_TRAY_ICON_H__ */
Index: gnome-cups-manager/gnome-cups-icon.c
===================================================================
RCS file: /cvs/gnome/gnome-cups-manager/gnome-cups-manager/gnome-cups-icon.c,v
retrieving revision 1.4
diff -p -u -B -r1.4 gnome-cups-icon.c
--- gnome-cups-manager/gnome-cups-icon.c	19 Aug 2004 02:45:33 -0000	1.4
+++ gnome-cups-manager/gnome-cups-icon.c	10 Dec 2006 15:25:46 -0000
@@ -122,18 +122,20 @@ already_running (void)
 int 
 main (int argc, char *argv[])
 {
-	gnome_program_init ("gnome-cups-icon", 
-			    VERSION,
-			    LIBGNOMEUI_MODULE, argc, argv,
-			    GNOME_PROGRAM_STANDARD_PROPERTIES,
-			    GNOME_PARAM_HUMAN_READABLE_NAME, _("Print Monitor"),
-			    NULL);
+	GnomeProgram *program;
 
 	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
-	bonobo_init (&argc, argv);
+	program = gnome_program_init ("gnome-cups-icon",
+				      VERSION,
+				      LIBGNOMEUI_MODULE,
+				      argc, argv,
+				      GNOME_PROGRAM_STANDARD_PROPERTIES,
+				      GNOME_PARAM_HUMAN_READABLE_NAME, _("Print Monitor"),
+				      NULL);
+
 	bonobo_activate ();
 	
 	if (!already_running ()) {
@@ -143,6 +145,8 @@ main (int argc, char *argv[])
 		add_to_session ();
 		gtk_main ();
 	}
-	
+
+	g_object_unref (program);
+
 	return 0;
 }
Index: gnome-cups-manager/tray.c
===================================================================
RCS file: /cvs/gnome/gnome-cups-manager/gnome-cups-manager/tray.c,v
retrieving revision 1.11
diff -p -u -B -r1.11 tray.c
--- gnome-cups-manager/tray.c	10 Nov 2006 10:21:25 -0000	1.11
+++ gnome-cups-manager/tray.c	10 Dec 2006 15:25:46 -0000
@@ -6,17 +6,15 @@
 #include <cups/http.h>
 #include <cups/ipp.h>
 
-#include "eggtrayicon.h"
-
-#include <gtk/gtkeventbox.h>
+#include <gtk/gtkstatusicon.h>
 #include <gtk/gtkimage.h>
 #include <gtk/gtkimagemenuitem.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtkmenu.h>
+#include <gtk/gtkmenushell.h>
 #include <gtk/gtkmenuitem.h>
 #include <gtk/gtkseparatormenuitem.h>
 #include <gtk/gtkstock.h>
-#include <gtk/gtktooltips.h>
 #include <libgnome/gnome-i18n.h>
 
 #include <libgnomecups/gnome-cups-printer.h>
@@ -26,8 +24,7 @@
 #include "printer-properties.h"
 #include "view-queue.h"
 
-static GtkTooltips *tooltips = NULL;
-static GHashTable *tray_icons = NULL;
+static GHashTable *status_icons = NULL;
 
 static void
 launch_queue (const char *printer_name)
@@ -111,7 +108,10 @@ properties_activate_cb (GtkWidget *item,
 }
 
 static void
-popup_printer_menu (GnomeCupsPrinter *printer, GdkEventButton *event)
+status_icon_popup_menu_cb (GtkStatusIcon *status_icon,
+			   guint button,
+			   guint32 timestamp,
+			   GnomeCupsPrinter *printer)
 {
 	GtkWidget *menu;
 	GtkWidget *item;
@@ -140,111 +140,98 @@ popup_printer_menu (GnomeCupsPrinter *pr
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	
 	gtk_widget_show_all (menu);
-	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 
-			event->button, event->time);
+
+	gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+			gtk_status_icon_position_menu, status_icon,
+			button, timestamp);
+	if (button == 0)
+		gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
 }
 
-static gboolean
-button_press_cb (GtkWidget *event_box,
-		 GdkEventButton *event,
-		 gpointer user_data)
+static void
+status_icon_activate_cb (GtkStatusIcon *status_icon,
+			 GnomeCupsPrinter *printer)
 {
-	GnomeCupsPrinter *printer = GNOME_CUPS_PRINTER (user_data);	
-
-	if (event->type != GDK_BUTTON_PRESS) {
-		return FALSE;
-	}
-
-	if (event->button == 1) {
 		launch_queue (gnome_cups_printer_get_name (printer));
-		return TRUE;
-	} else if (event->button == 3) {
-		popup_printer_menu (printer, event);
-		return TRUE;
-	}
-	
-	return FALSE;
 }
 
-static char *
-get_icon_path (GnomeCupsPrinter *printer)
+static void
+update_tray_icon (GtkStatusIcon *status_icon,
+		  GnomeCupsPrinter *printer)
 {
+	const char *filename;
+
 	if (gnome_cups_printer_get_state (printer) == IPP_PRINTER_STOPPED) {
-		return g_strdup (GNOME_CUPS_MANAGER_PIXMAPDIR "/printer-tray-stopped.png");
+		filename = GNOME_CUPS_MANAGER_PIXMAPDIR "/printer-tray-stopped.png";
 	} else {
-		return g_strdup (GNOME_CUPS_MANAGER_PIXMAPDIR "/printer-tray-normal.png");
+		filename = GNOME_CUPS_MANAGER_PIXMAPDIR "/printer-tray-normal.png";
 	}
+
+	/* FIXME: we really should install themeable icons in different sizes
+	 * and use icon theme images here, with _set_from_icon_name.
+	 * That would also make size_changed handler unnecessary.
+	 */
+	gtk_status_icon_set_from_file (status_icon, filename);
 }
 
 static void
-update_tray_icon (GnomeCupsPrinter *printer)
+update_tray_tooltip (GtkStatusIcon *status_icon,
+		     GnomeCupsPrinter *printer)
 {
 	char *title;
-	char *filename;
-	EggTrayIcon *tray_icon;
-	GtkWidget *image;
-	GtkWidget *event_box;
-	
-	tray_icon = g_hash_table_lookup (tray_icons, printer);
-	g_return_if_fail (tray_icon != NULL);
-
-	image = g_object_get_data (G_OBJECT (tray_icon), "image");
-	event_box = g_object_get_data (G_OBJECT (tray_icon), "event-box");
-
-	filename = get_icon_path (printer);
-	gtk_image_set_from_file (GTK_IMAGE (image), filename);
-	g_free (filename);
 
 	title = g_strdup_printf (_("%s - %s"),
 				 gnome_cups_printer_get_name (printer),
 				 gnome_cups_printer_get_state_name (printer));
-	gtk_tooltips_set_tip (tooltips, event_box, title, NULL);
+	gtk_status_icon_set_tooltip (status_icon, title);
 	g_free (title);
 }
 
+static gboolean
+status_icon_size_changed_cb (GtkStatusIcon *status_icon,
+			     gint size,
+			     GnomeCupsPrinter *printer)
+{
+	update_tray_icon (status_icon, printer);
+
+	return TRUE;
+}
+
 static void
 set_tray_icon (GnomeCupsPrinter *printer)
 {
-	EggTrayIcon *tray_icon;
-	GtkWidget *image;
-	GtkWidget *event_box;
+	GtkStatusIcon *status_icon;
 	
-	tray_icon = g_hash_table_lookup (tray_icons, printer);
+	status_icon = g_hash_table_lookup (status_icons, printer);
 	
-	if (tray_icon) {
-		update_tray_icon (printer);
+	if (status_icon) {
+		update_tray_icon (status_icon, printer);
+		update_tray_tooltip (status_icon, printer);
 	} else {
-		tray_icon = egg_tray_icon_new (gnome_cups_printer_get_name (printer));
-		
-		/* FIXME */
-		event_box = gtk_event_box_new ();
-		image = gtk_image_new ();
-		
-		gtk_container_add (GTK_CONTAINER (event_box), image);
-		gtk_container_add (GTK_CONTAINER (tray_icon), event_box);
+		status_icon = gtk_status_icon_new ();
 
-		g_object_set_data (G_OBJECT (tray_icon), "printer", printer);
-		g_object_set_data (G_OBJECT (tray_icon), "image", image);
-		g_object_set_data (G_OBJECT (tray_icon), "event-box", event_box);
-		g_hash_table_insert (tray_icons, printer, tray_icon);
+		g_object_set_data (G_OBJECT (status_icon), "printer", printer);
 
-		
-		g_signal_connect (G_OBJECT (event_box), 
-				  "button_press_event",
-				  G_CALLBACK (button_press_cb),
-				  printer);		
+		g_hash_table_insert (status_icons, printer, status_icon);
 
-		update_tray_icon (printer);
-		
-		gtk_widget_show_all (GTK_WIDGET (tray_icon));
+		g_signal_connect (status_icon, "size-changed",
+				  G_CALLBACK (status_icon_size_changed_cb), printer);
+		g_signal_connect (status_icon, "activate",
+				  G_CALLBACK (status_icon_activate_cb), printer);
+		g_signal_connect (status_icon, "popup-menu",
+				  G_CALLBACK (status_icon_popup_menu_cb), printer);
+
+		update_tray_icon (status_icon, printer);
+		update_tray_tooltip (status_icon, printer);
 		
+		gtk_status_icon_set_visible (status_icon, TRUE);
 	}
 }
 
 static void
 remove_tray_icon (GnomeCupsPrinter *printer)
 {
-	g_hash_table_remove (tray_icons, printer);
+	g_hash_table_remove (status_icons, printer);
 }
 
 static void
@@ -293,12 +280,11 @@ gnome_cups_manager_start_icon (void)
 {
 	GList *printers;
 	GList *l;
-	
-	tooltips = gtk_tooltips_new ();
-	tray_icons = g_hash_table_new_full (g_direct_hash,
+
+	status_icons = g_hash_table_new_full (g_direct_hash,
 					    g_direct_equal,
 					    NULL,
-					    (GDestroyNotify)gtk_widget_destroy);
+					    (GDestroyNotify) g_object_unref);
 
 	/* Watch the intial printers */
 	printers = gnome_cups_get_printers ();
