Use consistent style in the tests

This commit is contained in:
William Jon McCann 2010-01-29 02:59:26 -05:00
parent a8524aed6a
commit 5d5a284ca6
14 changed files with 530 additions and 418 deletions

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-basic.c Unit test: basics * @file tests/test-basic.c Unit test: basics
* *
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx> * @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
@ -23,14 +24,17 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
int main() { int
main ()
{
NotifyNotification *n; NotifyNotification *n;
notify_init ("Basics"); notify_init ("Basics");
n = notify_notification_new ("Summary", n = notify_notification_new ("Summary",
"Content that is very long 8374983278r32j4 rhjjfh dw8f 43jhf 8ds7 ur2389f jdbjkt h8924yf jkdbjkt 892hjfiHER98HEJIF BDSJHF hjdhF JKLH 890YRHEJHFU 89HRJKSHdd dddd ddddd dddd ddddd dddd ddddd dddd dddd ddd ddd dddd Fdd d ddddd dddddddd ddddddddhjkewdkjsjfjk sdhkjf hdkj dadasdadsa adsd asd sd saasd fadskfkhsjf hsdkhfkshfjkhsd kjfhsjdkhfj ksdhfkjshkjfsd sadhfjkhaskd jfhsdajkfhkjs dhfkjsdhfkjs adhjkfhasdkj fhdsakjhfjk asdhkjkfhd akfjshjfsk afhjkasdhf jkhsdaj hf kjsdfahkfh sakjhfksdah kfdashkjf ksdahfj shdjdh", "Content that is very long 8374983278r32j4 rhjjfh dw8f 43jhf 8ds7 ur2389f jdbjkt h8924yf jkdbjkt 892hjfiHER98HEJIF BDSJHF hjdhF JKLH 890YRHEJHFU 89HRJKSHdd dddd ddddd dddd ddddd dddd ddddd dddd dddd ddd ddd dddd Fdd d ddddd dddddddd ddddddddhjkewdkjsjfjk sdhkjf hdkj dadasdadsa adsd asd sd saasd fadskfkhsjf hsdkhfkshfjkhsd kjfhsjdkhfj ksdhfkjshkjfsd sadhfjkhaskd jfhsdajkfhkjs dhfkjsdhfkjs adhjkfhasdkj fhdsakjhfjk asdhkjkfhd akfjshjfsk afhjkasdhf jkhsdaj hf kjsdfahkfh sakjhfksdah kfdashkjf ksdahfj shdjdh",
NULL, NULL); NULL,
NULL);
notify_notification_set_timeout (n, 3000); //3 seconds notify_notification_set_timeout (n, 3000); //3 seconds
if (!notify_notification_show (n, NULL)) { if (!notify_notification_show (n, NULL)) {

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-default-action.c Unit test: default action * @file tests/test-default-action.c Unit test: default action
* *
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx> * @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
@ -35,7 +36,10 @@
static GMainLoop *loop; static GMainLoop *loop;
static void callback(NotifyNotification *n, const char *action, void *user_data) static void
callback (NotifyNotification *n,
const char *action,
void *user_data)
{ {
printf ("callback\n"); printf ("callback\n");
assert (action != NULL); assert (action != NULL);
@ -52,7 +56,8 @@ main()
NotifyNotification *n; NotifyNotification *n;
DBusConnection *conn; DBusConnection *conn;
if (!notify_init("Default Action Test")) exit(1); if (!notify_init ("Default Action Test"))
exit (1);
conn = dbus_bus_get (DBUS_BUS_SESSION, NULL); conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);
@ -61,9 +66,12 @@ main()
n = notify_notification_new ("Matt is online", "", NULL, NULL); n = notify_notification_new ("Matt is online", "", NULL, NULL);
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT); notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
notify_notification_add_action (n, "default", "Do Default Action", notify_notification_add_action (n,
"default",
"Do Default Action",
(NotifyActionCallback) callback, (NotifyActionCallback) callback,
NULL, NULL); NULL,
NULL);
notify_notification_set_category (n, "presence.online"); notify_notification_set_category (n, "presence.online");
if (!notify_notification_show (n, NULL)) { if (!notify_notification_show (n, NULL)) {

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-default-action.c Unit test: error handling * @file tests/test-default-action.c Unit test: error handling
* *
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx> * @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
@ -23,16 +24,16 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
int main() { int
main ()
{
NotifyNotification *n; NotifyNotification *n;
g_type_init (); g_type_init ();
notify_init ("Error Handling"); notify_init ("Error Handling");
n = notify_notification_new ("Summary", n = notify_notification_new ("Summary", "Content", NULL, NULL);
"Content",
NULL, NULL);
notify_notification_set_timeout (n, 3000); //3 seconds notify_notification_set_timeout (n, 3000); //3 seconds
/* TODO: Create an error condition */ /* TODO: Create an error condition */

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-image.c Unit test: images * @file tests/test-image.c Unit test: images
* *
* @Copyright(C) 2004 Mike Hearn <mike@navi.cx> * @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
@ -56,11 +57,12 @@ main(int argc, char *argv[])
exit (1); exit (1);
/* Stock icon */ /* Stock icon */
n = notify_notification_new("Icon Test", "Testing stock icon", n = notify_notification_new ("Icon Test",
"appointment-new", NULL); "Testing stock icon",
"appointment-new",
NULL);
if (!notify_notification_show(n, NULL)) if (!notify_notification_show (n, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
return 1; return 1;
} }
@ -68,16 +70,20 @@ main(int argc, char *argv[])
g_object_unref (G_OBJECT (n)); g_object_unref (G_OBJECT (n));
file = g_get_current_dir (); file = g_get_current_dir ();
uri = g_strdup_printf("file://%s/%s", file, "applet-critical.png"); uri = g_strdup_printf ("file://%s/%s",
file,
"applet-critical.png");
g_free (file); g_free (file);
printf ("sending %s\n", uri); printf ("sending %s\n", uri);
/* URIs */ /* URIs */
n = notify_notification_new("Alert!", "Testing URI icons", uri, NULL); n = notify_notification_new ("Alert!",
"Testing URI icons",
uri,
NULL);
if (!notify_notification_show(n, NULL)) if (!notify_notification_show (n, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
return 1; return 1;
} }
@ -86,7 +92,9 @@ main(int argc, char *argv[])
/* Raw image */ /* Raw image */
n = notify_notification_new ("Raw image test", n = notify_notification_new ("Raw image test",
"Testing sending raw pixbufs", NULL, NULL); "Testing sending raw pixbufs",
NULL,
NULL);
/* /*
* This is just a hack to get a stock icon's pixbuf in a realworld app * This is just a hack to get a stock icon's pixbuf in a realworld app
@ -103,8 +111,7 @@ main(int argc, char *argv[])
notify_notification_set_icon_from_pixbuf (n, icon); notify_notification_set_icon_from_pixbuf (n, icon);
g_object_unref (G_OBJECT (icon)); g_object_unref (G_OBJECT (icon));
if (!notify_notification_show(n, NULL)) if (!notify_notification_show (n, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
return 1; return 1;
} }

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-markup.c Unit test: markup * @file tests/test-markup.c Unit test: markup
* *
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx> * @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
@ -23,7 +24,9 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
int main() { int
main ()
{
NotifyNotification *n; NotifyNotification *n;
notify_init ("Markup"); notify_init ("Markup");
@ -31,7 +34,8 @@ int main() {
n = notify_notification_new ("Summary", n = notify_notification_new ("Summary",
"Some <b>bold</b>, <u>underlined</u>, <i>italic</i>, " "Some <b>bold</b>, <u>underlined</u>, <i>italic</i>, "
"<a href='http://www.google.com'>linked</a> text", "<a href='http://www.google.com'>linked</a> text",
NULL, NULL); NULL,
NULL);
notify_notification_set_timeout (n, 3000); //3 seconds notify_notification_set_timeout (n, 3000); //3 seconds
if (!notify_notification_show (n, NULL)) { if (!notify_notification_show (n, NULL)) {

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-multi-actions.c Unit test: multiple actions * @file tests/test-multi-actions.c Unit test: multiple actions
* *
* @Copyright(C) 2004 Mike Hearn <mike@navi.cx> * @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
@ -35,7 +36,8 @@
static GMainLoop *loop; static GMainLoop *loop;
static void static void
help_callback(NotifyNotification *n, const char *action) help_callback (NotifyNotification *n,
const char *action)
{ {
g_assert (action != NULL); g_assert (action != NULL);
g_assert (strcmp (action, "help") == 0); g_assert (strcmp (action, "help") == 0);
@ -48,7 +50,8 @@ help_callback(NotifyNotification *n, const char *action)
} }
static void static void
ignore_callback(NotifyNotification *n, const char *action) ignore_callback (NotifyNotification *n,
const char *action)
{ {
g_assert (action != NULL); g_assert (action != NULL);
g_assert (strcmp (action, "ignore") == 0); g_assert (strcmp (action, "ignore") == 0);
@ -61,7 +64,8 @@ ignore_callback(NotifyNotification *n, const char *action)
} }
static void static void
empty_callback(NotifyNotification *n, const char *action) empty_callback (NotifyNotification *n,
const char *action)
{ {
g_assert (action != NULL); g_assert (action != NULL);
g_assert (strcmp (action, "empty") == 0); g_assert (strcmp (action, "empty") == 0);
@ -91,22 +95,32 @@ main(int argc, char **argv)
n = notify_notification_new ("Low disk space", n = notify_notification_new ("Low disk space",
"You can free up some disk space by " "You can free up some disk space by "
"emptying the trash can.", "emptying the trash can.",
NULL, NULL); NULL,
NULL);
notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL); notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT); notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
notify_notification_add_action(n, "help", "Help", notify_notification_add_action (n,
"help",
"Help",
(NotifyActionCallback) help_callback, (NotifyActionCallback) help_callback,
NULL, NULL); NULL,
notify_notification_add_action(n, "ignore", "Ignore", NULL);
(NotifyActionCallback)ignore_callback, notify_notification_add_action (n,
NULL, NULL); "ignore",
notify_notification_add_action(n, "empty", "Empty Trash", "Ignore",
(NotifyActionCallback)
ignore_callback,
NULL,
NULL);
notify_notification_add_action (n,
"empty",
"Empty Trash",
(NotifyActionCallback) empty_callback, (NotifyActionCallback) empty_callback,
NULL, NULL); NULL,
NULL);
notify_notification_set_category (n, "device"); notify_notification_set_category (n, "device");
if (!notify_notification_show(n, NULL)) if (!notify_notification_show (n, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
return 1; return 1;
} }

View File

@ -1,3 +1,21 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <libnotify/notify.h> #include <libnotify/notify.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -7,7 +25,9 @@
static int count = 0; static int count = 0;
static void static void
on_exposed(GtkWidget *widget, GdkEventExpose *ev, void *user_data) on_exposed (GtkWidget *widget,
GdkEventExpose *ev,
void *user_data)
{ {
NotifyNotification *n = NOTIFY_NOTIFICATION (user_data); NotifyNotification *n = NOTIFY_NOTIFICATION (user_data);
@ -17,7 +37,8 @@ on_exposed(GtkWidget *widget, GdkEventExpose *ev, void *user_data)
} }
static void static void
on_clicked(GtkButton *button, void *user_data) on_clicked (GtkButton *button,
void *user_data)
{ {
gchar *buf; gchar *buf;
NotifyNotification *n = NOTIFY_NOTIFICATION (user_data); NotifyNotification *n = NOTIFY_NOTIFICATION (user_data);
@ -41,8 +62,10 @@ main(int argc, char *argv[])
notify_init ("Replace Test"); notify_init ("Replace Test");
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete_event", g_signal_connect (G_OBJECT (window),
G_CALLBACK(gtk_main_quit), NULL); "delete_event",
G_CALLBACK (gtk_main_quit),
NULL);
button = gtk_button_new_with_label ("click here to change notification"); button = gtk_button_new_with_label ("click here to change notification");
gtk_container_add (GTK_CONTAINER (window), button); gtk_container_add (GTK_CONTAINER (window), button);
@ -56,10 +79,14 @@ main(int argc, char *argv[])
notify_notification_set_timeout (n, 0); //don't timeout notify_notification_set_timeout (n, 0); //don't timeout
g_signal_connect(G_OBJECT(button), "clicked", g_signal_connect (G_OBJECT (button),
G_CALLBACK(on_clicked), n); "clicked",
g_signal_connect_after(G_OBJECT(button), "expose-event", G_CALLBACK (on_clicked),
G_CALLBACK(on_exposed), n); n);
g_signal_connect_after (G_OBJECT (button),
"expose-event",
G_CALLBACK (on_exposed),
n);
gtk_main (); gtk_main ();

View File

@ -1,9 +1,29 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <libnotify/notify.h> #include <libnotify/notify.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <glib.h> #include <glib.h>
int main() { int
main ()
{
NotifyNotification *n; NotifyNotification *n;
GError *error; GError *error;
error = NULL; error = NULL;
@ -12,7 +32,8 @@ int main() {
notify_init ("Replace Test"); notify_init ("Replace Test");
n = notify_notification_new ("Summary", "First message", n = notify_notification_new ("Summary",
"First message",
NULL, //no icon NULL, //no icon
NULL); //don't attach to widget NULL); //don't attach to widget
@ -20,19 +41,24 @@ int main() {
notify_notification_set_timeout (n, 0); //don't timeout notify_notification_set_timeout (n, 0); //don't timeout
if (!notify_notification_show (n, &error)) { if (!notify_notification_show (n, &error)) {
fprintf(stderr, "failed to send notification: %s\n", error->message); fprintf (stderr, "failed to send notification: %s\n",
error->message);
g_error_free (error); g_error_free (error);
return 1; return 1;
} }
sleep (3); sleep (3);
notify_notification_update (n, "Second Summary", notify_notification_update (n,
"First mesage was replaced", NULL); "Second Summary",
"First mesage was replaced",
NULL);
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT); notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
if (!notify_notification_show (n, &error)) { if (!notify_notification_show (n, &error)) {
fprintf(stderr, "failed to send notification: %s\n", error->message); fprintf (stderr,
"failed to send notification: %s\n",
error->message);
g_error_free (error); g_error_free (error);
return 1; return 1;
} }

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-server-info.c Retrieves the server info and caps * @file tests/test-server-info.c Retrieves the server info and caps
* *
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx> * @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
@ -31,8 +32,7 @@ main(int argc, char **argv)
notify_init ("TestCaps"); notify_init ("TestCaps");
if (!notify_get_server_info(&name, &vendor, &version, &spec_version)) if (!notify_get_server_info (&name, &vendor, &version, &spec_version)) {
{
fprintf (stderr, "Failed to receive server info.\n"); fprintf (stderr, "Failed to receive server info.\n");
exit (1); exit (1);
} }
@ -45,8 +45,7 @@ main(int argc, char **argv)
caps = notify_get_server_caps (); caps = notify_get_server_caps ();
if (caps == NULL) if (caps == NULL) {
{
fprintf (stderr, "Failed to receive server caps.\n"); fprintf (stderr, "Failed to receive server caps.\n");
exit (1); exit (1);
} }

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-size-changes.c Unit test: Notification size changes * @file tests/test-size-changes.c Unit test: Notification size changes
* *
* @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com> * @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com>
@ -30,35 +31,38 @@ main()
notify_init ("Size Changes"); notify_init ("Size Changes");
n1 = notify_notification_new("Notification 1", "Notification number 1!", n1 = notify_notification_new ("Notification 1",
NULL, NULL); "Notification number 1!",
NULL,
NULL);
notify_notification_set_timeout (n1, 7000); notify_notification_set_timeout (n1, 7000);
if (!notify_notification_show(n1, NULL)) if (!notify_notification_show (n1, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
return 1; return 1;
} }
g_object_unref (G_OBJECT (n1)); g_object_unref (G_OBJECT (n1));
n2 = notify_notification_new("Notification 2", "Notification number 2!", n2 = notify_notification_new ("Notification 2",
NULL, NULL); "Notification number 2!",
NULL,
NULL);
notify_notification_set_timeout (n2, 7000); notify_notification_set_timeout (n2, 7000);
if (!notify_notification_show(n2, NULL)) if (!notify_notification_show (n2, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
return 1; return 1;
} }
n3 = notify_notification_new("Notification 3", "Notification number 3!", n3 = notify_notification_new ("Notification 3",
NULL, NULL); "Notification number 3!",
NULL,
NULL);
notify_notification_set_timeout (n3, 7000); notify_notification_set_timeout (n3, 7000);
if (!notify_notification_show(n3, NULL)) if (!notify_notification_show (n3, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
return 1; return 1;
} }
@ -67,15 +71,14 @@ main()
sleep (2); sleep (2);
notify_notification_update(n2, "Longer Notification 2", notify_notification_update (n2,
"Longer Notification 2",
"This is a much longer notification.\n" "This is a much longer notification.\n"
"Two lines.\n" "Two lines.\n"
"Well, okay, three.\n" "Well, okay, three.\n" "Last one.",
"Last one.",
NULL); NULL);
if (!notify_notification_show(n2, NULL)) if (!notify_notification_show (n2, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
return 1; return 1;
} }

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-urgency.c Unit test: urgency levels * @file tests/test-urgency.c Unit test: urgency levels
* *
* @Copyright(C) 2006 Christian Hammond <chipx8@chipx86.com> * @Copyright(C) 2006 Christian Hammond <chipx8@chipx86.com>
@ -29,11 +30,12 @@ main(int argc, char *argv[])
notify_init ("Urgency"); notify_init ("Urgency");
n = notify_notification_new("Low Urgency", "Joe signed online.", n = notify_notification_new ("Low Urgency",
NULL, NULL); "Joe signed online.",
NULL,
NULL);
notify_notification_set_urgency (n, NOTIFY_URGENCY_LOW); notify_notification_set_urgency (n, NOTIFY_URGENCY_LOW);
if (!notify_notification_show(n, NULL)) if (!notify_notification_show (n, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
exit (1); exit (1);
} }
@ -43,10 +45,10 @@ main(int argc, char *argv[])
n = notify_notification_new ("Normal Urgency", n = notify_notification_new ("Normal Urgency",
"You have a meeting in 10 minutes.", "You have a meeting in 10 minutes.",
NULL, NULL); NULL,
NULL);
notify_notification_set_urgency (n, NOTIFY_URGENCY_NORMAL); notify_notification_set_urgency (n, NOTIFY_URGENCY_NORMAL);
if (!notify_notification_show(n, NULL)) if (!notify_notification_show (n, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
exit (1); exit (1);
} }
@ -57,12 +59,12 @@ main(int argc, char *argv[])
n = notify_notification_new ("Critical Urgency", n = notify_notification_new ("Critical Urgency",
"This message will self-destruct in 10 " "This message will self-destruct in 10 "
"seconds.", "seconds.",
NULL, NULL); NULL,
NULL);
notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL); notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
notify_notification_set_timeout (n, 10000); // 10 seconds notify_notification_set_timeout (n, 10000); // 10 seconds
if (!notify_notification_show(n, NULL)) if (!notify_notification_show (n, NULL)) {
{
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");
exit (1); exit (1);
} }

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-xy-actions.c Unit test: X, Y hints and actions * @file tests/test-xy-actions.c Unit test: X, Y hints and actions
* *
* @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com> * @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com>
@ -31,7 +32,8 @@
static GMainLoop *loop; static GMainLoop *loop;
static void static void
action_cb(NotifyNotification *n, const char *action) action_cb (NotifyNotification *n,
const char *action)
{ {
printf ("You clicked '%s'\n", action); printf ("You clicked '%s'\n", action);
@ -54,16 +56,23 @@ main(int argc, char **argv)
n = notify_notification_new ("System update available", n = notify_notification_new ("System update available",
"New system updates are available. It is " "New system updates are available. It is "
"recommended that you install the updates.", "recommended that you install the updates.",
NULL, NULL); NULL,
NULL);
notify_notification_set_hint_int32 (n, "x", 600); notify_notification_set_hint_int32 (n, "x", 600);
notify_notification_set_hint_int32 (n, "y", 10); notify_notification_set_hint_int32 (n, "y", 10);
notify_notification_add_action(n, "help", "Help", notify_notification_add_action (n,
"help",
"Help",
(NotifyActionCallback) action_cb, (NotifyActionCallback) action_cb,
NULL, NULL); NULL,
notify_notification_add_action(n, "update", "Update", NULL);
notify_notification_add_action (n,
"update",
"Update",
(NotifyActionCallback) action_cb, (NotifyActionCallback) action_cb,
NULL, NULL); NULL,
NULL);
if (!notify_notification_show (n, NULL)) { if (!notify_notification_show (n, NULL)) {
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-xy.c Unit test: X, Y hints * @file tests/test-xy.c Unit test: X, Y hints
* *
* @Copyright(C) 2005 Christian Hammond <chipx86@chipx86.com> * @Copyright(C) 2005 Christian Hammond <chipx86@chipx86.com>
@ -38,7 +39,8 @@ emit_notification(int x, int y)
NotifyNotification *n; NotifyNotification *n;
buffer = g_strdup_printf ("This notification should point to %d, %d.", buffer = g_strdup_printf ("This notification should point to %d, %d.",
x, y); x,
y);
n = notify_notification_new ("X, Y Test", buffer, NULL, NULL); n = notify_notification_new ("X, Y Test", buffer, NULL, NULL);
g_free (buffer); g_free (buffer);
@ -46,8 +48,10 @@ emit_notification(int x, int y)
notify_notification_set_hint_int32 (n, "x", x); notify_notification_set_hint_int32 (n, "x", x);
notify_notification_set_hint_int32 (n, "y", y); notify_notification_set_hint_int32 (n, "y", y);
g_signal_connect(G_OBJECT(n), "closed", g_signal_connect (G_OBJECT (n),
G_CALLBACK(_handle_closed), NULL); "closed",
G_CALLBACK (_handle_closed),
NULL);
if (!notify_notification_show (n, NULL)) if (!notify_notification_show (n, NULL))
fprintf (stderr, "failed to send notification\n"); fprintf (stderr, "failed to send notification\n");

View File

@ -1,4 +1,5 @@
/* /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file tests/test-xy.c Unit test: X, Y hints * @file tests/test-xy.c Unit test: X, Y hints
* *
* @Copyright (C) 2005 Christian Hammond <chipx86@chipx86.com> * @Copyright (C) 2005 Christian Hammond <chipx86@chipx86.com>
@ -23,14 +24,17 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
int main() { int
main ()
{
NotifyNotification *n; NotifyNotification *n;
notify_init ("XY"); notify_init ("XY");
n = notify_notification_new ("X, Y Test", n = notify_notification_new ("X, Y Test",
"This notification should point to 150, 10", "This notification should point to 150, 10",
NULL, NULL); NULL,
NULL);
notify_notification_set_hint_int32 (n, "x", 150); notify_notification_set_hint_int32 (n, "x", 150);
notify_notification_set_hint_int32 (n, "y", 10); notify_notification_set_hint_int32 (n, "y", 10);