| 1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
| 2 |
* |
| 3 |
* @file tests/test-urgency.c Unit test: urgency levels |
| 4 |
* |
| 5 |
* @Copyright(C) 2006 Christian Hammond <[email protected]> |
| 6 |
* |
| 7 |
* This library is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU Lesser General Public |
| 9 |
* License as published by the Free Software Foundation; either |
| 10 |
* version 2.1 of the License, or(at your option) any later version. |
| 11 |
* |
| 12 |
* This library is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public |
| 18 |
* License along with this library; if not, write to the |
| 19 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 |
* Boston, MA 02111-1307, USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
#include <libnotify/notify.h> |
| 24 |
#include <stdlib.h> |
| 25 |
|
| 26 |
int |
| 27 |
main (int argc, char *argv[]) |
| 28 |
{ |
| 29 |
NotifyNotification *n; |
| 30 |
|
| 31 |
notify_init ("Urgency"); |
| 32 |
|
| 33 |
n = notify_notification_new ("Low Urgency", |
| 34 |
"Joe signed online.", |
| 35 |
NULL); |
| 36 |
notify_notification_set_urgency (n, NOTIFY_URGENCY_LOW); |
| 37 |
if (!notify_notification_show (n, NULL)) { |
| 38 |
fprintf (stderr, "failed to send notification\n"); |
| 39 |
exit (1); |
| 40 |
} |
| 41 |
|
| 42 |
g_object_unref (G_OBJECT (n)); |
| 43 |
|
| 44 |
|
| 45 |
n = notify_notification_new ("Normal Urgency", |
| 46 |
"You have a meeting in 10 minutes.", |
| 47 |
NULL); |
| 48 |
notify_notification_set_urgency (n, NOTIFY_URGENCY_NORMAL); |
| 49 |
if (!notify_notification_show (n, NULL)) { |
| 50 |
fprintf (stderr, "failed to send notification\n"); |
| 51 |
exit (1); |
| 52 |
} |
| 53 |
|
| 54 |
g_object_unref (G_OBJECT (n)); |
| 55 |
|
| 56 |
|
| 57 |
n = notify_notification_new ("Critical Urgency", |
| 58 |
"This message will self-destruct in 10 seconds.", |
| 59 |
NULL); |
| 60 |
notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL); |
| 61 |
notify_notification_set_timeout (n, 10000); // 10 seconds |
| 62 |
|
| 63 |
if (!notify_notification_show (n, NULL)) { |
| 64 |
fprintf (stderr, "failed to send notification\n"); |
| 65 |
exit (1); |
| 66 |
} |
| 67 |
|
| 68 |
g_object_unref (G_OBJECT (n)); |
| 69 |
|
| 70 |
return 0; |
| 71 |
} |