35
36
static GMainLoop *loop;
38
help_callback(NotifyNotification *n, const char *action)
40
g_assert(action != NULL);
41
g_assert(strcmp(action, "help") == 0);
43
printf("You clicked Help\n");
45
notify_notification_close(n, NULL);
47
g_main_loop_quit(loop);
51
ignore_callback(NotifyNotification *n, const char *action)
53
g_assert(action != NULL);
54
g_assert(strcmp(action, "ignore") == 0);
56
printf("You clicked Ignore\n");
58
notify_notification_close(n, NULL);
60
g_main_loop_quit(loop);
64
empty_callback(NotifyNotification *n, const char *action)
66
g_assert(action != NULL);
67
g_assert(strcmp(action, "empty") == 0);
69
printf("You clicked Empty Trash\n");
71
notify_notification_close(n, NULL);
73
g_main_loop_quit(loop);
39
help_callback (NotifyNotification *n,
42
g_assert (action != NULL);
43
g_assert (strcmp (action, "help") == 0);
45
printf ("You clicked Help\n");
47
notify_notification_close (n, NULL);
49
g_main_loop_quit (loop);
53
ignore_callback (NotifyNotification *n,
56
g_assert (action != NULL);
57
g_assert (strcmp (action, "ignore") == 0);
59
printf ("You clicked Ignore\n");
61
notify_notification_close (n, NULL);
63
g_main_loop_quit (loop);
67
empty_callback (NotifyNotification *n,
70
g_assert (action != NULL);
71
g_assert (strcmp (action, "empty") == 0);
73
printf ("You clicked Empty Trash\n");
75
notify_notification_close (n, NULL);
77
g_main_loop_quit (loop);
78
main(int argc, char **argv)
82
main (int argc, char **argv)
80
NotifyNotification *n;
83
if (!notify_init("Multi Action Test"))
86
conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
87
loop = g_main_loop_new(NULL, FALSE);
89
dbus_connection_setup_with_g_main(conn, NULL);
91
n = notify_notification_new("Low disk space",
92
"You can free up some disk space by "
93
"emptying the trash can.",
95
notify_notification_set_urgency(n, NOTIFY_URGENCY_CRITICAL);
96
notify_notification_set_timeout(n, NOTIFY_EXPIRES_DEFAULT);
97
notify_notification_add_action(n, "help", "Help",
98
(NotifyActionCallback)help_callback,
100
notify_notification_add_action(n, "ignore", "Ignore",
101
(NotifyActionCallback)ignore_callback,
103
notify_notification_add_action(n, "empty", "Empty Trash",
104
(NotifyActionCallback)empty_callback,
106
notify_notification_set_category(n, "device");
108
if (!notify_notification_show(n, NULL))
110
fprintf(stderr, "failed to send notification\n");
114
g_main_loop_run(loop);
84
NotifyNotification *n;
87
if (!notify_init ("Multi Action Test"))
90
conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
91
loop = g_main_loop_new (NULL, FALSE);
93
dbus_connection_setup_with_g_main (conn, NULL);
95
n = notify_notification_new ("Low disk space",
96
"You can free up some disk space by "
97
"emptying the trash can.",
100
notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
101
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
102
notify_notification_add_action (n,
105
(NotifyActionCallback) help_callback,
108
notify_notification_add_action (n,
111
(NotifyActionCallback)
115
notify_notification_add_action (n,
118
(NotifyActionCallback) empty_callback,
121
notify_notification_set_category (n, "device");
123
if (!notify_notification_show (n, NULL)) {
124
fprintf (stderr, "failed to send notification\n");
128
g_main_loop_run (loop);