empathy r2297 - trunk/src



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

Log:
Unref the notification after it has been closed.

Modified:
   trunk/src/empathy-chat-window.c

Modified: trunk/src/empathy-chat-window.c
==============================================================================
--- trunk/src/empathy-chat-window.c	(original)
+++ trunk/src/empathy-chat-window.c	Fri Jan 30 17:08:13 2009
@@ -836,27 +836,29 @@
 	gtk_window_set_urgency_hint (GTK_WINDOW (priv->dialog), urgent);
 }
 
-static gboolean
-notification_closed_idle_cb (EmpathyChat *chat)
-{
-	empathy_chat_window_present_chat (chat);
-
-	return FALSE;
-}
+typedef struct {
+	EmpathyChatWindow *window;
+	EmpathyChat *chat;
+} NotificationData;
 
 static void
 chat_window_notification_closed_cb (NotifyNotification *notify,
-				    EmpathyChat *chat)
+				    NotificationData *cb_data)
 {
 	int reason = 1;
+	EmpathyChatWindowPriv *priv = GET_PRIV (cb_data->window);
 
 #ifdef notify_notification_get_closed_reason
 	reason = notify_notification_get_closed_reason (notify);
 #endif
-
 	if (reason == 2) {
-		g_idle_add ((GSourceFunc) notification_closed_idle_cb, chat);
+		empathy_chat_window_present_chat (cb_data->chat);
 	}
+
+	g_object_unref (notify);
+	priv->notification = NULL;
+	g_object_unref (cb_data->chat);
+	g_slice_free (NotificationData, cb_data);
 }
 
 static void
@@ -868,6 +870,7 @@
 	char *header, *escaped;
 	const char *body;
 	GdkPixbuf *pixbuf;
+	NotificationData *cb_data;
 	EmpathyChatWindowPriv *priv = GET_PRIV (window);
 	gboolean res;
 
@@ -881,6 +884,10 @@
 		}
 	}
 
+	cb_data = g_slice_new0 (NotificationData);
+	cb_data->chat = g_object_ref (chat);
+	cb_data->window = window;
+
 	sender = empathy_message_get_sender (message);
 	header = g_strdup_printf (_("New message from %s"),
 				  empathy_contact_get_name (sender));
@@ -902,7 +909,7 @@
 		notify_notification_set_icon_from_pixbuf (priv->notification, pixbuf);
 
 		g_signal_connect (priv->notification, "closed",
-				  G_CALLBACK (chat_window_notification_closed_cb), chat);
+				  G_CALLBACK (chat_window_notification_closed_cb), cb_data);
 	}
 
 	notify_notification_show (priv->notification, NULL);



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