[evolution-patches] Mailer bug #127516 Panel notification applet for new mail (bounties)



Hi all,

I've finished the panel notification applet, you can setup it by means
of the "New Mail Notification" tab I've added to the Mailer Preferences.
The notification types includes:

+ None
  - Do not notify when new mail arrives.

+ All Folders
  - Notify when new mail arrives to any folder.
  - You can setup the sound to play and image to blink in the panel
    notification area when new mail arrives.

+ Selected Folders
  - Notify when new mail arrives to any of the selected folders.
  - You can setup the sound to play and image to blink in the panel
    notification area for every selected folder

I attach the following files:
e-util.diff: diff file for the e-util directory.
mail.diff: diff file for the mail directory.
eggmarshalers.c/h: Needed to run eggtraymanager (put into e-util
                  directory).
eggtraymanager.c/h: put into e-util directory.
em-panel-applet.c/h : The notification applet (put into mail directory)

Well, this is not only my first evolution patch but my very first gnome
patch so, I hope this is good enough :)

P.D. I almost forget it... the Screenshots are in:
http://www.gulev.org.mx/~miguel/ScreenshotsBountie/

Greetings,
Miguel
? eggmarshalers.c
? eggmarshalers.h
? eggtraymanager.c
? eggtraymanager.h
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/e-util/Makefile.am,v
retrieving revision 1.108
diff -u -r1.108 Makefile.am
--- Makefile.am	6 Dec 2003 18:15:20 -0000	1.108
+++ Makefile.am	11 Jan 2004 10:16:20 -0000
@@ -79,6 +79,10 @@
 	e-xml-hash-utils.c			\
 	eggtrayicon.c				\
 	eggtrayicon.h				\
+	eggmarshalers.c				\
+	eggmarshalers.h				\
+	eggtraymanager.c			\
+	eggtraymanager.h			\
 	md5-utils.c
 
 MARSHAL_GENERATED = e-util-marshal.c e-util-marshal.h
@@ -114,4 +118,4 @@
 CLEANFILES    = $(BUILT_SOURCES)
 
 dist-hook:
-	cd $(distdir); rm -f $(BUILT_SOURCES)
\ No newline at end of file
+	cd $(distdir); rm -f $(BUILT_SOURCES)
Index: eggtrayicon.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/eggtrayicon.c,v
retrieving revision 1.1
diff -u -r1.1 eggtrayicon.c
--- eggtrayicon.c	28 Aug 2003 20:03:42 -0000	1.1
+++ eggtrayicon.c	11 Jan 2004 10:16:21 -0000
@@ -18,19 +18,50 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
 #include <string.h>
-#include <gdk/gdkx.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
@@ -63,6 +94,7 @@
 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);
 }
@@ -70,7 +102,95 @@
 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
@@ -87,6 +207,11 @@
     }
   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);
@@ -97,6 +222,30 @@
 }
 
 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,
@@ -117,11 +266,7 @@
   ev.data.l[3] = data2;
   ev.data.l[4] = data3;
 
-#if HAVE_GTK_MULTIHEAD
   display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-#else
-  display = gdk_display;
-#endif
   
   gdk_error_trap_push ();
   XSendEvent (display,
@@ -145,22 +290,14 @@
 {
   Display *xdisplay;
   
-#if HAVE_GTK_MULTIHEAD
   xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-#else
-  xdisplay = gdk_display;
-#endif
   
   if (icon->manager_window != None)
     {
       GdkWindow *gdkwin;
 
-#if HAVE_GTK_MULTIHEAD
-      gdkwin = gdk_window_lookup_for_display (display,
+      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
 					      icon->manager_window);
-#else
-      gdkwin = gdk_window_lookup (icon->manager_window);
-#endif
       
       gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
     }
@@ -172,7 +309,7 @@
 
   if (icon->manager_window != None)
     XSelectInput (xdisplay,
-		  icon->manager_window, StructureNotifyMask);
+		  icon->manager_window, StructureNotifyMask|PropertyChangeMask);
 
   XUngrabServer (xdisplay);
   XFlush (xdisplay);
@@ -181,87 +318,85 @@
     {
       GdkWindow *gdkwin;
 
-#if HAVE_GTK_MULTIHEAD
       gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
 					      icon->manager_window);
-#else
-      gdkwin = gdk_window_lookup (icon->manager_window);
-#endif
       
       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 EggTrayIcon *
-egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name)
+static void
+egg_tray_icon_realize (GtkWidget *widget)
 {
-  EggTrayIcon *icon;
+  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
+  GdkScreen *screen;
+  GdkDisplay *display;
+  Display *xdisplay;
   char buffer[256];
   GdkWindow *root_window;
 
-  g_return_val_if_fail (xscreen != NULL, NULL);
-  
-  icon = g_object_new (EGG_TYPE_TRAY_ICON, NULL);
-  gtk_window_set_title (GTK_WINDOW (icon), name);
+  if (GTK_WIDGET_CLASS (parent_class)->realize)
+    GTK_WIDGET_CLASS (parent_class)->realize (widget);
 
-#if HAVE_GTK_MULTIHEAD
-  gtk_plug_construct_for_display (GTK_PLUG (icon),
-				  gdk_screen_get_display (screen), 0);
-#else
-  gtk_plug_construct (GTK_PLUG (icon), 0);
-#endif
-  
-  gtk_widget_realize (GTK_WIDGET (icon));
+  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",
-	      XScreenNumberOfScreen (xscreen));
-  
-  icon->selection_atom = XInternAtom (DisplayOfScreen (xscreen),
-				      buffer, False);
+	      gdk_screen_get_number (screen));
+
+  icon->selection_atom = XInternAtom (xdisplay, buffer, False);
   
-  icon->manager_atom = XInternAtom (DisplayOfScreen (xscreen),
-				    "MANAGER", False);
+  icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
   
-  icon->system_tray_opcode_atom = XInternAtom (DisplayOfScreen (xscreen),
-					       "_NET_SYSTEM_TRAY_OPCODE", 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);
 
-#if HAVE_GTK_MULTIHEAD
   root_window = gdk_screen_get_root_window (screen);
-#else
-  root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
-#endif
   
   /* Add a root window filter so that we get changes on MANAGER */
   gdk_window_add_filter (root_window,
 			 egg_tray_icon_manager_filter, icon);
-		      
-  return icon;
 }
 
-#if HAVE_GTK_MULTIHEAD
 EggTrayIcon *
-egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
+egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name)
 {
-  EggTrayIcon *icon;
-  char buffer[256];
+  GdkDisplay *display;
+  GdkScreen *screen;
+
+  display = gdk_x11_lookup_xdisplay (DisplayOfScreen (xscreen));
+  screen = gdk_display_get_screen (display, XScreenNumberOfScreen (xscreen));
 
+  return egg_tray_icon_new_for_screen (screen, name);
+}
+
+EggTrayIcon *
+egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
+{
   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
 
-  return egg_tray_icon_new_for_xscreen (GDK_SCREEN_XSCREEN (screen), name);
+  return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL);
 }
-#endif
 
 EggTrayIcon*
 egg_tray_icon_new (const gchar *name)
 {
-  return egg_tray_icon_new_for_xscreen (DefaultScreenOfDisplay (gdk_display), name);
+  return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
 }
 
 guint
@@ -296,11 +431,7 @@
       XClientMessageEvent ev;
       Display *xdisplay;
 
-#if HAVE_GTK_MULTIHEAD
       xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-#else
-      xdisplay = gdk_display;
-#endif
       
       ev.type = ClientMessage;
       ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
@@ -338,4 +469,12 @@
   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: eggtrayicon.h
===================================================================
RCS file: /cvs/gnome/evolution/e-util/eggtrayicon.h,v
retrieving revision 1.1
diff -u -r1.1 eggtrayicon.h
--- eggtrayicon.h	28 Aug 2003 20:03:42 -0000	1.1
+++ eggtrayicon.h	11 Jan 2004 10:16:21 -0000
@@ -45,7 +45,10 @@
   Atom selection_atom;
   Atom manager_atom;
   Atom system_tray_opcode_atom;
+  Atom orientation_atom;
   Window manager_window;
+
+  GtkOrientation orientation;
 };
 
 struct _EggTrayIconClass
@@ -55,10 +58,8 @@
 
 GType        egg_tray_icon_get_type       (void);
 
-#if EGG_TRAY_ENABLE_MULTIHEAD
 EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen   *screen,
 					   const gchar *name);
-#endif
 
 EggTrayIcon *egg_tray_icon_new            (const gchar *name);
 
@@ -69,7 +70,7 @@
 void         egg_tray_icon_cancel_message (EggTrayIcon *icon,
 					   guint        id);
 
-
+GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon);
 					    
 G_END_DECLS
 
? em-panel-applet.c
? em-panel-applet.h
? evolution-mail-1.5.schemas
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/mail/Makefile.am,v
retrieving revision 1.237
diff -u -r1.237 Makefile.am
--- Makefile.am	11 Dec 2003 21:00:06 -0000	1.237
+++ Makefile.am	11 Jan 2004 10:28:24 -0000
@@ -120,6 +120,8 @@
 	em-junk-plugin.h			\
 	em-html-stream.c			\
 	em-html-stream.h			\
+	em-panel-applet.c			\
+	em-panel-applet.h			\
 	mail-account-editor.c			\
 	mail-account-editor.h			\
 	mail-account-gui.c			\
Index: em-mailer-prefs.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-mailer-prefs.c,v
retrieving revision 1.4
diff -u -r1.4 em-mailer-prefs.c
--- em-mailer-prefs.c	11 Dec 2003 19:24:10 -0000	1.4
+++ em-mailer-prefs.c	11 Jan 2004 10:28:24 -0000
@@ -37,6 +37,7 @@
 
 #include "mail-config.h"
 
+#include "em-panel-applet.h"
 
 static void em_mailer_prefs_class_init (EMMailerPrefsClass *class);
 static void em_mailer_prefs_init       (EMMailerPrefs *dialog);
@@ -387,15 +388,200 @@
 }
 
 static void
