Debian Codegraph @

tests/test-removal.c

raw
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or(at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 02111-1307, USA.
17 */
18
19 #include <stdlib.h>
20 #include <libnotify/notify.h>
21 #include <gtk/gtk.h>
22
23 static GMainLoop *loop;
24
25 static void
26 next_callback (NotifyNotification *n,
27 const char *action)
28 {
29 g_assert (action != NULL);
30
31 printf ("You clicked Next\n");
32
33 notify_notification_close (n, NULL);
34
35 g_main_loop_quit (loop);
36 }
37
38 int
39 main (int argc, char *argv[])
40 {
41 NotifyNotification *n;
42
43 loop = g_main_loop_new (NULL, FALSE);
44
45 notify_init ("Urgency");
46
47 n = notify_notification_new ("Low Urgency",
48 "Joe signed online.",
49 NULL);
50 notify_notification_set_urgency (n, NOTIFY_URGENCY_LOW);
51 if (!notify_notification_show (n, NULL)) {
52 fprintf (stderr, "failed to send notification\n");
53 exit (1);
54 }
55
56 sleep (3);
57
58 if (!notify_notification_close (n, NULL)) {
59 fprintf (stderr, "failed to remove notification\n");
60 exit (1);
61 }
62
63 g_object_unref (G_OBJECT (n));
64
65
66 n = notify_notification_new ("Normal Urgency",
67 "You have a meeting in 10 minutes.",
68 NULL);
69 notify_notification_set_urgency (n, NOTIFY_URGENCY_NORMAL);
70 if (!notify_notification_show (n, NULL)) {
71 fprintf (stderr, "failed to send notification\n");
72 exit (1);
73 }
74
75 sleep (3);
76
77 if (!notify_notification_close (n, NULL)) {
78 fprintf (stderr, "failed to remove notification\n");
79 exit (1);
80 }
81
82 g_object_unref (G_OBJECT (n));
83
84
85 n = notify_notification_new ("Critical Urgency",
86 "This message will self-destruct in 10 seconds.",
87 NULL);
88 notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
89 notify_notification_set_timeout (n, NOTIFY_EXPIRES_NEVER);
90 notify_notification_add_action (n,
91 "media-skip-forward",
92 "Next",
93 (NotifyActionCallback) next_callback,
94 NULL,
95 NULL);
96
97 if (!notify_notification_show (n, NULL)) {
98 fprintf (stderr, "failed to send notification\n");
99 exit (1);
100 }
101
102 sleep (3);
103
104 if (!notify_notification_close (n, NULL)) {
105 fprintf (stderr, "failed to remove notification\n");
106 exit (1);
107 }
108
109 g_main_loop_run (loop);
110
111 g_object_unref (G_OBJECT (n));
112
113 return 0;
114 }