| 1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
| 2 |
* |
| 3 |
* @file tests/test-image.c Unit test: images |
| 4 |
* |
| 5 |
* @Copyright(C) 2004 Mike Hearn <[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 <stdio.h> |
| 25 |
#include <unistd.h> |
| 26 |
#include <stdlib.h> |
| 27 |
#include <assert.h> |
| 28 |
#include <string.h> |
| 29 |
#include <errno.h> |
| 30 |
#include <sys/mman.h> |
| 31 |
#include <sys/stat.h> |
| 32 |
#include <unistd.h> |
| 33 |
#include <fcntl.h> |
| 34 |
#include <gtk/gtk.h> |
| 35 |
|
| 36 |
GMainLoop *loop; |
| 37 |
NotifyNotification *n; |
| 38 |
|
| 39 |
int |
| 40 |
main (int argc, char *argv[]) |
| 41 |
{ |
| 42 |
char *file; |
| 43 |
char *uri; |
| 44 |
GdkPixbuf *pixbuf; |
| 45 |
|
| 46 |
gtk_init (); |
| 47 |
|
| 48 |
if (!notify_init ("Images Test")) |
| 49 |
exit (1); |
| 50 |
|
| 51 |
/* Stock icon */ |
| 52 |
n = notify_notification_new ("Icon Test", |
| 53 |
"Testing stock icon", |
| 54 |
"appointment-new"); |
| 55 |
|
| 56 |
if (!notify_notification_show (n, NULL)) { |
| 57 |
fprintf (stderr, "failed to send notification\n"); |
| 58 |
return 1; |
| 59 |
} |
| 60 |
|
| 61 |
g_object_unref (G_OBJECT (n)); |
| 62 |
|
| 63 |
file = g_get_current_dir (); |
| 64 |
uri = g_strdup_printf ("file://%s/%s", |
| 65 |
file, |
| 66 |
"dewdop_leaf.jpg"); |
| 67 |
|
| 68 |
g_free (file); |
| 69 |
printf ("sending %s\n", uri); |
| 70 |
|
| 71 |
/* URIs */ |
| 72 |
n = notify_notification_new ("Alert!", |
| 73 |
"Testing URI icons", |
| 74 |
uri); |
| 75 |
|
| 76 |
if (!notify_notification_show (n, NULL)) { |
| 77 |
fprintf (stderr, "failed to send notification\n"); |
| 78 |
return 1; |
| 79 |
} |
| 80 |
|
| 81 |
g_object_unref (G_OBJECT (n)); |
| 82 |
|
| 83 |
/* Raw image */ |
| 84 |
n = notify_notification_new ("Raw image test", |
| 85 |
"Testing sending raw pixbufs", |
| 86 |
NULL); |
| 87 |
|
| 88 |
pixbuf = gdk_pixbuf_new_from_file ("applet-critical.png", NULL); |
| 89 |
|
| 90 |
if (pixbuf == NULL) { |
| 91 |
fprintf (stderr, "failed to render pixbuf\n"); |
| 92 |
return 1; |
| 93 |
} |
| 94 |
|
| 95 |
notify_notification_set_image_from_pixbuf (n, pixbuf); |
| 96 |
g_object_unref (pixbuf); |
| 97 |
|
| 98 |
if (!notify_notification_show (n, NULL)) { |
| 99 |
fprintf (stderr, "failed to send notification\n"); |
| 100 |
return 1; |
| 101 |
} |
| 102 |
|
| 103 |
return 0; |
| 104 |
} |