]> Pileus Git - ~andy/gtk/blob - tests/testbuttons.c
fe19534ac1379d0eacc69b17b940a8d45e567354
[~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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <gtk/gtk.h>
21
22 /* various combinations of use_underline and use_stock */
23
24 int main (int argc, char *argv[])
25 {
26         GtkWidget *window, *box, *button, *hbox;
27         gchar *text;
28         gboolean use_underline, use_stock;
29         GtkWidget *image, *label;
30
31         gtk_init (&argc, &argv);
32
33         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
34
35         box = gtk_vbox_new (0, FALSE);
36
37         gtk_container_add (GTK_CONTAINER (window), box);
38
39         hbox = gtk_hbox_new (0, FALSE);
40         gtk_container_add (GTK_CONTAINER (box), hbox);
41         button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
42         gtk_container_add (GTK_CONTAINER (hbox), button);
43
44         g_object_get (button,
45                       "label", &text,
46                       "use-stock", &use_stock,
47                       "use-underline", &use_underline,
48                       "image", &image,
49                       NULL);
50         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");
51         label = gtk_label_new (text);
52         g_free (text);
53         gtk_container_add (GTK_CONTAINER (hbox), label);
54
55         hbox = gtk_hbox_new (0, FALSE);
56         gtk_container_add (GTK_CONTAINER (box), hbox);
57         button = g_object_new (GTK_TYPE_BUTTON,
58                                "label", "document-save",
59                                "use-stock", TRUE,
60                                NULL);
61         gtk_container_add (GTK_CONTAINER (hbox), button);
62
63         g_object_get (button,
64                       "label", &text,
65                       "use-stock", &use_stock,
66                       "use-underline", &use_underline,
67                       "image", &image,
68                       NULL);
69         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");
70         label = gtk_label_new (text);
71         g_free (text);
72         gtk_container_add (GTK_CONTAINER (hbox), label);
73
74         hbox = gtk_hbox_new (0, FALSE);
75         gtk_container_add (GTK_CONTAINER (box), hbox);
76         button = gtk_button_new_with_label ("_Save");
77         gtk_container_add (GTK_CONTAINER (hbox), button);
78
79         g_object_get (button,
80                       "label", &text,
81                       "use-stock", &use_stock,
82                       "use-underline", &use_underline,
83                       "image", &image,
84                       NULL);
85         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");
86         label = gtk_label_new (text);
87         g_free (text);
88         gtk_container_add (GTK_CONTAINER (hbox), label);
89
90         hbox = gtk_hbox_new (0, FALSE);
91         gtk_container_add (GTK_CONTAINER (box), hbox);
92         button = gtk_button_new_with_mnemonic ("_Save");
93         gtk_container_add (GTK_CONTAINER (hbox), button);
94
95         g_object_get (button,
96                       "label", &text,
97                       "use-stock", &use_stock,
98                       "use-underline", &use_underline,
99                       "image", &image,
100                       NULL);
101         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");
102         label = gtk_label_new (text);
103         g_free (text);
104         gtk_container_add (GTK_CONTAINER (hbox), label);
105
106         hbox = gtk_hbox_new (0, FALSE);
107         gtk_container_add (GTK_CONTAINER (box), hbox);
108         button = gtk_button_new_with_label ("_Save");
109         gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON));
110         gtk_container_add (GTK_CONTAINER (hbox), button);
111
112         g_object_get (button,
113                       "label", &text,
114                       "use-stock", &use_stock,
115                       "use-underline", &use_underline,
116                       "image", &image,
117                       NULL);
118         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");
119         label = gtk_label_new (text);
120         g_free (text);
121         gtk_container_add (GTK_CONTAINER (hbox), label);
122
123         hbox = gtk_hbox_new (0, FALSE);
124         gtk_container_add (GTK_CONTAINER (box), hbox);
125         button = gtk_button_new_with_mnemonic ("_Save");
126         gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON));
127         gtk_container_add (GTK_CONTAINER (hbox), button);
128         g_object_get (button,
129                       "label", &text,
130                       "use-stock", &use_stock,
131                       "use-underline", &use_underline,
132                       "image", &image,
133                       NULL);
134         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");
135         label = gtk_label_new (text);
136         g_free (text);
137         gtk_container_add (GTK_CONTAINER (hbox), label);
138
139         gtk_widget_show_all (window);
140
141         gtk_main ();
142
143         return 0;
144 }
145