summaryrefslogtreecommitdiff
path: root/src/empathy-notifications-approver.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-11-23 11:56:17 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-11-23 14:01:40 +0100
commit212a4ecbdb3a41933a208f401f1803a930061cb7 (patch)
treeca4e5fb0edce066c5ab76d1a4524c7760ee0e44b /src/empathy-notifications-approver.c
parent5196ab5cec62faae3ae7eaa3b3a9529fe7a2c33a (diff)
downloadempathy-212a4ecbdb3a41933a208f401f1803a930061cb7.tar.gz
Clean up the way we keep references on notifications
Diffstat (limited to 'src/empathy-notifications-approver.c')
-rw-r--r--src/empathy-notifications-approver.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/empathy-notifications-approver.c b/src/empathy-notifications-approver.c
index 2fd6534be..0bfe03274 100644
--- a/src/empathy-notifications-approver.c
+++ b/src/empathy-notifications-approver.c
@@ -104,10 +104,8 @@ static void
notification_closed_cb (NotifyNotification *notification,
EmpathyNotificationsApprover *self)
{
- g_object_unref (notification);
-
if (self->priv->notification == notification)
- self->priv->notification = NULL;
+ tp_clear_object (&self->priv->notification);
}
static void
@@ -116,7 +114,7 @@ notification_close_helper (EmpathyNotificationsApprover *self)
if (self->priv->notification != NULL)
{
notify_notification_close (self->priv->notification, NULL);
- self->priv->notification = NULL;
+ tp_clear_object (&self->priv->notification);
}
}
@@ -230,7 +228,7 @@ update_notification (EmpathyNotificationsApprover *self)
GdkPixbuf *pixbuf = NULL;
gchar *message_esc = NULL;
gboolean has_x_canonical_append;
- NotifyNotification *notification = self->priv->notification;
+ NotifyNotification *notification;
if (!empathy_notify_manager_notification_is_enabled (self->priv->notify_mgr))
{
@@ -251,11 +249,13 @@ update_notification (EmpathyNotificationsApprover *self)
has_x_canonical_append = empathy_notify_manager_has_capability (
self->priv->notify_mgr, EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND);
- if (notification != NULL && ! has_x_canonical_append)
+ if (self->priv->notification != NULL && ! has_x_canonical_append)
{
/* if the notification server does NOT supports x-canonical-append, it is
* better to not use notify_notification_update to avoid
* overwriting the current notification message */
+ notification = g_object_ref (self->priv->notification);
+
notify_notification_update (notification,
self->priv->event->header, message_esc, NULL);
}
@@ -271,7 +271,12 @@ update_notification (EmpathyNotificationsApprover *self)
message_esc, NULL);
if (self->priv->notification == NULL)
- self->priv->notification = notification;
+ {
+ self->priv->notification = g_object_ref (notification);
+
+ g_signal_connect (notification, "closed",
+ G_CALLBACK (notification_closed_cb), self);
+ }
notify_notification_set_timeout (notification,
NOTIFY_EXPIRES_DEFAULT);
@@ -283,9 +288,6 @@ update_notification (EmpathyNotificationsApprover *self)
if (empathy_notify_manager_has_capability (self->priv->notify_mgr,
EMPATHY_NOTIFY_MANAGER_CAP_ACTIONS))
add_notification_actions (self, notification);
-
- g_signal_connect (notification, "closed",
- G_CALLBACK (notification_closed_cb), self);
}
pixbuf = empathy_notify_manager_get_pixbuf_for_notification (
@@ -301,6 +303,7 @@ update_notification (EmpathyNotificationsApprover *self)
notify_notification_show (notification, NULL);
g_free (message_esc);
+ g_object_unref (notification);
}
static void