summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hammond <chipx86@chipx86.com>2006-01-20 10:19:44 +0000
committerChristian Hammond <chipx86@chipx86.com>2006-01-20 10:19:44 +0000
commitab651643eb3c37dd317b995554ce0a2cfea7eb37 (patch)
treefe6cc7939b97e296a3117053746caa23c1ae31eb
parent8297e321bfb5c5c8c0764e145e33f8b2e5fa71fd (diff)
downloadlibnotify-ab651643eb3c37dd317b995554ce0a2cfea7eb37.tar.gz
Remove notify_notification_show_and_forget(). It's less confusing to have one show function, and require that the user unref. It also simplifies the code quite a bit.
-rw-r--r--ChangeLog10
-rw-r--r--libnotify/notification.c98
-rw-r--r--libnotify/notification.h3
-rw-r--r--tests/test-basic.c4
-rw-r--r--tools/notify-send.c3
5 files changed, 39 insertions, 79 deletions
diff --git a/ChangeLog b/ChangeLog
index a1557aa..6241786 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Jan 20 02:19:29 PST 2006 Christian Hammond <chipx86@chipx86.com>
+
+ * libnotify/notification.c:
+ * libnotify/notification.h:
+ * tests/test-basic.c:
+ * tools/notify-send.c:
+ - Remove notify_notification_show_and_forget(). It's less confusing to
+ have one show function, and require that the user unref. It also
+ simplifies the code quite a bit.
+
Fri Jan 20 02:10:50 PST 2006 Christian Hammond <chipx86@chipx86.com>
* libnotify/notification.c:
diff --git a/libnotify/notification.c b/libnotify/notification.c
index 1deed34..32f8212 100644
--- a/libnotify/notification.c
+++ b/libnotify/notification.c
@@ -51,7 +51,7 @@ struct _NotifyNotificationPrivate
gchar *summary;
gchar *body;
- /* NULL to use icon data anything else to have server lookup icon */
+ /* NULL to use icon data. Anything else to have server lookup icon */
gchar *icon_name;
/*
@@ -74,18 +74,11 @@ struct _NotifyNotificationPrivate
DBusGProxy *proxy;
};
-typedef enum
+enum
{
SIGNAL_CLOSED,
LAST_SIGNAL
-
-} NotifyNotificationSignalType;
-
-typedef struct
-{
- NotifyNotification *object;
-
-} NotifyNotificationSignal;
+};
static guint signals[LAST_SIGNAL] = { 0 };
static GObjectClass *parent_class = NULL;
@@ -399,16 +392,19 @@ _gslist_to_string_array(GSList *list)
return (gchar **)g_array_free(a, FALSE);
}
-static gboolean
-_notify_notification_show_internal(NotifyNotification *notification,
- GError **error, gboolean ignore_reply)
+gboolean
+notify_notification_show(NotifyNotification *notification, GError **error)
{
- NotifyNotificationPrivate *priv = notification->priv;
+ NotifyNotificationPrivate *priv;
GError *tmp_error = NULL;
gchar **action_array;
+ g_return_val_if_fail(notification != NULL, FALSE);
+ g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(notification), FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+ priv = notification->priv;
+
if (priv->proxy == NULL)
{
DBusGConnection *bus = dbus_g_bus_get(DBUS_BUS_SESSION, &tmp_error);
@@ -446,39 +442,20 @@ _notify_notification_show_internal(NotifyNotification *notification,
action_array = _gslist_to_string_array(priv->actions);
/* TODO: make this nonblocking */
-
- if (ignore_reply)
- {
- dbus_g_proxy_call_no_reply(
- priv->proxy, "Notify",
- G_TYPE_STRING, notify_get_app_name(),
- G_TYPE_UINT, priv->id,
- G_TYPE_STRING, priv->icon_name != NULL ? priv->icon_name : "",
- G_TYPE_STRING, priv->summary,
- G_TYPE_STRING, priv->body,
- G_TYPE_STRV, action_array,
- dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
- G_TYPE_VALUE), priv->hints,
- G_TYPE_INT, priv->timeout,
- G_TYPE_INVALID);
- }
- else
- {
- dbus_g_proxy_call(
- priv->proxy, "Notify", &tmp_error,
- G_TYPE_STRING, notify_get_app_name(),
- G_TYPE_UINT, priv->id,
- G_TYPE_STRING, priv->icon_name != NULL ? priv->icon_name : "",
- G_TYPE_STRING, priv->summary,
- G_TYPE_STRING, priv->body,
- G_TYPE_STRV, action_array,
- dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
- G_TYPE_VALUE), priv->hints,
- G_TYPE_INT, priv->timeout,
- G_TYPE_INVALID,
- G_TYPE_UINT, &priv->id,
- G_TYPE_INVALID);
- }
+ dbus_g_proxy_call(
+ priv->proxy, "Notify", &tmp_error,
+ G_TYPE_STRING, notify_get_app_name(),
+ G_TYPE_UINT, priv->id,
+ G_TYPE_STRING, priv->icon_name != NULL ? priv->icon_name : "",
+ G_TYPE_STRING, priv->summary,
+ G_TYPE_STRING, priv->body,
+ G_TYPE_STRV, action_array,
+ dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
+ G_TYPE_VALUE), priv->hints,
+ G_TYPE_INT, priv->timeout,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &priv->id,
+ G_TYPE_INVALID);
/* Don't free the elements because they are owned by priv->actions */
g_free(action_array);
@@ -492,33 +469,6 @@ _notify_notification_show_internal(NotifyNotification *notification,
return TRUE;
}
-gboolean
-notify_notification_show(NotifyNotification *notification, GError **error)
-{
- g_return_val_if_fail(notification != NULL, FALSE);
- g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(notification), FALSE);
- g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
-
- return _notify_notification_show_internal(notification, error, FALSE);
-}
-
-gboolean
-notify_notification_show_and_forget(NotifyNotification *notification,
- GError **error)
-{
- gboolean result;
-
- g_return_val_if_fail(notification != NULL, FALSE);
- g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(notification), FALSE);
- g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
-
- result = _notify_notification_show_internal(notification, error, TRUE);
-
- g_object_unref(G_OBJECT(notification));
-
- return result;
-}
-
void
notify_notification_set_timeout(NotifyNotification *notification,
gint timeout)
diff --git a/libnotify/notification.h b/libnotify/notification.h
index 87cc732..17a197d 100644
--- a/libnotify/notification.h
+++ b/libnotify/notification.h
@@ -98,9 +98,6 @@ void notify_notification_attach_to_widget(NotifyNotification* notification,
gboolean notify_notification_show(NotifyNotification *notification,
GError **error);
-gboolean notify_notification_show_and_forget(NotifyNotification *notification,
- GError **error);
-
void notify_notification_set_timeout(NotifyNotification *notification,
gint timeout);
diff --git a/tests/test-basic.c b/tests/test-basic.c
index 4599b08..a271a1e 100644
--- a/tests/test-basic.c
+++ b/tests/test-basic.c
@@ -33,10 +33,12 @@ int main() {
NULL, NULL);
notify_notification_set_timeout (n, 3000); //3 seconds
- if (!notify_notification_show_and_forget (n, NULL)) {
+ if (!notify_notification_show (n, NULL)) {
fprintf(stderr, "failed to send notification\n");
return 1;
}
+ g_object_unref(G_OBJECT(n));
+
return 0;
}
diff --git a/tools/notify-send.c b/tools/notify-send.c
index 327a068..ebbfa46 100644
--- a/tools/notify-send.c
+++ b/tools/notify-send.c
@@ -133,7 +133,8 @@ main(int argc, const char **argv)
notify_notification_set_urgency(notify, urgency);
notify_notification_set_timeout(notify, expire_timeout);
- notify_notification_show_and_forget(notify, NULL);
+ notify_notification_show(notify, NULL);
+ g_object_unref(G_OBJECT(notify));
poptFreeContext(opt_ctx);
notify_uninit();