]> Pileus Git - ~andy/gtk/blob - tests/testheightforwidth.c
c4774d57bdc525a8caf52b245a67951c304d42a4
[~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     "Wrapping Frame Label",
621     "This test demonstrates how the frame label can fill to its natural width "
622     "and also trade height for width.",
623     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
624     "<interface>"
625     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
626     "  <!-- interface-naming-policy project-wide -->"
627     "  <object class=\"GtkWindow\" id=\"window\">"
628     "    <property name=\"default_width\">400</property>"
629     "    <property name=\"default_height\">150</property>"
630     "    <child>"
631     "      <object class=\"GtkFrame\" id=\"frame1\">"
632     "        <property name=\"visible\">True</property>"
633     "        <property name=\"border_width\">8</property>"
634     "        <property name=\"label_xalign\">0</property>"
635     "        <child>"
636     "          <object class=\"GtkAlignment\" id=\"alignment1\">"
637     "            <property name=\"visible\">True</property>"
638     "            <property name=\"left_padding\">12</property>"
639     "            <child>"
640     "              <object class=\"GtkLabel\" id=\"label2\">"
641     "                <property name=\"visible\">True</property>"
642     "                <property name=\"label\" translatable=\"yes\">some content</property>"
643     "              </object>"
644     "            </child>"
645     "          </object>"
646     "        </child>"
647     "        <child type=\"label\">"
648     "          <object class=\"GtkLabel\" id=\"label1\">"
649     "            <property name=\"visible\">True</property>"
650     "            <property name=\"label\" translatable=\"yes\">A frame label that's a little long and wraps</property>"
651     "            <property name=\"use_markup\">True</property>"
652     "            <property name=\"wrap\">True</property>"
653     "          </object>"
654     "        </child>"
655     "      </object>"
656     "    </child>"
657     "  </object>"
658     "</interface>",
659     NULL
660   },
661
662   {
663     "Combo Boxes and Menus",
664     "This test shows wrapping and ellipsizing text in combo boxes (and consequently in menu items).",
665     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
666     "<interface>"
667     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
668     "  <!-- interface-naming-policy project-wide -->"
669     "  <object class=\"GtkWindow\" id=\"window\">"
670     "    <property name=\"border_width\">8</property>"
671     "    <property name=\"default_width\">600</property>"
672     "    <child>"
673     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
674     "        <property name=\"visible\">True</property>"
675     "        <property name=\"can_focus\">True</property>"
676     "        <child>"
677     "          <object class=\"GtkVBox\" id=\"vbox1\">"
678     "            <property name=\"visible\">True</property>"
679     "            <property name=\"spacing\">5</property>"
680     "            <child>"
681     "              <object class=\"GtkHBox\" id=\"hbox1\">"
682     "                <property name=\"visible\">True</property>"
683     "                <property name=\"spacing\">5</property>"
684     "                <child>"
685     "                  <object class=\"GtkLabel\" id=\"label1\">"
686     "                    <property name=\"visible\">True</property>"
687     "                    <property name=\"label\" translatable=\"yes\">this combo box</property>"
688     "                    <attributes>"
689     "                      <attribute name=\"weight\" value=\"bold\"/>"
690     "                      <attribute name=\"foreground\" value=\"#b3460000eb1c\"/>"
691     "                    </attributes>"
692     "                  </object>"
693     "                  <packing>"
694     "                    <property name=\"expand\">True</property>"
695     "                    <property name=\"fill\">True</property>"
696     "                    <property name=\"position\">0</property>"
697     "                  </packing>"
698     "                </child>"
699     "                <child>"
700     "                  <object class=\"GtkLabel\" id=\"label2\">"
701     "                    <property name=\"visible\">True</property>"
702     "                    <property name=\"label\" translatable=\"yes\">contains some wrapping locations</property>"
703     "                    <property name=\"ellipsize\">end</property>"
704     "                    <property name=\"width_chars\">10</property>"
705     "                    <attributes>"
706     "                      <attribute name=\"weight\" value=\"bold\"/>"
707     "                      <attribute name=\"foreground\" value=\"#b3460000eb1c\"/>"
708     "                    </attributes>"
709     "                  </object>"
710     "                  <packing>"
711     "                    <property name=\"expand\">True</property>"
712     "                    <property name=\"fill\">True</property>"
713     "                    <property name=\"position\">1</property>"
714     "                  </packing>"
715     "                </child>"
716     "                <child>"
717     "                  <object class=\"GtkComboBox\" id=\"combobox1\">"
718     "                    <property name=\"visible\">True</property>"
719     "                    <property name=\"model\">liststore1</property>"
720     "                    <property name=\"active\">0</property>"
721     "                    <child>"
722     "                      <object class=\"GtkCellRendererPixbuf\" id=\"cellrenderertext1\"/>"
723     "                      <attributes>"
724     "                        <attribute name=\"stock-id\">1</attribute>"
725     "                      </attributes>"
726     "                    </child>"
727     "                    <child>"
728     "                      <object class=\"GtkCellRendererText\" id=\"cellrenderertext2\">"
729     "                        <property name=\"foreground\">purple</property>"
730     "                        <property name=\"weight\">600</property>"
731     "                        <property name=\"wrap_mode\">word</property>"
732     "                        <property name=\"wrap_width\">100</property>"
733     "                      </object>"
734     "                      <attributes>"
735     "                        <attribute name=\"text\">0</attribute>"
736     "                      </attributes>"
737     "                    </child>"
738     "                  </object>"
739     "                  <packing>"
740     "                    <property name=\"expand\">True</property>"
741     "                    <property name=\"fill\">True</property>"
742     "                    <property name=\"position\">2</property>"
743     "                  </packing>"
744     "                </child>"
745     "              </object>"
746     "              <packing>"
747     "                <property name=\"expand\">False</property>"
748     "                <property name=\"fill\">True</property>"
749     "                <property name=\"position\">0</property>"
750     "              </packing>"
751     "            </child>"
752     "            <child>"
753     "              <object class=\"GtkFrame\" id=\"frame1\">"
754     "                <property name=\"visible\">True</property>"
755     "                <property name=\"label_xalign\">0</property>"
756     "                <child>"
757     "                  <object class=\"GtkLabel\" id=\"label3\">"
758     "                    <property name=\"visible\">True</property>"
759     "                    <property name=\"label\" translatable=\"yes\">This test shows combo boxes\n"
760     "requesting and allocating space\n"
761     "for its backing content using\n"
762     "height-for-width geometry\n"
763     "management.\n"
764     "\n"
765     "Note this test also demonstrates\n"
766     "height-for-width menu items.</property>"
767     "                    <property name=\"justify\">center</property>"
768     "                    <attributes>"
769     "                      <attribute name=\"weight\" value=\"bold\"/>"
770     "                      <attribute name=\"foreground\" value=\"#00000000ffff\"/>"
771     "                    </attributes>"
772     "                  </object>"
773     "                </child>"
774     "              </object>"
775     "              <packing>"
776     "                <property name=\"expand\">True</property>"
777     "                <property name=\"fill\">True</property>"
778     "                <property name=\"position\">1</property>"
779     "              </packing>"
780     "            </child>"
781     "            <child>"
782     "              <object class=\"GtkHBox\" id=\"hbox2\">"
783     "                <property name=\"visible\">True</property>"
784     "                <property name=\"spacing\">5</property>"
785     "                <child>"
786     "                  <object class=\"GtkLabel\" id=\"label4\">"
787     "                    <property name=\"visible\">True</property>"
788     "                    <property name=\"label\" translatable=\"yes\">this combo box</property>"
789     "                    <attributes>"
790     "                      <attribute name=\"weight\" value=\"bold\"/>"
791     "                      <attribute name=\"foreground\" value=\"#ffffa5a50000\"/>"
792     "                    </attributes>"
793     "                  </object>"
794     "                  <packing>"
795     "                    <property name=\"expand\">True</property>"
796     "                    <property name=\"fill\">True</property>"
797     "                    <property name=\"position\">0</property>"
798     "                  </packing>"
799     "                </child>"
800     "                <child>"
801     "                  <object class=\"GtkLabel\" id=\"label5\">"
802     "                    <property name=\"visible\">True</property>"
803     "                    <property name=\"label\" translatable=\"yes\">contains some ellipsizing locations</property>"
804     "                    <property name=\"ellipsize\">end</property>"
805     "                    <property name=\"width_chars\">10</property>"
806     "                    <attributes>"
807     "                      <attribute name=\"weight\" value=\"bold\"/>"
808     "                      <attribute name=\"foreground\" value=\"#ffffa5a50000\"/>"
809     "                    </attributes>"
810     "                  </object>"
811     "                  <packing>"
812     "                    <property name=\"expand\">True</property>"
813     "                    <property name=\"fill\">True</property>"
814     "                    <property name=\"position\">1</property>"
815     "                  </packing>"
816     "                </child>"
817     "                <child>"
818     "                  <object class=\"GtkComboBox\" id=\"combobox2\">"
819     "                    <property name=\"visible\">True</property>"
820     "                    <property name=\"model\">liststore1</property>"
821     "                    <property name=\"active\">0</property>"
822     "                    <child>"
823     "                      <object class=\"GtkCellRendererPixbuf\" id=\"cellrenderertext3\"/>"
824     "                      <attributes>"
825     "                        <attribute name=\"stock-id\">1</attribute>"
826     "                      </attributes>"
827     "                    </child>"
828     "                    <child>"
829     "                      <object class=\"GtkCellRendererText\" id=\"cellrenderertext4\">"
830     "                        <property name=\"ellipsize\">end</property>"
831     "                        <property name=\"foreground\">orange</property>"
832     "                        <property name=\"weight\">600</property>"
833     "                        <property name=\"width_chars\">10</property>"
834     "                      </object>"
835     "                      <attributes>"
836     "                        <attribute name=\"text\">0</attribute>"
837     "                      </attributes>"
838     "                    </child>"
839     "                  </object>"
840     "                  <packing>"
841     "                    <property name=\"expand\">True</property>"
842     "                    <property name=\"fill\">True</property>"
843     "                    <property name=\"position\">2</property>"
844     "                  </packing>"
845     "                </child>"
846     "              </object>"
847     "              <packing>"
848     "                <property name=\"expand\">False</property>"
849     "                <property name=\"fill\">True</property>"
850     "                <property name=\"position\">2</property>"
851     "              </packing>"
852     "            </child>"
853     "          </object>"
854     "          <packing>"
855     "            <property name=\"resize\">True</property>"
856     "            <property name=\"shrink\">False</property>"
857     "          </packing>"
858     "        </child>"
859     "        <child>"
860     "          <object class=\"GtkLabel\" id=\"label6\">"
861     "            <property name=\"visible\">True</property>"
862     "            <property name=\"label\" translatable=\"yes\">Some static\n"
863     "text here\n"
864     "that shrinks.</property>"
865     "            <property name=\"justify\">center</property>"
866     "            <attributes>"
867     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
868     "            </attributes>"
869     "          </object>"
870     "          <packing>"
871     "            <property name=\"resize\">False</property>"
872     "            <property name=\"shrink\">True</property>"
873     "          </packing>"
874     "        </child>"
875     "      </object>"
876     "    </child>"
877     "  </object>"
878     "  <object class=\"GtkListStore\" id=\"liststore1\">"
879     "    <columns>"
880     "      <!-- column-name item-text -->"
881     "      <column type=\"gchararray\"/>"
882     "      <!-- column-name icon-name -->"
883     "      <column type=\"gchararray\"/>"
884     "    </columns>"
885     "    <data>"
886     "      <row>"
887     "        <col id=\"0\" translatable=\"yes\">Montreal, Quebec Canada</col>"
888     "        <col id=\"1\" translatable=\"yes\">gtk-yes</col>"
889     "      </row>"
890     "      <row>"
891     "        <col id=\"0\" translatable=\"yes\">Sao Paulo, SP Brazil</col>"
892     "        <col id=\"1\" translatable=\"yes\">gtk-no</col>"
893     "      </row>"
894     "      <row>"
895     "        <col id=\"0\" translatable=\"yes\">Buenos Aires, Argentina</col>"
896     "        <col id=\"1\" translatable=\"yes\">gtk-stop</col>"
897     "      </row>"
898     "      <row>"
899     "        <col id=\"0\" translatable=\"yes\">Los Angelos, California USA</col>"
900     "        <col id=\"1\" translatable=\"yes\">gtk-media-record</col>"
901     "      </row>"
902     "      <row>"
903     "        <col id=\"0\" translatable=\"yes\">Rio de Janeiro, RJ Brazil</col>"
904     "        <col id=\"1\" translatable=\"yes\">gtk-dialog-error</col>"
905     "      </row>"
906     "      <row>"
907     "        <col id=\"0\" translatable=\"yes\">Seoul, South Korea</col>"
908     "        <col id=\"1\" translatable=\"yes\">gtk-info</col>"
909     "      </row>"
910     "    </data>"
911     "  </object>"
912     "</interface>",
913     NULL
914   },
915   
916 };
917
918
919 static void
920 test_clicked (GtkWidget     *button, 
921               TestInterface *interface)
922 {
923   if (!interface->window)
924     {
925       GtkBuilder *builder = gtk_builder_new ();
926       
927       gtk_builder_add_from_string (builder, interface->interface, -1, NULL);
928       interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");
929
930       g_signal_connect (interface->window, "delete_event", 
931                         G_CALLBACK (gtk_widget_hide_on_delete), NULL);
932     }
933
934   gtk_widget_show (interface->window);
935 }
936
937
938 static GtkWidget *
939 create_window (void)
940 {
941   GtkWidget *window, *vbox, *button;
942   gint i;
943
944   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
945   vbox   = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
946
947   gtk_container_set_border_width (GTK_CONTAINER (window), 8);
948
949   gtk_widget_show (vbox);
950   gtk_container_add (GTK_CONTAINER (window), vbox);
951
952   for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
953     {
954       button = gtk_button_new_with_label (interfaces[i].name);
955
956       gtk_widget_set_tooltip_text (button, interfaces[i].tooltip);
957
958       g_signal_connect (G_OBJECT (button), "clicked", 
959                         G_CALLBACK (test_clicked), &interfaces[i]);
960
961       gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
962       gtk_widget_show (button);
963     }
964
965   return window;
966 }
967
968
969
970 int
971 main (int argc, char *argv[])
972 {
973   GtkWidget *window;
974
975   gtk_init (&argc, &argv);
976
977   window = create_window ();
978
979   g_signal_connect (window, "delete-event",
980                     G_CALLBACK (gtk_main_quit), window);
981
982   gtk_widget_show (window);
983
984   gtk_main ();
985
986   return 0;
987 }