+settings_notify_changed (GtkWidget *widget, gpointer user_data)
+{
+	EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
+	gboolean bool;
+	
+	prefs->notify_type = gtk_option_menu_get_history (prefs->notify_menu);
+	
+	gtk_label_set_text (prefs->notify_desc, MailNotifyType[prefs->notify_type].description);
+	
+	
+	if (prefs->notify_type == MAIL_CONFIG_NOTIFY_NONE) {
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_folders), FALSE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_image), FALSE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_sound), FALSE);
+	} else if (prefs->notify_type == MAIL_CONFIG_NOTIFY_ALL) {
+		bool = gnome_icon_entry_set_filename (prefs->img_notify, prefs->image_file->str);
+		gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)),
+				    prefs->sound_file->str);
+		gtk_toggle_button_set_active (prefs->notify_beep, prefs->play_beep);
+		gtk_toggle_button_set_active (prefs->notify_play_sound, !prefs->play_beep);
+	
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_folders), FALSE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_image), TRUE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_sound), TRUE);
+	} else if (prefs->notify_type == MAIL_CONFIG_NOTIFY_SELECTED) {
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_folders), TRUE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_image), FALSE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_sound), FALSE);
+	}
+}
+
+static void
+notify_folder_selected (GtkTreeSelection *selection, gpointer user_data)
+{
+	GtkTreeIter iter;
+	EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
+	gchar *name, *sound, *id, *image, *beep;
+	gboolean bool;
+
+	if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+		gtk_tree_model_get ((GtkTreeModel *) prefs->notify_folders_store, &iter,
+				    NOTIFY_NAME_COLUMN, &name,
+				    NOTIFY_SOUND_COLUMN, &sound,
+				    NOTIFY_ID_COLUMN, &id,
+				    NOTIFY_IMAGE_COLUMN, &image,
+				    NOTIFY_BEEP_COLUMN, &beep,
+				    -1);
+
+		bool = gnome_icon_entry_set_filename (prefs->img_notify, image ? image : "");
+		bool = !strcmp("yes", beep);
+		gtk_toggle_button_set_active (prefs->notify_beep, bool);
+		gtk_toggle_button_set_active (prefs->notify_play_sound, !bool);
+		gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)), 
+				    sound);
+
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->del_folder), TRUE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_image), TRUE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_sound), TRUE);
+	} else {
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->del_folder), FALSE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_image), FALSE);
+		gtk_widget_set_sensitive (GTK_WIDGET (prefs->frame_sound), FALSE);
+	}
+}
+
+static void
+notify_beep_changed (GtkWidget *widget, gpointer user_data)
+{
+	EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
+	gboolean beep = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	GtkTreeIter iter;
+	GtkTreeSelection *selection = gtk_tree_view_get_selection (prefs->notify_folders);
+	gchar *snd_file;
+
+	if (prefs->notify_type == MAIL_CONFIG_NOTIFY_SELECTED) {
+		if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+			gtk_list_store_set (GTK_LIST_STORE (prefs->notify_folders_store), &iter,
+					    NOTIFY_BEEP_COLUMN, beep ? "yes" : "no",
+					    -1);
+			
+			gtk_tree_model_get (GTK_TREE_MODEL (prefs->notify_folders_store), &iter, 
+					    NOTIFY_SOUND_COLUMN, &snd_file,
+					    -1);
+			
+			if (!beep) {
+				snd_file = strcmp (snd_file, "") ? snd_file : DEFAULT_SOUND_NOTIFY;
+				gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)),
+						    snd_file);
+			} else {
+				snd_file = strcmp (snd_file, "") ? snd_file : "";
+				gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)),
+						    snd_file);
+			}
+		}
+		gtk_list_store_set (GTK_LIST_STORE (prefs->notify_folders_store), &iter,
+				    NOTIFY_SOUND_COLUMN, snd_file,
+				    -1);
+	} else if (prefs->notify_type == MAIL_CONFIG_NOTIFY_ALL) {
+		prefs->play_beep = beep;
+
+		if (!beep) {
+			snd_file = strcmp (prefs->sound_file->str, "") ? prefs->sound_file->str : DEFAULT_SOUND_NOTIFY;
+			gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)),
+					    snd_file);
+		} else {
+			snd_file = strcmp (prefs->sound_file->str, "") ? prefs->sound_file->str : "";
+			gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)),
+					    snd_file);
+		}
+	}
+	
+	if (prefs->control)
+		evolution_config_control_changed (prefs->control);
+}
+
+static void
+notify_sound_changed (GtkWidget *widget, gpointer user_data)
+{
+	EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
+	GtkWidget *entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (prefs->notify_sound_file));
+	GtkTreeIter iter;
+	GtkTreeSelection *selection = gtk_tree_view_get_selection (prefs->notify_folders);
+	char *snd_file;
+
+	snd_file = gtk_entry_get_text (GTK_ENTRY (entry));
+
+	if (prefs->notify_type == MAIL_CONFIG_NOTIFY_SELECTED)
+		if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+			gtk_list_store_set (GTK_LIST_STORE (prefs->notify_folders_store), &iter,
+					    NOTIFY_SOUND_COLUMN, snd_file,
+					    -1);
+	else 	if (prefs->notify_type == MAIL_CONFIG_NOTIFY_ALL)
+		prefs->sound_file = g_string_assign (prefs->sound_file, snd_file);
+
+	if (prefs->control)
+		evolution_config_control_changed (prefs->control);
+}
+
+static void
+notify_image_changed (GtkWidget *widget, gpointer user_data)
+{
+	EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
+	GtkTreeIter iter;
+	GtkTreeSelection *selection = gtk_tree_view_get_selection (prefs->notify_folders);
+	gchar *img_file;
+	GdkPixbuf *pixbuf;
+
+	if (prefs->notify_type == MAIL_CONFIG_NOTIFY_SELECTED) {
+		if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+			img_file = gnome_icon_entry_get_filename (prefs->img_notify, NULL);
+			pixbuf = em_tray_get_image_scaled (img_file);
+			gtk_list_store_set (GTK_LIST_STORE (prefs->notify_folders_store), &iter,
+					    NOTIFY_PIXBUF_COLUMN, pixbuf,
+					    NOTIFY_IMAGE_COLUMN, img_file,
+					    -1);
+		}
+	}
+
+	if (prefs->control)
+		evolution_config_control_changed (prefs->control);
+}
+
+static void
+notify_add_folder (GtkWidget *button, gpointer user_data)
+{
+	EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
+
+	em_tray_add_folder (button, prefs);
+}
+
+static void
+notify_remove_folder (GtkWidget *button, gpointer user_data)
+{
+	EMMailerPrefs *prefs = (EMMailerPrefs *) user_data;
+	GtkTreeIter iter;
+	
+	if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (prefs->notify_folders), NULL, &iter))
+		gtk_list_store_remove (GTK_LIST_STORE (prefs->notify_folders_store), &iter);
+
+	if (prefs->control)
+		evolution_config_control_changed (prefs->control);
+}
+
+static void
 em_mailer_prefs_construct (EMMailerPrefs *prefs)
 {
 	GSList *list, *header_config_list, *header_add_list, *p;
 	GHashTable *default_header_hash;
 	GtkWidget *toplevel, *menu;
-	GtkTreeSelection *selection;
+	GtkTreeSelection *selection, *folder_selec;
 	GtkCellRenderer *renderer;
+	GtkTreeViewColumn *column;
 	GtkTreeIter iter;
-	char *font, *buf;
+	char *font, *buf, *img, *snd;
 	GladeXML *gui;
 	gboolean bool;
 	int val, i;
@@ -455,26 +641,74 @@
 	g_signal_connect (prefs->confirm_expunge, "toggled", G_CALLBACK (settings_changed), prefs);
 	
 	/* New Mail Notification */
-	val = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/notify/type", NULL);
-	prefs->notify_not = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyNot"));
-	gtk_toggle_button_set_active (prefs->notify_not, val == MAIL_CONFIG_NOTIFY_NOT);
-	g_signal_connect (prefs->notify_not, "toggled", G_CALLBACK (settings_changed), prefs);
-	
+	prefs->notify_type = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/notify/type", NULL);
+
+	prefs->notify_menu = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenu_NotifyType"));
+	g_signal_connect (prefs->notify_menu, "changed", G_CALLBACK (settings_notify_changed), prefs);
+
+	prefs->none_notify = GTK_MENU_ITEM (glade_xml_get_widget (gui, "none_notify"));
+	g_signal_connect (prefs->none_notify, "activate", G_CALLBACK (settings_changed), prefs);
+	prefs->all_folders_notify = GTK_MENU_ITEM (glade_xml_get_widget (gui, "all_folders_notify"));
+	g_signal_connect (prefs->all_folders_notify, "activate", G_CALLBACK (settings_changed), prefs);
+	prefs->selected_folders_notify = GTK_MENU_ITEM (glade_xml_get_widget (gui, "selected_folders_notify"));
+	g_signal_connect (prefs->selected_folders_notify, "activate", G_CALLBACK (settings_changed), prefs);
+
+	prefs->notify_folders = GTK_TREE_VIEW (glade_xml_get_widget (gui, "treeviewFolders"));
+	prefs->notify_folders_store = GTK_LIST_STORE (em_tray_get_store());
+	folder_selec = gtk_tree_view_get_selection (prefs->notify_folders);
+	g_signal_connect (folder_selec, "changed", G_CALLBACK (notify_folder_selected), prefs);
+	gtk_tree_view_set_model (prefs->notify_folders, GTK_TREE_MODEL (prefs->notify_folders_store));
+
+	renderer = gtk_cell_renderer_pixbuf_new ();
+	column = gtk_tree_view_column_new_with_attributes (N_("Image"), renderer, "pixbuf", NOTIFY_PIXBUF_COLUMN, NULL);
+	gtk_tree_view_append_column (prefs->notify_folders, column);
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (N_("Name"), renderer, "text", NOTIFY_NAME_COLUMN, NULL);
+	gtk_tree_view_append_column (prefs->notify_folders, column);
+	column = gtk_tree_view_column_new_with_attributes (N_("Sound"), renderer, "text", NOTIFY_SOUND_COLUMN, NULL);
+	gtk_tree_view_append_column (prefs->notify_folders, column);
+
+	prefs->frame_folders = GTK_FRAME(glade_xml_get_widget (gui, "frameFolders"));
+	prefs->frame_image = GTK_FRAME(glade_xml_get_widget (gui, "frameImage"));
+	prefs->frame_sound = GTK_FRAME(glade_xml_get_widget (gui, "frameSound"));
+	prefs->notify_desc = GTK_LABEL (glade_xml_get_widget (gui, "lblDescNotifyType"));
+
+	prefs->img_notify = glade_xml_get_widget (gui, "iconentryImageNotify");
+	img = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/notify/image", NULL);
+	prefs->image_file = g_string_new (img);
+
+	bool = gnome_icon_entry_set_filename (prefs->img_notify, img ? img : "");
+	g_signal_connect (prefs->img_notify, "changed", G_CALLBACK (notify_image_changed), prefs);
+	g_free (img);
+
+	prefs->notify_sound_file = GNOME_FILE_ENTRY (glade_xml_get_widget (gui, "fileNotifyPlaySound"));
+	snd = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/notify/sound", NULL);
+	prefs->sound_file = g_string_new (snd);
+
+	gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)), snd ? snd : "");
+	g_signal_connect (gnome_file_entry_gtk_entry (prefs->notify_sound_file), "changed",
+			  G_CALLBACK (notify_sound_changed), prefs);
+	g_free (snd);
+
+	prefs->add_folder = GTK_BUTTON(glade_xml_get_widget (gui, "buttonAddFolder"));
+	g_signal_connect (G_OBJECT (prefs->add_folder), "clicked", G_CALLBACK (notify_add_folder), prefs);
+
+	prefs->del_folder = GTK_BUTTON(glade_xml_get_widget (gui, "buttonDelFolder"));
+	g_signal_connect (G_OBJECT (prefs->del_folder), "clicked", G_CALLBACK (notify_remove_folder), prefs);
+
 	prefs->notify_beep = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyBeep"));
-	gtk_toggle_button_set_active (prefs->notify_beep, val == MAIL_CONFIG_NOTIFY_BEEP);
-	g_signal_connect (prefs->notify_beep, "toggled", G_CALLBACK (settings_changed), prefs);
+	bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/notify/beep", NULL);
+	prefs->play_beep = bool;
+	gtk_toggle_button_set_active (prefs->notify_beep, bool);
+	g_signal_connect (prefs->notify_beep, "toggled", G_CALLBACK (notify_beep_changed), prefs);
 	
 	prefs->notify_play_sound = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyPlaySound"));
-	gtk_toggle_button_set_active (prefs->notify_play_sound, val == MAIL_CONFIG_NOTIFY_PLAY_SOUND);
+	gtk_toggle_button_set_active (prefs->notify_play_sound, !bool);
 	g_signal_connect (prefs->notify_play_sound, "toggled", G_CALLBACK (settings_changed), prefs);
-	
-	prefs->notify_sound_file = GNOME_FILE_ENTRY (glade_xml_get_widget (gui, "fileNotifyPlaySound"));
-	buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/notify/sound", NULL);
-	gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)), buf ? buf : "");
-	g_signal_connect (gnome_file_entry_gtk_entry (prefs->notify_sound_file), "changed",
-			  G_CALLBACK (settings_changed), prefs);
-	g_free (buf);
-	
+
+	em_tray_folders_refresh ();
+	gtk_option_menu_set_history (prefs->notify_menu, prefs->notify_type);
+
 	/* Mail  Fonts */
 	font = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/fonts/monospace", NULL);
 	prefs->font_fixed = GNOME_FONT_PICKER (glade_xml_get_widget (gui, "radFontFixed"));
@@ -677,8 +911,10 @@
 	guint32 rgb;
 	int i, val;
 	GtkTreeIter iter;
-	gboolean valid;
+	gboolean valid, cont;
 	GSList *header_list;
+        FolderTrayNotify *folder_notify;
+	gchar *name, *sound, *id, *image, *beep, *folder_xml;
 	
 	/* General tab */
 	
@@ -711,18 +947,43 @@
 			       gtk_toggle_button_get_active (prefs->confirm_expunge), NULL);
 	
 	/* New Mail Notification */
