]> Pileus Git - ~andy/gtk/blob - tests/testheightforwidth.c
Implemented GtkSizeRequest on GtkExpander and added test
[~andy/gtk] / tests / testheightforwidth.c
1 /* extendedlayoutexample.c
2  * Copyright (C) 2010 Openismus GmbH
3  *
4  * Author:
5  *      Tristan Van Berkom <tristan.van.berkom@gmail.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 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  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library 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 <gtk/gtk.h>
24
25 typedef struct {
26   const gchar *name;
27   const gchar *tooltip;
28   const gchar *interface;
29   GtkWidget   *window;
30 } TestInterface;
31
32
33 /* These strings were generated with:
34  *
35  *     IFS=""; while read line; do echo -n \"; echo -n $line | sed -e 's|\"|\\"|g'; echo \"; done < file.glade
36  */
37 TestInterface interfaces[] = {
38   {
39     "Ellipsizing Labels",
40     "Demonstrates how labels will request a natural size in a horizontal space",
41     "<interface>"
42     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
43     "  <!-- interface-naming-policy project-wide -->"
44     "  <object class=\"GtkWindow\" id=\"window\">"
45     "    <property name=\"default_width\">450</property>"
46     "    <property name=\"default_height\">50</property>"
47     "    <child>"
48     "      <object class=\"GtkHBox\" id=\"hbox5\">"
49     "        <property name=\"visible\">True</property>"
50     "        <child>"
51     "          <object class=\"GtkLabel\" id=\"label9\">"
52     "            <property name=\"visible\">True</property>"
53     "            <property name=\"label\" translatable=\"yes\">Some labels do ellipsize</property>"
54     "            <property name=\"ellipsize\">end</property>"
55     "            <attributes>"
56     "              <attribute name=\"weight\" value=\"bold\"/>"
57     "              <attribute name=\"foreground\" value=\"#09610feefe03\"/>"
58     "            </attributes>"
59     "          </object>"
60     "          <packing>"
61     "            <property name=\"position\">0</property>"
62     "          </packing>"
63     "        </child>"
64     "        <child>"
65     "          <object class=\"GtkLabel\" id=\"label10\">"
66     "            <property name=\"visible\">True</property>"
67     "            <property name=\"label\" translatable=\"yes\">but some</property>"
68     "            <property name=\"ellipsize\">end</property>"
69     "            <attributes>"
70     "              <attribute name=\"weight\" value=\"bold\"/>"
71     "              <attribute name=\"foreground\" value=\"#0000af6b0993\"/>"
72     "            </attributes>"
73     "          </object>"
74     "          <packing>"
75     "            <property name=\"position\">1</property>"
76     "          </packing>"
77     "        </child>"
78     "        <child>"
79     "          <object class=\"GtkLabel\" id=\"label11\">"
80     "            <property name=\"visible\">True</property>"
81     "            <property name=\"label\" translatable=\"yes\">do not at all</property>"
82     "            <attributes>"
83     "              <attribute name=\"style\" value=\"normal\"/>"
84     "              <attribute name=\"weight\" value=\"bold\"/>"
85     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
86     "            </attributes>"
87     "          </object>"
88     "          <packing>"
89     "            <property name=\"position\">2</property>"
90     "          </packing>"
91     "        </child>"
92     "      </object>"
93     "    </child>"
94     "  </object>"
95     "</interface>",
96     NULL
97   },
98
99   {
100     "Wrapping Label",
101     "Demonstrates how a wrapping label can require a height contextual to its allocated width",
102     "<interface>"
103     "  <requires lib=\"gtk+\" version=\"2.18\"/>"
104     "  <!-- interface-naming-policy project-wide -->"
105     "  <object class=\"GtkWindow\" id=\"window\">"
106     "    <property name=\"border_width\">12</property>"
107     "    <property name=\"default_width\">300</property>"
108     "    <child>"
109     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
110     "        <property name=\"visible\">True</property>"
111     "        <property name=\"can_focus\">True</property>"
112     "        <child>"
113     "          <object class=\"GtkVBox\" id=\"vbox2\">"
114     "            <property name=\"visible\">True</property>"
115     "            <child>"
116     "              <object class=\"GtkLabel\" id=\"label3\">"
117     "                <property name=\"visible\">True</property>"
118     "                <property name=\"label\" translatable=\"yes\">A short static label.</property>"
119     "                <attributes>"
120     "                  <attribute name=\"weight\" value=\"bold\"/>"
121     "                </attributes>"
122     "              </object>"
123     "              <packing>"
124     "                <property name=\"position\">0</property>"
125     "              </packing>"
126     "            </child>"
127     "            <child>"
128     "              <object class=\"GtkFrame\" id=\"frame1\">"
129     "                <property name=\"label\">Long label</property>"
130     "                <property name=\"visible\">True</property>"
131     "                <child>"
132     "                  <object class=\"GtkLabel\" id=\"label1\">"
133     "                    <property name=\"visible\">True</property>"
134     "                    <property name=\"label\" translatable=\"yes\">This is a really long label for the purpose of testing line wrapping is working correctly in conjunction with height-for-width support in GTK+</property>"
135     "                    <property name=\"wrap\">True</property>"
136     "                    <property name=\"max_width_chars\">30</property>"
137     "                    <attributes>"
138     "                      <attribute name=\"foreground\" value=\"#18c52119f796\"/>"
139     "                    </attributes>"
140     "                  </object>"
141     "                </child>"
142     "              </object>"
143     "              <packing>"
144     "                <property name=\"expand\">False</property>"
145     "                <property name=\"position\">1</property>"
146     "              </packing>"
147     "            </child>"
148     "            <child>"
149     "              <object class=\"GtkButton\" id=\"button2\">"
150     "                <property name=\"visible\">True</property>"
151     "                <property name=\"can_focus\">True</property>"
152     "                <property name=\"receives_default\">True</property>"
153     "                <child>"
154     "                  <object class=\"GtkLabel\" id=\"label2\">"
155     "                    <property name=\"visible\">True</property>"
156     "                    <property name=\"label\" translatable=\"yes\">A really really long label inside a button to demonstrate height for width working inside buttons</property>"
157     "                    <property name=\"wrap\">True</property>"
158     "                    <property name=\"max_width_chars\">25</property>"
159     "                    <attributes>"
160     "                      <attribute name=\"foreground\" value=\"#1e3687ab0a52\"/>"
161     "                    </attributes>"
162     "                  </object>"
163     "                </child>"
164     "              </object>"
165     "              <packing>"
166     "                <property name=\"expand\">False</property>"
167     "                <property name=\"position\">2</property>"
168     "              </packing>"
169     "            </child>"
170     "          </object>"
171     "          <packing>"
172     "            <property name=\"resize\">False</property>"
173     "            <property name=\"shrink\">False</property>"
174     "          </packing>"
175     "        </child>"
176     "        <child>"
177     "          <object class=\"GtkLabel\" id=\"label4\">"
178     "            <property name=\"visible\">True</property>"
179     "            <property name=\"label\" translatable=\"yes\">This static label\n"
180     "can shrink.</property>"
181     "            <property name=\"justify\">center</property>"
182     "            <attributes>"
183     "              <attribute name=\"style\" value=\"normal\"/>"
184     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
185     "            </attributes>"
186     "          </object>"
187     "          <packing>"
188     "            <property name=\"resize\">True</property>"
189     "            <property name=\"shrink\">True</property>"
190     "          </packing>"
191     "        </child>"
192     "      </object>"
193     "    </child>"
194     "  </object>"
195     "</interface>",
196     NULL
197   },
198
199   {
200     "Horizontal Box",
201     "Demonstrates how a horizontal box can calculate the collective height for an allocated width",
202     "<interface>"
203     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
204     "  <!-- interface-naming-policy project-wide -->"
205     "  <object class=\"GtkWindow\" id=\"window\">"
206     "    <property name=\"default_height\">200</property>"
207     "    <property name=\"default_width\">600</property>"
208     "    <child>"
209     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
210     "        <property name=\"visible\">True</property>"
211     "        <property name=\"can_focus\">True</property>"
212     "        <child>"
213     "          <object class=\"GtkVBox\" id=\"vbox1\">"
214     "            <property name=\"visible\">True</property>"
215     "            <child>"
216     "              <object class=\"GtkHBox\" id=\"hbox1\">"
217     "                <property name=\"visible\">True</property>"
218     "                <child>"
219     "                  <object class=\"GtkButton\" id=\"button1\">"
220     "                    <property name=\"visible\">True</property>"
221     "                    <property name=\"can_focus\">True</property>"
222     "                    <property name=\"receives_default\">True</property>"
223     "                    <property name=\"use_action_appearance\">False</property>"
224     "                    <child>"
225     "                      <object class=\"GtkLabel\" id=\"label2\">"
226     "                        <property name=\"visible\">True</property>"
227     "                        <property name=\"label\" translatable=\"yes\">A button that wraps.</property>"
228     "                        <property name=\"wrap\">True</property>"
229     "                        <property name=\"width_chars\">10</property>"
230     "                        <attributes>"
231     "                          <attribute name=\"foreground\" value=\"#0000041dffff\"/>"
232     "                        </attributes>"
233     "                      </object>"
234     "                    </child>"
235     "                  </object>"
236     "                  <packing>"
237     "                    <property name=\"expand\">False</property>"
238     "                    <property name=\"position\">0</property>"
239     "                  </packing>"
240     "                </child>"
241     "                <child>"
242     "                  <object class=\"GtkLabel\" id=\"label1\">"
243     "                    <property name=\"visible\">True</property>"
244     "                    <property name=\"label\" translatable=\"yes\">Lets try setting up some long text to wrap up in this hbox and see if the height-for-width is gonna work !</property>"
245     "                    <property name=\"wrap\">True</property>"
246     "                    <property name=\"width_chars\">30</property>"
247     "                    <attributes>"
248     "                      <attribute name=\"foreground\" value=\"#07d0a9b20972\"/>"
249     "                    </attributes>"
250     "                  </object>"
251     "                  <packing>"
252     "                    <property name=\"position\">1</property>"
253     "                  </packing>"
254     "                </child>"
255     "              </object>"
256     "              <packing>"
257     "                <property name=\"expand\">False</property>"
258     "                <property name=\"position\">0</property>"
259     "              </packing>"
260     "            </child>"
261     "            <child>"
262     "              <object class=\"GtkButton\" id=\"button2\">"
263     "                <property name=\"label\" translatable=\"yes\">A button that expands in the vbox</property>"
264     "                <property name=\"visible\">True</property>"
265     "                <property name=\"can_focus\">True</property>"
266     "                <property name=\"receives_default\">True</property>"
267     "                <property name=\"use_action_appearance\">False</property>"
268     "              </object>"
269     "              <packing>"
270     "                <property name=\"position\">1</property>"
271     "              </packing>"
272     "            </child>"
273     "          </object>"
274     "          <packing>"
275     "            <property name=\"resize\">False</property>"
276     "            <property name=\"shrink\">False</property>"
277     "          </packing>"
278     "        </child>"
279     "        <child>"
280     "          <object class=\"GtkLabel\" id=\"label4\">"
281     "            <property name=\"visible\">True</property>"
282     "            <property name=\"label\" translatable=\"yes\">This label is\n"
283     "set to shrink inside\n"
284     "the paned window.</property>"
285     "            <property name=\"justify\">center</property>"
286     "            <attributes>"
287     "              <attribute name=\"style\" value=\"normal\"/>"
288     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
289     "            </attributes>"
290     "          </object>"
291     "          <packing>"
292     "            <property name=\"resize\">True</property>"
293     "            <property name=\"shrink\">True</property>"
294     "          </packing>"
295     "        </child>"
296     "      </object>"
297     "    </child>"
298     "  </object>"
299     "</interface>",
300     NULL
301   },
302
303   {
304     "Vertical Labels",
305     "Demonstrates how a horizontal box will consider width-for-height when allocating children "
306     "even if the toplevel window is requested as height-for-width.",
307     "<interface>"
308     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
309     "  <!-- interface-naming-policy project-wide -->"
310     "  <object class=\"GtkWindow\" id=\"window\">"
311     "    <property name=\"default_width\">400</property>"
312     "    <property name=\"default_height\">300</property>"
313     "    <child>"
314     "      <object class=\"GtkVPaned\" id=\"vpaned1\">"
315     "        <property name=\"visible\">True</property>"
316     "        <property name=\"can_focus\">True</property>"
317     "        <child>"
318     "          <object class=\"GtkHBox\" id=\"hbox1\">"
319     "            <property name=\"visible\">True</property>"
320     "            <child>"
321     "              <object class=\"GtkLabel\" id=\"label1\">"
322     "                <property name=\"visible\">True</property>"
323     "                <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
324     "                <property name=\"justify\">center</property>"
325     "                <property name=\"wrap\">True</property>"
326     "                <property name=\"width_chars\">10</property>"
327     "                <property name=\"angle\">90</property>"
328     "                <attributes>"
329     "                  <attribute name=\"weight\" value=\"bold\"/>"
330     "                  <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
331     "                </attributes>"
332     "              </object>"
333     "              <packing>"
334     "                <property name=\"expand\">False</property>"
335     "                <property name=\"position\">0</property>"
336     "              </packing>"
337     "            </child>"
338     "            <child>"
339     "              <object class=\"GtkFrame\" id=\"frame1\">"
340     "                <property name=\"visible\">True</property>"
341     "                <property name=\"label_xalign\">0</property>"
342     "                <property name=\"shadow_type\">out</property>"
343     "                <child>"
344     "                  <object class=\"GtkLabel\" id=\"label5\">"
345     "                    <property name=\"visible\">True</property>"
346     "                    <property name=\"label\" translatable=\"yes\">Neither of the panes are\n"
347     "set to shrink.</property>"
348     "                    <property name=\"justify\">center</property>"
349     "                    <attributes>"
350     "                      <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
351     "                    </attributes>"
352     "                  </object>"
353     "                </child>"
354     "                <child type=\"label_item\">"
355     "                  <placeholder/>"
356     "                </child>"
357     "              </object>"
358     "              <packing>"
359     "                <property name=\"position\">1</property>"
360     "              </packing>"
361     "            </child>"
362     "          </object>"
363     "          <packing>"
364     "            <property name=\"resize\">False</property>"
365     "            <property name=\"shrink\">False</property>"
366     "          </packing>"
367     "        </child>"
368     "        <child>"
369     "          <object class=\"GtkHBox\" id=\"hbox2\">"
370     "            <property name=\"visible\">True</property>"
371     "            <child>"
372     "              <object class=\"GtkFrame\" id=\"frame2\">"
373     "                <property name=\"visible\">True</property>"
374     "                <property name=\"label_xalign\">0</property>"
375     "                <property name=\"shadow_type\">out</property>"
376     "                <child>"
377     "                  <object class=\"GtkLabel\" id=\"label4\">"
378     "                    <property name=\"visible\">True</property>"
379     "                    <property name=\"label\" translatable=\"yes\">The interface is allocated as height\n"
380     "for width, but the horizontal boxes\n"
381     "allocate in width for height mode.</property>"
382     "                    <attributes>"
383     "                      <attribute name=\"foreground\" value=\"#000097970808\"/>"
384     "                    </attributes>"
385     "                  </object>"
386     "                </child>"
387     "                <child type=\"label_item\">"
388     "                  <placeholder/>"
389     "                </child>"
390     "              </object>"
391     "              <packing>"
392     "                <property name=\"position\">0</property>"
393     "              </packing>"
394     "            </child>"
395     "            <child>"
396     "              <object class=\"GtkLabel\" id=\"label3\">"
397     "                <property name=\"visible\">True</property>"
398     "                <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
399     "                <property name=\"justify\">center</property>"
400     "                <property name=\"wrap\">True</property>"
401     "                <property name=\"width_chars\">10</property>"
402     "                <property name=\"angle\">270</property>"
403     "                <attributes>"
404     "                  <attribute name=\"weight\" value=\"bold\"/>"
405     "                  <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
406     "                </attributes>"
407     "              </object>"
408     "              <packing>"
409     "                <property name=\"expand\">False</property>"
410     "                <property name=\"position\">1</property>"
411     "              </packing>"
412     "            </child>"
413     "          </object>"
414     "          <packing>"
415     "            <property name=\"resize\">False</property>"
416     "            <property name=\"shrink\">False</property>"
417     "          </packing>"
418     "        </child>"
419     "      </object>"
420     "    </child>"
421     "  </object>"
422     "</interface>",
423     NULL
424   },
425
426   {
427     "Label Parameters",
428     "This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
429     "to effect minimum and natural widths in wrapping labels.",
430     "<interface>"
431     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
432     "  <!-- interface-naming-policy project-wide -->"
433     "  <object class=\"GtkWindow\" id=\"window\">"
434     "    <property name=\"default_width\">900</property>"
435     "    <child>"
436     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
437     "        <property name=\"visible\">True</property>"
438     "        <property name=\"can_focus\">True</property>"
439     "        <child>"
440     "          <object class=\"GtkVBox\" id=\"vbox1\">"
441     "            <property name=\"visible\">True</property>"
442     "            <child>"
443     "              <object class=\"GtkHBox\" id=\"hbox1\">"
444     "                <property name=\"visible\">True</property>"
445     "                <property name=\"spacing\">6</property>"
446     "                <child>"
447     "                  <object class=\"GtkLabel\" id=\"label1\">"
448     "                    <property name=\"visible\">True</property>"
449     "                    <property name=\"label\" translatable=\"yes\">The first 2 labels require 10 characters.</property>"
450     "                    <property name=\"wrap\">True</property>"
451     "                    <property name=\"width_chars\">10</property>"
452     "                    <attributes>"
453     "                      <attribute name=\"weight\" value=\"bold\"/>"
454     "                      <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
455     "                    </attributes>"
456     "                  </object>"
457     "                  <packing>"
458     "                    <property name=\"expand\">False</property>"
459     "                    <property name=\"fill\">False</property>"
460     "                    <property name=\"position\">0</property>"
461     "                  </packing>"
462     "                </child>"
463     "                <child>"
464     "                  <object class=\"GtkLabel\" id=\"label2\">"
465     "                    <property name=\"visible\">True</property>"
466     "                    <property name=\"label\" translatable=\"yes\">This label has a maximum natural width of 20 characters. The second two labels expand.</property>"
467     "                    <property name=\"wrap\">True</property>"
468     "                    <property name=\"width_chars\">10</property>"
469     "                    <property name=\"max_width_chars\">20</property>"
470     "                    <attributes>"
471     "                      <attribute name=\"weight\" value=\"bold\"/>"
472     "                      <attribute name=\"foreground\" value=\"#05c2a161134b\"/>"
473     "                    </attributes>"
474     "                  </object>"
475     "                  <packing>"
476     "                    <property name=\"expand\">True</property>"
477     "                    <property name=\"fill\">True</property>"
478     "                    <property name=\"position\">1</property>"
479     "                  </packing>"
480     "                </child>"
481     "                <child>"
482     "                  <object class=\"GtkLabel\" id=\"label3\">"
483     "                    <property name=\"visible\">True</property>"
484     "                    <property name=\"label\" translatable=\"yes\">This label requires a default minimum size.</property>"
485     "                    <property name=\"wrap\">True</property>"
486     "                    <attributes>"
487     "                      <attribute name=\"weight\" value=\"bold\"/>"
488     "                      <attribute name=\"foreground\" value=\"#03e30758fb5f\"/>"
489     "                    </attributes>"
490     "                  </object>"
491     "                  <packing>"
492     "                    <property name=\"position\">2</property>"
493     "                  </packing>"
494     "                </child>"
495     "              </object>"
496     "              <packing>"
497     "                <property name=\"position\">0</property>"
498     "              </packing>"
499     "            </child>"
500     "            <child>"
501     "              <object class=\"GtkLabel\" id=\"label4\">"
502     "                <property name=\"visible\">True</property>"
503     "                <property name=\"label\" translatable=\"yes\">This test demonstrates how the \"width-chars\" and \"max-width-chars\"\n"
504     "properties can be used to specify the minimum requested wrap width\n"
505     "and the maximum natural wrap width respectively.</property>"
506     "                <property name=\"ellipsize\">end</property>"
507     "                <property name=\"width_chars\">30</property>"
508     "                <attributes>"
509     "                  <attribute name=\"style\" value=\"normal\"/>"
510     "                  <attribute name=\"foreground\" value=\"#05470000abaf\"/>"
511     "                </attributes>"
512     "              </object>"
513     "              <packing>"
514     "                <property name=\"position\">1</property>"
515     "              </packing>"
516     "            </child>"
517     "          </object>"
518     "          <packing>"
519     "            <property name=\"resize\">False</property>"
520     "            <property name=\"shrink\">False</property>"
521     "          </packing>"
522     "        </child>"
523     "        <child>"
524     "          <object class=\"GtkLabel\" id=\"label5\">"
525     "            <property name=\"visible\">True</property>"
526     "            <property name=\"label\" translatable=\"yes\">Some static\n"
527     "text that shrinks.\n"
528     "\n"
529     "You will need to stretch\n"
530     "this window quite wide\n"
531     "to see the effects.</property>"
532     "            <property name=\"justify\">center</property>"
533     "            <attributes>"
534     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
535     "            </attributes>"
536     "          </object>"
537     "          <packing>"
538     "            <property name=\"resize\">True</property>"
539     "            <property name=\"shrink\">True</property>"
540     "          </packing>"
541     "        </child>"
542     "      </object>"
543     "    </child>"
544     "  </object>"
545     "</interface>",
546     NULL
547   },
548
549   {
550     "Wrapping Expander",
551     "This test demonstrates how the expander label can fill to its natural width "
552     "and also trade height for width.",
553     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
554     "<interface>"
555     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
556     "  <!-- interface-naming-policy project-wide -->"
557     "  <object class=\"GtkWindow\" id=\"window\">"
558     "    <property name=\"default_width\">500</property>"
559     "    <child>"
560     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
561     "        <property name=\"visible\">True</property>"
562     "        <property name=\"can_focus\">True</property>"
563     "        <child>"
564     "          <object class=\"GtkExpander\" id=\"expander1\">"
565     "            <property name=\"visible\">True</property>"
566     "            <property name=\"can_focus\">True</property>"
567     "            <child>"
568     "              <object class=\"GtkLabel\" id=\"label2\">"
569     "                <property name=\"visible\">True</property>"
570     "                <property name=\"label\" translatable=\"yes\">More wrapping text to fill the largish content area in the expander </property>"
571     "                <property name=\"wrap\">True</property>"
572     "                <property name=\"width_chars\">10</property>"
573     "                <attributes>"
574     "                  <attribute name=\"weight\" value=\"bold\"/>"
575     "                  <attribute name=\"foreground\" value=\"#0000D0F00000\"/>"
576     "                </attributes>"
577     "              </object>"
578     "            </child>"
579     "            <child type=\"label\">"
580     "              <object class=\"GtkLabel\" id=\"label1\">"
581     "                <property name=\"visible\">True</property>"
582     "                <property name=\"label\" translatable=\"yes\">Here is some expander text that wraps</property>"
583     "                <property name=\"wrap\">True</property>"
584     "                <property name=\"width_chars\">10</property>"
585     "                <attributes>"
586     "                  <attribute name=\"weight\" value=\"bold\"/>"
587     "                  <attribute name=\"foreground\" value=\"blue\"/>"
588     "                </attributes>"
589     "              </object>"
590     "            </child>"
591     "          </object>"
592     "          <packing>"
593     "            <property name=\"resize\">False</property>"
594     "            <property name=\"shrink\">False</property>"
595     "          </packing>"
596     "        </child>"
597     "        <child>"
598     "          <object class=\"GtkLabel\" id=\"label3\">"
599     "            <property name=\"visible\">True</property>"
600     "            <property name=\"label\" translatable=\"yes\">static\n"
601     "text\n"
602     "here</property>"
603     "            <attributes>"
604     "              <attribute name=\"foreground\" value=\"red\"/>"
605     "            </attributes>"
606     "          </object>"
607     "          <packing>"
608     "            <property name=\"resize\">True</property>"
609     "            <property name=\"shrink\">True</property>"
610     "          </packing>"
611     "        </child>"
612     "      </object>"
613     "    </child>"
614     "  </object>"
615     "</interface>",
616     NULL
617   },
618 };
619
620
621 static void
622 test_clicked (GtkWidget     *button, 
623               TestInterface *interface)
624 {
625   if (!interface->window)
626     {
627       GtkBuilder *builder = gtk_builder_new ();
628       
629       gtk_builder_add_from_string (builder, interface->interface, -1, NULL);
630       interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");
631
632       g_signal_connect (interface->window, "delete_event", 
633                         G_CALLBACK (gtk_widget_hide_on_delete), NULL);
634     }
635
636   gtk_widget_show (interface->window);
637 }
638
639
640 static GtkWidget *
641 create_window (void)
642 {
643   GtkWidget *window, *vbox, *button;
644   gint i;
645
646   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
647   vbox   = gtk_vbox_new (FALSE, 6);
648
649   gtk_container_set_border_width (GTK_CONTAINER (window), 8);
650
651   gtk_widget_show (vbox);
652   gtk_container_add (GTK_CONTAINER (window), vbox);
653
654   for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
655     {
656       button = gtk_button_new_with_label (interfaces[i].name);
657
658       gtk_widget_set_tooltip_text (button, interfaces[i].tooltip);
659
660       g_signal_connect (G_OBJECT (button), "clicked", 
661                         G_CALLBACK (test_clicked), &interfaces[i]);
662
663       gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
664       gtk_widget_show (button);
665     }
666
667   return window;
668 }
669
670
671
672 int
673 main (int argc, char *argv[])
674 {
675   GtkWidget *window;
676
677   gtk_init (&argc, &argv);
678
679   window = create_window ();
680
681   g_signal_connect (window, "delete-event",
682                     G_CALLBACK (gtk_main_quit), window);
683
684   gtk_widget_show (window);
685
686   gtk_main ();
687
688   return 0;
689 }