aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-31 01:06:50 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-31 01:06:50 +0800
commit75a7efa7a05d8630ca0933cab53b44474bd6353d (patch)
treee5f05db3cc91034d2d077d7fe1d6b21e8059eefd /src
parent15bb9b3096599d3684c2ce2aca32682632fe845e (diff)
downloadgsoc2013-empathy-75a7efa7a05d8630ca0933cab53b44474bd6353d.tar
gsoc2013-empathy-75a7efa7a05d8630ca0933cab53b44474bd6353d.tar.gz
gsoc2013-empathy-75a7efa7a05d8630ca0933cab53b44474bd6353d.tar.bz2
gsoc2013-empathy-75a7efa7a05d8630ca0933cab53b44474bd6353d.tar.lz
gsoc2013-empathy-75a7efa7a05d8630ca0933cab53b44474bd6353d.tar.xz
gsoc2013-empathy-75a7efa7a05d8630ca0933cab53b44474bd6353d.tar.zst
gsoc2013-empathy-75a7efa7a05d8630ca0933cab53b44474bd6353d.zip
mimic tooltip and icon notifications; unref any outstanding notification
on finalize svn path=/trunk/; revision=2272
Diffstat (limited to 'src')
-rw-r--r--src/empathy-status-icon.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index 254a1b863..dc1e8ddbc 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -59,6 +59,7 @@ typedef struct {
guint blink_timeout;
EmpathyEventManager *event_manager;
EmpathyEvent *event;
+ NotifyNotification *notification;
GtkWindow *window;
GtkWidget *popup_menu;
@@ -94,9 +95,40 @@ status_icon_notification_cb (NotifyNotification *notification,
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_event_added_cb (EmpathyEventManager *manager,
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_event_removed_cb (EmpathyEventManager *manager,
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_finalize (GObject *object)
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);