-	if (gtk_toggle_button_get_active (prefs->notify_not))
-		val = MAIL_CONFIG_NOTIFY_NOT;
-	else if (gtk_toggle_button_get_active (prefs->notify_beep))
-		val = MAIL_CONFIG_NOTIFY_BEEP;
-	else
-		val = MAIL_CONFIG_NOTIFY_PLAY_SOUND;
-	
-	gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/notify/type", val, NULL);
-	
-	entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (prefs->notify_sound_file));
-	cstring = gtk_entry_get_text (GTK_ENTRY (entry));
-	gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/notify/sound", cstring, NULL);
+	gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/notify/type", prefs->notify_type, NULL);
+
+	if (prefs->notify_type == MAIL_CONFIG_NOTIFY_ALL) {
+		gconf_client_set_bool (prefs->gconf, "/apps/evolution/mail/notify/beep",
+				       gtk_toggle_button_get_active (prefs->notify_beep), NULL);
+		cstring = gnome_icon_entry_get_filename (prefs->img_notify);
+		gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/notify/image", cstring, NULL);
+		
+		entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (prefs->notify_sound_file));
+		cstring = gtk_entry_get_text (GTK_ENTRY (entry));
+		gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/notify/sound", cstring, NULL);
+	}
+
+	list = NULL;
+	folder_notify = g_new0 (FolderTrayNotify, 1);
+	for (cont = gtk_tree_model_get_iter_first ((GtkTreeModel *) prefs->notify_folders_store, &iter); cont;
+	     cont = gtk_tree_model_iter_next ((GtkTreeModel *) prefs->notify_folders_store, &iter)) {
+		gtk_tree_model_get ((GtkTreeModel *) prefs->notify_folders_store, &iter,
+				    NOTIFY_NAME_COLUMN, &name,
+				    NOTIFY_SOUND_COLUMN, &sound,
+				    NOTIFY_ID_COLUMN, &id,
+				    NOTIFY_IMAGE_COLUMN, &image,
+				    NOTIFY_BEEP_COLUMN, &beep,
+				    -1);
+
+		folder_notify->name = name;
+		folder_notify->sound = sound;
+		folder_notify->id = id;
+		folder_notify->image = image;
+		folder_notify->beep = beep;
+
+		folder_xml = em_folder_tray_notify_to_xml (folder_notify);
+
+		list = g_slist_append (list, folder_xml);
+	}
+	gconf_client_set_list (prefs->gconf, "/apps/evolution/mail/notify/folders",GCONF_VALUE_STRING, list, NULL);
+	em_tray_folders_refresh ();
 	
 	/* HTML Mail */
 	if (gtk_toggle_button_get_active (prefs->images_always))
Index: em-mailer-prefs.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-mailer-prefs.h,v
retrieving revision 1.5
diff -u -r1.5 em-mailer-prefs.h
--- em-mailer-prefs.h	11 Dec 2003 04:56:12 -0000	1.5
+++ em-mailer-prefs.h	11 Jan 2004 10:28:24 -0000
@@ -81,7 +81,28 @@
 	GtkToggleButton *confirm_expunge;
 	
 	/* New Mail Notification */
-	GtkToggleButton *notify_not;
+	guint notify_type;
+	GtkLabel *notify_desc;
+	GtkTreeView *notify_folders;
+	GtkListStore *notify_folders_store;
+
+	GtkOptionMenu *notify_menu;
+	GtkMenuItem *none_notify;
+	GtkMenuItem *all_folders_notify;
+	GtkMenuItem *selected_folders_notify;
+
+	GtkFrame *frame_folders;
+	GtkFrame *frame_image;
+	GtkFrame *frame_sound;
+
+	GtkWidget *img_notify;
+
+	GtkButton *add_folder;
+	GtkButton *del_folder;
+
+	GString *image_file;
+	GString *sound_file;
+	gboolean play_beep;
 	GtkToggleButton *notify_beep;
 	GtkToggleButton *notify_play_sound;
 	GnomeFileEntry *notify_sound_file;
Index: evolution-mail.schemas.in.in
===================================================================
RCS file: /cvs/gnome/evolution/mail/evolution-mail.schemas.in.in,v
retrieving revision 1.3
diff -u -r1.3 evolution-mail.schemas.in.in
--- evolution-mail.schemas.in.in	11 Dec 2003 04:56:12 -0000	1.3
+++ evolution-mail.schemas.in.in	11 Jan 2004 10:28:25 -0000
@@ -499,6 +499,65 @@
     <!-- New Mail Notification settings -->
 
     <schema>
+      <key>/schemas/apps/evolution/mail/notify/beep</key>
+      <applyto>/apps/evolution/mail/notify/beep</applyto>
+      <owner>evolution-mail</owner>
+      <type>bool</type>
+      <default>1</default>
+      <locale name="C">
+         <short>Beep when new mail arrives</short>
+         <long>
+          Specify if the system must beep when new mail 
+          arrives and all folders are selected
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/evolution/mail/notify/folders</key>
+      <applyto>/apps/evolution/mail/notify/folders</applyto>
+      <owner>evolution-mail</owner>
+      <type>list</type>
+      <list_type>string</list_type>
+      <locale name="C">
+         <short>List of folders</short>
+         <long>
+           List of folders for notify when new mail arrives
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/evolution/mail/notify/image</key>
+      <applyto>/apps/evolution/mail/notify/image</applyto>
+      <owner>evolution-mail</owner>
+      <type>string</type>
+      <default></default>
+      <locale name="C">
+         <short>Name of image</short>
+         <long>
+          Name of image to blink when new mail arrives and
+          all folders are selected
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/evolution/mail/notify/sound</key>
+      <applyto>/apps/evolution/mail/notify/sound</applyto>
+      <owner>evolution-mail</owner>
+      <type>string</type>
+      <default></default>
+      <locale name="C">
+         <short>Name of sound</short>
+         <long>
+          Name of sound to play when new mail arrives and
+          all folders are selected
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/evolution/mail/notify/type</key>
       <applyto>/apps/evolution/mail/notify/type</applyto>
       <owner>evolution-mail</owner>
Index: mail-component-factory.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-component-factory.c,v
retrieving revision 1.7
diff -u -r1.7 mail-component-factory.c
--- mail-component-factory.c	3 Dec 2003 15:37:55 -0000	1.7
+++ mail-component-factory.c	11 Jan 2004 10:28:25 -0000
@@ -42,6 +42,7 @@
 
 #include <string.h>
 
+#include "mail/em-panel-applet.h"
 
 #define FACTORY_ID	"OAFIID:GNOME_Evolution_Mail_Factory:" BASE_VERSION
 
