From 41c9a97e743d179f2990d47cf19a6a3a6e88a841 Mon Sep 17 00:00:00 2001 From: hiro Date: Thu, 28 Sep 2006 04:39:38 +0000 Subject: cleanup trayicon on exit. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1198 ee746299-78ed-0310-b773-934348b2243d --- src/main.c | 3 +++ src/mainwindow.c | 4 ++-- src/trayicon.c | 23 +++++++++++++++++++---- src/trayicon.h | 1 + 4 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 37e8088e..5fd89c2b 100644 --- a/src/main.c +++ b/src/main.c @@ -79,6 +79,7 @@ #include "gtkutils.h" #include "socket.h" #include "stock_pixmap.h" +#include "trayicon.h" #if USE_GPGME # include "rfc2015.h" @@ -654,6 +655,8 @@ void app_will_exit(gboolean force) procmsg_remove_all_cached_messages(FOLDER(ac->folder)); } + trayicon_destroy(mainwin->tray_icon); + /* save all state before exiting */ folder_write_list(); summary_write_cache(mainwin->summaryview); diff --git a/src/mainwindow.c b/src/mainwindow.c index 814fbcf5..76a4e7ba 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -1224,8 +1224,8 @@ void main_window_reflect_prefs_all(void) if (prefs_common.show_trayicon) trayicon_show(mainwin->tray_icon); else { - /* trayicon is automatically restored after this */ - trayicon_destroy(mainwin->tray_icon); + /* trayicon is automatically replaced by new one */ + trayicon_hide(mainwin->tray_icon); } } diff --git a/src/trayicon.c b/src/trayicon.c index 35a20083..fb33f0a1 100644 --- a/src/trayicon.c +++ b/src/trayicon.c @@ -172,16 +172,18 @@ TrayIcon *trayicon_create(MainWindow *mainwin) void trayicon_show(TrayIcon *tray_icon) { - gtk_status_icon_set_visible(trayicon.status_icon, TRUE); + gtk_status_icon_set_visible(tray_icon->status_icon, TRUE); }; +void trayicon_hide(TrayIcon *tray_icon) +{ + gtk_status_icon_set_visible(tray_icon->status_icon, FALSE); +} + 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) @@ -247,8 +249,17 @@ void trayicon_show(TrayIcon *tray_icon) gtk_widget_show(tray_icon->widget); }; +void trayicon_hide(TrayIcon *tray_icon) +{ + gtk_widget_destroy(tray_icon->widget); + tray_icon->widget = NULL; +} + void trayicon_destroy(TrayIcon *tray_icon) { + g_signal_handlers_disconnect_by_func(G_OBJECT(trayicon->widget), + G_CALLBACK(trayicon_destroy_cb), + mainwin); gtk_widget_destroy(tray_icon->widget); tray_icon->widget = NULL; } @@ -369,6 +380,10 @@ void trayicon_show(TrayIcon *tray_icon) { } +void trayicon_hide(TrayIcon *tray_icon) +{ +} + void trayicon_destroy(TrayIcon *tray_icon) { } diff --git a/src/trayicon.h b/src/trayicon.h index af509dd9..eea46af0 100644 --- a/src/trayicon.h +++ b/src/trayicon.h @@ -44,6 +44,7 @@ struct _TrayIcon TrayIcon *trayicon_create (MainWindow *mainwin); void trayicon_show (TrayIcon *tray_icon); +void trayicon_hide (TrayIcon *tray_icon); void trayicon_destroy (TrayIcon *tray_icon); void trayicon_set_tooltip (const gchar *text); void trayicon_set_notify (gboolean enabled); -- cgit v1.2.3