| 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 <libnotify/notify.h> |
| 20 |
#include <stdio.h> |
| 21 |
#include <unistd.h> |
| 22 |
#include <glib.h> |
| 23 |
|
| 24 |
int |
| 25 |
main () |
| 26 |
{ |
| 27 |
NotifyNotification *n; |
| 28 |
GError *error; |
| 29 |
error = NULL; |
| 30 |
|
| 31 |
notify_init ("Replace Test"); |
| 32 |
|
| 33 |
n = notify_notification_new ("Summary", |
| 34 |
"First message", |
| 35 |
NULL); //no icon |
| 36 |
|
| 37 |
notify_notification_set_timeout (n, 0); //don't timeout |
| 38 |
|
| 39 |
if (!notify_notification_show (n, &error)) { |
| 40 |
fprintf (stderr, "failed to send notification: %s\n", |
| 41 |
error->message); |
| 42 |
g_error_free (error); |
| 43 |
return 1; |
| 44 |
} |
| 45 |
|
| 46 |
sleep (3); |
| 47 |
|
| 48 |
notify_notification_update (n, |
| 49 |
"Second Summary", |
| 50 |
"First mesage was replaced", |
| 51 |
NULL); |
| 52 |
notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT); |
| 53 |
|
| 54 |
if (!notify_notification_show (n, &error)) { |
| 55 |
fprintf (stderr, |
| 56 |
"failed to send notification: %s\n", |
| 57 |
error->message); |
| 58 |
g_error_free (error); |
| 59 |
return 1; |
| 60 |
} |
| 61 |
|
| 62 |
return 0; |
| 63 |
} |