@@ -88,6 +89,7 @@
 	static int init = 0;
 
 	if (!init) {
+		em_tray_init ();
 		mail_config_init ();
 		mail_msg_init ();
 		init = 1;
Index: mail-config.glade
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config.glade,v
retrieving revision 1.126
diff -u -r1.126 mail-config.glade
--- mail-config.glade	11 Dec 2003 04:56:12 -0000	1.126
+++ mail-config.glade	11 Jan 2004 10:28:26 -0000
@@ -11,6 +11,11 @@
   <property name="modal">False</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
     <widget class="GnomeDruid" id="druid">
@@ -158,6 +163,11 @@
   <property name="modal">False</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
     <widget class="GtkNotebook" id="account_editor_notebook">
@@ -281,6 +291,7 @@
 			  <property name="label" translatable="yes">_Make this my default account</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -630,6 +641,7 @@
 			      <property name="label" translatable="yes">Add new signature...</property>
 			      <property name="use_underline">True</property>
 			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
 			      <signal name="clicked" handler="sigAddNewClicked"/>
 			    </widget>
 			    <packing>
@@ -1263,6 +1275,10 @@
 			      <property name="yalign">0.5</property>
 			      <property name="xscale">1</property>
 			      <property name="yscale">1</property>
+			      <property name="top_padding">0</property>
+			      <property name="bottom_padding">0</property>
+			      <property name="left_padding">0</property>
+			      <property name="right_padding">0</property>
 
 			      <child>
 				<widget class="GtkButton" id="source_check_supported">
@@ -1271,6 +1287,7 @@
 				  <property name="label" translatable="yes"> _Check for supported types </property>
 				  <property name="use_underline">True</property>
 				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
 				</widget>
 			      </child>
 			    </widget>
@@ -1296,6 +1313,7 @@
 			  <property name="label" translatable="yes">Re_member this password</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -1434,6 +1452,7 @@
 			      <property name="label" translatable="yes">_Automatically check for new mail every</property>
 			      <property name="use_underline">True</property>
 			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
 			      <property name="active">False</property>
 			      <property name="inconsistent">False</property>
 			      <property name="draw_indicator">True</property>
@@ -1885,6 +1904,7 @@
 			  <property name="label" translatable="yes">Ser_ver requires authentication</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -2008,6 +2028,10 @@
 			      <property name="yalign">0.5</property>
 			      <property name="xscale">1</property>
 			      <property name="yscale">1</property>
+			      <property name="top_padding">0</property>
+			      <property name="bottom_padding">0</property>
+			      <property name="left_padding">0</property>
+			      <property name="right_padding">0</property>
 
 			      <child>
 				<widget class="GtkButton" id="transport_check_supported">
@@ -2016,6 +2040,7 @@
 				  <property name="label" translatable="yes"> _Check for supported types </property>
 				  <property name="use_underline">True</property>
 				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
 				</widget>
 			      </child>
 			    </widget>
@@ -2095,6 +2120,7 @@
 			  <property name="label" translatable="yes">Remember this _password</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -2287,6 +2313,7 @@
 			  <property name="label" translatable="yes">Restore Defaults</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			</widget>
 			<packing>
 			  <property name="left_attach">1</property>
@@ -2362,6 +2389,7 @@
 				  <property name="label" translatable="yes">Always _carbon-copy (Cc) to:</property>
 				  <property name="use_underline">True</property>
 				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
 				  <property name="active">False</property>
 				  <property name="inconsistent">False</property>
 				  <property name="draw_indicator">True</property>
@@ -2383,6 +2411,7 @@
 				  <property name="label" translatable="yes">Always _blind carbon-copy (Bcc) to:</property>
 				  <property name="use_underline">True</property>
 				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
 				  <property name="active">False</property>
 				  <property name="inconsistent">False</property>
 				  <property name="draw_indicator">True</property>
@@ -2602,6 +2631,7 @@
 			  <property name="label" translatable="yes">_Always sign outgoing messages when using this account</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -2620,6 +2650,7 @@
 			  <property name="label" translatable="yes">Don't sign _meeting requests (for Outlook compatibility)</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -2638,6 +2669,7 @@
 			  <property name="label" translatable="yes">Al_ways encrypt to myself when sending encrypted mail</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">True</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -2656,6 +2688,7 @@
 			  <property name="label" translatable="yes">Always _trust keys in my keyring when encrypting</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -2815,6 +2848,7 @@
 			  <property name="visible">True</property>
 			  <property name="can_focus">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 
 			  <child>
 			    <widget class="GtkAlignment" id="alignment28">
@@ -2823,6 +2857,10 @@
 			      <property name="yalign">0.5</property>
 			      <property name="xscale">0</property>
 			      <property name="yscale">0</property>
+			      <property name="top_padding">0</property>
+			      <property name="bottom_padding">0</property>
+			      <property name="left_padding">0</property>
+			      <property name="right_padding">0</property>
 
 			      <child>
 				<widget class="GtkHBox" id="hbox175">
@@ -2887,6 +2925,7 @@
 			  <property name="visible">True</property>
 			  <property name="can_focus">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 
 			  <child>
 			    <widget class="GtkAlignment" id="alignment29">
@@ -2895,6 +2934,10 @@
 			      <property name="yalign">0.5</property>
 			      <property name="xscale">0</property>
 			      <property name="yscale">0</property>
+			      <property name="top_padding">0</property>
+			      <property name="bottom_padding">0</property>
+			      <property name="left_padding">0</property>
+			      <property name="right_padding">0</property>
 
 			      <child>
 				<widget class="GtkHBox" id="hbox176">
@@ -2961,6 +3004,7 @@
 			  <property name="label">gtk-clear</property>
 			  <property name="use_stock">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			</widget>
 			<packing>
 			  <property name="left_attach">3</property>
@@ -2979,6 +3023,7 @@
 			  <property name="label">gtk-clear</property>
 			  <property name="use_stock">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			</widget>
 			<packing>
 			  <property name="left_attach">3</property>
@@ -2997,6 +3042,7 @@
 			  <property name="label" translatable="yes">A_lso encrypt to self when sending encrypted mail</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -3018,6 +3064,7 @@
 			  <property name="label" translatable="yes">_Encrypt outgoing messages (by default)</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -3054,6 +3101,7 @@
 			  <property name="label" translatable="yes">Digitally _sign outgoing messages (by default)</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -3138,6 +3186,11 @@
   <property name="modal">False</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
     <widget class="GtkHBox" id="toplevel">
@@ -3203,6 +3256,7 @@
 		  <property name="label">gtk-add</property>
 		  <property name="use_stock">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
 		</widget>
 	      </child>
 
@@ -3215,6 +3269,7 @@
 		  <property name="label" translatable="yes">_Edit</property>
 		  <property name="use_underline">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
 		</widget>
 	      </child>
 
@@ -3227,6 +3282,7 @@
 		  <property name="label">gtk-remove</property>
 		  <property name="use_stock">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
 		</widget>
 	      </child>
 	    </widget>
@@ -3274,6 +3330,7 @@
 		  <property name="label" translatable="yes">De_fault</property>
 		  <property name="use_underline">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
 		</widget>
 	      </child>
 
@@ -3286,6 +3343,7 @@
 		  <property name="label" translatable="yes">E_nable</property>
 		  <property name="use_underline">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
 		</widget>
 	      </child>
 	    </widget>
@@ -3313,6 +3371,11 @@
   <property name="modal">False</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
     <widget class="GtkNotebook" id="toplevel">
@@ -3352,6 +3415,7 @@
 		      <property name="label" translatable="yes">_Use the same fonts as other applications</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -3406,6 +3470,7 @@
 			  <property name="show_size">True</property>
 			  <property name="use_font_in_label">False</property>
 			  <property name="label_font_size">14</property>
+			  <property name="focus_on_click">True</property>
 			  <signal name="font_set" handler="changed"/>
 			</widget>
 			<packing>
@@ -3427,6 +3492,7 @@
 			  <property name="show_size">True</property>
 			  <property name="use_font_in_label">False</property>
 			  <property name="label_font_size">14</property>
+			  <property name="focus_on_click">True</property>
 			  <signal name="font_set" handler="changed"/>
 			</widget>
 			<packing>
@@ -3526,6 +3592,7 @@
 			  <property name="label" translatable="yes">_Mark messages as read after</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -3667,6 +3734,7 @@
 			  <property name="label" translatable="yes">Highlight _quotations with</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <property name="active">True</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
@@ -3685,6 +3753,7 @@
 			  <property name="dither">True</property>
 			  <property name="use_alpha">False</property>
 			  <property name="title" translatable="yes">Pick a color</property>
+			  <property name="focus_on_click">True</property>
 			</widget>
 			<packing>
 			  <property name="padding">0</property>
@@ -3770,6 +3839,7 @@
 		      <property name="label" translatable="yes">Empty _trash folders on exit</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -3788,6 +3858,7 @@
 		      <property name="label" translatable="yes">_Confirm when expunging a folder</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -3822,172 +3893,13 @@
 	    </widget>
 	    <packing>
 	      <property name="padding">0</property>
-	      <property name="expand">True</property>
+	      <property name="expand">False</property>
 	      <property name="fill">True</property>
 	    </packing>
 	  </child>
 
 	  <child>
-	    <widget class="GtkFrame" id="frameNewMailNotify">
-	      <property name="visible">True</property>
-	      <property name="label_xalign">0</property>
-	      <property name="label_yalign">0.5</property>
-	      <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
-
-	      <child>
-		<widget class="GtkVBox" id="vboxNewMailNotify">
-		  <property name="border_width">6</property>
-		  <property name="visible">True</property>
-		  <property name="homogeneous">False</property>
-		  <property name="spacing">3</property>
-
-		  <child>
-		    <widget class="GtkRadioButton" id="radNotifyNot">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">_Do not notify me when new mail arrives</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">True</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">False</property>
-		      <property name="fill">False</property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkRadioButton" id="radNotifyBeep">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">_Beep when new mail arrives</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		      <property name="group">radNotifyNot</property>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">False</property>
-		      <property name="fill">False</property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkRadioButton" id="radNotifyPlaySound">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">_Play sound file when new mail arrives</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		      <property name="group">radNotifyNot</property>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">False</property>
-		      <property name="fill">False</property>
-		    </packing>
-		  </child>
-
-		  <child>
-		    <widget class="GtkHBox" id="hbox154">
-		      <property name="border_width">3</property>
-		      <property name="visible">True</property>
-		      <property name="homogeneous">False</property>
-		      <property name="spacing">3</property>
-
-		      <child>
-			<widget class="GtkLabel" id="lblNotifyFilename">
-			  <property name="visible">True</property>
-			  <property name="label" translatable="yes">Specify _filename:</property>
-			  <property name="use_underline">True</property>
-			  <property name="use_markup">False</property>
-			  <property name="justify">GTK_JUSTIFY_CENTER</property>
-			  <property name="wrap">False</property>
-			  <property name="selectable">False</property>
-			  <property name="xalign">0.5</property>
-			  <property name="yalign">0.5</property>
-			  <property name="xpad">0</property>
-			  <property name="ypad">0</property>
-			  <property name="mnemonic_widget">txtNotifyPlaySound</property>
-			</widget>
-			<packing>
-			  <property name="padding">0</property>
-			  <property name="expand">False</property>
-			  <property name="fill">False</property>
-			</packing>
-		      </child>
-
-		      <child>
-			<widget class="GnomeFileEntry" id="fileNotifyPlaySound">
-			  <property name="visible">True</property>
-			  <property name="max_saved">10</property>
-			  <property name="browse_dialog_title" translatable="yes">Execute Command...</property>
-			  <property name="directory_entry">False</property>
-			  <property name="modal">False</property>
-
-			  <child internal-child="entry">
-			    <widget class="GtkEntry" id="txtNotifyPlaySound">
-			      <property name="visible">True</property>
-			      <property name="can_focus">True</property>
-			      <property name="editable">True</property>
-			      <property name="visibility">True</property>
-			      <property name="max_length">0</property>
-			      <property name="text" translatable="yes"></property>
-			      <property name="has_frame">True</property>
-			      <property name="invisible_char" translatable="yes">*</property>
-			      <property name="activates_default">False</property>
-			    </widget>
-			  </child>
-			</widget>
-			<packing>
-			  <property name="padding">0</property>
-			  <property name="expand">True</property>
-			  <property name="fill">True</property>
-			</packing>
-		      </child>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">False</property>
-		      <property name="fill">False</property>
-		    </packing>
-		  </child>
-		</widget>
-	      </child>
-
-	      <child>
-		<widget class="GtkLabel" id="label454">
-		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">New Mail Notification</property>
-		  <property name="use_underline">False</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_LEFT</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0.5</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">0</property>
-		  <property name="ypad">0</property>
-		</widget>
-		<packing>
-		  <property name="type">label_item</property>
-		</packing>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="padding">0</property>
-	      <property name="expand">True</property>
-	      <property name="fill">True</property>
-	    </packing>
+	    <placeholder/>
 	  </child>
 	</widget>
 	<packing>
@@ -4043,6 +3955,7 @@
 		      <property name="label" translatable="yes">_Never load images off the net</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">True</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -4061,6 +3974,7 @@
 		      <property name="label" translatable="yes">_Load images if sender is in addressbook</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -4080,6 +3994,7 @@
 		      <property name="label" translatable="yes">_Always load images off the net</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -4127,6 +4042,7 @@
 	      <property name="label" translatable="yes">_Show animated images</property>
 	      <property name="use_underline">True</property>
 	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
 	      <property name="active">False</property>
 	      <property name="inconsistent">False</property>
 	      <property name="draw_indicator">True</property>
@@ -4145,6 +4061,7 @@
 	      <property name="label" translatable="yes">_Prompt when sending HTML messages to contacts that don't want them</property>
 	      <property name="use_underline">True</property>
 	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
 	      <property name="active">False</property>
 	      <property name="inconsistent">False</property>
 	      <property name="draw_indicator">True</property>
@@ -4212,6 +4129,7 @@
 		      <property name="dither">True</property>
 		      <property name="use_alpha">False</property>
 		      <property name="title" translatable="yes">Pick a color</property>
+		      <property name="focus_on_click">True</property>
 		    </widget>
 		    <packing>
 		      <property name="left_attach">1</property>
@@ -4230,6 +4148,7 @@
 		      <property name="dither">True</property>
 		      <property name="use_alpha">False</property>
 		      <property name="title" translatable="yes">Pick a color</property>
+		      <property name="focus_on_click">True</property>
 		    </widget>
 		    <packing>
 		      <property name="left_attach">1</property>
@@ -4248,6 +4167,7 @@
 		      <property name="dither">True</property>
 		      <property name="use_alpha">False</property>
 		      <property name="title" translatable="yes">Pick a color</property>
+		      <property name="focus_on_click">True</property>
 		    </widget>
 		    <packing>
 		      <property name="left_attach">1</property>
@@ -4266,6 +4186,7 @@
 		      <property name="dither">True</property>
 		      <property name="use_alpha">False</property>
 		      <property name="title" translatable="yes">Pick a color</property>
+		      <property name="focus_on_click">True</property>
 		    </widget>
 		    <packing>
 		      <property name="left_attach">1</property>
@@ -4284,6 +4205,7 @@
 		      <property name="dither">True</property>
 		      <property name="use_alpha">False</property>
 		      <property name="title" translatable="yes">Pick a color</property>
+		      <property name="focus_on_click">True</property>
 		    </widget>
 		    <packing>
 		      <property name="left_attach">1</property>
@@ -4412,6 +4334,7 @@
 		      <property name="label" translatable="yes">_Restore defaults</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		    </widget>
 		    <packing>
 		      <property name="left_attach">2</property>
@@ -4585,6 +4508,7 @@
 		      <property name="label">gtk-add</property>
 		      <property name="use_stock">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		    </widget>
 		    <packing>
 		      <property name="padding">6</property>
@@ -4600,6 +4524,7 @@
 		      <property name="label">gtk-remove</property>
 		      <property name="use_stock">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		    </widget>
 		    <packing>
 		      <property name="padding">0</property>
@@ -4668,6 +4593,7 @@
 		  <property name="label" translatable="yes">Check _Incoming Mail</property>
 		  <property name="use_underline">True</property>
 		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
 		  <property name="active">False</property>
 		  <property name="inconsistent">False</property>
 		  <property name="draw_indicator">True</property>
@@ -4747,6 +4673,545 @@
 	  <property name="type">tab</property>
 	</packing>
       </child>
+
+      <child>
+	<widget class="GtkVBox" id="vboxNewMailTab">
+	  <property name="border_width">6</property>
+	  <property name="visible">True</property>
+	  <property name="homogeneous">False</property>
+	  <property name="spacing">3</property>
+
+	  <child>
+	    <widget class="GtkHBox" id="hbox177">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">3</property>
+
+	      <child>
+		<widget class="GtkLabel" id="label478">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Notification _Type:</property>
+		  <property name="use_underline">True</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="mnemonic_widget">omenu_NotifyType</property>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkOptionMenu" id="omenu_NotifyType">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="history">0</property>
+
+		  <child>
+		    <widget class="GtkMenu" id="menu1">
+
+		      <child>
+			<widget class="GtkMenuItem" id="none_notify">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">None</property>
+			  <property name="use_underline">True</property>
+			</widget>
+		      </child>
+
+		      <child>
+			<widget class="GtkMenuItem" id="all_folders_notify">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">All Folders</property>
+			  <property name="use_underline">True</property>
+			</widget>
+		      </child>
+
+		      <child>
+			<widget class="GtkMenuItem" id="selected_folders_notify">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">Selected Folders</property>
+			  <property name="use_underline">True</property>
+			</widget>
+		      </child>
+		    </widget>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<placeholder/>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">False</property>
+	      <property name="fill">False</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkHBox" id="hbox178">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">3</property>
+
+	      <child>
+		<widget class="GtkLabel" id="label479">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Description:</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="lblDescNotifyType">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Do not notify when new mail arrived.</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">False</property>
+	      <property name="fill">False</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkVBox" id="vbox165">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">3</property>
+
+	      <child>
+		<widget class="GtkFrame" id="frameFolders">
+		  <property name="visible">True</property>
+		  <property name="sensitive">False</property>
+		  <property name="label_xalign">0</property>
+		  <property name="label_yalign">0.5</property>
+		  <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox179">
+		      <property name="border_width">6</property>
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">3</property>
+
+		      <child>
+			<widget class="GtkScrolledWindow" id="scrolledwindow50">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+			  <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+			  <property name="shadow_type">GTK_SHADOW_IN</property>
+			  <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+			  <child>
+			    <widget class="GtkTreeView" id="treeviewFolders">
+			      <property name="visible">True</property>
+			      <property name="can_focus">True</property>
+			      <property name="headers_visible">True</property>
+			      <property name="rules_hint">False</property>
+			      <property name="reorderable">False</property>
+			      <property name="enable_search">True</property>
+			    </widget>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">True</property>
+			  <property name="fill">True</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkVBox" id="vbox166">
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">3</property>
+
+			  <child>
+			    <widget class="GtkButton" id="buttonAddFolder">
+			      <property name="visible">True</property>
+			      <property name="can_focus">True</property>
+			      <property name="label">gtk-add</property>
+			      <property name="use_stock">True</property>
+			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkButton" id="buttonDelFolder">
+			      <property name="visible">True</property>
+			      <property name="sensitive">False</property>
+			      <property name="can_focus">True</property>
+			      <property name="label">gtk-remove</property>
+			      <property name="use_stock">True</property>
+			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkLabel" id="label485">
+			      <property name="visible">True</property>
+			      <property name="label" translatable="yes">
+
+
+
+
+
+</property>
+			      <property name="use_underline">False</property>
+			      <property name="use_markup">False</property>
+			      <property name="justify">GTK_JUSTIFY_LEFT</property>
+			      <property name="wrap">False</property>
+			      <property name="selectable">False</property>
+			      <property name="xalign">0.5</property>
+			      <property name="yalign">0.5</property>
+			      <property name="xpad">0</property>
+			      <property name="ypad">0</property>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+		    </widget>
+		  </child>
+
+		  <child>
+		    <widget class="GtkLabel" id="label484">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">Folders</property>
+		      <property name="use_underline">False</property>
+		      <property name="use_markup">False</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
+		      <property name="wrap">False</property>
+		      <property name="selectable">False</property>
+		      <property name="xalign">0.5</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		    </widget>
+		    <packing>
+		      <property name="type">label_item</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">True</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">False</property>
+	      <property name="fill">True</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkHBox" id="hbox181">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">6</property>
+
+	      <child>
+		<widget class="GtkFrame" id="frameImage">
+		  <property name="visible">True</property>
+		  <property name="sensitive">False</property>
+		  <property name="label_xalign">0</property>
+		  <property name="label_yalign">0.5</property>
+		  <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox180">
+		      <property name="border_width">6</property>
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">3</property>
+
+		      <child>
+			<widget class="GnomeIconEntry" id="iconentryImageNotify">
+			  <property name="visible">True</property>
+			  <property name="max_saved">10</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+		    </widget>
+		  </child>
+
+		  <child>
+		    <widget class="GtkLabel" id="label486">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">Image</property>
+		      <property name="use_underline">False</property>
+		      <property name="use_markup">False</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
+		      <property name="wrap">False</property>
+		      <property name="selectable">False</property>
+		      <property name="xalign">0.5</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		    </widget>
+		    <packing>
+		      <property name="type">label_item</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkFrame" id="frameSound">
+		  <property name="visible">True</property>
+		  <property name="sensitive">False</property>
+		  <property name="label_xalign">0</property>
+		  <property name="label_yalign">0.5</property>
+		  <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+
+		  <child>
+		    <widget class="GtkVBox" id="vboxNewMailNotify">
+		      <property name="border_width">6</property>
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">3</property>
+
+		      <child>
+			<widget class="GtkRadioButton" id="radNotifyBeep">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="label" translatable="yes">_Beep when new mail arrives</property>
+			  <property name="use_underline">True</property>
+			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
+			  <property name="active">False</property>
+			  <property name="inconsistent">False</property>
+			  <property name="draw_indicator">True</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkRadioButton" id="radNotifyPlaySound">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="label" translatable="yes">_Play sound file when new mail arrives</property>
+			  <property name="use_underline">True</property>
+			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
+			  <property name="active">False</property>
+			  <property name="inconsistent">False</property>
+			  <property name="draw_indicator">True</property>
+			  <property name="group">radNotifyBeep</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkHBox" id="hbox154">
+			  <property name="border_width">3</property>
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">3</property>
+
+			  <child>
+			    <widget class="GtkLabel" id="lblNotifyFilename">
+			      <property name="visible">True</property>
+			      <property name="label" translatable="yes">Specify _filename:</property>
+			      <property name="use_underline">True</property>
+			      <property name="use_markup">False</property>
+			      <property name="justify">GTK_JUSTIFY_CENTER</property>
+			      <property name="wrap">False</property>
+			      <property name="selectable">False</property>
+			      <property name="xalign">0.5</property>
+			      <property name="yalign">0.5</property>
+			      <property name="xpad">0</property>
+			      <property name="ypad">0</property>
+			      <property name="mnemonic_widget">txtNotifyPlaySound</property>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GnomeFileEntry" id="fileNotifyPlaySound">
+			      <property name="visible">True</property>
+			      <property name="max_saved">10</property>
+			      <property name="browse_dialog_title" translatable="yes">Execute Command...</property>
+			      <property name="directory_entry">False</property>
+			      <property name="modal">False</property>
+
+			      <child internal-child="entry">
+				<widget class="GtkEntry" id="txtNotifyPlaySound">
+				  <property name="visible">True</property>
+				  <property name="can_focus">True</property>
+				  <property name="editable">True</property>
+				  <property name="visibility">True</property>
+				  <property name="max_length">0</property>
+				  <property name="text" translatable="yes"></property>
+				  <property name="has_frame">True</property>
+				  <property name="invisible_char" translatable="yes">*</property>
+				  <property name="activates_default">False</property>
+				</widget>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">True</property>
+			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+		    </widget>
+		  </child>
+
+		  <child>
+		    <widget class="GtkLabel" id="label454">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">Sound</property>
+		      <property name="use_underline">False</property>
+		      <property name="use_markup">False</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
+		      <property name="wrap">False</property>
+		      <property name="selectable">False</property>
+		      <property name="xalign">0.5</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		    </widget>
+		    <packing>
+		      <property name="type">label_item</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">True</property>
+		  <property name="fill">True</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">False</property>
+	      <property name="fill">False</property>
+	    </packing>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="tab_expand">False</property>
+	  <property name="tab_fill">True</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkLabel" id="lblNewMail">
+	  <property name="visible">True</property>
+	  <property name="label" translatable="yes">_New Mail Notification</property>
+	  <property name="use_underline">True</property>
+	  <property name="use_markup">False</property>
+	  <property name="justify">GTK_JUSTIFY_LEFT</property>
+	  <property name="wrap">False</property>
+	  <property name="selectable">False</property>
+	  <property name="xalign">0.5</property>
+	  <property name="yalign">0.5</property>
+	  <property name="xpad">0</property>
+	  <property name="ypad">0</property>
+	</widget>
+	<packing>
+	  <property name="type">tab</property>
+	</packing>
+      </child>
     </widget>
   </child>
 </widget>
@@ -4758,6 +5223,11 @@
   <property name="modal">False</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
     <widget class="GtkNotebook" id="toplevel">
@@ -4854,6 +5324,10 @@
 			  <property name="yalign">0.5</property>
 			  <property name="xscale">0</property>
 			  <property name="yscale">1</property>
+			  <property name="top_padding">0</property>
+			  <property name="bottom_padding">0</property>
+			  <property name="left_padding">0</property>
+			  <property name="right_padding">0</property>
 
 			  <child>
 			    <widget class="GtkHBox" id="hboxReplyStyle">
@@ -5052,6 +5526,7 @@
 		      <property name="label" translatable="yes">Format messages in _HTML</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -5070,6 +5545,7 @@
 		      <property name="label" translatable="yes">_Automatically insert smiley images</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -5130,6 +5606,7 @@
 		      <property name="label" translatable="yes">_Prompt when sending messages with an empty subject line</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -5148,6 +5625,7 @@
 		      <property name="label" translatable="yes">Pr_ompt when sending messages with only Bcc recipients defined</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -5293,6 +5771,7 @@
 			  <property name="label">gtk-add</property>
 			  <property name="use_stock">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			</widget>
 		      </child>
 
@@ -5304,6 +5783,7 @@
 			  <property name="label" translatable="yes">Add Sc_ript</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <signal name="clicked" handler="cmdSignatureAddScriptClicked"/>
 			</widget>
 		      </child>
@@ -5316,6 +5796,7 @@
 			  <property name="label" translatable="yes">_Edit</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			</widget>
 		      </child>
 
@@ -5327,6 +5808,7 @@
 			  <property name="label">gtk-remove</property>
 			  <property name="use_stock">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			</widget>
 		      </child>
 		    </widget>
@@ -5560,6 +6042,7 @@
 			  <property name="label" translatable="yes">_Enable</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
 			  <signal name="clicked" handler="spellLanguageEnable"/>
 			</widget>
 		      </child>
@@ -5606,6 +6089,7 @@
 		      <property name="label" translatable="yes">Check spelling while I _type</property>
 		      <property name="use_underline">True</property>
 		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
 		      <property name="active">False</property>
 		      <property name="inconsistent">False</property>
 		      <property name="draw_indicator">True</property>
@@ -5652,6 +6136,7 @@
 			  <property name="dither">True</property>
 			  <property name="use_alpha">False</property>
 			  <property name="title" translatable="yes">Pick a color</property>
+			  <property name="focus_on_click">True</property>
 			  <signal name="color_set" handler="spellColorSet"/>
 			</widget>
 			<packing>
@@ -5731,6 +6216,11 @@
   <property name="modal">False</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
     <widget class="GtkVBox" id="toplevel">
@@ -5819,6 +6309,7 @@
 		  <property name="show_size">True</property>
 		  <property name="use_font_in_label">False</property>
 		  <property name="label_font_size">14</property>
+		  <property name="focus_on_click">True</property>
 		  <signal name="font_set" handler="changed"/>
 		</widget>
 		<packing>
@@ -5840,6 +6331,7 @@
 		  <property name="show_size">True</property>
 		  <property name="use_font_in_label">False</property>
 		  <property name="label_font_size">14</property>
+		  <property name="focus_on_click">True</property>
 		  <signal name="font_set" handler="changed"/>
 		</widget>
 		<packing>
@@ -5890,6 +6382,11 @@
   <property name="modal">False</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="has_separator">True</property>
 
   <child internal-child="vbox">
@@ -5911,6 +6408,7 @@
 	      <property name="label" translatable="yes">_Add Signature</property>
 	      <property name="use_underline">True</property>
 	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
 	      <property name="response_id">0</property>
 	    </widget>
 	  </child>
@@ -5923,6 +6421,7 @@
 	      <property name="label">gtk-cancel</property>
 	      <property name="use_stock">True</property>
 	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
 	      <property name="response_id">0</property>
 	    </widget>
 	  </child>
@@ -6141,6 +6640,11 @@
   <property name="modal">False</property>
   <property name="resizable">True</property>
   <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
     <widget class="GtkVBox" id="vbox163">
@@ -6156,6 +6660,7 @@
 	  <property name="label" translatable="yes">_Local Tests Only</property>
 	  <property name="use_underline">True</property>
 	  <property name="relief">GTK_RELIEF_NORMAL</property>
+	  <property name="focus_on_click">True</property>
 	  <property name="active">False</property>
 	  <property name="inconsistent">False</property>
 	  <property name="draw_indicator">True</property>
@@ -6174,6 +6679,7 @@
 	  <property name="label" translatable="yes">Use _Daemon</property>
 	  <property name="use_underline">True</property>
 	  <property name="relief">GTK_RELIEF_NORMAL</property>
+	  <property name="focus_on_click">True</property>
 	  <property name="active">False</property>
 	  <property name="inconsistent">False</property>
 	  <property name="draw_indicator">True</property>
Index: mail-config.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config.h,v
retrieving revision 1.113
diff -u -r1.113 mail-config.h
--- mail-config.h	1 Dec 2003 18:28:26 -0000	1.113
+++ mail-config.h	11 Jan 2004 10:28:26 -0000
@@ -73,12 +73,6 @@
 } MailConfigDisplayStyle;
 
 typedef enum {
-	MAIL_CONFIG_NOTIFY_NOT,
-	MAIL_CONFIG_NOTIFY_BEEP,
-	MAIL_CONFIG_NOTIFY_PLAY_SOUND,
-} MailConfigNewMailNotify;
-
-typedef enum {
 	MAIL_CONFIG_XMAILER_NONE            = 0,
 	MAIL_CONFIG_XMAILER_EVO             = 1,
 	MAIL_CONFIG_XMAILER_OTHER           = 2,
Index: mail-folder-cache.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-folder-cache.c,v
retrieving revision 1.77
diff -u -r1.77 mail-folder-cache.c
--- mail-folder-cache.c	10 Dec 2003 18:36:13 -0000	1.77
+++ mail-folder-cache.c	11 Jan 2004 10:28:26 -0000
@@ -53,6 +53,9 @@
 #include "mail-config.h"
 #include "em-folder-tree-model.h"
 
+/* New mail notification */
+#include "em-panel-applet.h"
+
 #define w(x) 
 #define d(x) /*(printf("%s(%d):%s: ",  __FILE__, __LINE__, __PRETTY_FUNCTION__), (x))*/
 
@@ -147,25 +150,9 @@
 static gboolean
 notify_idle_cb (gpointer user_data)
 {
-	GConfClient *gconf;
-	char *filename;
-	
-	gconf = mail_config_get_gconf_client ();
-	
-	switch (notify_type) {
-	case MAIL_CONFIG_NOTIFY_PLAY_SOUND:
-		filename = gconf_client_get_string (gconf, "/apps/evolution/mail/notify/sound", NULL);
-		if (filename != NULL) {
-			gnome_sound_play (filename);
-			g_free (filename);
-		}
-		break;
-	case MAIL_CONFIG_NOTIFY_BEEP:
-		gdk_beep ();
-		break;
-	default:
-		break;
-	}
+	GString *uri = (GString *) user_data;
+
+	em_tray_notify (TRUE, uri->str, notify_type);
 	
 	time (&last_notify);
 	
@@ -189,6 +176,7 @@
 	struct _folder_update *up;
 	struct _store_info *si;
 	time_t now;
+	GString *uri;
 	
 	component = mail_component_peek ();
 	model = mail_component_peek_tree_model (component);
@@ -238,8 +226,10 @@
 		}
 		
 		time (&now);
-		if (notify_type != 0 && up->new && notify_idle_id == 0 && (now - last_notify >= 5))
-			notify_idle_id = g_idle_add_full (G_PRIORITY_LOW, notify_idle_cb, NULL, NULL);
+		if (notify_type != 0 && up->new && notify_idle_id == 0 && (now - last_notify >= 5)) {
+			uri = g_string_new (notify_type == MAIL_CONFIG_NOTIFY_ALL ? up->path : up->uri);
+			notify_idle_id = g_idle_add_full (G_PRIORITY_LOW, notify_idle_cb, uri, NULL);
+		}
 		
 		free_update(up);
 		
@@ -353,6 +343,7 @@
 
 	up = g_malloc0(sizeof(*up));
 	up->path = g_strdup(mfi->path);
+	up->uri = g_strdup(mfi->uri); // For use with MAIL_CONFIG_NOTIFY_SELECTED notification
 	up->unread = unread;
 	up->new = new ? 1 : 0;
 	up->store = mfi->store_info->store;
#include	<glib-object.h>


#ifdef G_ENABLE_DEBUG
#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
#define g_marshal_value_peek_char(v)     g_value_get_char (v)
#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
#define g_marshal_value_peek_int(v)      g_value_get_int (v)
#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
#define g_marshal_value_peek_long(v)     g_value_get_long (v)
#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
#define g_marshal_value_peek_float(v)    g_value_get_float (v)
#define g_marshal_value_peek_double(v)   g_value_get_double (v)
#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
#define g_marshal_value_peek_param(v)    g_value_get_param (v)
#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
#define g_marshal_value_peek_object(v)   g_value_get_object (v)
#else /* !G_ENABLE_DEBUG */
/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
 *          Do not access GValues directly in your code. Instead, use the
 *          g_value_get_*() functions
 */
#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
#define g_marshal_value_peek_enum(v)     (v)->data[0].v_int
#define g_marshal_value_peek_flags(v)    (v)->data[0].v_uint
#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
#endif /* !G_ENABLE_DEBUG */


/* VOID:OBJECT,OBJECT (eggmarshalers.list:1) */
void
_egg_marshal_VOID__OBJECT_OBJECT (GClosure     *closure,
                                  GValue       *return_value,
                                  guint         n_param_values,
                                  const GValue *param_values,
                                  gpointer      invocation_hint,
                                  gpointer      marshal_data)
{
  typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer     data1,
                                                    gpointer     arg_1,
                                                    gpointer     arg_2,
                                                    gpointer     data2);
  register GMarshalFunc_VOID__OBJECT_OBJECT callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;

  g_return_if_fail (n_param_values == 3);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);

  callback (data1,
            g_marshal_value_peek_object (param_values + 1),
            g_marshal_value_peek_object (param_values + 2),
            data2);
}

