* libnotify/notify.c: Use pointers instead of GINT_TO_POINTER
* tools/test-replace.c: Test replacing notifications
This commit is contained in:
parent
d513d0de37
commit
392d030acf
|
@ -1,7 +1,11 @@
|
|||
Tue Jul 13 23:58:54 2004 Mike Hearn <mike@navi.cx>
|
||||
Wed Jul 14 02:11:48 GMT 2004 Mike Hearn <mike@navi.cx>
|
||||
* libnotify/notify.c: Use pointers instead of GINT_TO_POINTER
|
||||
* tools/test-replace.c: Test replacing notifications
|
||||
|
||||
Tue Jul 13 23:58:54 GMT 2004 Mike Hearn <mike@navi.cx>
|
||||
* SPECIFICATION: CloseNotification sends NotificationClosed signal.
|
||||
|
||||
Mon Jul 5 00:12:03 2004 Mike Hearn <mike@navi.cx>
|
||||
Mon Jul 5 00:12:03 GMT 2004 Mike Hearn <mike@navi.cx>
|
||||
* tools/notify-send.c (main): Treat expiry times < current time
|
||||
as timeouts from current instant
|
||||
|
||||
|
|
|
@ -106,9 +106,9 @@ _notify_handle_new(guint32 id)
|
|||
|
||||
handle->id = id;
|
||||
|
||||
handle->replaces = -1;
|
||||
handle->replaces = 0;
|
||||
|
||||
g_hash_table_insert(_handles, GINT_TO_POINTER(id), handle);
|
||||
g_hash_table_insert(_handles, &handle->id, handle);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ _filter_func(DBusConnection *dbus_conn, DBusMessage *message, void *user_data)
|
|||
|
||||
reason = dbus_message_iter_get_uint32(&iter);
|
||||
|
||||
g_hash_table_remove(_handles, GINT_TO_POINTER(id));
|
||||
g_hash_table_remove(_handles, &id);
|
||||
}
|
||||
else if (dbus_message_is_signal(message, NOTIFY_DBUS_CORE_INTERFACE,
|
||||
"ActionInvoked"))
|
||||
|
@ -230,7 +230,7 @@ _filter_func(DBusConnection *dbus_conn, DBusMessage *message, void *user_data)
|
|||
|
||||
action_id = dbus_message_iter_get_uint32(&iter);
|
||||
|
||||
handle = g_hash_table_lookup(_handles, GINT_TO_POINTER(id));
|
||||
handle = g_hash_table_lookup(_handles, &id);
|
||||
|
||||
if (handle->actions_table == NULL)
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ _filter_func(DBusConnection *dbus_conn, DBusMessage *message, void *user_data)
|
|||
NotifyAction *action;
|
||||
|
||||
action = g_hash_table_lookup(handle->actions_table,
|
||||
GINT_TO_POINTER(action_id));
|
||||
&action_id);
|
||||
|
||||
if (action == NULL)
|
||||
{
|
||||
|
@ -578,7 +578,7 @@ notify_icon_destroy(NotifyIcon *icon)
|
|||
* Notifications API
|
||||
**************************************************************************/
|
||||
NotifyHandle *
|
||||
notify_send_notification(guint32 replaces, NotifyUrgency urgency, const char *summary,
|
||||
notify_send_notification(NotifyHandle *replaces, NotifyUrgency urgency, const char *summary,
|
||||
const char *detailed, const NotifyIcon *icon,
|
||||
gboolean expires, time_t expire_time,
|
||||
gpointer user_data, size_t action_count, ...)
|
||||
|
@ -598,7 +598,7 @@ notify_send_notification(guint32 replaces, NotifyUrgency urgency, const char *su
|
|||
}
|
||||
|
||||
NotifyHandle *
|
||||
notify_send_notification_varg(guint32 replaces, NotifyUrgency urgency, const char *summary,
|
||||
notify_send_notification_varg(NotifyHandle *replaces, NotifyUrgency urgency, const char *summary,
|
||||
const char *detailed, const NotifyIcon *icon,
|
||||
gboolean expires, time_t expire_time,
|
||||
gpointer user_data, size_t action_count,
|
||||
|
@ -619,7 +619,8 @@ notify_send_notification_varg(guint32 replaces, NotifyUrgency urgency, const cha
|
|||
#if 0
|
||||
_notify_dbus_message_iter_append_app_info(&iter);
|
||||
#endif
|
||||
dbus_message_iter_append_uint32(&iter, replaces);
|
||||
|
||||
dbus_message_iter_append_uint32(&iter, replaces ? replaces->id : 0);
|
||||
dbus_message_iter_append_byte(&iter, urgency);
|
||||
dbus_message_iter_append_string(&iter, summary);
|
||||
_notify_dbus_message_iter_append_string_or_nil(&iter, detailed);
|
||||
|
|
|
@ -77,6 +77,7 @@ gboolean notify_is_initted(void);
|
|||
*/
|
||||
void notify_close(NotifyHandle *handle);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the server information.
|
||||
*
|
||||
|
@ -165,7 +166,7 @@ void notify_icon_destroy(NotifyIcon *icon);
|
|||
*
|
||||
* @return A unique ID for the notification.
|
||||
*/
|
||||
NotifyHandle *notify_send_notification(guint32 replaces,
|
||||
NotifyHandle *notify_send_notification(NotifyHandle *replaces,
|
||||
NotifyUrgency urgency,
|
||||
const char *summary,
|
||||
const char *detailed,
|
||||
|
@ -183,7 +184,7 @@ NotifyHandle *notify_send_notification(guint32 replaces,
|
|||
* void callback(NotifyHandle *handle, guint32 action, void *user_data);
|
||||
* @endcode
|
||||
*
|
||||
* @param replaces The ID of the notification to atomically replace
|
||||
* @param replaces The handle of the notification to atomically replace
|
||||
* @param urgency The urgency level.
|
||||
* @param summary The summary of the notification.
|
||||
* @param detailed The optional detailed information.
|
||||
|
@ -198,7 +199,7 @@ NotifyHandle *notify_send_notification(guint32 replaces,
|
|||
*
|
||||
* @return A unique ID for the notification.
|
||||
*/
|
||||
NotifyHandle *notify_send_notification_varg(guint32 replaces,
|
||||
NotifyHandle *notify_send_notification_varg(NotifyHandle *replaces,
|
||||
NotifyUrgency urgency,
|
||||
const char *summary,
|
||||
const char *detailed,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
bin_PROGRAMS = notify-send
|
||||
bin_PROGRAMS = notify-send test-replace
|
||||
|
||||
common_ldflags = \
|
||||
$(top_builddir)/libnotify/libnotify.la \
|
||||
|
@ -8,4 +8,7 @@ common_ldflags = \
|
|||
notify_send_SOURCES = notify-send.c
|
||||
notify_send_LDADD = $(common_ldflags)
|
||||
|
||||
test_replace_SOURCES = test-replace.c
|
||||
test_replace_LDADD = $(common_ldflags)
|
||||
|
||||
INCLUDES = $(PACKAGE_CFLAGS)
|
||||
|
|
|
@ -130,7 +130,7 @@ main(int argc, const char **argv)
|
|||
/* if the given time is < current time, treat it as a timeout in seconds (ie 5 seconds) */
|
||||
if (expire_time && expire_time < time(NULL)) expire_time += time(NULL);
|
||||
|
||||
notify_send_notification(0, urgency, summary, description, icon,
|
||||
notify_send_notification(NULL, urgency, summary, description, icon,
|
||||
TRUE, expire_time, NULL, 0);
|
||||
|
||||
if (icon != NULL)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
#include <libnotify/notify.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
notify_init("Replace Test");
|
||||
|
||||
NotifyHandle *n = notify_send_notification(NULL, // replaces nothing
|
||||
NOTIFY_URGENCY_NORMAL,
|
||||
"Summary", "Content",
|
||||
NULL, // no icon
|
||||
FALSE, 0, // does not expire
|
||||
NULL, // no user data
|
||||
0); // no actions
|
||||
|
||||
if (!n) {
|
||||
fprintf(stderr, "failed to send notification\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
sleep(3);
|
||||
|
||||
notify_send_notification(n, NOTIFY_URGENCY_NORMAL, "Second Summary", "Second Content",
|
||||
NULL, TRUE, time(NULL) + 5, NULL, 0);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue