Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > d60bd1f35e0c82afb5f88d78afd23ee9 > files > 23

NetworkManager-0.7.0-9.el5.src.rpm

https://bugzilla.redhat.com/show_bug.cgi?id=467037

NM 0.7 connects more quickly than 0.6, which exposes problems in the older
libnotify that RHEL-5 ships, which cannot accurately place notification bubbles
when the nm-applet status icon moves.

diff -up NetworkManager-0.7.0/network-manager-applet-0.7.0/src/applet.c.defer NetworkManager-0.7.0/network-manager-applet-0.7.0/src/applet.c
--- NetworkManager-0.7.0/network-manager-applet-0.7.0/src/applet.c.defer	2008-10-16 07:47:21.000000000 -0400
+++ NetworkManager-0.7.0/network-manager-applet-0.7.0/src/applet.c	2008-10-16 07:47:46.000000000 -0400
@@ -357,7 +357,8 @@ applet_clear_notify (NMApplet *applet)
 	if (applet->notification == NULL)
 		return;
 
-	notify_notification_close (applet->notification, NULL);
+	if (!applet->notify_defer_id)
+		notify_notification_close (applet->notification, NULL);
 	g_object_unref (applet->notification);
 	applet->notification = NULL;
 }
@@ -399,9 +400,15 @@ applet_do_notify (NMApplet *applet,
 		                                action1_cb, action1_user_data, NULL);
 	}
 
-	if (!notify_notification_show (notify, &error)) {
-		g_warning ("Failed to show notification: %s", error->message);
-		g_error_free (error);
+	/* If notifications are deferred, just cache the notification for display
+	 * later when the deferral is over.
+	 */
+	if (!applet->notify_defer_id) {
+		if (!notify_notification_show (notify, &error)) {
+			g_warning ("Failed to show notification: %s",
+			           error && error->message ? error->message : "(none)");
+			g_error_free (error);
+		}
 	}
 }
 
@@ -2168,6 +2175,27 @@ setup_widgets (NMApplet *applet)
 	}
 }
 
+static gboolean
+notify_defer_cb (gpointer user_data)
+{
+	NMApplet *applet = NM_APPLET (user_data);
+
+	applet->notify_defer_id = 0;
+
+	/* Show any deferred notification */
+	if (applet->notification) {
+		GError *error = NULL;
+
+		if (!notify_notification_show (applet->notification, &error)) {
+			g_warning ("Failed to show notification: %s",
+			           error && error->message ? error->message : "(none)");
+			g_error_free (error);
+		}
+	}
+
+	return FALSE;
+}
+
 static GObject *
 constructor (GType type,
              guint n_props,
@@ -2246,6 +2274,11 @@ constructor (GType type,
 	applet->update_timestamps_id = g_timeout_add (300000,
 			(GSourceFunc) periodic_update_active_connection_timestamps, applet);
 
+	/* Defer notifications for 9 seconds since older libnotify can't reliably
+	 * position notifications on the static icon.
+	 */
+	applet->notify_defer_id = g_timeout_add (9000, notify_defer_cb, applet);
+
 	nm_gconf_set_pre_keyring_callback (applet_pre_keyring_callback, applet);
 
 	return G_OBJECT (applet);
diff -up NetworkManager-0.7.0/network-manager-applet-0.7.0/src/applet.h.defer NetworkManager-0.7.0/network-manager-applet-0.7.0/src/applet.h
--- NetworkManager-0.7.0/network-manager-applet-0.7.0/src/applet.h.defer	2008-10-16 07:47:25.000000000 -0400
+++ NetworkManager-0.7.0/network-manager-applet-0.7.0/src/applet.h	2008-10-16 07:47:46.000000000 -0400
@@ -140,6 +140,7 @@ typedef struct
 
 	GladeXML *		info_dialog_xml;
 	NotifyNotification*	notification;
+	guint			notify_defer_id;
 } NMApplet;