/* VOID:OBJECT,STRING,LONG,LONG (eggmarshalers.list:2) */
void
_egg_marshal_VOID__OBJECT_STRING_LONG_LONG (GClosure     *closure,
                                            GValue       *return_value,
                                            guint         n_param_values,
                                            const GValue *param_values,
                                            gpointer      invocation_hint,
                                            gpointer      marshal_data)
{
  typedef void (*GMarshalFunc_VOID__OBJECT_STRING_LONG_LONG) (gpointer     data1,
                                                              gpointer     arg_1,
                                                              gpointer     arg_2,
                                                              glong        arg_3,
                                                              glong        arg_4,
                                                              gpointer     data2);
  register GMarshalFunc_VOID__OBJECT_STRING_LONG_LONG callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;

  g_return_if_fail (n_param_values == 5);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_VOID__OBJECT_STRING_LONG_LONG) (marshal_data ? marshal_data : cc->callback);

  callback (data1,
            g_marshal_value_peek_object (param_values + 1),
            g_marshal_value_peek_string (param_values + 2),
            g_marshal_value_peek_long (param_values + 3),
            g_marshal_value_peek_long (param_values + 4),
            data2);
}

/* VOID:OBJECT,LONG (eggmarshalers.list:3) */
void
_egg_marshal_VOID__OBJECT_LONG (GClosure     *closure,
                                GValue       *return_value,
                                guint         n_param_values,
                                const GValue *param_values,
                                gpointer      invocation_hint,
                                gpointer      marshal_data)
{
  typedef void (*GMarshalFunc_VOID__OBJECT_LONG) (gpointer     data1,
                                                  gpointer     arg_1,
                                                  glong        arg_2,
                                                  gpointer     data2);
  register GMarshalFunc_VOID__OBJECT_LONG callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;

  g_return_if_fail (n_param_values == 3);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_VOID__OBJECT_LONG) (marshal_data ? marshal_data : cc->callback);

  callback (data1,
            g_marshal_value_peek_object (param_values + 1),
            g_marshal_value_peek_long (param_values + 2),
            data2);
}

