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
23typedef struct {
24 const char *name;
25 const char *tooltip;
26 const char *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 */
35static 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=\"3.99\"/>"
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=\"GtkBox\" id=\"hbox5\">"
47 " <property name=\"orientation\">horizontal</property>"
48 " <child>"
49 " <object class=\"GtkLabel\" id=\"label9\">"
50 " <property name=\"label\" translatable=\"yes\">Some labels do ellipsize</property>"
51 " <property name=\"ellipsize\">end</property>"
52 " <attributes>"
53 " <attribute name=\"weight\" value=\"bold\"/>"
54 " <attribute name=\"foreground\" value=\"#09610feefe03\"/>"
55 " </attributes>"
56 " </object>"
57 " </child>"
58 " <child>"
59 " <object class=\"GtkLabel\" id=\"label10\">"
60 " <property name=\"label\" translatable=\"yes\">but some</property>"
61 " <property name=\"ellipsize\">end</property>"
62 " <attributes>"
63 " <attribute name=\"weight\" value=\"bold\"/>"
64 " <attribute name=\"foreground\" value=\"#0000af6b0993\"/>"
65 " </attributes>"
66 " </object>"
67 " </child>"
68 " <child>"
69 " <object class=\"GtkLabel\" id=\"label11\">"
70 " <property name=\"label\" translatable=\"yes\">do not at all</property>"
71 " <attributes>"
72 " <attribute name=\"style\" value=\"normal\"/>"
73 " <attribute name=\"weight\" value=\"bold\"/>"
74 " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
75 " </attributes>"
76 " </object>"
77 " </child>"
78 " </object>"
79 " </child>"
80 " </object>"
81 "</interface>",
82 NULL
83 },
84
85 {
86 "Wrapping Label",
87 "Demonstrates how a wrapping label can require a height contextual to its allocated width",
88 "<interface>"
89 " <requires lib=\"gtk\" version=\"3.99\"/>"
90 " <!-- interface-naming-policy project-wide -->"
91 " <object class=\"GtkWindow\" id=\"window\">"
92 " <property name=\"default_width\">300</property>"
93 " <child>"
94 " <object class=\"GtkPaned\" id=\"hpaned1\">"
95 " <property name=\"orientation\">horizontal</property>"
96 " <property name=\"can_focus\">True</property>"
97 " <property name=\"resize-child1\">False</property>"
98 " <property name=\"shrink-child1\">False</property>"
99 " <child>"
100 " <object class=\"GtkBox\" id=\"vbox2\">"
101 " <property name=\"orientation\">vertical</property>"
102 " <child>"
103 " <object class=\"GtkLabel\" id=\"label3\">"
104 " <property name=\"label\" translatable=\"yes\">A short static label.</property>"
105 " <attributes>"
106 " <attribute name=\"weight\" value=\"bold\"/>"
107 " </attributes>"
108 " </object>"
109 " </child>"
110 " <child>"
111 " <object class=\"GtkFrame\" id=\"frame1\">"
112 " <property name=\"label\">Long label</property>"
113 " <child>"
114 " <object class=\"GtkLabel\" id=\"label1\">"
115 " <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>"
116 " <property name=\"wrap\">True</property>"
117 " <property name=\"max_width_chars\">30</property>"
118 " <attributes>"
119 " <attribute name=\"foreground\" value=\"#18c52119f796\"/>"
120 " </attributes>"
121 " </object>"
122 " </child>"
123 " </object>"
124 " </child>"
125 " <child>"
126 " <object class=\"GtkButton\" id=\"button2\">"
127 " <property name=\"can_focus\">True</property>"
128 " <property name=\"receives_default\">True</property>"
129 " <child>"
130 " <object class=\"GtkLabel\" id=\"label2\">"
131 " <property name=\"label\" translatable=\"yes\">A really really long label inside a button to demonstrate height for width working inside buttons</property>"
132 " <property name=\"wrap\">True</property>"
133 " <property name=\"max_width_chars\">25</property>"
134 " <attributes>"
135 " <attribute name=\"foreground\" value=\"#1e3687ab0a52\"/>"
136 " </attributes>"
137 " </object>"
138 " </child>"
139 " </object>"
140 " </child>"
141 " </object>"
142 " </child>"
143 " <child>"
144 " <object class=\"GtkLabel\" id=\"label4\">"
145 " <property name=\"label\" translatable=\"yes\">This static label\n"
146 "can shrink.</property>"
147 " <property name=\"justify\">center</property>"
148 " <attributes>"
149 " <attribute name=\"style\" value=\"normal\"/>"
150 " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
151 " </attributes>"
152 " </object>"
153 " </child>"
154 " </object>"
155 " </child>"
156 " </object>"
157 "</interface>",
158 NULL
159 },
160
161 {
162 "Horizontal Box",
163 "Demonstrates how a horizontal box can calculate the collective height for an allocated width",
164 "<interface>"
165 " <requires lib=\"gtk\" version=\"3.99\"/>"
166 " <!-- interface-naming-policy project-wide -->"
167 " <object class=\"GtkWindow\" id=\"window\">"
168 " <property name=\"default_height\">200</property>"
169 " <property name=\"default_width\">600</property>"
170 " <child>"
171 " <object class=\"GtkPaned\" id=\"hpaned1\">"
172 " <property name=\"orientation\">horizontal</property>"
173 " <property name=\"can_focus\">True</property>"
174 " <property name=\"resize-child1\">False</property>"
175 " <property name=\"shrink-child1\">False</property>"
176 " <child>"
177 " <object class=\"GtkBox\" id=\"vbox1\">"
178 " <property name=\"orientation\">vertical</property>"
179 " <child>"
180 " <object class=\"GtkBox\" id=\"hbox1\">"
181 " <property name=\"orientation\">horizontal</property>"
182 " <child>"
183 " <object class=\"GtkButton\" id=\"button1\">"
184 " <property name=\"can_focus\">True</property>"
185 " <property name=\"receives_default\">True</property>"
186 " <child>"
187 " <object class=\"GtkLabel\" id=\"label2\">"
188 " <property name=\"label\" translatable=\"yes\">A button that wraps.</property>"
189 " <property name=\"wrap\">True</property>"
190 " <property name=\"width_chars\">10</property>"
191 " <attributes>"
192 " <attribute name=\"foreground\" value=\"#0000041dffff\"/>"
193 " </attributes>"
194 " </object>"
195 " </child>"
196 " </object>"
197 " </child>"
198 " <child>"
199 " <object class=\"GtkLabel\" id=\"label1\">"
200 " <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>"
201 " <property name=\"wrap\">True</property>"
202 " <property name=\"width_chars\">30</property>"
203 " <attributes>"
204 " <attribute name=\"foreground\" value=\"#07d0a9b20972\"/>"
205 " </attributes>"
206 " </object>"
207 " </child>"
208 " </object>"
209 " </child>"
210 " <child>"
211 " <object class=\"GtkButton\" id=\"button2\">"
212 " <property name=\"label\" translatable=\"yes\">A button that expands in the vbox</property>"
213 " <property name=\"can_focus\">True</property>"
214 " <property name=\"receives_default\">True</property>"
215 " </object>"
216 " </child>"
217 " </object>"
218 " </child>"
219 " <child>"
220 " <object class=\"GtkLabel\" id=\"label4\">"
221 " <property name=\"label\" translatable=\"yes\">This label is\n"
222 "set to shrink inside\n"
223 "the paned window.</property>"
224 " <property name=\"justify\">center</property>"
225 " <attributes>"
226 " <attribute name=\"style\" value=\"normal\"/>"
227 " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
228 " </attributes>"
229 " </object>"
230 " </child>"
231 " </object>"
232 " </child>"
233 " </object>"
234 "</interface>",
235 NULL
236 },
237
238 {
239 "Label Parameters",
240 "This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
241 "to effect minimum and natural widths in wrapping labels.",
242 "<interface>"
243 " <requires lib=\"gtk\" version=\"3.99\"/>"
244 " <!-- interface-naming-policy project-wide -->"
245 " <object class=\"GtkWindow\" id=\"window\">"
246 " <property name=\"default_width\">900</property>"
247 " <child>"
248 " <object class=\"GtkPaned\" id=\"hpaned1\">"
249 " <property name=\"orientation\">horizontal</property>"
250 " <property name=\"can_focus\">True</property>"
251 " <property name=\"resize-child1\">False</property>"
252 " <property name=\"shrink-child1\">False</property>"
253 " <child>"
254 " <object class=\"GtkBox\" id=\"vbox1\">"
255 " <property name=\"orientation\">vertical</property>"
256 " <child>"
257 " <object class=\"GtkBox\" id=\"hbox1\">"
258 " <property name=\"orientation\">horizontal</property>"
259 " <property name=\"spacing\">6</property>"
260 " <child>"
261 " <object class=\"GtkLabel\" id=\"label1\">"
262 " <property name=\"label\" translatable=\"yes\">The first 2 labels require 10 characters.</property>"
263 " <property name=\"wrap\">True</property>"
264 " <property name=\"width_chars\">10</property>"
265 " <attributes>"
266 " <attribute name=\"weight\" value=\"bold\"/>"
267 " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
268 " </attributes>"
269 " </object>"
270 " </child>"
271 " <child>"
272 " <object class=\"GtkLabel\" id=\"label2\">"
273 " <property name=\"label\" translatable=\"yes\">This label has a maximum natural width of 20 characters. The second two labels expand.</property>"
274 " <property name=\"wrap\">True</property>"
275 " <property name=\"width_chars\">10</property>"
276 " <property name=\"max_width_chars\">20</property>"
277 " <attributes>"
278 " <attribute name=\"weight\" value=\"bold\"/>"
279 " <attribute name=\"foreground\" value=\"#05c2a161134b\"/>"
280 " </attributes>"
281 " </object>"
282 " </child>"
283 " <child>"
284 " <object class=\"GtkLabel\" id=\"label3\">"
285 " <property name=\"label\" translatable=\"yes\">This label requires a default minimum size.</property>"
286 " <property name=\"wrap\">True</property>"
287 " <attributes>"
288 " <attribute name=\"weight\" value=\"bold\"/>"
289 " <attribute name=\"foreground\" value=\"#03e30758fb5f\"/>"
290 " </attributes>"
291 " </object>"
292 " </child>"
293 " </object>"
294 " </child>"
295 " <child>"
296 " <object class=\"GtkLabel\" id=\"label4\">"
297 " <property name=\"label\" translatable=\"yes\">This test demonstrates how the \"width-chars\" and \"max-width-chars\"\n"
298 "properties can be used to specify the minimum requested wrap width\n"
299 "and the maximum natural wrap width respectively.</property>"
300 " <property name=\"ellipsize\">end</property>"
301 " <property name=\"width_chars\">30</property>"
302 " <attributes>"
303 " <attribute name=\"style\" value=\"normal\"/>"
304 " <attribute name=\"foreground\" value=\"#05470000abaf\"/>"
305 " </attributes>"
306 " </object>"
307 " </child>"
308 " </object>"
309 " </child>"
310 " <child>"
311 " <object class=\"GtkLabel\" id=\"label5\">"
312 " <property name=\"label\" translatable=\"yes\">Some static\n"
313 "text that shrinks.\n"
314 "\n"
315 "You will need to stretch\n"
316 "this window quite wide\n"
317 "to see the effects.</property>"
318 " <property name=\"justify\">center</property>"
319 " <attributes>"
320 " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
321 " </attributes>"
322 " </object>"
323 " </child>"
324 " </object>"
325 " </child>"
326 " </object>"
327 "</interface>",
328 NULL
329 },
330
331 {
332 "Wrapping Expander",
333 "This test demonstrates how the expander label can fill to its natural width "
334 "and also trade height for width.",
335 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
336 "<interface>"
337 " <requires lib=\"gtk\" version=\"3.99\"/>"
338 " <!-- interface-naming-policy project-wide -->"
339 " <object class=\"GtkWindow\" id=\"window\">"
340 " <property name=\"default_width\">500</property>"
341 " <child>"
342 " <object class=\"GtkPaned\" id=\"hpaned1\">"
343 " <property name=\"orientation\">horizontal</property>"
344 " <property name=\"can_focus\">True</property>"
345 " <property name=\"resize-child1\">False</property>"
346 " <property name=\"shrink-child1\">False</property>"
347 " <child>"
348 " <object class=\"GtkExpander\" id=\"expander1\">"
349 " <property name=\"can_focus\">True</property>"
350 " <child>"
351 " <object class=\"GtkLabel\" id=\"label2\">"
352 " <property name=\"label\" translatable=\"yes\">More wrapping text to fill the largish content area in the expander </property>"
353 " <property name=\"wrap\">True</property>"
354 " <property name=\"width_chars\">10</property>"
355 " <attributes>"
356 " <attribute name=\"weight\" value=\"bold\"/>"
357 " <attribute name=\"foreground\" value=\"#0000D0F00000\"/>"
358 " </attributes>"
359 " </object>"
360 " </child>"
361 " <child type=\"label\">"
362 " <object class=\"GtkLabel\" id=\"label1\">"
363 " <property name=\"label\" translatable=\"yes\">Here is some expander text that wraps</property>"
364 " <property name=\"wrap\">True</property>"
365 " <property name=\"width_chars\">10</property>"
366 " <attributes>"
367 " <attribute name=\"weight\" value=\"bold\"/>"
368 " <attribute name=\"foreground\" value=\"blue\"/>"
369 " </attributes>"
370 " </object>"
371 " </child>"
372 " </object>"
373 " </child>"
374 " <child>"
375 " <object class=\"GtkLabel\" id=\"label3\">"
376 " <property name=\"label\" translatable=\"yes\">static\n"
377 "text\n"
378 "here</property>"
379 " <attributes>"
380 " <attribute name=\"foreground\" value=\"red\"/>"
381 " </attributes>"
382 " </object>"
383 " </child>"
384 " </object>"
385 " </child>"
386 " </object>"
387 "</interface>",
388 NULL
389 },
390
391 {
392 "Wrapping Frame Label",
393 "This test demonstrates how the frame label can fill to its natural width "
394 "and also trade height for width.",
395 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
396 "<interface>"
397 " <requires lib=\"gtk\" version=\"3.99\"/>"
398 " <!-- interface-naming-policy project-wide -->"
399 " <object class=\"GtkWindow\" id=\"window\">"
400 " <property name=\"default_width\">400</property>"
401 " <property name=\"default_height\">150</property>"
402 " <child>"
403 " <object class=\"GtkFrame\" id=\"frame1\">"
404 " <property name=\"label_xalign\">0</property>"
405 " <child>"
406 " <object class=\"GtkLabel\" id=\"label2\">"
407 " <property name=\"margin_start\">12</property>"
408 " <property name=\"label\" translatable=\"yes\">some content</property>"
409 " </object>"
410 " </child>"
411 " <child type=\"label\">"
412 " <object class=\"GtkLabel\" id=\"label1\">"
413 " <property name=\"label\" translatable=\"yes\">A frame label that's a little long and wraps</property>"
414 " <property name=\"use_markup\">True</property>"
415 " <property name=\"wrap\">True</property>"
416 " </object>"
417 " </child>"
418 " </object>"
419 " </child>"
420 " </object>"
421 "</interface>",
422 NULL
423 },
424
425 {
426 "Combo Boxes and Menus",
427 "This test shows wrapping and ellipsizing text in combo boxes (and consequently in menu items).",
428 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
429 "<interface>"
430 " <requires lib=\"gtk\" version=\"3.99\"/>"
431 " <!-- interface-naming-policy project-wide -->"
432 " <object class=\"GtkWindow\" id=\"window\">"
433 " <property name=\"default_width\">600</property>"
434 " <child>"
435 " <object class=\"GtkPaned\" id=\"hpaned1\">"
436 " <property name=\"orientation\">horizontal</property>"
437 " <property name=\"can_focus\">True</property>"
438 " <property name=\"shrink-child1\">False</property>"
439 " <property name=\"resize-child2\">False</property>"
440 " <child>"
441 " <object class=\"GtkBox\" id=\"vbox1\">"
442 " <property name=\"orientation\">vertical</property>"
443 " <property name=\"spacing\">5</property>"
444 " <child>"
445 " <object class=\"GtkBox\" id=\"hbox1\">"
446 " <property name=\"orientation\">horizontal</property>"
447 " <property name=\"spacing\">5</property>"
448 " <child>"
449 " <object class=\"GtkLabel\" id=\"label1\">"
450 " <property name=\"label\" translatable=\"yes\">this combo box</property>"
451 " <attributes>"
452 " <attribute name=\"weight\" value=\"bold\"/>"
453 " <attribute name=\"foreground\" value=\"#b3460000eb1c\"/>"
454 " </attributes>"
455 " </object>"
456 " </child>"
457 " <child>"
458 " <object class=\"GtkLabel\" id=\"label2\">"
459 " <property name=\"label\" translatable=\"yes\">contains some wrapping locations</property>"
460 " <property name=\"ellipsize\">end</property>"
461 " <property name=\"width_chars\">10</property>"
462 " <attributes>"
463 " <attribute name=\"weight\" value=\"bold\"/>"
464 " <attribute name=\"foreground\" value=\"#b3460000eb1c\"/>"
465 " </attributes>"
466 " </object>"
467 " </child>"
468 " <child>"
469 " <object class=\"GtkComboBox\" id=\"combobox1\">"
470 " <property name=\"model\">liststore1</property>"
471 " <property name=\"active\">0</property>"
472 " <child>"
473 " <object class=\"GtkCellRendererPixbuf\" id=\"cellrenderertext1\"/>"
474 " <attributes>"
475 " <attribute name=\"icon-name\">1</attribute>"
476 " </attributes>"
477 " </child>"
478 " <child>"
479 " <object class=\"GtkCellRendererText\" id=\"cellrenderertext2\">"
480 " <property name=\"foreground\">purple</property>"
481 " <property name=\"weight\">600</property>"
482 " <property name=\"wrap_mode\">word</property>"
483 " <property name=\"wrap_width\">100</property>"
484 " </object>"
485 " <attributes>"
486 " <attribute name=\"text\">0</attribute>"
487 " </attributes>"
488 " </child>"
489 " </object>"
490 " </child>"
491 " </object>"
492 " </child>"
493 " <child>"
494 " <object class=\"GtkFrame\" id=\"frame1\">"
495 " <property name=\"label_xalign\">0</property>"
496 " <child>"
497 " <object class=\"GtkLabel\" id=\"label3\">"
498 " <property name=\"label\" translatable=\"yes\">This test shows combo boxes\n"
499 "requesting and allocating space\n"
500 "for its backing content using\n"
501 "height-for-width geometry\n"
502 "management.\n"
503 "\n"
504 "Note this test also demonstrates\n"
505 "height-for-width menu items.</property>"
506 " <property name=\"justify\">center</property>"
507 " <attributes>"
508 " <attribute name=\"weight\" value=\"bold\"/>"
509 " <attribute name=\"foreground\" value=\"#00000000ffff\"/>"
510 " </attributes>"
511 " </object>"
512 " </child>"
513 " </object>"
514 " </child>"
515 " <child>"
516 " <object class=\"GtkBox\" id=\"hbox2\">"
517 " <property name=\"orientation\">horizontal</property>"
518 " <property name=\"spacing\">5</property>"
519 " <child>"
520 " <object class=\"GtkLabel\" id=\"label4\">"
521 " <property name=\"label\" translatable=\"yes\">this combo box</property>"
522 " <attributes>"
523 " <attribute name=\"weight\" value=\"bold\"/>"
524 " <attribute name=\"foreground\" value=\"#ffffa5a50000\"/>"
525 " </attributes>"
526 " </object>"
527 " </child>"
528 " <child>"
529 " <object class=\"GtkLabel\" id=\"label5\">"
530 " <property name=\"label\" translatable=\"yes\">contains some ellipsizing locations</property>"
531 " <property name=\"ellipsize\">end</property>"
532 " <property name=\"width_chars\">10</property>"
533 " <attributes>"
534 " <attribute name=\"weight\" value=\"bold\"/>"
535 " <attribute name=\"foreground\" value=\"#ffffa5a50000\"/>"
536 " </attributes>"
537 " </object>"
538 " </child>"
539 " <child>"
540 " <object class=\"GtkComboBox\" id=\"combobox2\">"
541 " <property name=\"model\">liststore1</property>"
542 " <property name=\"active\">0</property>"
543 " <child>"
544 " <object class=\"GtkCellRendererPixbuf\" id=\"cellrenderertext3\"/>"
545 " <attributes>"
546 " <attribute name=\"icon-name\">1</attribute>"
547 " </attributes>"
548 " </child>"
549 " <child>"
550 " <object class=\"GtkCellRendererText\" id=\"cellrenderertext4\">"
551 " <property name=\"ellipsize\">end</property>"
552 " <property name=\"foreground\">orange</property>"
553 " <property name=\"weight\">600</property>"
554 " <property name=\"width_chars\">10</property>"
555 " </object>"
556 " <attributes>"
557 " <attribute name=\"text\">0</attribute>"
558 " </attributes>"
559 " </child>"
560 " </object>"
561 " </child>"
562 " </object>"
563 " </child>"
564 " </object>"
565 " </child>"
566 " <child>"
567 " <object class=\"GtkLabel\" id=\"label6\">"
568 " <property name=\"label\" translatable=\"yes\">Some static\n"
569 "text here\n"
570 "that shrinks.</property>"
571 " <property name=\"justify\">center</property>"
572 " <attributes>"
573 " <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
574 " </attributes>"
575 " </object>"
576 " </child>"
577 " </object>"
578 " </child>"
579 " </object>"
580 " <object class=\"GtkListStore\" id=\"liststore1\">"
581 " <columns>"
582 " <!-- column-name item-text -->"
583 " <column type=\"gchararray\"/>"
584 " <!-- column-name icon-name -->"
585 " <column type=\"gchararray\"/>"
586 " </columns>"
587 " <data>"
588 " <row>"
589 " <col id=\"0\" translatable=\"yes\">Montreal, Quebec Canada</col>"
590 " <col id=\"1\" translatable=\"yes\">edit-undo</col>"
591 " </row>"
592 " <row>"
593 " <col id=\"0\" translatable=\"yes\">Sao Paulo, SP Brazil</col>"
594 " <col id=\"1\" translatable=\"yes\">edit-redo</col>"
595 " </row>"
596 " <row>"
597 " <col id=\"0\" translatable=\"yes\">Buenos Aires, Argentina</col>"
598 " <col id=\"1\" translatable=\"yes\">process-stop</col>"
599 " </row>"
600 " <row>"
601 " <col id=\"0\" translatable=\"yes\">Los Angelos, California USA</col>"
602 " <col id=\"1\" translatable=\"yes\">media-record</col>"
603 " </row>"
604 " <row>"
605 " <col id=\"0\" translatable=\"yes\">Rio de Janeiro, RJ Brazil</col>"
606 " <col id=\"1\" translatable=\"yes\">dialog-error</col>"
607 " </row>"
608 " <row>"
609 " <col id=\"0\" translatable=\"yes\">Seoul, South Korea</col>"
610 " <col id=\"1\" translatable=\"yes\">dialog-information</col>"
611 " </row>"
612 " </data>"
613 " </object>"
614 "</interface>",
615 NULL
616 },
617
618};
619
620
621static void
622test_clicked (GtkWidget *button,
623 TestInterface *interface)
624{
625 if (!interface->window)
626 {
627 GtkBuilder *builder = gtk_builder_new ();
628 GError *error = NULL;
629
630 gtk_builder_add_from_string (builder, buffer: interface->interface, length: -1, error: &error);
631
632 if (error)
633 {
634 g_printerr (format: "GtkBuilder for interface \"%s\" returned error \"%s\"\n",
635 interface->name, error->message);
636
637 g_error_free (error);
638 g_object_unref (object: builder);
639
640 return;
641 }
642
643 interface->window = (GtkWidget *)gtk_builder_get_object (builder, name: "window");
644
645 gtk_window_set_hide_on_close (GTK_WINDOW (interface->window), TRUE);
646
647 g_object_unref (object: builder);
648 }
649
650 gtk_widget_show (widget: interface->window);
651}
652
653
654static GtkWidget *
655create_window (void)
656{
657 GtkWidget *window, *vbox, *button;
658 int i;
659
660 window = gtk_window_new ();
661 vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 6);
662
663 gtk_widget_set_margin_start (widget: vbox, margin: 8);
664 gtk_widget_set_margin_end (widget: vbox, margin: 8);
665 gtk_widget_set_margin_top (widget: vbox, margin: 8);
666 gtk_widget_set_margin_bottom (widget: vbox, margin: 8);
667
668 gtk_window_set_child (GTK_WINDOW (window), child: vbox);
669
670 for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
671 {
672 button = gtk_button_new_with_label (label: interfaces[i].name);
673
674 gtk_widget_set_tooltip_text (widget: button, text: interfaces[i].tooltip);
675
676 g_signal_connect (button, "clicked",
677 G_CALLBACK (test_clicked), &interfaces[i]);
678
679 gtk_box_append (GTK_BOX (vbox), child: button);
680 }
681
682 return window;
683}
684
685static void
686quit_cb (GtkWidget *widget,
687 gpointer data)
688{
689 gboolean *done = data;
690
691 *done = TRUE;
692
693 g_main_context_wakeup (NULL);
694}
695
696int
697main (int argc, char *argv[])
698{
699 GtkWidget *window;
700 gboolean done = FALSE;
701
702 gtk_init ();
703
704 window = create_window ();
705
706 g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
707
708 gtk_widget_show (widget: window);
709
710 while (!done)
711 g_main_context_iteration (NULL, TRUE);
712
713 return 0;
714}
715

source code of gtk/tests/testheightforwidth.c