34
34
#define DBUS_API_SUBJECT_TO_CHANGE 1
37
38
#include <dbus/dbus.h>
38
39
#include <dbus/dbus-glib.h>
39
40
#include <dbus/dbus-glib-lowlevel.h>
44
static void send(char *i, size_t rawlen, char *s, char *b)
49
icon = notify_icon_new_from_data(rawlen, i);
51
icon = notify_icon_new_from_uri(i);
53
n = notify_send_notification(NULL, // replaces nothing
55
NOTIFY_URGENCY_NORMAL,
64
fprintf(stderr, "failed to send notification\n");
68
notify_icon_destroy(icon);
72
main(int argc, char **argv)
74
loop = g_main_loop_new(NULL, FALSE);
76
if (!notify_glib_init("Images Test", NULL))
80
* These images exist on fedora core 2 workstation profile.
84
send("gnome-starthere",
87
"This is your first login. To begin exploring the system, click on 'Start Here', 'Computer' or 'Applications'");
90
readlink("/proc/self/exe", file, sizeof(file));
91
*strrchr(file, '/') = '\0';
92
strcat(file, "/../applet-critical.png");
94
printf("sending %s\n", file);
103
if (stat(file, &buf) == -1)
105
fprintf(stderr, "could not stat %s: %s", file, strerror(errno));
109
int fd = open(file, O_RDONLY);
111
void *pngbase = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
118
"This is an image marshalling test");
43
NotifyNotification *n;
45
int main(int argc, char *argv[]) {
54
gtk_init (&argc, &argv);
56
if (!notify_init("Images Test")) exit(1);
58
n = notify_notification_new ("Icon Test", "Testing stock icon", "stock_help", NULL);
60
notify_notification_set_hint_int32 (n, "x", 300);
61
notify_notification_set_hint_int32 (n, "y", 24);
63
notify_notification_set_timeout (n, NOTIFY_TIMEOUT_NEVER);
64
if (!notify_notification_show (n, NULL)) {
65
fprintf(stderr, "failed to send notification\n");
69
g_usleep (5000000); //5 seconds
71
size = readlink("/proc/self/cwd", file, PATH_MAX - 1);
73
uri = g_strdup_printf ("file://%s/%s", file, "applet-critical.png");
75
printf("sending %s\n", uri);
77
notify_notification_update (n, "Alert!", "Testing URI icons", uri);
79
if (!notify_notification_show (n, NULL)) {
80
fprintf(stderr, "failed to send notification\n");
84
g_usleep (5000000); //5 seconds
86
notify_notification_update (n, "Raw image test", "Testing sending raw pixbufs", NULL);
88
/* This is just a hack to get a stock icon's pixbuf
89
in a realworld app if you were sending bitmapped data
90
you would know the file location and open it up with
91
a method that could generate a bmp for you*/
92
helper = gtk_button_new();
93
icon = gtk_widget_render_icon (helper,
94
GTK_STOCK_DIALOG_QUESTION,
99
notify_notification_set_icon_data_from_pixbuf (n,
102
if (!notify_notification_show (n, NULL)) {
103
fprintf(stderr, "failed to send notification\n");
108
gtk_widget_destroy (helper);
109
g_object_unref ((GObject *)icon);
111
g_usleep (5000000); //5 seconds