/* VOID:OBJECT,STRING,STRING (eggmarshalers.list:4) */
void
_egg_marshal_VOID__OBJECT_STRING_STRING (GClosure     *closure,
                                         GValue       *return_value,
                                         guint         n_param_values,
                                         const GValue *param_values,
                                         gpointer      invocation_hint,
                                         gpointer      marshal_data)
{
  typedef void (*GMarshalFunc_VOID__OBJECT_STRING_STRING) (gpointer     data1,
                                                           gpointer     arg_1,
                                                           gpointer     arg_2,
                                                           gpointer     arg_3,
                                                           gpointer     data2);
  register GMarshalFunc_VOID__OBJECT_STRING_STRING callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;

  g_return_if_fail (n_param_values == 4);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_VOID__OBJECT_STRING_STRING) (marshal_data ? marshal_data : cc->callback);

  callback (data1,
            g_marshal_value_peek_object (param_values + 1),
            g_marshal_value_peek_string (param_values + 2),
            g_marshal_value_peek_string (param_values + 3),
            data2);
}

/* VOID:UINT,UINT (eggmarshalers.list:5) */
void
_egg_marshal_VOID__UINT_UINT (GClosure     *closure,
                              GValue       *return_value,
                              guint         n_param_values,
                              const GValue *param_values,
                              gpointer      invocation_hint,
                              gpointer      marshal_data)
{
  typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer     data1,
                                                guint        arg_1,
                                                guint        arg_2,
                                                gpointer     data2);
  register GMarshalFunc_VOID__UINT_UINT callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;

  g_return_if_fail (n_param_values == 3);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);

  callback (data1,
            g_marshal_value_peek_uint (param_values + 1),
            g_marshal_value_peek_uint (param_values + 2),
            data2);
}

/* BOOLEAN:INT (eggmarshalers.list:6) */
void
_egg_marshal_BOOLEAN__INT (GClosure     *closure,
                           GValue       *return_value,
                           guint         n_param_values,
                           const GValue *param_values,
                           gpointer      invocation_hint,
                           gpointer      marshal_data)
{
  typedef gboolean (*GMarshalFunc_BOOLEAN__INT) (gpointer     data1,
                                                 gint         arg_1,
                                                 gpointer     data2);
  register GMarshalFunc_BOOLEAN__INT callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;
  gboolean v_return;

  g_return_if_fail (return_value != NULL);
  g_return_if_fail (n_param_values == 2);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_BOOLEAN__INT) (marshal_data ? marshal_data : cc->callback);

  v_return = callback (data1,
                       g_marshal_value_peek_int (param_values + 1),
                       data2);

  g_value_set_boolean (return_value, v_return);
}

/* BOOLEAN:ENUM (eggmarshalers.list:7) */
void
_egg_marshal_BOOLEAN__ENUM (GClosure     *closure,
                            GValue       *return_value,
                            guint         n_param_values,
                            const GValue *param_values,
                            gpointer      invocation_hint,
                            gpointer      marshal_data)
{
  typedef gboolean (*GMarshalFunc_BOOLEAN__ENUM) (gpointer     data1,
                                                  gint         arg_1,
                                                  gpointer     data2);
  register GMarshalFunc_BOOLEAN__ENUM callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;
  gboolean v_return;

  g_return_if_fail (return_value != NULL);
  g_return_if_fail (n_param_values == 2);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_BOOLEAN__ENUM) (marshal_data ? marshal_data : cc->callback);

  v_return = callback (data1,
                       g_marshal_value_peek_enum (param_values + 1),
                       data2);

  g_value_set_boolean (return_value, v_return);
}

/* BOOLEAN:VOID (eggmarshalers.list:8) */
void
_egg_marshal_BOOLEAN__VOID (GClosure     *closure,
                            GValue       *return_value,
                            guint         n_param_values,
                            const GValue *param_values,
                            gpointer      invocation_hint,
                            gpointer      marshal_data)
{
  typedef gboolean (*GMarshalFunc_BOOLEAN__VOID) (gpointer     data1,
                                                  gpointer     data2);
  register GMarshalFunc_BOOLEAN__VOID callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;
  gboolean v_return;

  g_return_if_fail (return_value != NULL);
  g_return_if_fail (n_param_values == 1);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_BOOLEAN__VOID) (marshal_data ? marshal_data : cc->callback);

  v_return = callback (data1,
                       data2);

  g_value_set_boolean (return_value, v_return);
}

/* OBJECT:VOID (eggmarshalers.list:9) */
void
_egg_marshal_OBJECT__VOID (GClosure     *closure,
                           GValue       *return_value,
                           guint         n_param_values,
                           const GValue *param_values,
                           gpointer      invocation_hint,
                           gpointer      marshal_data)
{
  typedef GObject* (*GMarshalFunc_OBJECT__VOID) (gpointer     data1,
                                                 gpointer     data2);
  register GMarshalFunc_OBJECT__VOID callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;
  GObject* v_return;

  g_return_if_fail (return_value != NULL);
  g_return_if_fail (n_param_values == 1);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_OBJECT__VOID) (marshal_data ? marshal_data : cc->callback);

  v_return = callback (data1,
                       data2);

  g_value_take_object (return_value, v_return);
}

/* VOID:VOID (eggmarshalers.list:10) */

/* VOID:INT,INT (eggmarshalers.list:11) */
void
_egg_marshal_VOID__INT_INT (GClosure     *closure,
                            GValue       *return_value,
                            guint         n_param_values,
                            const GValue *param_values,
                            gpointer      invocation_hint,
                            gpointer      marshal_data)
{
  typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer     data1,
                                              gint         arg_1,
                                              gint         arg_2,
                                              gpointer     data2);
  register GMarshalFunc_VOID__INT_INT callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;

  g_return_if_fail (n_param_values == 3);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback);

  callback (data1,
            g_marshal_value_peek_int (param_values + 1),
            g_marshal_value_peek_int (param_values + 2),
            data2);
}

/* VOID:UINT,UINT (eggmarshalers.list:12) */

/* VOID:BOOLEAN (eggmarshalers.list:13) */

