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.
This commit is contained in:
parent
8297e321bf
commit
ab651643eb
10
ChangeLog
10
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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue