testheightforwidth.c 43.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* extendedlayoutexample.c
 * Copyright (C) 2010 Openismus GmbH
 *
 * Author:
 *      Tristan Van Berkom <tristan.van.berkom@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
Javier Jardón's avatar
Javier Jardón committed
18
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
 */

#include <gtk/gtk.h>

typedef struct {
  const gchar *name;
  const gchar *tooltip;
  const gchar *interface;
  GtkWidget   *window;
} TestInterface;


/* These strings were generated with:
 *
 *     IFS=""; while read line; do echo -n \"; echo -n $line | sed -e 's|\"|\\"|g'; echo \"; done < file.glade
 */
TestInterface interfaces[] = {
  {
    "Ellipsizing Labels",
    "Demonstrates how labels will request a natural size in a horizontal space",
    "<interface>"
    "  <requires lib=\"gtk+\" version=\"2.20\"/>"
    "  <!-- interface-naming-policy project-wide -->"
    "  <object class=\"GtkWindow\" id=\"window\">"
    "    <property name=\"default_width\">450</property>"
    "    <property name=\"default_height\">50</property>"
    "    <child>"
    "      <object class=\"GtkHBox\" id=\"hbox5\">"
    "        <property name=\"visible\">True</property>"
    "        <child>"
    "          <object class=\"GtkLabel\" id=\"label9\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">Some labels do ellipsize</property>"
    "            <property name=\"ellipsize\">end</property>"
    "            <attributes>"
    "              <attribute name=\"weight\" value=\"bold\"/>"
    "              <attribute name=\"foreground\" value=\"#09610feefe03\"/>"
    "            </attributes>"
    "          </object>"
    "          <packing>"
    "            <property name=\"position\">0</property>"
    "          </packing>"
    "        </child>"
    "        <child>"
    "          <object class=\"GtkLabel\" id=\"label10\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">but some</property>"
    "            <property name=\"ellipsize\">end</property>"
    "            <attributes>"
    "              <attribute name=\"weight\" value=\"bold\"/>"
    "              <attribute name=\"foreground\" value=\"#0000af6b0993\"/>"
    "            </attributes>"
    "          </object>"
    "          <packing>"
    "            <property name=\"position\">1</property>"
    "          </packing>"
    "        </child>"
    "        <child>"
    "          <object class=\"GtkLabel\" id=\"label11\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">do not at all</property>"
    "            <attributes>"
    "              <attribute name=\"style\" value=\"normal\"/>"
    "              <attribute name=\"weight\" value=\"bold\"/>"
    "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
    "            </attributes>"
    "          </object>"
    "          <packing>"
    "            <property name=\"position\">2</property>"
    "          </packing>"
    "        </child>"
    "      </object>"
    "    </child>"
    "  </object>"
    "</interface>",
    NULL
  },

  {
    "Wrapping Label",
    "Demonstrates how a wrapping label can require a height contextual to its allocated width",
    "<interface>"
    "  <requires lib=\"gtk+\" version=\"2.18\"/>"
    "  <!-- interface-naming-policy project-wide -->"
    "  <object class=\"GtkWindow\" id=\"window\">"
    "    <property name=\"border_width\">12</property>"
    "    <property name=\"default_width\">300</property>"
    "    <child>"
    "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
    "        <property name=\"visible\">True</property>"
    "        <property name=\"can_focus\">True</property>"
    "        <child>"
    "          <object class=\"GtkVBox\" id=\"vbox2\">"
    "            <property name=\"visible\">True</property>"
    "            <child>"
    "              <object class=\"GtkLabel\" id=\"label3\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label\" translatable=\"yes\">A short static label.</property>"
    "                <attributes>"
    "                  <attribute name=\"weight\" value=\"bold\"/>"
    "                </attributes>"
    "              </object>"
    "              <packing>"
    "                <property name=\"position\">0</property>"
    "              </packing>"
    "            </child>"
    "            <child>"
    "              <object class=\"GtkFrame\" id=\"frame1\">"
    "                <property name=\"label\">Long label</property>"
    "                <property name=\"visible\">True</property>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label1\">"
    "                    <property name=\"visible\">True</property>"
    "                    <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>"
    "                    <property name=\"wrap\">True</property>"
    "                    <property name=\"max_width_chars\">30</property>"
    "                    <attributes>"
    "                      <attribute name=\"foreground\" value=\"#18c52119f796\"/>"
    "                    </attributes>"
    "                  </object>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"expand\">False</property>"
    "                <property name=\"position\">1</property>"
    "              </packing>"
    "            </child>"
    "            <child>"
    "              <object class=\"GtkButton\" id=\"button2\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"can_focus\">True</property>"
    "                <property name=\"receives_default\">True</property>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label2\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">A really really long label inside a button to demonstrate height for width working inside buttons</property>"
    "                    <property name=\"wrap\">True</property>"
    "                    <property name=\"max_width_chars\">25</property>"
    "                    <attributes>"
    "                      <attribute name=\"foreground\" value=\"#1e3687ab0a52\"/>"
    "                    </attributes>"
    "                  </object>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"expand\">False</property>"
    "                <property name=\"position\">2</property>"
    "              </packing>"
    "            </child>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">False</property>"
    "            <property name=\"shrink\">False</property>"
    "          </packing>"
    "        </child>"
    "        <child>"
    "          <object class=\"GtkLabel\" id=\"label4\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">This static label\n"
    "can shrink.</property>"
    "            <property name=\"justify\">center</property>"
    "            <attributes>"
    "              <attribute name=\"style\" value=\"normal\"/>"
    "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
    "            </attributes>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">True</property>"
    "            <property name=\"shrink\">True</property>"
    "          </packing>"
    "        </child>"
    "      </object>"
    "    </child>"
    "  </object>"
    "</interface>",
    NULL
  },

  {
    "Horizontal Box",
    "Demonstrates how a horizontal box can calculate the collective height for an allocated width",
    "<interface>"
    "  <requires lib=\"gtk+\" version=\"2.20\"/>"
    "  <!-- interface-naming-policy project-wide -->"
    "  <object class=\"GtkWindow\" id=\"window\">"
    "    <property name=\"default_height\">200</property>"
    "    <property name=\"default_width\">600</property>"
    "    <child>"
    "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
    "        <property name=\"visible\">True</property>"
    "        <property name=\"can_focus\">True</property>"
    "        <child>"
    "          <object class=\"GtkVBox\" id=\"vbox1\">"
    "            <property name=\"visible\">True</property>"
    "            <child>"
    "              <object class=\"GtkHBox\" id=\"hbox1\">"
    "                <property name=\"visible\">True</property>"
    "                <child>"
    "                  <object class=\"GtkButton\" id=\"button1\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"can_focus\">True</property>"
    "                    <property name=\"receives_default\">True</property>"
    "                    <property name=\"use_action_appearance\">False</property>"
    "                    <child>"
    "                      <object class=\"GtkLabel\" id=\"label2\">"
    "                        <property name=\"visible\">True</property>"
    "                        <property name=\"label\" translatable=\"yes\">A button that wraps.</property>"
    "                        <property name=\"wrap\">True</property>"
    "                        <property name=\"width_chars\">10</property>"
    "                        <attributes>"
    "                          <attribute name=\"foreground\" value=\"#0000041dffff\"/>"
    "                        </attributes>"
    "                      </object>"
    "                    </child>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">False</property>"
    "                    <property name=\"position\">0</property>"
    "                  </packing>"
    "                </child>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label1\">"
    "                    <property name=\"visible\">True</property>"
    "                    <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>"
    "                    <property name=\"wrap\">True</property>"
    "                    <property name=\"width_chars\">30</property>"
    "                    <attributes>"
    "                      <attribute name=\"foreground\" value=\"#07d0a9b20972\"/>"
    "                    </attributes>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"position\">1</property>"
    "                  </packing>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"expand\">False</property>"
    "                <property name=\"position\">0</property>"
    "              </packing>"
    "            </child>"
    "            <child>"
    "              <object class=\"GtkButton\" id=\"button2\">"
    "                <property name=\"label\" translatable=\"yes\">A button that expands in the vbox</property>"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"can_focus\">True</property>"
    "                <property name=\"receives_default\">True</property>"
    "                <property name=\"use_action_appearance\">False</property>"
    "              </object>"
    "              <packing>"
    "                <property name=\"position\">1</property>"
    "              </packing>"
    "            </child>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">False</property>"
    "            <property name=\"shrink\">False</property>"
    "          </packing>"
    "        </child>"
    "        <child>"
    "          <object class=\"GtkLabel\" id=\"label4\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">This label is\n"
    "set to shrink inside\n"
    "the paned window.</property>"
    "            <property name=\"justify\">center</property>"
    "            <attributes>"
    "              <attribute name=\"style\" value=\"normal\"/>"
    "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
    "            </attributes>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">True</property>"
    "            <property name=\"shrink\">True</property>"
    "          </packing>"
    "        </child>"
    "      </object>"
    "    </child>"
    "  </object>"
    "</interface>",
    NULL
  },

  {
    "Vertical Labels",
    "Demonstrates how a horizontal box will consider width-for-height when allocating children "
    "even if the toplevel window is requested as height-for-width.",
    "<interface>"
    "  <requires lib=\"gtk+\" version=\"2.20\"/>"
    "  <!-- interface-naming-policy project-wide -->"
    "  <object class=\"GtkWindow\" id=\"window\">"
    "    <property name=\"default_width\">400</property>"
    "    <property name=\"default_height\">300</property>"
    "    <child>"
    "      <object class=\"GtkVPaned\" id=\"vpaned1\">"
    "        <property name=\"visible\">True</property>"
    "        <property name=\"can_focus\">True</property>"
    "        <child>"
    "          <object class=\"GtkHBox\" id=\"hbox1\">"
    "            <property name=\"visible\">True</property>"
    "            <child>"
    "              <object class=\"GtkLabel\" id=\"label1\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
    "                <property name=\"justify\">center</property>"
    "                <property name=\"wrap\">True</property>"
    "                <property name=\"width_chars\">10</property>"
    "                <property name=\"angle\">90</property>"
    "                <attributes>"
    "                  <attribute name=\"weight\" value=\"bold\"/>"
    "                  <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
    "                </attributes>"
    "              </object>"
    "              <packing>"
    "                <property name=\"expand\">False</property>"
    "                <property name=\"position\">0</property>"
    "              </packing>"
    "            </child>"
    "            <child>"
    "              <object class=\"GtkFrame\" id=\"frame1\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label_xalign\">0</property>"
    "                <property name=\"shadow_type\">out</property>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label5\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">Neither of the panes are\n"
    "set to shrink.</property>"
    "                    <property name=\"justify\">center</property>"
    "                    <attributes>"
    "                      <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
    "                    </attributes>"
    "                  </object>"
    "                </child>"
    "                <child type=\"label_item\">"
    "                  <placeholder/>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"position\">1</property>"
    "              </packing>"
    "            </child>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">False</property>"
    "            <property name=\"shrink\">False</property>"
    "          </packing>"
    "        </child>"
    "        <child>"
    "          <object class=\"GtkHBox\" id=\"hbox2\">"
    "            <property name=\"visible\">True</property>"
    "            <child>"
    "              <object class=\"GtkFrame\" id=\"frame2\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label_xalign\">0</property>"
    "                <property name=\"shadow_type\">out</property>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label4\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">The interface is allocated as height\n"
    "for width, but the horizontal boxes\n"
    "allocate in width for height mode.</property>"
    "                    <attributes>"
    "                      <attribute name=\"foreground\" value=\"#000097970808\"/>"
    "                    </attributes>"
    "                  </object>"
    "                </child>"
    "                <child type=\"label_item\">"
    "                  <placeholder/>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"position\">0</property>"
    "              </packing>"
    "            </child>"
    "            <child>"
    "              <object class=\"GtkLabel\" id=\"label3\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
    "                <property name=\"justify\">center</property>"
    "                <property name=\"wrap\">True</property>"
    "                <property name=\"width_chars\">10</property>"
    "                <property name=\"angle\">270</property>"
    "                <attributes>"
    "                  <attribute name=\"weight\" value=\"bold\"/>"
    "                  <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
    "                </attributes>"
    "              </object>"
    "              <packing>"
    "                <property name=\"expand\">False</property>"
    "                <property name=\"position\">1</property>"
    "              </packing>"
    "            </child>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">False</property>"
    "            <property name=\"shrink\">False</property>"
    "          </packing>"
    "        </child>"
    "      </object>"
    "    </child>"
    "  </object>"
    "</interface>",
    NULL
  },

  {
    "Label Parameters",
    "This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
    "to effect minimum and natural widths in wrapping labels.",
    "<interface>"
    "  <requires lib=\"gtk+\" version=\"2.20\"/>"
    "  <!-- interface-naming-policy project-wide -->"
    "  <object class=\"GtkWindow\" id=\"window\">"
    "    <property name=\"default_width\">900</property>"
    "    <child>"
    "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
    "        <property name=\"visible\">True</property>"
    "        <property name=\"can_focus\">True</property>"
    "        <child>"
    "          <object class=\"GtkVBox\" id=\"vbox1\">"
    "            <property name=\"visible\">True</property>"
    "            <child>"
    "              <object class=\"GtkHBox\" id=\"hbox1\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"spacing\">6</property>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label1\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">The first 2 labels require 10 characters.</property>"
    "                    <property name=\"wrap\">True</property>"
    "                    <property name=\"width_chars\">10</property>"
    "                    <attributes>"
    "                      <attribute name=\"weight\" value=\"bold\"/>"
    "                      <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
    "                    </attributes>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">False</property>"
    "                    <property name=\"fill\">False</property>"
    "                    <property name=\"position\">0</property>"
    "                  </packing>"
    "                </child>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label2\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">This label has a maximum natural width of 20 characters. The second two labels expand.</property>"
    "                    <property name=\"wrap\">True</property>"
    "                    <property name=\"width_chars\">10</property>"
    "                    <property name=\"max_width_chars\">20</property>"
    "                    <attributes>"
    "                      <attribute name=\"weight\" value=\"bold\"/>"
    "                      <attribute name=\"foreground\" value=\"#05c2a161134b\"/>"
    "                    </attributes>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">True</property>"
    "                    <property name=\"fill\">True</property>"
    "                    <property name=\"position\">1</property>"
    "                  </packing>"
    "                </child>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label3\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">This label requires a default minimum size.</property>"
    "                    <property name=\"wrap\">True</property>"
    "                    <attributes>"
    "                      <attribute name=\"weight\" value=\"bold\"/>"
    "                      <attribute name=\"foreground\" value=\"#03e30758fb5f\"/>"
    "                    </attributes>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"position\">2</property>"
    "                  </packing>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"position\">0</property>"
    "              </packing>"
    "            </child>"
    "            <child>"
    "              <object class=\"GtkLabel\" id=\"label4\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label\" translatable=\"yes\">This test demonstrates how the \"width-chars\" and \"max-width-chars\"\n"
    "properties can be used to specify the minimum requested wrap width\n"
    "and the maximum natural wrap width respectively.</property>"
    "                <property name=\"ellipsize\">end</property>"
    "                <property name=\"width_chars\">30</property>"
    "                <attributes>"
    "                  <attribute name=\"style\" value=\"normal\"/>"
    "                  <attribute name=\"foreground\" value=\"#05470000abaf\"/>"
    "                </attributes>"
    "              </object>"
    "              <packing>"
    "                <property name=\"position\">1</property>"
    "              </packing>"
    "            </child>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">False</property>"
    "            <property name=\"shrink\">False</property>"
    "          </packing>"
    "        </child>"
    "        <child>"
    "          <object class=\"GtkLabel\" id=\"label5\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">Some static\n"
    "text that shrinks.\n"
    "\n"
    "You will need to stretch\n"
    "this window quite wide\n"
    "to see the effects.</property>"
    "            <property name=\"justify\">center</property>"
    "            <attributes>"
    "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
    "            </attributes>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">True</property>"
    "            <property name=\"shrink\">True</property>"
    "          </packing>"
    "        </child>"
    "      </object>"
    "    </child>"
    "  </object>"
    "</interface>",
    NULL
  },

547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
  {
    "Wrapping Expander",
    "This test demonstrates how the expander label can fill to its natural width "
    "and also trade height for width.",
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    "<interface>"
    "  <requires lib=\"gtk+\" version=\"2.20\"/>"
    "  <!-- interface-naming-policy project-wide -->"
    "  <object class=\"GtkWindow\" id=\"window\">"
    "    <property name=\"default_width\">500</property>"
    "    <child>"
    "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
    "        <property name=\"visible\">True</property>"
    "        <property name=\"can_focus\">True</property>"
    "        <child>"
    "          <object class=\"GtkExpander\" id=\"expander1\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"can_focus\">True</property>"
    "            <child>"
    "              <object class=\"GtkLabel\" id=\"label2\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label\" translatable=\"yes\">More wrapping text to fill the largish content area in the expander </property>"
    "                <property name=\"wrap\">True</property>"
    "                <property name=\"width_chars\">10</property>"
    "                <attributes>"
    "                  <attribute name=\"weight\" value=\"bold\"/>"
    "                  <attribute name=\"foreground\" value=\"#0000D0F00000\"/>"
    "                </attributes>"
    "              </object>"
    "            </child>"
    "            <child type=\"label\">"
    "              <object class=\"GtkLabel\" id=\"label1\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label\" translatable=\"yes\">Here is some expander text that wraps</property>"
    "                <property name=\"wrap\">True</property>"
    "                <property name=\"width_chars\">10</property>"
    "                <attributes>"
    "                  <attribute name=\"weight\" value=\"bold\"/>"
    "                  <attribute name=\"foreground\" value=\"blue\"/>"
    "                </attributes>"
    "              </object>"
    "            </child>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">False</property>"
    "            <property name=\"shrink\">False</property>"
    "          </packing>"
    "        </child>"
    "        <child>"
    "          <object class=\"GtkLabel\" id=\"label3\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">static\n"
    "text\n"
    "here</property>"
    "            <attributes>"
    "              <attribute name=\"foreground\" value=\"red\"/>"
    "            </attributes>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">True</property>"
    "            <property name=\"shrink\">True</property>"
    "          </packing>"
    "        </child>"
    "      </object>"
    "    </child>"
    "  </object>"
    "</interface>",
    NULL
  },
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658

  {
    "Wrapping Frame Label",
    "This test demonstrates how the frame label can fill to its natural width "
    "and also trade height for width.",
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    "<interface>"
    "  <requires lib=\"gtk+\" version=\"2.20\"/>"
    "  <!-- interface-naming-policy project-wide -->"
    "  <object class=\"GtkWindow\" id=\"window\">"
    "    <property name=\"default_width\">400</property>"
    "    <property name=\"default_height\">150</property>"
    "    <child>"
    "      <object class=\"GtkFrame\" id=\"frame1\">"
    "        <property name=\"visible\">True</property>"
    "        <property name=\"border_width\">8</property>"
    "        <property name=\"label_xalign\">0</property>"
    "        <child>"
    "          <object class=\"GtkAlignment\" id=\"alignment1\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"left_padding\">12</property>"
    "            <child>"
    "              <object class=\"GtkLabel\" id=\"label2\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label\" translatable=\"yes\">some content</property>"
    "              </object>"
    "            </child>"
    "          </object>"
    "        </child>"
    "        <child type=\"label\">"
    "          <object class=\"GtkLabel\" id=\"label1\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">A frame label that's a little long and wraps</property>"
    "            <property name=\"use_markup\">True</property>"
    "            <property name=\"wrap\">True</property>"
    "          </object>"
    "        </child>"
    "      </object>"
    "    </child>"
    "  </object>"
    "</interface>",
    NULL
  },
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721

  {
    "Combo Boxes and Menus",
    "This test shows wrapping and ellipsizing text in combo boxes (and consequently in menu items).",
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    "<interface>"
    "  <requires lib=\"gtk+\" version=\"2.20\"/>"
    "  <!-- interface-naming-policy project-wide -->"
    "  <object class=\"GtkWindow\" id=\"window\">"
    "    <property name=\"border_width\">8</property>"
    "    <property name=\"default_width\">600</property>"
    "    <child>"
    "      <object class=\"GtkHPaned\" id=\"hpaned1\">"
    "        <property name=\"visible\">True</property>"
    "        <property name=\"can_focus\">True</property>"
    "        <child>"
    "          <object class=\"GtkVBox\" id=\"vbox1\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"spacing\">5</property>"
    "            <child>"
    "              <object class=\"GtkHBox\" id=\"hbox1\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"spacing\">5</property>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label1\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">this combo box</property>"
    "                    <attributes>"
    "                      <attribute name=\"weight\" value=\"bold\"/>"
    "                      <attribute name=\"foreground\" value=\"#b3460000eb1c\"/>"
    "                    </attributes>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">True</property>"
    "                    <property name=\"fill\">True</property>"
    "                    <property name=\"position\">0</property>"
    "                  </packing>"
    "                </child>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label2\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">contains some wrapping locations</property>"
    "                    <property name=\"ellipsize\">end</property>"
    "                    <property name=\"width_chars\">10</property>"
    "                    <attributes>"
    "                      <attribute name=\"weight\" value=\"bold\"/>"
    "                      <attribute name=\"foreground\" value=\"#b3460000eb1c\"/>"
    "                    </attributes>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">True</property>"
    "                    <property name=\"fill\">True</property>"
    "                    <property name=\"position\">1</property>"
    "                  </packing>"
    "                </child>"
    "                <child>"
    "                  <object class=\"GtkComboBox\" id=\"combobox1\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"model\">liststore1</property>"
    "                    <property name=\"active\">0</property>"
    "                    <child>"
    "                      <object class=\"GtkCellRendererPixbuf\" id=\"cellrenderertext1\"/>"
    "                      <attributes>"
722
    "                        <attribute name=\"icon-name\">1</attribute>"
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
    "                      </attributes>"
    "                    </child>"
    "                    <child>"
    "                      <object class=\"GtkCellRendererText\" id=\"cellrenderertext2\">"
    "                        <property name=\"foreground\">purple</property>"
    "                        <property name=\"weight\">600</property>"
    "                        <property name=\"wrap_mode\">word</property>"
    "                        <property name=\"wrap_width\">100</property>"
    "                      </object>"
    "                      <attributes>"
    "                        <attribute name=\"text\">0</attribute>"
    "                      </attributes>"
    "                    </child>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">True</property>"
    "                    <property name=\"fill\">True</property>"
    "                    <property name=\"position\">2</property>"
    "                  </packing>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"expand\">False</property>"
    "                <property name=\"fill\">True</property>"
    "                <property name=\"position\">0</property>"
    "              </packing>"
    "            </child>"
    "            <child>"
    "              <object class=\"GtkFrame\" id=\"frame1\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"label_xalign\">0</property>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label3\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">This test shows combo boxes\n"
    "requesting and allocating space\n"
    "for its backing content using\n"
    "height-for-width geometry\n"
    "management.\n"
    "\n"
    "Note this test also demonstrates\n"
    "height-for-width menu items.</property>"
    "                    <property name=\"justify\">center</property>"
    "                    <attributes>"
    "                      <attribute name=\"weight\" value=\"bold\"/>"
    "                      <attribute name=\"foreground\" value=\"#00000000ffff\"/>"
    "                    </attributes>"
    "                  </object>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"expand\">True</property>"
    "                <property name=\"fill\">True</property>"
    "                <property name=\"position\">1</property>"
    "              </packing>"
    "            </child>"
    "            <child>"
    "              <object class=\"GtkHBox\" id=\"hbox2\">"
    "                <property name=\"visible\">True</property>"
    "                <property name=\"spacing\">5</property>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label4\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">this combo box</property>"
    "                    <attributes>"
    "                      <attribute name=\"weight\" value=\"bold\"/>"
    "                      <attribute name=\"foreground\" value=\"#ffffa5a50000\"/>"
    "                    </attributes>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">True</property>"
    "                    <property name=\"fill\">True</property>"
    "                    <property name=\"position\">0</property>"
    "                  </packing>"
    "                </child>"
    "                <child>"
    "                  <object class=\"GtkLabel\" id=\"label5\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"label\" translatable=\"yes\">contains some ellipsizing locations</property>"
    "                    <property name=\"ellipsize\">end</property>"
    "                    <property name=\"width_chars\">10</property>"
    "                    <attributes>"
    "                      <attribute name=\"weight\" value=\"bold\"/>"
    "                      <attribute name=\"foreground\" value=\"#ffffa5a50000\"/>"
    "                    </attributes>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">True</property>"
    "                    <property name=\"fill\">True</property>"
    "                    <property name=\"position\">1</property>"
    "                  </packing>"
    "                </child>"
    "                <child>"
    "                  <object class=\"GtkComboBox\" id=\"combobox2\">"
    "                    <property name=\"visible\">True</property>"
    "                    <property name=\"model\">liststore1</property>"
    "                    <property name=\"active\">0</property>"
    "                    <child>"
    "                      <object class=\"GtkCellRendererPixbuf\" id=\"cellrenderertext3\"/>"
    "                      <attributes>"
823
    "                        <attribute name=\"icon-name\">1</attribute>"
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885
    "                      </attributes>"
    "                    </child>"
    "                    <child>"
    "                      <object class=\"GtkCellRendererText\" id=\"cellrenderertext4\">"
    "                        <property name=\"ellipsize\">end</property>"
    "                        <property name=\"foreground\">orange</property>"
    "                        <property name=\"weight\">600</property>"
    "                        <property name=\"width_chars\">10</property>"
    "                      </object>"
    "                      <attributes>"
    "                        <attribute name=\"text\">0</attribute>"
    "                      </attributes>"
    "                    </child>"
    "                  </object>"
    "                  <packing>"
    "                    <property name=\"expand\">True</property>"
    "                    <property name=\"fill\">True</property>"
    "                    <property name=\"position\">2</property>"
    "                  </packing>"
    "                </child>"
    "              </object>"
    "              <packing>"
    "                <property name=\"expand\">False</property>"
    "                <property name=\"fill\">True</property>"
    "                <property name=\"position\">2</property>"
    "              </packing>"
    "            </child>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">True</property>"
    "            <property name=\"shrink\">False</property>"
    "          </packing>"
    "        </child>"
    "        <child>"
    "          <object class=\"GtkLabel\" id=\"label6\">"
    "            <property name=\"visible\">True</property>"
    "            <property name=\"label\" translatable=\"yes\">Some static\n"
    "text here\n"
    "that shrinks.</property>"
    "            <property name=\"justify\">center</property>"
    "            <attributes>"
    "              <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
    "            </attributes>"
    "          </object>"
    "          <packing>"
    "            <property name=\"resize\">False</property>"
    "            <property name=\"shrink\">True</property>"
    "          </packing>"
    "        </child>"
    "      </object>"
    "    </child>"
    "  </object>"
    "  <object class=\"GtkListStore\" id=\"liststore1\">"
    "    <columns>"
    "      <!-- column-name item-text -->"
    "      <column type=\"gchararray\"/>"
    "      <!-- column-name icon-name -->"
    "      <column type=\"gchararray\"/>"
    "    </columns>"
    "    <data>"
    "      <row>"
    "        <col id=\"0\" translatable=\"yes\">Montreal, Quebec Canada</col>"
886
    "        <col id=\"1\" translatable=\"yes\">edit-undo</col>"
887 888 889
    "      </row>"
    "      <row>"
    "        <col id=\"0\" translatable=\"yes\">Sao Paulo, SP Brazil</col>"
890
    "        <col id=\"1\" translatable=\"yes\">edit-redo</col>"
891 892 893
    "      </row>"
    "      <row>"
    "        <col id=\"0\" translatable=\"yes\">Buenos Aires, Argentina</col>"
894
    "        <col id=\"1\" translatable=\"yes\">process-stop</col>"
895 896 897
    "      </row>"
    "      <row>"
    "        <col id=\"0\" translatable=\"yes\">Los Angelos, California USA</col>"
898
    "        <col id=\"1\" translatable=\"yes\">media-record</col>"
899 900 901
    "      </row>"
    "      <row>"
    "        <col id=\"0\" translatable=\"yes\">Rio de Janeiro, RJ Brazil</col>"
902
    "        <col id=\"1\" translatable=\"yes\">dialog-error</col>"
903 904 905
    "      </row>"
    "      <row>"
    "        <col id=\"0\" translatable=\"yes\">Seoul, South Korea</col>"
906
    "        <col id=\"1\" translatable=\"yes\">dialog-information</col>"
907 908 909 910 911 912 913
    "      </row>"
    "    </data>"
    "  </object>"
    "</interface>",
    NULL
  },
  
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
};


static void
test_clicked (GtkWidget     *button, 
	      TestInterface *interface)
{
  if (!interface->window)
    {
      GtkBuilder *builder = gtk_builder_new ();
      
      gtk_builder_add_from_string (builder, interface->interface, -1, NULL);
      interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");

      g_signal_connect (interface->window, "delete_event", 
			G_CALLBACK (gtk_widget_hide_on_delete), NULL);
    }

  gtk_widget_show (interface->window);
}


static GtkWidget *
create_window (void)
{
  GtkWidget *window, *vbox, *button;
  gint i;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
943
  vbox   = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985

  gtk_container_set_border_width (GTK_CONTAINER (window), 8);

  gtk_widget_show (vbox);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
    {
      button = gtk_button_new_with_label (interfaces[i].name);

      gtk_widget_set_tooltip_text (button, interfaces[i].tooltip);

      g_signal_connect (G_OBJECT (button), "clicked", 
			G_CALLBACK (test_clicked), &interfaces[i]);

      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
      gtk_widget_show (button);
    }

  return window;
}



int
main (int argc, char *argv[])
{
  GtkWidget *window;

  gtk_init (&argc, &argv);

  window = create_window ();

  g_signal_connect (window, "delete-event",
                    G_CALLBACK (gtk_main_quit), window);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}