empathy r2272 - trunk/src



Author: xclaesse
Date: Fri Jan 30 17:06:50 2009
New Revision: 2272
URL: http://svn.gnome.org/viewvc/empathy?rev=2272&view=rev

Log:
mimic tooltip and icon notifications; unref any outstanding notification
on finalize

Modified:
   trunk/src/empathy-status-icon.c

Modified: trunk/src/empathy-status-icon.c
==============================================================================
--- trunk/src/empathy-status-icon.c	(original)
+++ trunk/src/empathy-status-icon.c	Fri Jan 30 17:06:50 2009
@@ -59,6 +59,7 @@
 	guint                blink_timeout;
 	EmpathyEventManager *event_manager;
 	EmpathyEvent        *event;
+	NotifyNotification  *notification;
 
 	GtkWindow           *window;
 	GtkWidget           *popup_menu;
@@ -94,9 +95,40 @@
 
 static void
 status_icon_notification_closed_cb (NotifyNotification *notification,
-				    gpointer            user_data)
+				    gpointer            data)
 {
-	g_object_unref (notification);
+	EmpathyStatusIcon *icon = EMPATHY_STATUS_ICON (data);
+	EmpathyStatusIconPriv *priv = GET_PRIV (icon);
+
+	if (priv->notification) {
+		g_object_unref (priv->notification);
+		priv->notification = NULL;
+	}
+}
+
+static void
+status_icon_update_notification (EmpathyStatusIcon *icon)
+{
+	EmpathyStatusIconPriv *priv = GET_PRIV (icon);
+
+	if (priv->event) {
+		priv->notification = notify_notification_new_with_status_icon ("New Event", priv->event->message, priv->event->icon_name, priv->icon);
+		notify_notification_add_action (priv->notification,
+						"activate",
+						"Activate",
+						status_icon_notification_cb,
+						icon, NULL);
+		notify_notification_set_timeout (priv->notification,
+						 NOTIFY_EXPIRES_DEFAULT);
+		g_signal_connect (priv->notification, "closed", G_CALLBACK (status_icon_notification_closed_cb), (gpointer) icon);
+		notify_notification_show (priv->notification, NULL);
+	} else {
+		if (priv->notification) {
+			notify_notification_close (priv->notification, NULL);
+			g_object_unref (priv->notification);
+			priv->notification = NULL;
+		}
+	}
 }
 
 static void
@@ -162,25 +194,13 @@
 
 	status_icon_update_icon (icon);
 	status_icon_update_tooltip (icon);
+	status_icon_update_notification (icon);
 
 	if (!priv->blink_timeout) {
 		priv->blink_timeout = g_timeout_add (BLINK_TIMEOUT,
 						     (GSourceFunc) status_icon_blink_timeout_cb,
 						     icon);
 	}
-
-	if (!priv->event)
-		return;
-	NotifyNotification *notification = notify_notification_new_with_status_icon ("Incoming Something", priv->event->message, priv->event->icon_name, priv->icon);
-	notify_notification_add_action (notification,
-					"activate",
-					"Activate",
-					status_icon_notification_cb,
-					icon, NULL);
-	notify_notification_set_timeout (notification,
-					 NOTIFY_EXPIRES_NEVER);
-	g_signal_connect (G_OBJECT (notification), "closed", G_CALLBACK (status_icon_notification_closed_cb), NULL);
-	notify_notification_show (notification, NULL);
 }
 
 static void
@@ -198,6 +218,7 @@
 
 	status_icon_update_tooltip (icon);
 	status_icon_update_icon (icon);
+	status_icon_update_notification (icon);
 
 	if (!priv->event && priv->blink_timeout) {
 		g_source_remove (priv->blink_timeout);
@@ -415,6 +436,11 @@
 					      status_icon_connection_changed_cb,
 					      object);
 
+	if (priv->notification) {
+		notify_notification_close (priv->notification, NULL);
+		g_object_unref (priv->notification);
+	}
+
 	g_object_unref (priv->icon);
 	g_object_unref (priv->idle);
 	g_object_unref (priv->account_manager);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]