]> Pileus Git - ~andy/gtk/blob - tests/testgiconpixbuf.c
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include <gtk/gtk.h>
20
21 int
22 main (int argc,
23       char **argv)
24 {
25   GdkPixbuf *pixbuf, *otherpix;
26   GtkWidget *image, *image2, *hbox, *vbox, *label, *toplevel;
27   GIcon *emblemed;
28   GEmblem *emblem;
29   gchar *str;
30
31   gtk_init (&argc, &argv);
32
33   pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);
34   toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
35   hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
36   gtk_container_add (GTK_CONTAINER (toplevel), hbox);
37
38   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
39   gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
40
41   image = gtk_image_new_from_gicon (G_ICON (pixbuf), GTK_ICON_SIZE_DIALOG);
42   gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
43
44   label = gtk_label_new (NULL);
45   str = g_strdup_printf ("Normal icon, hash %u", g_icon_hash (G_ICON (pixbuf)));
46   gtk_label_set_label (GTK_LABEL (label), str);
47   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
48
49   otherpix = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);
50   emblem = g_emblem_new (G_ICON (otherpix));
51   emblemed = g_emblemed_icon_new (G_ICON (pixbuf), emblem);
52
53   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
54   gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
55   
56   image2 = gtk_image_new_from_gicon (emblemed, GTK_ICON_SIZE_DIALOG);
57   gtk_box_pack_start (GTK_BOX (vbox), image2, FALSE, FALSE, 0);
58
59   label = gtk_label_new (NULL);
60   str = g_strdup_printf ("Emblemed icon, hash %u", g_icon_hash (emblemed));
61   gtk_label_set_label (GTK_LABEL (label), str);
62   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
63
64   gtk_widget_show_all (toplevel);
65
66   g_signal_connect (toplevel, "delete-event",
67                     G_CALLBACK (gtk_main_quit), NULL);
68
69   gtk_main ();
70
71   return 0;
72 }