[Galago-commits] r3014 - in trunk/libnotify: . libnotify

galago-commits at freedesktop.org galago-commits at freedesktop.org
Thu Sep 25 18:46:41 PDT 2008


Author: chipx86
Date: 2008-09-25 18:46:40 -0700 (Thu, 25 Sep 2008)
New Revision: 3014

Modified:
   trunk/libnotify/ChangeLog
   trunk/libnotify/libnotify/notification.c
   trunk/libnotify/libnotify/notification.h
Log:
Prevent a backwards-compatibility breakage introduced where the "reason" code was added to the "closed" signal. This meant that existing signal handlers that passed extra data would break. We now require that you call notify_notification_get_closed_reason() to get this data.


Modified: trunk/libnotify/ChangeLog
===================================================================
--- trunk/libnotify/ChangeLog	2008-09-26 01:27:19 UTC (rev 3013)
+++ trunk/libnotify/ChangeLog	2008-09-26 01:46:40 UTC (rev 3014)
@@ -1,3 +1,13 @@
+Thu Sep 25 18:45:41 PDT 2008  Christian Hammond <chipx86 at chipx86.com>
+
+	* libnotify/notification.c:
+	* libnotify/notification.h:
+	  - Prevent a backwards-compatibility breakage introduced where the
+	    "reason" code was added to the "closed" signal. This meant that
+	    existing signal handlers that passed extra data would break. We now
+	    require that you call notify_notification_get_closed_reason() to get
+	    this data.
+
 Thu Sep 25 18:05:38 PDT 2008  Christian Hammond <chipx86 at chipx86.com>
 
 	* libnotify/notification.h:

Modified: trunk/libnotify/libnotify/notification.c
===================================================================
--- trunk/libnotify/libnotify/notification.c	2008-09-26 01:27:19 UTC (rev 3013)
+++ trunk/libnotify/libnotify/notification.c	2008-09-26 01:46:40 UTC (rev 3014)
@@ -90,6 +90,8 @@
 	gboolean has_nondefault_actions;
 	gboolean updates_pending;
 	gboolean signals_registered;
+
+	gint closed_reason;
 };
 
 enum
@@ -106,7 +108,8 @@
 	PROP_BODY,
 	PROP_ICON_NAME,
 	PROP_ATTACH_WIDGET,
-	PROP_STATUS_ICON
+	PROP_STATUS_ICON,
+	PROP_CLOSED_REASON
 };
 
 static void notify_notification_set_property(GObject *object, guint prop_id,
@@ -224,6 +227,17 @@
 							G_PARAM_STATIC_NICK |
 							G_PARAM_STATIC_BLURB));
 #endif /* HAVE_STATUS_ICON */
+
+	g_object_class_install_property(object_class, PROP_CLOSED_REASON,
+		g_param_spec_int("closed-reason", "Closed Reason",
+		                 "The reason code for why the notification was closed",
+		                 -1,
+		                 G_MAXINT32,
+		                 -1,
+		                 G_PARAM_READABLE |
+		                 G_PARAM_STATIC_NAME |
+		                 G_PARAM_STATIC_NICK |
+		                 G_PARAM_STATIC_BLURB));
 }
 
 static void
@@ -312,6 +326,10 @@
 			break;
 #endif
 
+		case PROP_CLOSED_REASON:
+			g_value_set_int(value, priv->closed_reason);
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 			break;
@@ -339,6 +357,7 @@
 {
 	obj->priv = g_new0(NotifyNotificationPrivate, 1);
 	obj->priv->timeout = NOTIFY_EXPIRES_DEFAULT;
+	obj->priv->closed_reason = -1;
 	obj->priv->hints = g_hash_table_new_full(g_str_hash, g_str_equal,
 											 g_free,
 											 (GFreeFunc)_g_value_free);
@@ -717,7 +736,8 @@
 	if (id == notification->priv->id)
 	{
 		g_object_ref(G_OBJECT(notification));
-		g_signal_emit(notification, signals[SIGNAL_CLOSED], 0, reason);
+		notification->priv->closed_reason = reason;
+		g_signal_emit(notification, signals[SIGNAL_CLOSED], 0);
 		notification->priv->id = 0;
 		g_object_unref(G_OBJECT(notification));
 	}
@@ -1299,3 +1319,21 @@
 
 	return TRUE;
 }
+
+/**
+ * notify_notification_get_closed_reason:
+ * @notification: The notification.
+ *
+ * Returns the closed reason code for the notification. This is valid only
+ * after the "closed" signal is emitted.
+ *
+ * Returns: The closed reason code.
+ */
+gint
+notify_notification_get_closed_reason(const NotifyNotification *notification)
+{
+	g_return_val_if_fail(notification != NULL, -1);
+	g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(notification), -1);
+
+	return notification->priv->closed_reason;
+}

Modified: trunk/libnotify/libnotify/notification.h
===================================================================
--- trunk/libnotify/libnotify/notification.h	2008-09-26 01:27:19 UTC (rev 3013)
+++ trunk/libnotify/libnotify/notification.h	2008-09-26 01:46:40 UTC (rev 3014)
@@ -62,7 +62,7 @@
 	GObjectClass parent_class;
 
 	/* Signals */
-	void (*closed)(NotifyNotification *notification, gint reason);
+	void (*closed)(NotifyNotification *notification);
 };
 
 /*
@@ -155,6 +155,9 @@
 gboolean notify_notification_close(NotifyNotification *notification,
 								   GError **error);
 
+gint notify_notification_get_closed_reason(
+	const NotifyNotification *notification);
+
 G_END_DECLS
 
 #endif /* NOTIFY_NOTIFICATION_H */



More information about the galago-commits mailing list