]> Pileus Git - ~andy/gtk/blob - tests/testbuttons.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testbuttons.c
1 /* testbuttons.c
2  * Copyright (C) 2009 Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include <gtk/gtk.h>
19
20 /* various combinations of use_underline and use_stock */
21
22 int main (int argc, char *argv[])
23 {
24         GtkWidget *window, *box, *button, *hbox;
25         gchar *text;
26         gboolean use_underline, use_stock;
27         GtkWidget *image, *label;
28
29         gtk_init (&argc, &argv);
30
31         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
32
33         box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
34
35         gtk_container_add (GTK_CONTAINER (window), box);
36
37         hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
38         gtk_container_add (GTK_CONTAINER (box), hbox);
39         button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
40         gtk_container_add (GTK_CONTAINER (hbox), button);
41
42         g_object_get (button,
43                       "label", &text,
44                       "use-stock", &use_stock,
45                       "use-underline", &use_underline,
46                       "image", &image,
47                       NULL);
48         text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
49         label = gtk_label_new (text);
50         g_free (text);
51         gtk_container_add (GTK_CONTAINER (hbox), label);
52
53         hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
54         gtk_container_add (GTK_CONTAINER (box), hbox);
55         button = g_object_new (GTK_TYPE_BUTTON,
56                                "label", "document-save",
57                                "use-stock", TRUE,
58                                NULL);
59         gtk_container_add (GTK_CONTAINER (hbox), button);
60
61         g_object_get (button,
62                       "label", &text,
63                       "use-stock", &use_stock,
64                       "use-underline", &use_underline,
65                       "image", &image,
66                       NULL);
67         text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
68         label = gtk_label_new (text);
69         g_free (text);
70         gtk_container_add (GTK_CONTAINER (hbox), label);
71
72         hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
73         gtk_container_add (GTK_CONTAINER (box), hbox);
74         button = gtk_button_new_with_label ("_Save");
75         gtk_container_add (GTK_CONTAINER (hbox), button);
76
77         g_object_get (button,
78                       "label", &text,
79                       "use-stock", &use_stock,
80                       "use-underline", &use_underline,
81                       "image", &image,
82                       NULL);
83         text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
84         label = gtk_label_new (text);
85         g_free (text);
86         gtk_container_add (GTK_CONTAINER (hbox), label);
87
88         hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
89         gtk_container_add (GTK_CONTAINER (box), hbox);
90         button = gtk_button_new_with_mnemonic ("_Save");
91         gtk_container_add (GTK_CONTAINER (hbox), button);
92
93         g_object_get (button,
94                       "label", &text,
95                       "use-stock", &use_stock,
96                       "use-underline", &use_underline,
97                       "image", &image,
98                       NULL);
99         text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
100         label = gtk_label_new (text);
101         g_free (text);
102         gtk_container_add (GTK_CONTAINER (hbox), label);
103
104         hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
105         gtk_container_add (GTK_CONTAINER (box), hbox);
106         button = gtk_button_new_with_label ("_Save");
107         gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON));
108         gtk_container_add (GTK_CONTAINER (hbox), button);
109
110         g_object_get (button,
111                       "label", &text,
112                       "use-stock", &use_stock,
113                       "use-underline", &use_underline,
114                       "image", &image,
115                       NULL);
116         text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
117         label = gtk_label_new (text);
118         g_free (text);
119         gtk_container_add (GTK_CONTAINER (hbox), label);
120
121         hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
122         gtk_container_add (GTK_CONTAINER (box), hbox);
123         button = gtk_button_new_with_mnemonic ("_Save");
124         gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON));
125         gtk_container_add (GTK_CONTAINER (hbox), button);
126         g_object_get (button,
127                       "label", &text,
128                       "use-stock", &use_stock,
129                       "use-underline", &use_underline,
130                       "image", &image,
131                       NULL);
132         text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
133         label = gtk_label_new (text);
134         g_free (text);
135         gtk_container_add (GTK_CONTAINER (hbox), label);
136
137         gtk_widget_show_all (window);
138
139         gtk_main ();
140
141         return 0;
142 }
143