1
/*******************************************************************************
2
**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
3
** 10 20 30 40 50 60 70 80
6
** Example of how to use libnotify correctly and at the same time comply to
7
** the new jaunty notification spec (read: visual guidelines)
10
** gcc -O0 -ggdb -Wall -Werror `pkg-config --cflags --libs libnotify \
11
** glib-2.0` update-notifications.c example-util.c -o update-notifications
13
** Copyright 2009 Canonical Ltd.
16
** Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
18
** This program is free software: you can redistribute it and/or modify it
19
** under the terms of the GNU General Public License version 3, as published
20
** by the Free Software Foundation.
22
** This program is distributed in the hope that it will be useful, but
23
** WITHOUT ANY WARRANTY; without even the implied warranties of
24
** MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
25
** PURPOSE. See the GNU General Public License for more details.
27
** You should have received a copy of the GNU General Public License along
28
** with this program. If not, see <http://www.gnu.org/licenses/>.
30
*******************************************************************************/
32
#include "example-util.h"
38
NotifyNotification* notification;
42
if (!notify_init ("update-notifications"))
45
/* call this so we can savely use has_cap(CAP_SOMETHING) later */
48
/* show what's supported */
51
/* try the icon-summary-body case */
52
notification = notify_notification_new (
53
"Inital notification",
54
"This is the original content of "
55
"this notification-bubble.",
56
"notification-message-im");
58
success = notify_notification_show (notification, &error);
61
g_print ("That did not work ... \"%s\".\n", error->message);
65
g_signal_connect (G_OBJECT (notification),
67
G_CALLBACK (closed_handler),
70
sleep (3); /* simulate some app activity */
72
/* update the current notification with new content */
73
success = notify_notification_update (notification,
74
"Updated notification",
75
"Here the same bubble with new "
76
"title- and body-text, even the "
77
"icon can be changed on the update.",
78
"notification-message-email");
80
success = notify_notification_show (notification, &error);
83
g_print ("That did not work ... \"%s\".\n", error->message);
87
g_signal_connect (G_OBJECT (notification),
89
G_CALLBACK (closed_handler),
92
sleep (6); /* wait long enough to have the current bubble expire */
94
/* create a new bubble using the icon-summary-body layout */
95
notification = notify_notification_new (
97
"This bubble uses the icon-title-body "
99
"notification-message-im");
101
success = notify_notification_show (notification, &error);
104
g_print ("That did not work ... \"%s\".\n", error->message);
105
g_error_free (error);
108
g_signal_connect (G_OBJECT (notification),
110
G_CALLBACK (closed_handler),
113
sleep (3); /* again simulate some app activity */
115
/* now update current bubble again, but change the layout */
116
success = notify_notification_update (notification,
118
"After the update we now have a "
119
"bubble using the title-body layout.",
122
success = notify_notification_show (notification, &error);
125
g_print ("That did not work ... \"%s\".\n", error->message);
126
g_error_free (error);
129
g_signal_connect (G_OBJECT (notification),
131
G_CALLBACK (closed_handler),