]> Pileus Git - ~andy/gtk/blob - tests/testgiconpixbuf.c
3acf306b06a7be01bdb76651b01dc58baa94d950
[~andy/gtk] / tests / testgiconpixbuf.c
1 /* testgiconpixbuf.c
2  * Copyright (C) 2010 Red Hat, Inc.
3  * Authors: Cosimo Cecchi
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include <gtk/gtk.h>
22
23 int
24 main (int argc,
25       char **argv)
26 {
27   GdkPixbuf *pixbuf, *otherpix;
28   GtkWidget *image, *image2, *hbox, *vbox, *label, *toplevel;
29   GIcon *emblemed;
30   GEmblem *emblem;
31   gchar *str;
32
33   gtk_init (&argc, &argv);
34
35   pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);
36   toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
37   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
38   gtk_container_add (GTK_CONTAINER (toplevel), hbox);
39
40   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
41   gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
42
43   image = gtk_image_new_from_gicon (G_ICON (pixbuf), GTK_ICON_SIZE_DIALOG);
44   gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
45
46   label = gtk_label_new (NULL);
47   str = g_strdup_printf ("Normal icon, hash %u", g_icon_hash (G_ICON (pixbuf)));
48   gtk_label_set_label (GTK_LABEL (label), str);
49   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
50
51   otherpix = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);
52   emblem = g_emblem_new (G_ICON (otherpix));
53   emblemed = g_emblemed_icon_new (G_ICON (pixbuf), emblem);
54
55   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
56   gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
57   
58   image2 = gtk_image_new_from_gicon (emblemed, GTK_ICON_SIZE_DIALOG);
59   gtk_box_pack_start (GTK_BOX (vbox), image2, FALSE, FALSE, 0);
60
61   label = gtk_label_new (NULL);
62   str = g_strdup_printf ("Emblemed icon, hash %u", g_icon_hash (emblemed));
63   gtk_label_set_label (GTK_LABEL (label), str);
64   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
65
66   gtk_widget_show_all (toplevel);
67
68   g_signal_connect (toplevel, "delete-event",
69                     G_CALLBACK (gtk_main_quit), NULL);
70
71   gtk_main ();
72
73   return 0;
74 }