summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Jon McCann <jmccann@redhat.com>2010-10-29 18:16:31 -0400
committerWilliam Jon McCann <jmccann@redhat.com>2010-10-29 18:16:31 -0400
commit714c29afccd47aec22e4033634c3620c85843dc1 (patch)
treee453ea822d2b02c49b5dd7cb06cef7421e162db5
parent4026faf46b093d2f4207732f4019a595e08e8ada (diff)
downloadlibnotify-714c29afccd47aec22e4033634c3620c85843dc1.tar.gz
Enhance the resident test
-rw-r--r--tests/test-resident.c53
1 files changed, 50 insertions, 3 deletions
diff --git a/tests/test-resident.c b/tests/test-resident.c
index bcbe6f0..9bf2a93 100644
--- a/tests/test-resident.c
+++ b/tests/test-resident.c
@@ -23,35 +23,79 @@
#include <string.h>
static GMainLoop *loop;
+static int counter;
+static gboolean is_playing;
static void
prev_callback (NotifyNotification *n,
const char *action)
{
+ char *body;
+
g_assert (action != NULL);
g_assert (strcmp (action, "previous") == 0);
printf ("You clicked Previous\n");
+ body = g_strdup_printf ("Playing some fine song %d", --counter);
+ notify_notification_update (n,
+ "Music Player",
+ body,
+ "audio-x-generic");
+ g_free (body);
+
+ if (!notify_notification_show (n, NULL)) {
+ fprintf (stderr, "failed to send update\n");
+ }
}
static void
pause_callback (NotifyNotification *n,
- const char *action)
+ const char *action)
{
+ char *body;
+
g_assert (action != NULL);
g_assert (strcmp (action, "pause") == 0);
- printf ("You clicked Pause\n");
+ printf ("You clicked Play/Pause\n");
+ is_playing = !is_playing;
+ if (is_playing) {
+ body = g_strdup_printf ("Playing some fine song %d", counter);
+ } else {
+ body = g_strdup_printf ("Not playing some fine song %d", counter);
+ }
+
+ notify_notification_update (n,
+ "Music Player",
+ body,
+ "audio-x-generic");
+ g_free (body);
+
+ if (!notify_notification_show (n, NULL)) {
+ fprintf (stderr, "failed to send update\n");
+ }
}
static void
next_callback (NotifyNotification *n,
- const char *action)
+ const char *action)
{
+ char *body;
+
g_assert (action != NULL);
g_assert (strcmp (action, "next") == 0);
printf ("You clicked Next\n");
+ body = g_strdup_printf ("Playing some fine song %d", ++counter);
+ notify_notification_update (n,
+ "Music Player",
+ body,
+ "audio-x-generic");
+ g_free (body);
+
+ if (!notify_notification_show (n, NULL)) {
+ fprintf (stderr, "failed to send update\n");
+ }
}
@@ -66,6 +110,9 @@ main (int argc, char **argv)
loop = g_main_loop_new (NULL, FALSE);
+ counter = 0;
+ is_playing = TRUE;
+
n = notify_notification_new ("Music Player",
"Playing some fine song",
"audio-x-generic");