/* VOID:OBJECT,ENUM,BOXED (eggmarshalers.list:14) */
void
_egg_marshal_VOID__OBJECT_ENUM_BOXED (GClosure     *closure,
                                      GValue       *return_value,
                                      guint         n_param_values,
                                      const GValue *param_values,
                                      gpointer      invocation_hint,
                                      gpointer      marshal_data)
{
  typedef void (*GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (gpointer     data1,
                                                        gpointer     arg_1,
                                                        gint         arg_2,
                                                        gpointer     arg_3,
                                                        gpointer     data2);
  register GMarshalFunc_VOID__OBJECT_ENUM_BOXED callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;

  g_return_if_fail (n_param_values == 4);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (marshal_data ? marshal_data : cc->callback);

  callback (data1,
            g_marshal_value_peek_object (param_values + 1),
            g_marshal_value_peek_enum (param_values + 2),
            g_marshal_value_peek_boxed (param_values + 3),
            data2);
}

/* VOID:BOXED (eggmarshalers.list:15) */

/* BOOLEAN:BOOLEAN (eggmarshalers.list:16) */
void
_egg_marshal_BOOLEAN__BOOLEAN (GClosure     *closure,
                               GValue       *return_value,
                               guint         n_param_values,
                               const GValue *param_values,
                               gpointer      invocation_hint,
                               gpointer      marshal_data)
{
  typedef gboolean (*GMarshalFunc_BOOLEAN__BOOLEAN) (gpointer     data1,
                                                     gboolean     arg_1,
                                                     gpointer     data2);
  register GMarshalFunc_BOOLEAN__BOOLEAN callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;
  gboolean v_return;

  g_return_if_fail (return_value != NULL);
  g_return_if_fail (n_param_values == 2);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_BOOLEAN__BOOLEAN) (marshal_data ? marshal_data : cc->callback);

  v_return = callback (data1,
                       g_marshal_value_peek_boolean (param_values + 1),
                       data2);

  g_value_set_boolean (return_value, v_return);
}

/* BOOLEAN:OBJECT,STRING,STRING (eggmarshalers.list:17) */
void
_egg_marshal_BOOLEAN__OBJECT_STRING_STRING (GClosure     *closure,
                                            GValue       *return_value,
                                            guint         n_param_values,
                                            const GValue *param_values,
                                            gpointer      invocation_hint,
                                            gpointer      marshal_data)
{
  typedef gboolean (*GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING) (gpointer     data1,
                                                                  gpointer     arg_1,
                                                                  gpointer     arg_2,
                                                                  gpointer     arg_3,
                                                                  gpointer     data2);
  register GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;
  gboolean v_return;

  g_return_if_fail (return_value != NULL);
  g_return_if_fail (n_param_values == 4);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING) (marshal_data ? marshal_data : cc->callback);

  v_return = callback (data1,
                       g_marshal_value_peek_object (param_values + 1),
                       g_marshal_value_peek_string (param_values + 2),
                       g_marshal_value_peek_string (param_values + 3),
                       data2);

  g_value_set_boolean (return_value, v_return);
}

#ifndef ___egg_marshal_MARSHAL_H__
#define ___egg_marshal_MARSHAL_H__

#include	<glib-object.h>

G_BEGIN_DECLS

/* VOID:OBJECT,OBJECT (eggmarshalers.list:1) */
extern void _egg_marshal_VOID__OBJECT_OBJECT (GClosure     *closure,
                                              GValue       *return_value,
                                              guint         n_param_values,
                                              const GValue *param_values,
                                              gpointer      invocation_hint,
                                              gpointer      marshal_data);

/* VOID:OBJECT,STRING,LONG,LONG (eggmarshalers.list:2) */
extern void _egg_marshal_VOID__OBJECT_STRING_LONG_LONG (GClosure     *closure,
                                                        GValue       *return_value,
                                                        guint         n_param_values,
                                                        const GValue *param_values,
                                                        gpointer      invocation_hint,
                                                        gpointer      marshal_data);

/* VOID:OBJECT,LONG (eggmarshalers.list:3) */
extern void _egg_marshal_VOID__OBJECT_LONG (GClosure     *closure,
                                            GValue       *return_value,
                                            guint         n_param_values,
                                            const GValue *param_values,
                                            gpointer      invocation_hint,
                                            gpointer      marshal_data);

/* VOID:OBJECT,STRING,STRING (eggmarshalers.list:4) */
extern void _egg_marshal_VOID__OBJECT_STRING_STRING (GClosure     *closure,
                                                     GValue       *return_value,
                                                     guint         n_param_values,
                                                     const GValue *param_values,
                                                     gpointer      invocation_hint,
                                                     gpointer      marshal_data);

/* VOID:UINT,UINT (eggmarshalers.list:5) */
extern void _egg_marshal_VOID__UINT_UINT (GClosure     *closure,
                                          GValue       *return_value,
                                          guint         n_param_values,
                                          const GValue *param_values,
                                          gpointer      invocation_hint,
                                          gpointer      marshal_data);

/* BOOLEAN:INT (eggmarshalers.list:6) */
extern void _egg_marshal_BOOLEAN__INT (GClosure     *closure,
                                       GValue       *return_value,
                                       guint         n_param_values,
                                       const GValue *param_values,
                                       gpointer      invocation_hint,
                                       gpointer      marshal_data);

/* BOOLEAN:ENUM (eggmarshalers.list:7) */
extern void _egg_marshal_BOOLEAN__ENUM (GClosure     *closure,
                                        GValue       *return_value,
                                        guint         n_param_values,
                                        const GValue *param_values,
                                        gpointer      invocation_hint,
                                        gpointer      marshal_data);

/* BOOLEAN:VOID (eggmarshalers.list:8) */
extern void _egg_marshal_BOOLEAN__VOID (GClosure     *closure,
                                        GValue       *return_value,
                                        guint         n_param_values,
                                        const GValue *param_values,
                                        gpointer      invocation_hint,
                                        gpointer      marshal_data);

/* OBJECT:VOID (eggmarshalers.list:9) */
extern void _egg_marshal_OBJECT__VOID (GClosure     *closure,
                                       GValue       *return_value,
                                       guint         n_param_values,
                                       const GValue *param_values,
                                       gpointer      invocation_hint,
                                       gpointer      marshal_data);

/* VOID:VOID (eggmarshalers.list:10) */
#define _egg_marshal_VOID__VOID	g_cclosure_marshal_VOID__VOID

/* VOID:INT,INT (eggmarshalers.list:11) */
extern void _egg_marshal_VOID__INT_INT (GClosure     *closure,
                                        GValue       *return_value,
                                        guint         n_param_values,
                                        const GValue *param_values,
                                        gpointer      invocation_hint,
                                        gpointer      marshal_data);

/* VOID:UINT,UINT (eggmarshalers.list:12) */

/* VOID:BOOLEAN (eggmarshalers.list:13) */
#define _egg_marshal_VOID__BOOLEAN	g_cclosure_marshal_VOID__BOOLEAN

/* VOID:OBJECT,ENUM,BOXED (eggmarshalers.list:14) */
extern void _egg_marshal_VOID__OBJECT_ENUM_BOXED (GClosure     *closure,
                                                  GValue       *return_value,
                                                  guint         n_param_values,
                                                  const GValue *param_values,
                                                  gpointer      invocation_hint,
                                                  gpointer      marshal_data);

/* VOID:BOXED (eggmarshalers.list:15) */
#define _egg_marshal_VOID__BOXED	g_cclosure_marshal_VOID__BOXED

/* BOOLEAN:BOOLEAN (eggmarshalers.list:16) */
extern void _egg_marshal_BOOLEAN__BOOLEAN (GClosure     *closure,
                                           GValue       *return_value,
                                           guint         n_param_values,
                                           const GValue *param_values,
                                           gpointer      invocation_hint,
                                           gpointer      marshal_data);

/* BOOLEAN:OBJECT,STRING,STRING (eggmarshalers.list:17) */
extern void _egg_marshal_BOOLEAN__OBJECT_STRING_STRING (GClosure     *closure,
                                                        GValue       *return_value,
                                                        guint         n_param_values,
                                                        const GValue *param_values,
                                                        gpointer      invocation_hint,
                                                        gpointer      marshal_data);

G_END_DECLS

#endif /* ___egg_marshal_MARSHAL_H__ */

/* -*- 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_xscreen (Screen *xscreen, const char *name)
{
  GdkDisplay *display;
  GdkScreen *screen;

  display = gdk_x11_lookup_xdisplay (DisplayOfScreen (xscreen));
  screen = gdk_display_get_screen (display, XScreenNumberOfScreen (xscreen));

  return egg_tray_icon_new_for_screen (screen, name);
}

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;
}
/* -*- 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__ */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */

#include <gtk/gtk.h>
#include <gnome.h>
#include <gconf/gconf-client.h>
#include "e-util/eggtrayicon.h"
#include "e-util/eggtraymanager.h"
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
#include "em-folder-tree.h"
#include "em-folder-selector.h"
#include "em-panel-applet.h"
#include "em-mailer-prefs.h"

static gboolean em_tray_blink_icon (EvolutionTray *evo_tray);
static void em_tray_update_status (EvolutionTray *evo_tray);
static gboolean em_tray_folder_registered (gchar *uri);
static FolderTrayNotify * em_tray_get_folder_info (gchar *uri);
static FolderTrayNotify * em_tray_get_folders_from_xml (const char *xml);
static gboolean em_tray_icon_press (GtkWidget *widget, GdkEventButton *event, EvolutionTray *evo_tray);
static void em_tray_about (GtkMenuItem *menuitem, gpointer user_data);
static GdkPixbuf * em_tray_blank_icon ();
static void em_tray_create_ui (EvolutionTray *evo_tray);

static EvolutionTray *evo_tray;
static GtkWidget *image, *evbox;
static gint notify_type;
static GdkPixbuf *icon;
static gchar *show_uri;

char *
em_folder_tray_notify_to_xml (FolderTrayNotify *folder_notify)
{
        xmlDocPtr doc;
        xmlNodePtr root;
        xmlChar *xmlbuf;
        int n;
        char *tmp;
        
        doc = xmlNewDoc ("1.0");
        
        root = xmlNewDocNode (doc, NULL, "folder", NULL);
        xmlDocSetRootElement (doc, root);
        
        xmlSetProp (root, "id", folder_notify->id);
        
        xmlNewTextChild (root, NULL, "name", folder_notify->name);
        xmlNewTextChild (root, NULL, "image", folder_notify->image);
        xmlNewTextChild (root, NULL, "sound", folder_notify->sound);
        xmlNewTextChild (root, NULL, "beep", folder_notify->beep);

        xmlDocDumpMemory (doc, &xmlbuf, &n);
        xmlFreeDoc (doc);
        
        tmp = g_malloc (n + 1);
        memcpy (tmp, xmlbuf, n);
        tmp[n] = '\0';
        xmlFree (xmlbuf);
        
        return tmp;
}

static gboolean
em_tray_blink_icon (EvolutionTray *evo_tray)
{
        evo_tray->blink = !evo_tray->blink;
        
        if (egg_tray_manager_check_running (evo_tray->current_screen)) {
                if (evo_tray->newmail && egg_tray_manager_check_running (evo_tray->current_screen)) {
                        if (evo_tray->blink)
                                gtk_image_set_from_pixbuf (GTK_IMAGE (image), evo_tray->blank_icon);
                        else
                                gtk_image_set_from_pixbuf (GTK_IMAGE (image), icon);
                        
                        return TRUE;
                } else {
                        gtk_image_set_from_pixbuf (GTK_IMAGE (image), evo_tray->icon);

                        gtk_tooltips_set_tip (evo_tray->tray_icon_tooltip, GTK_WIDGET (evo_tray->tray_icon),
                                              _("Evolution New Mail Notification"),
                                              NULL);
                }
        }
        
        return FALSE;
}

static void
em_tray_update_status (EvolutionTray *evo_tray)
{
        if (egg_tray_manager_check_running (evo_tray->current_screen))
                g_timeout_add (500, em_tray_blink_icon, evo_tray);
}

static gboolean
em_tray_folder_registered (gchar *uri)
{
        gboolean cont;
        GtkTreeIter iter;
        gchar *id;
        
        for (cont = gtk_tree_model_get_iter_first ((GtkTreeModel *) evo_tray->model, &iter); cont;
             cont = gtk_tree_model_iter_next ((GtkTreeModel *) evo_tray->model, &iter)) {
                
                gtk_tree_model_get (evo_tray->model, &iter,
                                    NOTIFY_ID_COLUMN, &id,
                                    -1);
                
                if (!strcmp (uri, id))
                        return TRUE;
        }
        
        return FALSE;
}

