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