From 89509eaa2ec34175cf7bf559d2180a56f3d0a476 Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 27 Sep 2006 00:58:58 +0000 Subject: added mail arrival notification at tray icon. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1191 ee746299-78ed-0310-b773-934348b2243d --- src/trayicon.c | 84 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 29 deletions(-) (limited to 'src/trayicon.c') diff --git a/src/trayicon.c b/src/trayicon.c index 50c94f34..ae9b0244 100644 --- a/src/trayicon.c +++ b/src/trayicon.c @@ -163,6 +163,20 @@ TrayIcon *trayicon_create(MainWindow *mainwin) #if GTK_CHECK_VERSION(2, 10, 0) +void trayicon_show(TrayIcon *tray_icon) +{ + gtk_status_icon_set_visible(trayicon.status_icon, TRUE); +}; + +void trayicon_destroy(TrayIcon *tray_icon) +{ +#if 0 + g_object_unref(tray_icon->status_icon); + tray_icon->status_icon = NULL; +#endif + gtk_status_icon_set_visible(tray_icon->status_icon, FALSE); +} + void trayicon_set_tooltip(const gchar *text) { if (text) { @@ -175,6 +189,24 @@ void trayicon_set_tooltip(const gchar *text) } } +static guint notify_tag = 0; + +gboolean notify_timeout_cb(gpointer data) +{ + gtk_status_icon_set_blinking(trayicon.status_icon, FALSE); + notify_tag = 0; + return FALSE; +} + +void trayicon_set_notify(gboolean enabled) +{ + if (enabled && notify_tag == 0) { + gtk_status_icon_set_blinking(trayicon.status_icon, enabled); + notify_tag = g_timeout_add(5000, notify_timeout_cb, NULL); + } else if (!enabled && notify_tag > 0) + g_source_remove(notify_tag); +} + void trayicon_set_stock_icon(StockPixmap icon) { GdkPixbuf *pixbuf; @@ -187,20 +219,6 @@ void trayicon_set_stock_icon(StockPixmap icon) g_object_unref(scaled_pixbuf); } -void trayicon_show(TrayIcon *tray_icon) -{ - gtk_status_icon_set_visible(trayicon.status_icon, TRUE); -}; - -void trayicon_destroy(TrayIcon *tray_icon) -{ -#if 0 - g_object_unref(tray_icon->status_icon); - tray_icon->status_icon = NULL; -#endif - gtk_status_icon_set_visible(tray_icon->status_icon, FALSE); -} - static void trayicon_activated(GtkStatusIcon *status_icon, gpointer data) { MainWindow *mainwin = (MainWindow *)data; @@ -219,6 +237,17 @@ static void trayicon_popup_menu_cb(GtkStatusIcon *status_icon, guint button, #else +void trayicon_show(TrayIcon *tray_icon) +{ + gtk_widget_show(tray_icon->widget); +}; + +void trayicon_destroy(TrayIcon *tray_icon) +{ + gtk_widget_destroy(tray_icon->widget); + tray_icon->widget = NULL; +} + void trayicon_set_tooltip(const gchar *text) { if (text) { @@ -232,6 +261,10 @@ void trayicon_set_tooltip(const gchar *text) } } +void trayicon_set_notify(gboolean enabled) +{ +} + void trayicon_set_stock_icon(StockPixmap icon) { GdkPixbuf *pixbuf; @@ -244,17 +277,6 @@ void trayicon_set_stock_icon(StockPixmap icon) g_object_unref(scaled_pixbuf); } -void trayicon_show(TrayIcon *tray_icon) -{ - gtk_widget_show(tray_icon->widget); -}; - -void trayicon_destroy(TrayIcon *tray_icon) -{ - gtk_widget_destroy(tray_icon->widget); - tray_icon->widget = NULL; -} - static void trayicon_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer data) { @@ -336,19 +358,23 @@ TrayIcon *trayicon_create(MainWindow *mainwin) return NULL; } -void trayicon_set_tooltip(const gchar *text) +void trayicon_show(TrayIcon *tray_icon) { } -void trayicon_set_stock_icon(StockPixmap icon) +void trayicon_destroy(TrayIcon *tray_icon) { } -void trayicon_show(TrayIcon *tray_icon) +void trayicon_set_tooltip(const gchar *text) { } -void trayicon_destroy(TrayIcon *tray_icon) +void trayicon_set_notify(gboolean enabled) +{ +} + +void trayicon_set_stock_icon(StockPixmap icon) { } -- cgit v1.2.3