static FolderTrayNotify *
em_tray_get_folder_info (gchar *uri)
{
        gboolean cont;
        GtkTreeIter iter;
        gchar *id, *name, *image, *sound, *beep;
        FolderTrayNotify *folder;
        
        folder = g_new0 (FolderTrayNotify, 1);
        
        for (cont = gtk_tree_model_get_iter_first ((GtkTreeModel *) evo_tray->model, &iter); cont;
             cont = gtk_tree_model_iter_next ((GtkTreeModel *) evo_tray->model, &iter)) {
                
                gtk_tree_model_get (evo_tray->model, &iter,
                                    NOTIFY_ID_COLUMN, &id,
                                    NOTIFY_NAME_COLUMN, &name,
                                    NOTIFY_IMAGE_COLUMN, &image,
                                    NOTIFY_SOUND_COLUMN, &sound,
                                    NOTIFY_BEEP_COLUMN, &beep,
                                    -1);
                
                if (!strcmp (uri, id))
                        break;
        }
        
        folder->id = id;
        folder->name = name;
        folder->image = image;
        folder->sound = sound;
        folder->beep = beep;

        return folder;
}

static gboolean
em_tray_icon_press (GtkWidget *widget, GdkEventButton *event, EvolutionTray *evo_tray)
{
        switch (event->button) {
        case 1:
                evo_tray->newmail = FALSE;
                em_tray_update_status (evo_tray);
                return TRUE;
                break;
        case 3:
                gtk_menu_popup (GTK_MENU (evo_tray->popup_menu),
                                NULL,
                                NULL,
                                NULL,
                                NULL,
                                event->button,
                                event->time);
                return TRUE;
                break;
        default:
                return FALSE;
                break;
        }
}

static FolderTrayNotify *
em_tray_get_folders_from_xml (const char *xml)
{
        xmlNodePtr node;
        xmlDocPtr doc;
        FolderTrayNotify *folder;
        
        
        if (!(doc = xmlParseDoc ((char*) xml)))
                return NULL;
        
        node = doc->children;
        if (strcmp (node->name, "folder") != 0) {
                xmlFreeDoc (doc);
                return NULL;
        }
        
        folder = g_new0 (FolderTrayNotify, 1);
        
        folder->id = g_strdup (xmlGetProp (node, "id"));
        
        for (node = node->children; node; node = node->next) {
                if (!strcmp (node->name, "name"))
                        folder->name = g_strdup (xmlNodeGetContent (node));

                if (!strcmp (node->name, "image"))
                        folder->image = g_strdup (xmlNodeGetContent (node));

                if (!strcmp (node->name, "sound"))
                        folder->sound = g_strdup (xmlNodeGetContent (node));

                if (!strcmp (node->name, "beep"))
                        folder->beep = g_strdup (xmlNodeGetContent (node));
        }

        xmlFreeDoc (doc);

        return folder;
}

void
em_tray_folders_refresh ()
{
        GSList *list, *l;
        GtkTreeIter iter;
        FolderTrayNotify *folder;
        
        list = gconf_client_get_list (evo_tray->conf_client,
                                      "/apps/evolution/mail/notify/folders",
                                      GCONF_VALUE_STRING,
                                      NULL);
        if (!list)
                return;
        
        gtk_list_store_clear (GTK_LIST_STORE (evo_tray->model));
        
        for (l = list; l; l = l->next) {
                folder = em_tray_get_folders_from_xml (l->data);
                
                gtk_list_store_append (GTK_LIST_STORE (evo_tray->model), &iter);
                gtk_list_store_set (GTK_LIST_STORE (evo_tray->model),
                                    &iter,
                                    NOTIFY_PIXBUF_COLUMN, em_tray_get_image_scaled (folder->image),
                                    NOTIFY_NAME_COLUMN, folder->name,
                                    NOTIFY_SOUND_COLUMN, folder->sound,
                                    NOTIFY_ID_COLUMN, folder->id,
                                    NOTIFY_IMAGE_COLUMN, folder->image,
                                    NOTIFY_BEEP_COLUMN, folder->beep,
                                    -1);
        }
}

static void
em_tray_about (GtkMenuItem *menuitem, gpointer user_data)
{
        static GtkWidget *about = NULL;
        GdkPixbuf *pixbuf = NULL;
        const gchar *authors[] = {"Miguel Angel L� Hern�ez <miguel gulev org mx>", NULL};
        const gchar *documenters[] = {NULL};
        const gchar *translator_credits = "translator_credits";

        if (about != NULL) {
                gdk_window_raise (about->window);
                gdk_window_show (about->window);
                return;
        }

        pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_IMAGES "/ico-mail.png", NULL);

        about = gnome_about_new ("Evolution Notification Applet",
                                 "0.0.1",
                                 "Copyright \xc2\xa9 2003-2004 Miguel Angel L� Hern�ez",
                                 "Evolution notification applet",
                                 (const char**)authors,
                                 (const char**)documenters,
                                 strcmp (translator_credits, "translator_credits") != 0 ? translator_credits : NULL,
                                 pixbuf);

        if (pixbuf != NULL)
                gdk_pixbuf_unref (pixbuf);

        g_signal_connect (G_OBJECT (about), "destroy", G_CALLBACK (gtk_widget_destroyed), &about);

        g_object_add_weak_pointer (G_OBJECT (about), (void **)&(about));

        gtk_widget_show (about);
}

GdkPixbuf *
em_tray_get_image_scaled (gchar *image_file)
{
        GdkPixbuf *tmp, *scaled;
        gint width, height;

        tmp = gdk_pixbuf_new_from_file (image_file, NULL);
        gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &width, &height);
        scaled = gdk_pixbuf_scale_simple (tmp, width, height, GDK_INTERP_BILINEAR);

        return scaled;
}

static GdkPixbuf *
em_tray_blank_icon ()
{
        GdkPixbuf *blank;
        gint width, height;

        gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &width, &height);
        blank = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
        gdk_pixbuf_fill (blank, 0);

        return blank;
}

static void
em_tray_create_ui (EvolutionTray *evo_tray)
{
        GtkWidget *item;

        evo_tray->tray_icon = egg_tray_icon_new (_("Evolution Tray Icon"));

        evo_tray->icon = em_tray_get_image_scaled (DEFAULT_IMAGE_NOTIFY);

        image = gtk_image_new_from_pixbuf (evo_tray->icon);

        evo_tray->blank_icon = em_tray_blank_icon ();

        /* Tooltip */
        evo_tray->tray_icon_tooltip = gtk_tooltips_new ();
        gtk_tooltips_set_tip (evo_tray->tray_icon_tooltip, GTK_WIDGET (evo_tray->tray_icon),
                              _("Evolution New Mail Notification"),
                              NULL);

        /* Event box */
        evbox = gtk_event_box_new ();
        g_signal_connect (G_OBJECT (evbox), "button_press_event", G_CALLBACK (em_tray_icon_press), (gpointer) evo_tray);

        /* Popup menu */
        evo_tray->popup_menu = gtk_menu_new ();

        item = gtk_image_menu_item_new_from_stock (GNOME_STOCK_ABOUT, NULL);
        g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (em_tray_about), (gpointer) evo_tray);
        gtk_widget_show (item);
        gtk_menu_shell_append (GTK_MENU_SHELL (evo_tray->popup_menu), item);

        gtk_container_add (GTK_CONTAINER (evbox), image);
        gtk_container_add (GTK_CONTAINER (evo_tray->tray_icon), evbox);
        gtk_widget_show_all (GTK_WIDGET (evo_tray->tray_icon));

        evo_tray->created = TRUE;
}

GtkTreeModel *
em_tray_get_store ()
{
	return evo_tray->model;
}

void
em_tray_init ()
{
	evo_tray = g_new0 (EvolutionTray, 1);

        evo_tray->conf_client = gconf_client_get_default ();

        evo_tray->current_screen = gdk_screen_get_default();

        evo_tray->model = GTK_TREE_MODEL (gtk_list_store_new (NOTIFY_NUM_COLUMNS,
                                                              GDK_TYPE_PIXBUF,
                                                              G_TYPE_STRING,
                                                              G_TYPE_STRING,
                                                              G_TYPE_STRING,
                                                              G_TYPE_STRING,
                                                              G_TYPE_STRING));
        em_tray_folders_refresh ();

        if (egg_tray_manager_check_running (evo_tray->current_screen))
                em_tray_create_ui (evo_tray);
}

void
em_tray_notify (gboolean notify, gchar *uri, gint type)
{
        char *sound, *image_name;
        char *name, *tooltip;
        gboolean beep;
        FolderTrayNotify *folder;

        switch (type) {
        case MAIL_CONFIG_NOTIFY_ALL:
                beep = gconf_client_get_bool (evo_tray->conf_client, "/apps/evolution/mail/notify/beep", NULL);
                sound = gconf_client_get_string (evo_tray->conf_client, "/apps/evolution/mail/notify/sound", NULL);
                image_name = gconf_client_get_string (evo_tray->conf_client, "/apps/evolution/mail/notify/image", NULL);
                name = uri;
                break;
        case MAIL_CONFIG_NOTIFY_SELECTED:
                if (!em_tray_folder_registered (uri))
                        return;

                folder = em_tray_get_folder_info (uri);
                beep = !strcmp (folder->beep, "yes");
                sound = folder->sound;
                image_name = folder->image;
                name = folder->name;
                break;
        }

        show_uri = uri;
        icon = em_tray_get_image_scaled (image_name);
        tooltip = g_strdup_printf (_("New mail on:\n%s"), name);

        if (egg_tray_manager_check_running (evo_tray->current_screen)) {
                if (!evo_tray->created) {
                        em_tray_create_ui (evo_tray);
                        evo_tray->newmail = FALSE;
                }
                
                gtk_tooltips_set_tip (evo_tray->tray_icon_tooltip,
                                      GTK_WIDGET (evo_tray->tray_icon),
                                      tooltip,
                                      NULL);
        }
        
        if (beep)
                gdk_beep ();
        else {
                if (sound != NULL) {
                        gnome_sound_play (sound);
                        g_free (sound);
                }
        }
        
        notify_type = type;

        if (evo_tray->newmail)
                return;

        evo_tray->newmail = notify;
        em_tray_update_status (evo_tray);
}
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
#ifndef __EM_PANEL_APPLET_H__
#define __EM_PANEL_APPLET_H__

#include "e-util/eggtrayicon.h"
#include <glade/glade.h>

#define DEFAULT_SOUND_NOTIFY "/usr/share/sounds/email.wav"
#define DEFAULT_IMAGE_NOTIFY EVOLUTION_IMAGES "/ico-mail.png"

typedef enum {
	MAIL_CONFIG_NOTIFY_NONE,
	MAIL_CONFIG_NOTIFY_ALL,
	MAIL_CONFIG_NOTIFY_SELECTED,
	MAIL_NOTIFY_TYPES,
} MailConfigNewMailNotifyType;

static struct {
	const char *name;
	const char *description;
} MailNotifyType[MAIL_NOTIFY_TYPES] = {
	{ N_("None"),
		N_("Do not notify when new mail arrived.") },
	{ N_("All Folders"),
		N_("Notify when new mail arrived to any folder.") },
	{ N_("Selected Folders"),
		N_("Notify when new mail arrived to any of the selected folders.") },
};

typedef struct {
        GConfClient *conf_client;
                                                                                
        GdkScreen *current_screen;
                                                                                
        GtkTreeModel *model;

        EggTrayIcon *tray_icon;
        GtkTooltips *tray_icon_tooltip;
        GtkWidget *popup_menu;
        GdkPixbuf *icon;
        GdkPixbuf *blank_icon;

        gboolean blink;
        gboolean newmail;

        gboolean created;
} EvolutionTray;

typedef struct {
        gchar *id;
        gchar *name;
        gchar *image;
        gchar *sound;
	gchar *beep;
} FolderTrayNotify;

enum {
	NOTIFY_PIXBUF_COLUMN,
	NOTIFY_NAME_COLUMN,
	NOTIFY_SOUND_COLUMN,
	NOTIFY_ID_COLUMN,
	NOTIFY_IMAGE_COLUMN,
	NOTIFY_BEEP_COLUMN,
	NOTIFY_NUM_COLUMNS,
};

void em_tray_init ();
void em_tray_notify (gboolean notify, gchar *uri, gint type);
GtkTreeModel * em_tray_get_store ();
void em_tray_add_folder (GtkWidget *button, gpointer user_data);
void em_tray_folders_refresh ();
char * em_folder_tray_notify_to_xml (FolderTrayNotify *folder_notify);
GdkPixbuf * em_tray_get_image_scaled (gchar *image_file);

#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]