]> git.0d.be Git - empathy.git/commitdiff
Require latest libnotify. Don't crash when clicking the notification.
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:06:57 +0000 (17:06 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:06:57 +0000 (17:06 +0000)
svn path=/trunk/; revision=2274

configure.ac
src/empathy-status-icon.c

index 2797c0f80c7d162eac5cc8b8f3cef14952371775..23b1cbb3791f9a7d84d4b8116a091aa51f9ee13b 100644 (file)
@@ -34,6 +34,7 @@ TELEPATHY_GLIB_REQUIRED=0.7.19
 MISSION_CONTROL_REQUIRED=4.61
 ENCHANT_REQUIRED=1.2.0
 ISO_CODES_REQUIRED=0.35
+LIBNOTIFY_REQUIRED=0.4.5
 
 # Uncomment that to build with deprecated symbols disabled
 #AC_DEFINE(G_DISABLE_DEPRECATED, [], [Disable deprecated GLib symbols])
@@ -108,7 +109,7 @@ PKG_CHECK_MODULES(EMPATHY,
    libglade-2.0 >= $LIBGLADE_REQUIRED
    libebook-1.2
    libcanberra-gtk >= 0.4
-   libnotify
+   libnotify >= $LIBNOTIFY_REQUIRED
 ])
 
 # -----------------------------------------------------------
index dc1e8ddbcc8e036ec19ffbf14ccd37bda35d65ff..bb96e65e5226e2ed5b348d5884da63b58d04caaf 100644 (file)
@@ -71,39 +71,33 @@ typedef struct {
 G_DEFINE_TYPE (EmpathyStatusIcon, empathy_status_icon, G_TYPE_OBJECT);
 
 static gboolean
-status_icon_idle_event_activate (gpointer data)
+activate_event (EmpathyEvent *event)
 {
-       EmpathyStatusIcon     *icon = EMPATHY_STATUS_ICON (data);
-       EmpathyStatusIconPriv *priv = GET_PRIV (icon);
-
-       if (priv->event) {
-               empathy_event_activate (priv->event);
-       }
+       empathy_event_activate (event);
 
        return FALSE;
 }
 
-static void
-status_icon_notification_cb (NotifyNotification *notification,
-                            gchar *action_id,
-                            gpointer data)
-{
-       EmpathyStatusIcon *icon = EMPATHY_STATUS_ICON (data);
-
-       g_idle_add (status_icon_idle_event_activate, icon);
-}
-
 static void
 status_icon_notification_closed_cb (NotifyNotification *notification,
-                                   gpointer            data)
+                                   EmpathyStatusIcon  *icon)
 {
-       EmpathyStatusIcon *icon = EMPATHY_STATUS_ICON (data);
        EmpathyStatusIconPriv *priv = GET_PRIV (icon);
+       int reason;
+
+       reason = notify_notification_get_closed_reason (notification);
 
        if (priv->notification) {
                g_object_unref (priv->notification);
                priv->notification = NULL;
        }
+
+       /* the notification has been closed by the user, see the
+        * DesktopNotification spec.
+        */
+       if (reason == 2 && priv->event) {
+               g_idle_add ((GSourceFunc) activate_event, priv->event);
+       }
 }
 
 static void
@@ -112,15 +106,12 @@ 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);
+               priv->notification = notify_notification_new_with_status_icon
+                       ("New Event", priv->event->message, priv->event->icon_name, priv->icon);
                notify_notification_set_timeout (priv->notification,
                                                 NOTIFY_EXPIRES_DEFAULT);
-               g_signal_connect (priv->notification, "closed", G_CALLBACK (status_icon_notification_closed_cb), (gpointer) icon);
+               g_signal_connect (priv->notification, "closed",
+                                 G_CALLBACK (status_icon_notification_closed_cb), icon);               
                notify_notification_show (priv->notification, NULL);
        } else {
                if (priv->notification) {