diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-11-08 08:52:10 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-11-08 08:52:10 +0000 |
commit | a677da5952b975fe9163de56db0a956c3d11d94f (patch) | |
tree | ce7b2986eb1cb7472d7a087efc70328eaaa95347 /src/trayicon.c | |
parent | 6605977726961165229e7bc654b12e115f06bed0 (diff) |
added icons for notifying the arrival of new mail.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1281 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/trayicon.c')
-rw-r--r-- | src/trayicon.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/trayicon.c b/src/trayicon.c index ae5b7db9..1e8e3d98 100644 --- a/src/trayicon.c +++ b/src/trayicon.c @@ -47,13 +47,24 @@ #if GTK_CHECK_VERSION(2, 10, 0) || defined(GDK_WINDOWING_X11) #if GTK_CHECK_VERSION(2, 10, 0) - #include <gtk/gtkstatusicon.h> +#endif + +#ifdef G_OS_WIN32 +#define TRAYICON_IMAGE STOCK_PIXMAP_SYLPHEED_SMALL +#define TRAYICON_NEW_IMAGE STOCK_PIXMAP_SYLPHEED_NEWMAIL_SMALL +#else +#define TRAYICON_IMAGE STOCK_PIXMAP_SYLPHEED +#define TRAYICON_NEW_IMAGE STOCK_PIXMAP_SYLPHEED_NEWMAIL +#endif static TrayIcon trayicon; static GtkWidget *trayicon_menu; +static gboolean on_notify = FALSE; static gboolean default_tooltip = FALSE; +#if GTK_CHECK_VERSION(2, 10, 0) + static void trayicon_activated (GtkStatusIcon *status_icon, gpointer data); static void trayicon_popup_menu_cb (GtkStatusIcon *status_icon, @@ -63,12 +74,9 @@ static void trayicon_popup_menu_cb (GtkStatusIcon *status_icon, #else -static TrayIcon trayicon; static GtkWidget *trayicon_img; static GtkWidget *eventbox; static GtkTooltips *trayicon_tip; -static GtkWidget *trayicon_menu; -static gboolean default_tooltip = FALSE; static void trayicon_button_pressed (GtkWidget *widget, GdkEventButton *event, @@ -98,11 +106,7 @@ TrayIcon *trayicon_create(MainWindow *mainwin) #if GTK_CHECK_VERSION(2, 10, 0) GdkPixbuf *pixbuf; -#ifdef G_OS_WIN32 - stock_pixbuf_gdk(NULL, STOCK_PIXMAP_SYLPHEED_SMALL, &pixbuf); -#else - stock_pixbuf_gdk(NULL, STOCK_PIXMAP_SYLPHEED, &pixbuf); -#endif + stock_pixbuf_gdk(NULL, TRAYICON_IMAGE, &pixbuf); trayicon.status_icon = gtk_status_icon_new_from_pixbuf(pixbuf); g_signal_connect(G_OBJECT(trayicon.status_icon), "activate", @@ -119,13 +123,13 @@ TrayIcon *trayicon_create(MainWindow *mainwin) gtk_container_add(GTK_CONTAINER(trayicon.widget), eventbox); g_signal_connect(G_OBJECT(eventbox), "button_press_event", G_CALLBACK(trayicon_button_pressed), mainwin); - trayicon_img = stock_pixbuf_widget_scale(NULL, STOCK_PIXMAP_SYLPHEED, - 24, 24); + trayicon_img = stock_pixbuf_widget_scale(NULL, TRAYICON_IMAGE, 24, 24); gtk_widget_show(trayicon_img); gtk_container_add(GTK_CONTAINER(eventbox), trayicon_img); trayicon_tip = gtk_tooltips_new(); #endif + on_notify = FALSE; default_tooltip = FALSE; trayicon_set_tooltip(NULL); @@ -207,6 +211,18 @@ gboolean notify_timeout_cb(gpointer data) void trayicon_set_notify(gboolean enabled) { + GdkPixbuf *pixbuf; + + if (enabled && !on_notify) { + stock_pixbuf_gdk(NULL, TRAYICON_NEW_IMAGE, &pixbuf); + gtk_status_icon_set_from_pixbuf(trayicon.status_icon, pixbuf); + on_notify = TRUE; + } else if (!enabled && on_notify) { + stock_pixbuf_gdk(NULL, TRAYICON_IMAGE, &pixbuf); + gtk_status_icon_set_from_pixbuf(trayicon.status_icon, pixbuf); + on_notify = FALSE; + } + if (enabled && notify_tag == 0) { gtk_status_icon_set_blinking(trayicon.status_icon, enabled); notify_tag = g_timeout_add(5000, notify_timeout_cb, NULL); |