]> Pileus Git - ~andy/gtk/blob - tests/testheightforwidth.c
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <gtk/gtk.h>
22
23 typedef struct {
24   const gchar *name;
25   const gchar *tooltip;
26   const gchar *interface;
27   GtkWidget   *window;
28 } TestInterface;
29
30
31 /* These strings were generated with:
32  *
33  *     IFS=""; while read line; do echo -n \"; echo -n $line | sed -e 's|\"|\\"|g'; echo \"; done < file.glade
34  */
35 TestInterface interfaces[] = {
36   {
37     "Ellipsizing Labels",
38     "Demonstrates how labels will request a natural size in a horizontal space",
39     "<interface>"
40     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
41     "  <!-- interface-naming-policy project-wide -->"
42     "  <object class=\"GtkWindow\" id=\"window\">"
43     "    <property name=\"default_width\">450</property>"
44     "    <property name=\"default_height\">50</property>"
45     "    <child>"
46     "      <object class=\"GtkHBox\" id=\"hbox5\">"
47     "        <property name=\"visible\">True</property>"
48     "        <child>"
49     "          <object class=\"GtkLabel\" id=\"label9\">"
50     "            <property name=\"visible\">True</property>"
51     "            <property name=\"label\" translatable=\"yes\">Some labels do ellipsize</property>"
52     "            <property name=\"ellipsize\">end</property>"
53     "            <attributes>"
54     "              <attribute name=\"weight\" value=\"bold\"/>"
55     "              <attribute name=\"foreground\" value=\"#09610feefe03\"/>"
56     "            </attributes>"
57     "          </object>"
58     "          <packing>"
59     "            <property name=\"position\">0</property>"
60     "          </packing>"
61     "        </child>"
62     "        <child>"
63     "          <object class=\"GtkLabel\" id=\"label10\">"
64     "            <property name=\"visible\">True</property>"
65     "            <property name=\"label\" translatable=\"yes\">but some</property>"
66     "            <property name=\"ellipsize\">end</property>"
67     "            <attributes>"
68     "              <attribute name=\"weight\" value=\"bold\"/>"
69     "              <attribute name=\"foreground\" value=\"#0000af6b0993\"/>"
70     "            </attributes>"
71     "          </object>"
72     "          <packing>"
73     "            <property name=\"position\">1</property>"
74     "          </packing>"
75     "        </child>"
76     "        <child>"
77     "          <object class=\"GtkLabel\" id=\"label11\">"
78     "            <property name=\"visible\">True</property>"
79     "            <property name=\"label\" translatable=\"yes\">do not at all</property>"
80     "            <attributes>"
81     "              <attribute name=\"style\" value=\"normal\"/>"
82     "              <attribute name=\"weight\" value=\"bold\"/>"
83     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
84     "            </attributes>"
85     "          </object>"
86     "          <packing>"
87     "            <property name=\"position\">2</property>"
88     "          </packing>"
89     "        </child>"
90     "      </object>"
91     "    </child>"
92     "  </object>"
93     "</interface>",
94     NULL
95   },
96
97   {
98     "Wrapping Label",
99     "Demonstrates how a wrapping label can require a height contextual to its allocated width",
100     "<interface>"
101     "  <requires lib=\"gtk+\" version=\"2.18\"/>"
102     "  <!-- interface-naming-policy project-wide -->"
103     "  <object class=\"GtkWindow\" id=\"window\">"
104     "    <property name=\"border_width\">12</property>"
105     "    <property name=\"default_width\">300</property>"
106     "    <child>"
107     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
108     "        <property name=\"visible\">True</property>"
109     "        <property name=\"can_focus\">True</property>"
110     "        <child>"
111     "          <object class=\"GtkVBox\" id=\"vbox2\">"
112     "            <property name=\"visible\">True</property>"
113     "            <child>"
114     "              <object class=\"GtkLabel\" id=\"label3\">"
115     "                <property name=\"visible\">True</property>"
116     "                <property name=\"label\" translatable=\"yes\">A short static label.</property>"
117     "                <attributes>"
118     "                  <attribute name=\"weight\" value=\"bold\"/>"
119     "                </attributes>"
120     "              </object>"
121     "              <packing>"
122     "                <property name=\"position\">0</property>"
123     "              </packing>"
124     "            </child>"
125     "            <child>"
126     "              <object class=\"GtkFrame\" id=\"frame1\">"
127     "                <property name=\"label\">Long label</property>"
128     "                <property name=\"visible\">True</property>"
129     "                <child>"
130     "                  <object class=\"GtkLabel\" id=\"label1\">"
131     "                    <property name=\"visible\">True</property>"
132     "                    <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>"
133     "                    <property name=\"wrap\">True</property>"
134     "                    <property name=\"max_width_chars\">30</property>"
135     "                    <attributes>"
136     "                      <attribute name=\"foreground\" value=\"#18c52119f796\"/>"
137     "                    </attributes>"
138     "                  </object>"
139     "                </child>"
140     "              </object>"
141     "              <packing>"
142     "                <property name=\"expand\">False</property>"
143     "                <property name=\"position\">1</property>"
144     "              </packing>"
145     "            </child>"
146     "            <child>"
147     "              <object class=\"GtkButton\" id=\"button2\">"
148     "                <property name=\"visible\">True</property>"
149     "                <property name=\"can_focus\">True</property>"
150     "                <property name=\"receives_default\">True</property>"
151     "                <child>"
152     "                  <object class=\"GtkLabel\" id=\"label2\">"
153     "                    <property name=\"visible\">True</property>"
154     "                    <property name=\"label\" translatable=\"yes\">A really really long label inside a button to demonstrate height for width working inside buttons</property>"
155     "                    <property name=\"wrap\">True</property>"
156     "                    <property name=\"max_width_chars\">25</property>"
157     "                    <attributes>"
158     "                      <attribute name=\"foreground\" value=\"#1e3687ab0a52\"/>"
159     "                    </attributes>"
160     "                  </object>"
161     "                </child>"
162     "              </object>"
163     "              <packing>"
164     "                <property name=\"expand\">False</property>"
165     "                <property name=\"position\">2</property>"
166     "              </packing>"
167     "            </child>"
168     "          </object>"
169     "          <packing>"
170     "            <property name=\"resize\">False</property>"
171     "            <property name=\"shrink\">False</property>"
172     "          </packing>"
173     "        </child>"
174     "        <child>"
175     "          <object class=\"GtkLabel\" id=\"label4\">"
176     "            <property name=\"visible\">True</property>"
177     "            <property name=\"label\" translatable=\"yes\">This static label\n"
178     "can shrink.</property>"
179     "            <property name=\"justify\">center</property>"
180     "            <attributes>"
181     "              <attribute name=\"style\" value=\"normal\"/>"
182     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
183     "            </attributes>"
184     "          </object>"
185     "          <packing>"
186     "            <property name=\"resize\">True</property>"
187     "            <property name=\"shrink\">True</property>"
188     "          </packing>"
189     "        </child>"
190     "      </object>"
191     "    </child>"
192     "  </object>"
193     "</interface>",
194     NULL
195   },
196
197   {
198     "Horizontal Box",
199     "Demonstrates how a horizontal box can calculate the collective height for an allocated width",
200     "<interface>"
201     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
202     "  <!-- interface-naming-policy project-wide -->"
203     "  <object class=\"GtkWindow\" id=\"window\">"
204     "    <property name=\"default_height\">200</property>"
205     "    <property name=\"default_width\">600</property>"
206     "    <child>"
207     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
208     "        <property name=\"visible\">True</property>"
209     "        <property name=\"can_focus\">True</property>"
210     "        <child>"
211     "          <object class=\"GtkVBox\" id=\"vbox1\">"
212     "            <property name=\"visible\">True</property>"
213     "            <child>"
214     "              <object class=\"GtkHBox\" id=\"hbox1\">"
215     "                <property name=\"visible\">True</property>"
216     "                <child>"
217     "                  <object class=\"GtkButton\" id=\"button1\">"
218     "                    <property name=\"visible\">True</property>"
219     "                    <property name=\"can_focus\">True</property>"
220     "                    <property name=\"receives_default\">True</property>"
221     "                    <property name=\"use_action_appearance\">False</property>"
222     "                    <child>"
223     "                      <object class=\"GtkLabel\" id=\"label2\">"
224     "                        <property name=\"visible\">True</property>"
225     "                        <property name=\"label\" translatable=\"yes\">A button that wraps.</property>"
226     "                        <property name=\"wrap\">True</property>"
227     "                        <property name=\"width_chars\">10</property>"
228     "                        <attributes>"
229     "                          <attribute name=\"foreground\" value=\"#0000041dffff\"/>"
230     "                        </attributes>"
231     "                      </object>"
232     "                    </child>"
233     "                  </object>"
234     "                  <packing>"
235     "                    <property name=\"expand\">False</property>"
236     "                    <property name=\"position\">0</property>"
237     "                  </packing>"
238     "                </child>"
239     "                <child>"
240     "                  <object class=\"GtkLabel\" id=\"label1\">"
241     "                    <property name=\"visible\">True</property>"
242     "                    <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>"
243     "                    <property name=\"wrap\">True</property>"
244     "                    <property name=\"width_chars\">30</property>"
245     "                    <attributes>"
246     "                      <attribute name=\"foreground\" value=\"#07d0a9b20972\"/>"
247     "                    </attributes>"
248     "                  </object>"
249     "                  <packing>"
250     "                    <property name=\"position\">1</property>"
251     "                  </packing>"
252     "                </child>"
253     "              </object>"
254     "              <packing>"
255     "                <property name=\"expand\">False</property>"
256     "                <property name=\"position\">0</property>"
257     "              </packing>"
258     "            </child>"
259     "            <child>"
260     "              <object class=\"GtkButton\" id=\"button2\">"
261     "                <property name=\"label\" translatable=\"yes\">A button that expands in the vbox</property>"
262     "                <property name=\"visible\">True</property>"
263     "                <property name=\"can_focus\">True</property>"
264     "                <property name=\"receives_default\">True</property>"
265     "                <property name=\"use_action_appearance\">False</property>"
266     "              </object>"
267     "              <packing>"
268     "                <property name=\"position\">1</property>"
269     "              </packing>"
270     "            </child>"
271     "          </object>"
272     "          <packing>"
273     "            <property name=\"resize\">False</property>"
274     "            <property name=\"shrink\">False</property>"
275     "          </packing>"
276     "        </child>"
277     "        <child>"
278     "          <object class=\"GtkLabel\" id=\"label4\">"
279     "            <property name=\"visible\">True</property>"
280     "            <property name=\"label\" translatable=\"yes\">This label is\n"
281     "set to shrink inside\n"
282     "the paned window.</property>"
283     "            <property name=\"justify\">center</property>"
284     "            <attributes>"
285     "              <attribute name=\"style\" value=\"normal\"/>"
286     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
287     "            </attributes>"
288     "          </object>"
289     "          <packing>"
290     "            <property name=\"resize\">True</property>"
291     "            <property name=\"shrink\">True</property>"
292     "          </packing>"
293     "        </child>"
294     "      </object>"
295     "    </child>"
296     "  </object>"
297     "</interface>",
298     NULL
299   },
300
301   {
302     "Vertical Labels",
303     "Demonstrates how a horizontal box will consider width-for-height when allocating children "
304     "even if the toplevel window is requested as height-for-width.",
305     "<interface>"
306     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
307     "  <!-- interface-naming-policy project-wide -->"
308     "  <object class=\"GtkWindow\" id=\"window\">"
309     "    <property name=\"default_width\">400</property>"
310     "    <property name=\"default_height\">300</property>"
311     "    <child>"
312     "      <object class=\"GtkVPaned\" id=\"vpaned1\">"
313     "        <property name=\"visible\">True</property>"
314     "        <property name=\"can_focus\">True</property>"
315     "        <child>"
316     "          <object class=\"GtkHBox\" id=\"hbox1\">"
317     "            <property name=\"visible\">True</property>"
318     "            <child>"
319     "              <object class=\"GtkLabel\" id=\"label1\">"
320     "                <property name=\"visible\">True</property>"
321     "                <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
322     "                <property name=\"justify\">center</property>"
323     "                <property name=\"wrap\">True</property>"
324     "                <property name=\"width_chars\">10</property>"
325     "                <property name=\"angle\">90</property>"
326     "                <attributes>"
327     "                  <attribute name=\"weight\" value=\"bold\"/>"
328     "                  <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
329     "                </attributes>"
330     "              </object>"
331     "              <packing>"
332     "                <property name=\"expand\">False</property>"
333     "                <property name=\"position\">0</property>"
334     "              </packing>"
335     "            </child>"
336     "            <child>"
337     "              <object class=\"GtkFrame\" id=\"frame1\">"
338     "                <property name=\"visible\">True</property>"
339     "                <property name=\"label_xalign\">0</property>"
340     "                <property name=\"shadow_type\">out</property>"
341     "                <child>"
342     "                  <object class=\"GtkLabel\" id=\"label5\">"
343     "                    <property name=\"visible\">True</property>"
344     "                    <property name=\"label\" translatable=\"yes\">Neither of the panes are\n"
345     "set to shrink.</property>"
346     "                    <property name=\"justify\">center</property>"
347     "                    <attributes>"
348     "                      <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
349     "                    </attributes>"
350     "                  </object>"
351     "                </child>"
352     "                <child type=\"label_item\">"
353     "                  <placeholder/>"
354     "                </child>"
355     "              </object>"
356     "              <packing>"
357     "                <property name=\"position\">1</property>"
358     "              </packing>"
359     "            </child>"
360     "          </object>"
361     "          <packing>"
362     "            <property name=\"resize\">False</property>"
363     "            <property name=\"shrink\">False</property>"
364     "          </packing>"
365     "        </child>"
366     "        <child>"
367     "          <object class=\"GtkHBox\" id=\"hbox2\">"
368     "            <property name=\"visible\">True</property>"
369     "            <child>"
370     "              <object class=\"GtkFrame\" id=\"frame2\">"
371     "                <property name=\"visible\">True</property>"
372     "                <property name=\"label_xalign\">0</property>"
373     "                <property name=\"shadow_type\">out</property>"
374     "                <child>"
375     "                  <object class=\"GtkLabel\" id=\"label4\">"
376     "                    <property name=\"visible\">True</property>"
377     "                    <property name=\"label\" translatable=\"yes\">The interface is allocated as height\n"
378     "for width, but the horizontal boxes\n"
379     "allocate in width for height mode.</property>"
380     "                    <attributes>"
381     "                      <attribute name=\"foreground\" value=\"#000097970808\"/>"
382     "                    </attributes>"
383     "                  </object>"
384     "                </child>"
385     "                <child type=\"label_item\">"
386     "                  <placeholder/>"
387     "                </child>"
388     "              </object>"
389     "              <packing>"
390     "                <property name=\"position\">0</property>"
391     "              </packing>"
392     "            </child>"
393     "            <child>"
394     "              <object class=\"GtkLabel\" id=\"label3\">"
395     "                <property name=\"visible\">True</property>"
396     "                <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
397     "                <property name=\"justify\">center</property>"
398     "                <property name=\"wrap\">True</property>"
399     "                <property name=\"width_chars\">10</property>"
400     "                <property name=\"angle\">270</property>"
401     "                <attributes>"
402     "                  <attribute name=\"weight\" value=\"bold\"/>"
403     "                  <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
404     "                </attributes>"
405     "              </object>"
406     "              <packing>"
407     "                <property name=\"expand\">False</property>"
408     "                <property name=\"position\">1</property>"
409     "              </packing>"
410     "            </child>"
411     "          </object>"
412     "          <packing>"
413     "            <property name=\"resize\">False</property>"
414     "            <property name=\"shrink\">False</property>"
415     "          </packing>"
416     "        </child>"
417     "      </object>"
418     "    </child>"
419     "  </object>"
420     "</interface>",
421     NULL
422   },
423
424   {
425     "Label Parameters",
426     "This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
427     "to effect minimum and natural widths in wrapping labels.",
428     "<interface>"
429     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
430     "  <!-- interface-naming-policy project-wide -->"
431     "  <object class=\"GtkWindow\" id=\"window\">"
432     "    <property name=\"default_width\">900</property>"
433     "    <child>"
434     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
435     "        <property name=\"visible\">True</property>"
436     "        <property name=\"can_focus\">True</property>"
437     "        <child>"
438     "          <object class=\"GtkVBox\" id=\"vbox1\">"
439     "            <property name=\"visible\">True</property>"
440     "            <child>"
441     "              <object class=\"GtkHBox\" id=\"hbox1\">"
442     "                <property name=\"visible\">True</property>"
443     "                <property name=\"spacing\">6</property>"
444     "                <child>"
445     "                  <object class=\"GtkLabel\" id=\"label1\">"
446     "                    <property name=\"visible\">True</property>"
447     "                    <property name=\"label\" translatable=\"yes\">The first 2 labels require 10 characters.</property>"
448     "                    <property name=\"wrap\">True</property>"
449     "                    <property name=\"width_chars\">10</property>"
450     "                    <attributes>"
451     "                      <attribute name=\"weight\" value=\"bold\"/>"
452     "                      <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
453     "                    </attributes>"
454     "                  </object>"
455     "                  <packing>"
456     "                    <property name=\"expand\">False</property>"
457     "                    <property name=\"fill\">False</property>"
458     "                    <property name=\"position\">0</property>"
459     "                  </packing>"
460     "                </child>"
461     "                <child>"
462     "                  <object class=\"GtkLabel\" id=\"label2\">"
463     "                    <property name=\"visible\">True</property>"
464     "                    <property name=\"label\" translatable=\"yes\">This label has a maximum natural width of 20 characters. The second two labels expand.</property>"
465     "                    <property name=\"wrap\">True</property>"
466     "                    <property name=\"width_chars\">10</property>"
467     "                    <property name=\"max_width_chars\">20</property>"
468     "                    <attributes>"
469     "                      <attribute name=\"weight\" value=\"bold\"/>"
470     "                      <attribute name=\"foreground\" value=\"#05c2a161134b\"/>"
471     "                    </attributes>"
472     "                  </object>"
473     "                  <packing>"
474     "                    <property name=\"expand\">True</property>"
475     "                    <property name=\"fill\">True</property>"
476     "                    <property name=\"position\">1</property>"
477     "                  </packing>"
478     "                </child>"
479     "                <child>"
480     "                  <object class=\"GtkLabel\" id=\"label3\">"
481     "                    <property name=\"visible\">True</property>"
482     "                    <property name=\"label\" translatable=\"yes\">This label requires a default minimum size.</property>"
483     "                    <property name=\"wrap\">True</property>"
484     "                    <attributes>"
485     "                      <attribute name=\"weight\" value=\"bold\"/>"
486     "                      <attribute name=\"foreground\" value=\"#03e30758fb5f\"/>"
487     "                    </attributes>"
488     "                  </object>"
489     "                  <packing>"
490     "                    <property name=\"position\">2</property>"
491     "                  </packing>"
492     "                </child>"
493     "              </object>"
494     "              <packing>"
495     "                <property name=\"position\">0</property>"
496     "              </packing>"
497     "            </child>"
498     "            <child>"
499     "              <object class=\"GtkLabel\" id=\"label4\">"
500     "                <property name=\"visible\">True</property>"
501     "                <property name=\"label\" translatable=\"yes\">This test demonstrates how the \"width-chars\" and \"max-width-chars\"\n"
502     "properties can be used to specify the minimum requested wrap width\n"
503     "and the maximum natural wrap width respectively.</property>"
504     "                <property name=\"ellipsize\">end</property>"
505     "                <property name=\"width_chars\">30</property>"
506     "                <attributes>"
507     "                  <attribute name=\"style\" value=\"normal\"/>"
508     "                  <attribute name=\"foreground\" value=\"#05470000abaf\"/>"
509     "                </attributes>"
510     "              </object>"
511     "              <packing>"
512     "                <property name=\"position\">1</property>"
513     "              </packing>"
514     "            </child>"
515     "          </object>"
516     "          <packing>"
517     "            <property name=\"resize\">False</property>"
518     "            <property name=\"shrink\">False</property>"
519     "          </packing>"
520     "        </child>"
521     "        <child>"
522     "          <object class=\"GtkLabel\" id=\"label5\">"
523     "            <property name=\"visible\">True</property>"
524     "            <property name=\"label\" translatable=\"yes\">Some static\n"
525     "text that shrinks.\n"
526     "\n"
527     "You will need to stretch\n"
528     "this window quite wide\n"
529     "to see the effects.</property>"
530     "            <property name=\"justify\">center</property>"
531     "            <attributes>"
532     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
533     "            </attributes>"
534     "          </object>"
535     "          <packing>"
536     "            <property name=\"resize\">True</property>"
537     "            <property name=\"shrink\">True</property>"
538     "          </packing>"
539     "        </child>"
540     "      </object>"
541     "    </child>"
542     "  </object>"
543     "</interface>",
544     NULL
545   },
546
547   {
548     "Wrapping Expander",
549     "This test demonstrates how the expander label can fill to its natural width "
550     "and also trade height for width.",
551     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
552     "<interface>"
553     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
554     "  <!-- interface-naming-policy project-wide -->"
555     "  <object class=\"GtkWindow\" id=\"window\">"
556     "    <property name=\"default_width\">500</property>"
557     "    <child>"
558     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
559     "        <property name=\"visible\">True</property>"
560     "        <property name=\"can_focus\">True</property>"
561     "        <child>"
562     "          <object class=\"GtkExpander\" id=\"expander1\">"
563     "            <property name=\"visible\">True</property>"
564     "            <property name=\"can_focus\">True</property>"
565     "            <child>"
566     "              <object class=\"GtkLabel\" id=\"label2\">"
567     "                <property name=\"visible\">True</property>"
568     "                <property name=\"label\" translatable=\"yes\">More wrapping text to fill the largish content area in the expander </property>"
569     "                <property name=\"wrap\">True</property>"
570     "                <property name=\"width_chars\">10</property>"
571     "                <attributes>"
572     "                  <attribute name=\"weight\" value=\"bold\"/>"
573     "                  <attribute name=\"foreground\" value=\"#0000D0F00000\"/>"
574     "                </attributes>"
575     "              </object>"
576     "            </child>"
577     "            <child type=\"label\">"
578     "              <object class=\"GtkLabel\" id=\"label1\">"
579     "                <property name=\"visible\">True</property>"
580     "                <property name=\"label\" translatable=\"yes\">Here is some expander text that wraps</property>"
581     "                <property name=\"wrap\">True</property>"
582     "                <property name=\"width_chars\">10</property>"
583     "                <attributes>"
584     "                  <attribute name=\"weight\" value=\"bold\"/>"
585     "                  <attribute name=\"foreground\" value=\"blue\"/>"
586     "                </attributes>"
587     "              </object>"
588     "            </child>"
589     "          </object>"
590     "          <packing>"
591     "            <property name=\"resize\">False</property>"
592     "            <property name=\"shrink\">False</property>"
593     "          </packing>"
594     "        </child>"
595     "        <child>"
596     "          <object class=\"GtkLabel\" id=\"label3\">"
597     "            <property name=\"visible\">True</property>"
598     "            <property name=\"label\" translatable=\"yes\">static\n"
599     "text\n"
600     "here</property>"
601     "            <attributes>"
602     "              <attribute name=\"foreground\" value=\"red\"/>"
603     "            </attributes>"
604     "          </object>"
605     "          <packing>"
606     "            <property name=\"resize\">True</property>"
607     "            <property name=\"shrink\">True</property>"
608     "          </packing>"
609     "        </child>"
610     "      </object>"
611     "    </child>"
612     "  </object>"
613     "</interface>",
614     NULL
615   },
616
617   {
618     "Wrapping Frame Label",
619     "This test demonstrates how the frame label can fill to its natural width "
620     "and also trade height for width.",
621     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
622     "<interface>"
623     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
624     "  <!-- interface-naming-policy project-wide -->"
625     "  <object class=\"GtkWindow\" id=\"window\">"
626     "    <property name=\"default_width\">400</property>"
627     "    <property name=\"default_height\">150</property>"
628     "    <child>"
629     "      <object class=\"GtkFrame\" id=\"frame1\">"
630     "        <property name=\"visible\">True</property>"
631     "        <property name=\"border_width\">8</property>"
632     "        <property name=\"label_xalign\">0</property>"
633     "        <child>"
634     "          <object class=\"GtkAlignment\" id=\"alignment1\">"
635     "            <property name=\"visible\">True</property>"
636     "            <property name=\"left_padding\">12</property>"
637     "            <child>"
638     "              <object class=\"GtkLabel\" id=\"label2\">"
639     "                <property name=\"visible\">True</property>"
640     "                <property name=\"label\" translatable=\"yes\">some content</property>"
641     "              </object>"
642     "            </child>"
643     "          </object>"
644     "        </child>"
645     "        <child type=\"label\">"
646     "          <object class=\"GtkLabel\" id=\"label1\">"
647     "            <property name=\"visible\">True</property>"
648     "            <property name=\"label\" translatable=\"yes\">A frame label that's a little long and wraps</property>"
649     "            <property name=\"use_markup\">True</property>"
650     "            <property name=\"wrap\">True</property>"
651     "          </object>"
652     "        </child>"
653     "      </object>"
654     "    </child>"
655     "  </object>"
656     "</interface>",
657     NULL
658   },
659
660   {
661     "Combo Boxes and Menus",
662     "This test shows wrapping and ellipsizing text in combo boxes (and consequently in menu items).",
663     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
664     "<interface>"
665     "  <requires lib=\"gtk+\" version=\"2.20\"/>"
666     "  <!-- interface-naming-policy project-wide -->"
667     "  <object class=\"GtkWindow\" id=\"window\">"
668     "    <property name=\"border_width\">8</property>"
669     "    <property name=\"default_width\">600</property>"
670     "    <child>"
671     "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
672     "        <property name=\"visible\">True</property>"
673     "        <property name=\"can_focus\">True</property>"
674     "        <child>"
675     "          <object class=\"GtkVBox\" id=\"vbox1\">"
676     "            <property name=\"visible\">True</property>"
677     "            <property name=\"spacing\">5</property>"
678     "            <child>"
679     "              <object class=\"GtkHBox\" id=\"hbox1\">"
680     "                <property name=\"visible\">True</property>"
681     "                <property name=\"spacing\">5</property>"
682     "                <child>"
683     "                  <object class=\"GtkLabel\" id=\"label1\">"
684     "                    <property name=\"visible\">True</property>"
685     "                    <property name=\"label\" translatable=\"yes\">this combo box</property>"
686     "                    <attributes>"
687     "                      <attribute name=\"weight\" value=\"bold\"/>"
688     "                      <attribute name=\"foreground\" value=\"#b3460000eb1c\"/>"
689     "                    </attributes>"
690     "                  </object>"
691     "                  <packing>"
692     "                    <property name=\"expand\">True</property>"
693     "                    <property name=\"fill\">True</property>"
694     "                    <property name=\"position\">0</property>"
695     "                  </packing>"
696     "                </child>"
697     "                <child>"
698     "                  <object class=\"GtkLabel\" id=\"label2\">"
699     "                    <property name=\"visible\">True</property>"
700     "                    <property name=\"label\" translatable=\"yes\">contains some wrapping locations</property>"
701     "                    <property name=\"ellipsize\">end</property>"
702     "                    <property name=\"width_chars\">10</property>"
703     "                    <attributes>"
704     "                      <attribute name=\"weight\" value=\"bold\"/>"
705     "                      <attribute name=\"foreground\" value=\"#b3460000eb1c\"/>"
706     "                    </attributes>"
707     "                  </object>"
708     "                  <packing>"
709     "                    <property name=\"expand\">True</property>"
710     "                    <property name=\"fill\">True</property>"
711     "                    <property name=\"position\">1</property>"
712     "                  </packing>"
713     "                </child>"
714     "                <child>"
715     "                  <object class=\"GtkComboBox\" id=\"combobox1\">"
716     "                    <property name=\"visible\">True</property>"
717     "                    <property name=\"model\">liststore1</property>"
718     "                    <property name=\"active\">0</property>"
719     "                    <child>"
720     "                      <object class=\"GtkCellRendererPixbuf\" id=\"cellrenderertext1\"/>"
721     "                      <attributes>"
722     "                        <attribute name=\"stock-id\">1</attribute>"
723     "                      </attributes>"
724     "                    </child>"
725     "                    <child>"
726     "                      <object class=\"GtkCellRendererText\" id=\"cellrenderertext2\">"
727     "                        <property name=\"foreground\">purple</property>"
728     "                        <property name=\"weight\">600</property>"
729     "                        <property name=\"wrap_mode\">word</property>"
730     "                        <property name=\"wrap_width\">100</property>"
731     "                      </object>"
732     "                      <attributes>"
733     "                        <attribute name=\"text\">0</attribute>"
734     "                      </attributes>"
735     "                    </child>"
736     "                  </object>"
737     "                  <packing>"
738     "                    <property name=\"expand\">True</property>"
739     "                    <property name=\"fill\">True</property>"
740     "                    <property name=\"position\">2</property>"
741     "                  </packing>"
742     "                </child>"
743     "              </object>"
744     "              <packing>"
745     "                <property name=\"expand\">False</property>"
746     "                <property name=\"fill\">True</property>"
747     "                <property name=\"position\">0</property>"
748     "              </packing>"
749     "            </child>"
750     "            <child>"
751     "              <object class=\"GtkFrame\" id=\"frame1\">"
752     "                <property name=\"visible\">True</property>"
753     "                <property name=\"label_xalign\">0</property>"
754     "                <child>"
755     "                  <object class=\"GtkLabel\" id=\"label3\">"
756     "                    <property name=\"visible\">True</property>"
757     "                    <property name=\"label\" translatable=\"yes\">This test shows combo boxes\n"
758     "requesting and allocating space\n"
759     "for its backing content using\n"
760     "height-for-width geometry\n"
761     "management.\n"
762     "\n"
763     "Note this test also demonstrates\n"
764     "height-for-width menu items.</property>"
765     "                    <property name=\"justify\">center</property>"
766     "                    <attributes>"
767     "                      <attribute name=\"weight\" value=\"bold\"/>"
768     "                      <attribute name=\"foreground\" value=\"#00000000ffff\"/>"
769     "                    </attributes>"
770     "                  </object>"
771     "                </child>"
772     "              </object>"
773     "              <packing>"
774     "                <property name=\"expand\">True</property>"
775     "                <property name=\"fill\">True</property>"
776     "                <property name=\"position\">1</property>"
777     "              </packing>"
778     "            </child>"
779     "            <child>"
780     "              <object class=\"GtkHBox\" id=\"hbox2\">"
781     "                <property name=\"visible\">True</property>"
782     "                <property name=\"spacing\">5</property>"
783     "                <child>"
784     "                  <object class=\"GtkLabel\" id=\"label4\">"
785     "                    <property name=\"visible\">True</property>"
786     "                    <property name=\"label\" translatable=\"yes\">this combo box</property>"
787     "                    <attributes>"
788     "                      <attribute name=\"weight\" value=\"bold\"/>"
789     "                      <attribute name=\"foreground\" value=\"#ffffa5a50000\"/>"
790     "                    </attributes>"
791     "                  </object>"
792     "                  <packing>"
793     "                    <property name=\"expand\">True</property>"
794     "                    <property name=\"fill\">True</property>"
795     "                    <property name=\"position\">0</property>"
796     "                  </packing>"
797     "                </child>"
798     "                <child>"
799     "                  <object class=\"GtkLabel\" id=\"label5\">"
800     "                    <property name=\"visible\">True</property>"
801     "                    <property name=\"label\" translatable=\"yes\">contains some ellipsizing locations</property>"
802     "                    <property name=\"ellipsize\">end</property>"
803     "                    <property name=\"width_chars\">10</property>"
804     "                    <attributes>"
805     "                      <attribute name=\"weight\" value=\"bold\"/>"
806     "                      <attribute name=\"foreground\" value=\"#ffffa5a50000\"/>"
807     "                    </attributes>"
808     "                  </object>"
809     "                  <packing>"
810     "                    <property name=\"expand\">True</property>"
811     "                    <property name=\"fill\">True</property>"
812     "                    <property name=\"position\">1</property>"
813     "                  </packing>"
814     "                </child>"
815     "                <child>"
816     "                  <object class=\"GtkComboBox\" id=\"combobox2\">"
817     "                    <property name=\"visible\">True</property>"
818     "                    <property name=\"model\">liststore1</property>"
819     "                    <property name=\"active\">0</property>"
820     "                    <child>"
821     "                      <object class=\"GtkCellRendererPixbuf\" id=\"cellrenderertext3\"/>"
822     "                      <attributes>"
823     "                        <attribute name=\"stock-id\">1</attribute>"
824     "                      </attributes>"
825     "                    </child>"
826     "                    <child>"
827     "                      <object class=\"GtkCellRendererText\" id=\"cellrenderertext4\">"
828     "                        <property name=\"ellipsize\">end</property>"
829     "                        <property name=\"foreground\">orange</property>"
830     "                        <property name=\"weight\">600</property>"
831     "                        <property name=\"width_chars\">10</property>"
832     "                      </object>"
833     "                      <attributes>"
834     "                        <attribute name=\"text\">0</attribute>"
835     "                      </attributes>"
836     "                    </child>"
837     "                  </object>"
838     "                  <packing>"
839     "                    <property name=\"expand\">True</property>"
840     "                    <property name=\"fill\">True</property>"
841     "                    <property name=\"position\">2</property>"
842     "                  </packing>"
843     "                </child>"
844     "              </object>"
845     "              <packing>"
846     "                <property name=\"expand\">False</property>"
847     "                <property name=\"fill\">True</property>"
848     "                <property name=\"position\">2</property>"
849     "              </packing>"
850     "            </child>"
851     "          </object>"
852     "          <packing>"
853     "            <property name=\"resize\">True</property>"
854     "            <property name=\"shrink\">False</property>"
855     "          </packing>"
856     "        </child>"
857     "        <child>"
858     "          <object class=\"GtkLabel\" id=\"label6\">"
859     "            <property name=\"visible\">True</property>"
860     "            <property name=\"label\" translatable=\"yes\">Some static\n"
861     "text here\n"
862     "that shrinks.</property>"
863     "            <property name=\"justify\">center</property>"
864     "            <attributes>"
865     "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
866     "            </attributes>"
867     "          </object>"
868     "          <packing>"
869     "            <property name=\"resize\">False</property>"
870     "            <property name=\"shrink\">True</property>"
871     "          </packing>"
872     "        </child>"
873     "      </object>"
874     "    </child>"
875     "  </object>"
876     "  <object class=\"GtkListStore\" id=\"liststore1\">"
877     "    <columns>"
878     "      <!-- column-name item-text -->"
879     "      <column type=\"gchararray\"/>"
880     "      <!-- column-name icon-name -->"
881     "      <column type=\"gchararray\"/>"
882     "    </columns>"
883     "    <data>"
884     "      <row>"
885     "        <col id=\"0\" translatable=\"yes\">Montreal, Quebec Canada</col>"
886     "        <col id=\"1\" translatable=\"yes\">gtk-yes</col>"
887     "      </row>"
888     "      <row>"
889     "        <col id=\"0\" translatable=\"yes\">Sao Paulo, SP Brazil</col>"
890     "        <col id=\"1\" translatable=\"yes\">gtk-no</col>"
891     "      </row>"
892     "      <row>"
893     "        <col id=\"0\" translatable=\"yes\">Buenos Aires, Argentina</col>"
894     "        <col id=\"1\" translatable=\"yes\">gtk-stop</col>"
895     "      </row>"
896     "      <row>"
897     "        <col id=\"0\" translatable=\"yes\">Los Angelos, California USA</col>"
898     "        <col id=\"1\" translatable=\"yes\">gtk-media-record</col>"
899     "      </row>"
900     "      <row>"
901     "        <col id=\"0\" translatable=\"yes\">Rio de Janeiro, RJ Brazil</col>"
902     "        <col id=\"1\" translatable=\"yes\">gtk-dialog-error</col>"
903     "      </row>"
904     "      <row>"
905     "        <col id=\"0\" translatable=\"yes\">Seoul, South Korea</col>"
906     "        <col id=\"1\" translatable=\"yes\">gtk-info</col>"
907     "      </row>"
908     "    </data>"
909     "  </object>"
910     "</interface>",
911     NULL
912   },
913   
914 };
915
916
917 static void
918 test_clicked (GtkWidget     *button, 
919               TestInterface *interface)
920 {
921   if (!interface->window)
922     {
923       GtkBuilder *builder = gtk_builder_new ();
924       
925       gtk_builder_add_from_string (builder, interface->interface, -1, NULL);
926       interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");
927
928       g_signal_connect (interface->window, "delete_event", 
929                         G_CALLBACK (gtk_widget_hide_on_delete), NULL);
930     }
931
932   gtk_widget_show (interface->window);
933 }
934
935
936 static GtkWidget *
937 create_window (void)
938 {
939   GtkWidget *window, *vbox, *button;
940   gint i;
941
942   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
943   vbox   = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
944
945   gtk_container_set_border_width (GTK_CONTAINER (window), 8);
946
947   gtk_widget_show (vbox);
948   gtk_container_add (GTK_CONTAINER (window), vbox);
949
950   for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
951     {
952       button = gtk_button_new_with_label (interfaces[i].name);
953
954       gtk_widget_set_tooltip_text (button, interfaces[i].tooltip);
955
956       g_signal_connect (G_OBJECT (button), "clicked", 
957                         G_CALLBACK (test_clicked), &interfaces[i]);
958
959       gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
960       gtk_widget_show (button);
961     }
962
963   return window;
964 }
965
966
967
968 int
969 main (int argc, char *argv[])
970 {
971   GtkWidget *window;
972
973   gtk_init (&argc, &argv);
974
975   window = create_window ();
976
977   g_signal_connect (window, "delete-event",
978                     G_CALLBACK (gtk_main_quit), window);
979
980   gtk_widget_show (window);
981
982   gtk_main ();
983
984   return 0;
985 }