]> git.0d.be Git - empathy.git/commitdiff
Unref the notification after it has been closed.
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:08:13 +0000 (17:08 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:08:13 +0000 (17:08 +0000)
svn path=/trunk/; revision=2297

src/empathy-chat-window.c

index 85504c0d707fa3b3a43c4156e59d93655571171b..90091c795798584faa5bd4b11f50880026f1e9d3 100644 (file)
@@ -836,27 +836,29 @@ chat_window_set_urgency_hint (EmpathyChatWindow *window,
        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 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window,
        char *header, *escaped;
        const char *body;
        GdkPixbuf *pixbuf;
+       NotificationData *cb_data;
        EmpathyChatWindowPriv *priv = GET_PRIV (window);
        gboolean res;
 
@@ -881,6 +884,10 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window,
                }
        }
 
+       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 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window,
                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);