From ff296fdf61aecb42622c41c1a89c8d0b34be37a3 Mon Sep 17 00:00:00 2001 From: Christopher Aillon Date: Fri, 24 Mar 2006 14:55:40 +0000 Subject: [PATCH] 2006-03-24 Christopher Aillon * gnome/applet/applet-notifications.c: When displaying a notification, make sure to get rid of the previous notification so as to not have competing bubbles, and stop leaking the old one. * gnome/applet/applet.c: * gnome/applet/applet.h: Add a new 'notification' member to the applet, and zero it out and free it appropriately. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1635 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 12 ++++++++++++ gnome/applet/applet-notifications.c | 17 ++++++++++++----- gnome/applet/applet.c | 8 ++++++++ gnome/applet/applet.h | 11 +++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 751504f81..da1fe8cb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-03-24 Christopher Aillon + + * gnome/applet/applet-notifications.c: + When displaying a notification, make sure to get rid of the + previous notification so as to not have competing bubbles, + and stop leaking the old one. + + * gnome/applet/applet.c: + * gnome/applet/applet.h: + Add a new 'notification' member to the applet, and zero it out + and free it appropriately. + 2006-03-23 Robert Love Patch by j : diff --git a/gnome/applet/applet-notifications.c b/gnome/applet/applet-notifications.c index 4a13a6ca9..b7f7a5811 100644 --- a/gnome/applet/applet-notifications.c +++ b/gnome/applet/applet-notifications.c @@ -30,7 +30,7 @@ nma_send_event_notification (NMApplet *applet, const char *message, const char *icon) { - NotifyNotification *notification; + const char *notify_icon; g_return_if_fail (applet != NULL); g_return_if_fail (summary != NULL); @@ -39,9 +39,16 @@ nma_send_event_notification (NMApplet *applet, if (!notify_is_initted ()) notify_init ("NetworkManager"); - notification = notify_notification_new (summary, message, - icon ? icon : GTK_STOCK_NETWORK, GTK_WIDGET (applet)); - notify_notification_set_urgency (notification, urgency); - notify_notification_show (notification, NULL); + if (applet->notification != NULL) { + notify_notification_close (applet->notification, NULL); + g_object_unref (applet->notification); + } + + notify_icon = icon ? icon : GTK_STOCK_NETWORK; + + applet->notification = notify_notification_new (summary, message, notify_icon, GTK_WIDGET (applet)); + + notify_notification_set_urgency (applet->notification, urgency); + notify_notification_show (applet->notification, NULL); } diff --git a/gnome/applet/applet.c b/gnome/applet/applet.c index 117e1f0a0..8edb937e5 100644 --- a/gnome/applet/applet.c +++ b/gnome/applet/applet.c @@ -2538,6 +2538,10 @@ static void G_GNUC_NORETURN nma_destroy (NMApplet *applet) nma_icons_free (applet); nmi_passphrase_dialog_destroy (applet); +#ifdef ENABLE_NOTIFY + notify_notification_close (applet->notification, NULL); + g_object_unref (applet->notification); +#endif if (applet->redraw_timeout_id > 0) { @@ -2579,6 +2583,10 @@ static GtkWidget * nma_get_instance (NMApplet *applet) applet->nm_state = NM_STATE_DISCONNECTED; applet->tooltips = NULL; applet->passphrase_dialog = NULL; +#ifdef ENABLE_NOTIFY + applet->notification = NULL; +#endif + applet->glade_file = g_build_filename (GLADEDIR, "applet.glade", NULL); if (!applet->glade_file || !g_file_test (applet->glade_file, G_FILE_TEST_IS_REGULAR)) { diff --git a/gnome/applet/applet.h b/gnome/applet/applet.h index 16334c267..9661653b1 100644 --- a/gnome/applet/applet.h +++ b/gnome/applet/applet.h @@ -21,6 +21,11 @@ #ifndef APPLET_H #define APPLET_H + +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -33,6 +38,9 @@ #include "wireless-network.h" #include "dbus-method-dispatcher.h" +#ifdef ENABLE_NOTIFY +#include +#endif /* * Preference locations @@ -119,6 +127,9 @@ typedef struct GtkWidget * passphrase_dialog; GladeXML * info_dialog_xml; +#ifdef ENABLE_NOTIFY + NotifyNotification* notification; +#endif } NMApplet; typedef struct