testcombo.c 50 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* testcombo.c
 * Copyright (C) 2003  Kristian Rietveld
 *
 * 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
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16
 */
17
#include "config.h"
18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include <gtk/gtk.h>

#include <string.h>
#include <stdio.h>

/**
 * oh yes, this test app surely has a lot of ugly code
 */

/* grid combo demo */
static GdkPixbuf *
create_color_pixbuf (const char *color)
{
        GdkPixbuf *pixbuf;
32
        GdkRGBA rgba;
33 34 35 36 37

        int x;
        int num;
        guchar *pixels, *p;

38
        if (!gdk_rgba_parse (&rgba, color))
39 40 41 42 43 44 45 46 47 48 49 50
                return NULL;

        pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
                                 FALSE, 8,
                                 16, 16);

        p = pixels = gdk_pixbuf_get_pixels (pixbuf);

        num = gdk_pixbuf_get_width (pixbuf) *
                gdk_pixbuf_get_height (pixbuf);

        for (x = 0; x < num; x++) {
51 52 53
                p[0] = rgba.red * 255;
                p[1] = rgba.green * 255;
                p[2] = rgba.blue * 255;
54 55 56 57 58 59 60
                p += 3;
        }

        return pixbuf;
}

static GtkWidget *
61
create_combo_box_grid_demo (void)
62 63 64
{
        GtkWidget *combo;
        GtkTreeIter iter;
65
        GdkPixbuf *pixbuf;
66 67 68 69 70
        GtkCellRenderer *cell = gtk_cell_renderer_pixbuf_new ();
        GtkListStore *store;

        store = gtk_list_store_new (1, GDK_TYPE_PIXBUF);

Kristian Rietveld's avatar
Kristian Rietveld committed
71
        combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
72 73 74 75
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
                                    cell, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
                                        cell, "pixbuf", 0, NULL);
76 77 78 79
        gtk_combo_box_set_wrap_width (GTK_COMBO_BOX (combo),
                                      3);

        /* first row */
80
        pixbuf = create_color_pixbuf ("red");
81 82
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
83
                            0, pixbuf,
84
                            -1);
85
        g_object_unref (pixbuf);
86

87
        pixbuf = create_color_pixbuf ("green");
88 89
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
90
                            0, pixbuf,
91
                            -1);
92
        g_object_unref (pixbuf);
93

94
        pixbuf = create_color_pixbuf ("blue");
95 96
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
97
                            0, pixbuf,
98
                            -1);
99
        g_object_unref (pixbuf);
100 101

        /* second row */
102
        pixbuf = create_color_pixbuf ("yellow");
103 104
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
105
                            0, pixbuf,
106
                            -1);
107
        g_object_unref (pixbuf);
108

109
        pixbuf = create_color_pixbuf ("black");
110 111
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
112
                            0, pixbuf,
113
                            -1);
114
        g_object_unref (pixbuf);
115

116
        pixbuf = create_color_pixbuf ("white");
117 118
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
119
                            0, pixbuf,
120
                            -1);
121
        g_object_unref (pixbuf);
122 123

        /* third row */
124
        pixbuf = create_color_pixbuf ("gray");
125 126
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
127
                            0, pixbuf,
128
                            -1);
129
        g_object_unref (pixbuf);
130

131
        pixbuf = create_color_pixbuf ("snow");
132 133
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
134
                            0, pixbuf,
135
                            -1);
136
        g_object_unref (pixbuf);
137

138
        pixbuf = create_color_pixbuf ("magenta");
139 140
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
141
                            0, pixbuf,
142
                            -1);
143
        g_object_unref (pixbuf);
144

145 146
        g_object_unref (store);

147 148 149 150 151 152 153
        gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);

        return combo;
}

/* blaat */
static GtkTreeModel *
154
create_tree_blaat (void)
155 156 157 158 159 160 161 162 163 164
{
        GdkPixbuf *pixbuf;
        GtkWidget *cellview;
        GtkTreeIter iter, iter2;
        GtkTreeStore *store;

        cellview = gtk_cell_view_new ();

	store = gtk_tree_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN);

165 166
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_DIALOG_WARNING,
                                                GTK_ICON_SIZE_BUTTON);
167 168 169 170 171 172 173
        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-dialog-warning",
			    2, FALSE,
                            -1);

174 175
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_STOP,
                                                GTK_ICON_SIZE_BUTTON);
176 177 178 179 180 181 182
        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, pixbuf,
                            1, "gtk-stock-stop",
			    2, FALSE,
                            -1);

183 184
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_NEW,
                                                GTK_ICON_SIZE_BUTTON);
185 186 187 188 189 190 191
        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, pixbuf,
                            1, "gtk-stock-new",
			    2, FALSE,
                            -1);

192 193
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_CLEAR,
                                                GTK_ICON_SIZE_BUTTON);
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-clear",
			    2, FALSE,
                            -1);

#if 0
        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter,
                            0, NULL,
                            1, "separator",
			    2, TRUE,
                            -1);
#endif

210 211
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_OPEN,
                                                GTK_ICON_SIZE_BUTTON);
212 213 214 215 216 217 218 219 220 221 222 223
        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-open",
			    2, FALSE,
                            -1);

        gtk_widget_destroy (cellview);

        return GTK_TREE_MODEL (store);
}

224 225 226 227 228 229 230 231 232 233 234 235
static GtkTreeModel *
create_empty_list_blaat (void)
{
        GdkPixbuf *pixbuf;
        GtkWidget *cellview;
        GtkTreeIter iter;
        GtkListStore *store;

        cellview = gtk_cell_view_new ();

        store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);

236 237
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_DIALOG_WARNING,
                                                GTK_ICON_SIZE_BUTTON);
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
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-dialog-warning",
                            -1);

        gtk_widget_destroy (cellview);

        return GTK_TREE_MODEL (store);
}

static void
populate_list_blaat (gpointer data)
{
  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
  GtkListStore *store;
  GdkPixbuf *pixbuf;
  GtkWidget *cellview;
  GtkTreeIter iter;
  
  store = GTK_LIST_STORE (gtk_combo_box_get_model (combo_box));

  gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);

  if (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter))
    return;

  cellview = gtk_cell_view_new ();
  
267 268
  pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_STOP,
				          GTK_ICON_SIZE_BUTTON);
269 270 271 272 273 274
  gtk_list_store_append (store, &iter);			       
  gtk_list_store_set (store, &iter,
		      0, pixbuf,
		      1, "gtk-stock-stop",
		      -1);
  
275 276
  pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_NEW,
				          GTK_ICON_SIZE_BUTTON);
277 278 279 280 281 282
  gtk_list_store_append (store, &iter);			       
  gtk_list_store_set (store, &iter,
		      0, pixbuf,
		      1, "gtk-stock-new",
		      -1);
  
283 284
  pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_CLEAR,
				          GTK_ICON_SIZE_BUTTON);
285 286 287 288 289 290 291 292 293 294 295 296
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter,
		      0, pixbuf,
		      1, "gtk-stock-clear",
		      -1);
  
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter,
		      0, NULL,
		      1, "separator",
		      -1);
  
297 298
  pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_OPEN,
				          GTK_ICON_SIZE_BUTTON);
299 300 301 302 303 304 305 306 307
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter,
		      0, pixbuf,
		      1, "gtk-stock-open",
		      -1);
  
  gtk_widget_destroy (cellview);  
}

308
static GtkTreeModel *
309
create_list_blaat (void)
310 311 312 313 314 315 316 317
{
        GdkPixbuf *pixbuf;
        GtkWidget *cellview;
        GtkTreeIter iter;
        GtkListStore *store;

        cellview = gtk_cell_view_new ();

318
        store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
319

320 321
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_DIALOG_WARNING,
                                                GTK_ICON_SIZE_BUTTON);
322 323 324 325 326 327
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-dialog-warning",
                            -1);

328 329
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_STOP,
                                                GTK_ICON_SIZE_BUTTON);
330
        gtk_list_store_append (store, &iter);			       
331 332 333 334 335
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-stop",
                            -1);

336 337
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_NEW,
                                                GTK_ICON_SIZE_BUTTON);
338
        gtk_list_store_append (store, &iter);			       
339 340 341 342 343
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-new",
                            -1);

344 345
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_CLEAR,
                                                GTK_ICON_SIZE_BUTTON);
346 347 348 349
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-clear",
350 351 352 353 354 355 356 357
                            -1);

        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, NULL,
                            1, "separator",
                            -1);

358 359
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_OPEN,
                                                GTK_ICON_SIZE_BUTTON);
360 361 362 363
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, "gtk-stock-open",
364 365 366 367 368 369 370
                            -1);

        gtk_widget_destroy (cellview);

        return GTK_TREE_MODEL (store);
}

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

static GtkTreeModel *
create_list_long (void)
{
        GtkTreeIter iter;
        GtkListStore *store;

        store = gtk_list_store_new (1, G_TYPE_STRING);

        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, "here is some long long text that grows out of the combo's allocation",
                            -1);


        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, "with at least a few of these rows",
                            -1);

        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, "so that we can get some ellipsized text here",
                            -1);

        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, "and see the combo box menu being allocated without any constraints",
                            -1);

        return GTK_TREE_MODEL (store);
}

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
static GtkTreeModel *
create_food_list (void)
{
        GtkTreeIter iter;
        GtkListStore *store;

        store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, "Pepperoni",
                            1, "Pizza",
                            -1);

        gtk_list_store_append (store, &iter);			       
        gtk_list_store_set (store, &iter,
                            0, "Cheese",
                            1, "Burger",
                            -1);

        gtk_list_store_append (store, &iter);			       
        gtk_list_store_set (store, &iter,
                            0, "Pineapple",
                            1, "Milkshake",
                            -1);

        gtk_list_store_append (store, &iter);			       
        gtk_list_store_set (store, &iter,
                            0, "Orange",
                            1, "Soda",
                            -1);

        gtk_list_store_append (store, &iter);			       
        gtk_list_store_set (store, &iter,
                            0, "Club",
                            1, "Sandwich",
                            -1);

        return GTK_TREE_MODEL (store);
}


445 446
/* blaat */
static GtkTreeModel *
447
create_phylogenetic_tree (void)
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 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 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 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
{
        GtkTreeIter iter, iter2, iter3;
        GtkTreeStore *store;

	store = gtk_tree_store_new (1,G_TYPE_STRING);

        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter,
                            0, "Eubacteria",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Aquifecales",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Thermotogales",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Thermodesulfobacterium",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Thermus-Deinococcus group",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Chloroflecales",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Cyanobacteria",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Firmicutes",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Leptospirillium Group",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Synergistes",
                            -1);
        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Chlorobium-Flavobacteria group",
                            -1);
        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Chlamydia-Verrucomicrobia group",
                            -1);

        gtk_tree_store_append (store, &iter3, &iter2);			       
        gtk_tree_store_set (store, &iter3,
                            0, "Verrucomicrobia",
                            -1);
        gtk_tree_store_append (store, &iter3, &iter2);			       
        gtk_tree_store_set (store, &iter3,
                            0, "Chlamydia",
                            -1);

        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Flexistipes",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Fibrobacter group",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "spirocheteus",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Proteobacteria",
                            -1);


        gtk_tree_store_append (store, &iter3, &iter2);			       
        gtk_tree_store_set (store, &iter3,
                            0, "alpha",
                            -1);


        gtk_tree_store_append (store, &iter3, &iter2);			       
        gtk_tree_store_set (store, &iter3,
                            0, "beta",
                            -1);


        gtk_tree_store_append (store, &iter3, &iter2);			       
        gtk_tree_store_set (store, &iter3,
                            0, "delta ",
                            -1);


        gtk_tree_store_append (store, &iter3, &iter2);			       
        gtk_tree_store_set (store, &iter3,
                            0, "epsilon",
                            -1);


        gtk_tree_store_append (store, &iter3, &iter2);  
        gtk_tree_store_set (store, &iter3,
                            0, "gamma ",
                            -1);


        gtk_tree_store_append (store, &iter, NULL);			       
        gtk_tree_store_set (store, &iter,
                            0, "Eukaryotes",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Metazoa",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Bilateria",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Myxozoa",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Cnidaria",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Ctenophora",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Placozoa",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Porifera",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "choanoflagellates",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Fungi",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Microsporidia",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Aleveolates",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Stramenopiles",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Rhodophyta",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Viridaeplantae",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "crytomonads et al",
                            -1);


        gtk_tree_store_append (store, &iter, NULL);			       
        gtk_tree_store_set (store, &iter,
                            0, "Archaea ",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Korarchaeota",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Crenarchaeota",
                            -1);


        gtk_tree_store_append (store, &iter2, &iter);			       
        gtk_tree_store_set (store, &iter2,
                            0, "Buryarchaeota",
                            -1);

        return GTK_TREE_MODEL (store);
}


/* blaat */
static GtkTreeModel *
700
create_capital_tree (void)
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 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 823 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 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 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 943 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
{
        GtkTreeIter iter, iter2;
        GtkTreeStore *store;

	store = gtk_tree_store_new (1, G_TYPE_STRING);

        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter, 0, "A - B", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Albany", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Annapolis", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Atlanta", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Augusta", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Austin", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Baton Rouge", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Bismarck", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Boise", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Boston", -1);

        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter, 0, "C - D", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Carson City", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Charleston", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Cheyenne", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Columbia", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Columbus", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Concord", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Denver", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Des Moines", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Dover", -1);


        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter, 0, "E - J", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Frankfort", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Harrisburg", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Hartford", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Helena", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Honolulu", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Indianapolis", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Jackson", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Jefferson City", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Juneau", -1);


        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter, 0, "K - O", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Lansing", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Lincoln", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Little Rock", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Madison", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Montgomery", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Montpelier", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Nashville", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Oklahoma City", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Olympia", -1);


        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter, 0, "P - S", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Phoenix", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Pierre", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Providence", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Raleigh", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Richmond", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Sacramento", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Salem", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Salt Lake City", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Santa Fe", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Springfield", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "St. Paul", -1);


        gtk_tree_store_append (store, &iter, NULL);
        gtk_tree_store_set (store, &iter, 0, "T - Z", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Tallahassee", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Topeka", -1);

        gtk_tree_store_append (store, &iter2, &iter);
        gtk_tree_store_set (store, &iter2, 0, "Trenton", -1);

        return GTK_TREE_MODEL (store);
}

static void
capital_sensitive (GtkCellLayout   *cell_layout,
		   GtkCellRenderer *cell,
		   GtkTreeModel    *tree_model,
		   GtkTreeIter     *iter,
		   gpointer         data)
{
  gboolean sensitive;

  sensitive = !gtk_tree_model_iter_has_child (tree_model, iter);

  g_object_set (cell, "sensitive", sensitive, NULL);
}

static gboolean
capital_animation (gpointer data)
{
  static gint insert_count = 0;
  GtkTreeModel *model = GTK_TREE_MODEL (data);
  GtkTreePath *path;
  GtkTreeIter iter, parent;

  switch (insert_count % 8)
    {
    case 0:
      gtk_tree_store_insert (GTK_TREE_STORE (model), &iter, NULL, 0);
      gtk_tree_store_set (GTK_TREE_STORE (model), 
			  &iter,
			  0, "Europe", -1);
      break;

    case 1:
      path = gtk_tree_path_new_from_indices (0, -1);
      gtk_tree_model_get_iter (model, &parent, path);
      gtk_tree_path_free (path);
      gtk_tree_store_insert (GTK_TREE_STORE (model), &iter, &parent, 0);
      gtk_tree_store_set (GTK_TREE_STORE (model), 
			  &iter,
			  0, "Berlin", -1);
      break;

    case 2:
      path = gtk_tree_path_new_from_indices (0, -1);
      gtk_tree_model_get_iter (model, &parent, path);
      gtk_tree_path_free (path);
      gtk_tree_store_insert (GTK_TREE_STORE (model), &iter, &parent, 1);
      gtk_tree_store_set (GTK_TREE_STORE (model), 
			  &iter,
			  0, "London", -1);
      break;

    case 3:
      path = gtk_tree_path_new_from_indices (0, -1);
      gtk_tree_model_get_iter (model, &parent, path);
      gtk_tree_path_free (path);
      gtk_tree_store_insert (GTK_TREE_STORE (model), &iter, &parent, 2);
      gtk_tree_store_set (GTK_TREE_STORE (model), 
			  &iter,
			  0, "Paris", -1);
      break;

    case 4:
      path = gtk_tree_path_new_from_indices (0, 2, -1);
      gtk_tree_model_get_iter (model, &iter, path);
      gtk_tree_path_free (path);
      gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
      break;

    case 5:
      path = gtk_tree_path_new_from_indices (0, 1, -1);
      gtk_tree_model_get_iter (model, &iter, path);
      gtk_tree_path_free (path);
      gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
      break;

    case 6:
      path = gtk_tree_path_new_from_indices (0, 0, -1);
      gtk_tree_model_get_iter (model, &iter, path);
      gtk_tree_path_free (path);
      gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
      break;

    case 7:
      path = gtk_tree_path_new_from_indices (0, -1);
      gtk_tree_model_get_iter (model, &iter, path);
      gtk_tree_path_free (path);
      gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
      break;

    default: ;

    }
  insert_count++;

  return TRUE;
}

979
static void
980
setup_combo_entry (GtkComboBoxText *combo)
981
{
982
  gtk_combo_box_text_append_text (combo,
983
				   "dum de dum");
984
  gtk_combo_box_text_append_text (combo,
985
				   "la la la");
986
  gtk_combo_box_text_append_text (combo,
987
				   "la la la dum de dum la la la la la la boom de da la la");
988
  gtk_combo_box_text_append_text (combo,
989
				   "bloop");
990
  gtk_combo_box_text_append_text (combo,
991
				   "bleep");
992
  gtk_combo_box_text_append_text (combo,
993
				   "klaas");
994
  gtk_combo_box_text_append_text (combo,
995
				   "klaas0");
996
  gtk_combo_box_text_append_text (combo,
997
				   "klaas1");
998
  gtk_combo_box_text_append_text (combo,
999
				   "klaas2");
1000
  gtk_combo_box_text_append_text (combo,
1001
				   "klaas3");
1002
  gtk_combo_box_text_append_text (combo,
1003
				   "klaas4");
1004
  gtk_combo_box_text_append_text (combo,
1005
				   "klaas5");
1006
  gtk_combo_box_text_append_text (combo,
1007
				   "klaas6");
1008
  gtk_combo_box_text_append_text (combo,
1009
				   "klaas7");
1010
  gtk_combo_box_text_append_text (combo,
1011
				   "klaas8");
1012
  gtk_combo_box_text_append_text (combo,
1013
				   "klaas9");
1014
  gtk_combo_box_text_append_text (combo,
1015
				   "klaasa");
1016
  gtk_combo_box_text_append_text (combo,
1017
				   "klaasb");
1018
  gtk_combo_box_text_append_text (combo,
1019
				   "klaasc");
1020
  gtk_combo_box_text_append_text (combo,
1021
				   "klaasd");
1022
  gtk_combo_box_text_append_text (combo,
1023
				   "klaase");
1024
  gtk_combo_box_text_append_text (combo,
1025
				   "klaasf");
1026
  gtk_combo_box_text_append_text (combo,
1027
				   "klaas10");
1028
  gtk_combo_box_text_append_text (combo,
1029
				   "klaas11");
1030
  gtk_combo_box_text_append_text (combo,
1031
				   "klaas12");
1032 1033
}

1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045
static void
set_sensitive (GtkCellLayout   *cell_layout,
	       GtkCellRenderer *cell,
	       GtkTreeModel    *tree_model,
	       GtkTreeIter     *iter,
	       gpointer         data)
{
  GtkTreePath *path;
  gint *indices;
  gboolean sensitive;

  path = gtk_tree_model_get_path (tree_model, iter);
1046
  indices = gtk_tree_path_get_indices (path);
1047
  sensitive = indices[0] != 1;
1048 1049 1050 1051 1052
  gtk_tree_path_free (path);

  g_object_set (cell, "sensitive", sensitive, NULL);
}

1053 1054 1055 1056 1057 1058 1059 1060 1061
static gboolean
is_separator (GtkTreeModel *model,
	      GtkTreeIter  *iter,
	      gpointer      data)
{
  GtkTreePath *path;
  gboolean result;

  path = gtk_tree_model_get_path (model, iter);
1062
  result = gtk_tree_path_get_indices (path)[0] == 4;
1063 1064 1065 1066 1067 1068
  gtk_tree_path_free (path);

  return result;
  
}

1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
static void
displayed_row_changed (GtkComboBox *combo,
                       GtkCellView *cell)
{
  gint row;
  GtkTreePath *path;

  row = gtk_combo_box_get_active (combo);
  path = gtk_tree_path_new_from_indices (row, -1);
  gtk_cell_view_set_displayed_row (cell, path);
  gtk_tree_path_free (path);
}

1082 1083 1084 1085 1086 1087 1088 1089
int
main (int argc, char **argv)
{
        GtkWidget *window, *cellview, *mainbox;
        GtkWidget *combobox, *comboboxtext, *comboboxgrid;
        GtkWidget *tmp, *boom;
        GtkCellRenderer *renderer;
        GdkPixbuf *pixbuf;
1090
        GtkTreeModel *model;
1091 1092
	GtkTreePath *path;
	GtkTreeIter iter;
1093
	GdkRGBA color;
1094
	GtkCellArea *area;
1095

1096 1097
        gtk_init (&argc, &argv);

1098 1099 1100
	if (g_getenv ("RTL"))
	  gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);

1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114
	if (g_getenv ("LISTMODE"))
	  {
	    GtkCssProvider *provider = gtk_css_provider_new ();

	    gtk_css_provider_load_from_data (provider,
					     "* { -GtkComboBox-appears-as-list: true; }", 
					     -1, NULL);

	    gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
						       GTK_STYLE_PROVIDER (provider),
						       GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);

	  }

1115 1116
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_container_set_border_width (GTK_CONTAINER (window), 5);
1117
        g_signal_connect (window, "destroy", gtk_main_quit, NULL);
1118

1119
        mainbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
1120 1121 1122 1123 1124 1125
        gtk_container_add (GTK_CONTAINER (window), mainbox);

        /* GtkCellView */
        tmp = gtk_frame_new ("GtkCellView");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1126
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1127 1128 1129 1130 1131
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        cellview = gtk_cell_view_new ();
        renderer = gtk_cell_renderer_pixbuf_new ();
1132 1133
        pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_DIALOG_WARNING,
                                                GTK_ICON_SIZE_BUTTON);
1134

1135 1136 1137
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview),
                                    renderer,
                                    FALSE);
1138
        g_object_set (renderer, "pixbuf", pixbuf, NULL);
1139 1140

        renderer = gtk_cell_renderer_text_new ();
1141 1142 1143
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview),
                                    renderer,
                                    TRUE);
1144
        g_object_set (renderer, "text", "la la la", NULL);
1145 1146
        gtk_container_add (GTK_CONTAINER (boom), cellview);

1147 1148
        /* GtkComboBox list */
        tmp = gtk_frame_new ("GtkComboBox (list)");
1149 1150
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1151
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1152 1153 1154
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

1155
        model = create_list_blaat ();
1156
        combobox = gtk_combo_box_new_with_model (model);
1157
	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
1158
        g_object_unref (model);
1159 1160 1161
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_pixbuf_new ();
1162 1163 1164 1165 1166 1167
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "pixbuf", 0,
                                        NULL);
1168 1169 1170 1171
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
1172 1173

        renderer = gtk_cell_renderer_text_new ();
1174 1175 1176 1177 1178 1179
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);
1180 1181 1182 1183
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
1184 1185
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
					      is_separator, NULL, NULL);
1186 1187
						
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
1188

1189 1190 1191 1192
        /* GtkComboBox dynamic list */
        tmp = gtk_frame_new ("GtkComboBox (dynamic list)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1193
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1194 1195 1196 1197 1198
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_empty_list_blaat ();
        combobox = gtk_combo_box_new_with_model (model);
1199
	g_signal_connect (combobox, "notify::popup-shown", 
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232
			  G_CALLBACK (populate_list_blaat), combobox);

	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "pixbuf", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
					      is_separator, NULL, NULL);
						
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
1233
	gtk_combo_box_set_title (GTK_COMBO_BOX (combobox), "Dynamic list");
1234

1235 1236 1237 1238
        /* GtkComboBox custom entry */
        tmp = gtk_frame_new ("GtkComboBox (custom)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1239
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_list_blaat ();
        combobox = gtk_combo_box_new_with_model (model);
	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "pixbuf", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
					      is_separator, NULL, NULL);
						
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);

        tmp = gtk_cell_view_new ();
        gtk_widget_show (tmp);
        gtk_cell_view_set_model (GTK_CELL_VIEW (tmp), model);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tmp), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tmp), renderer,
                                        "text", 1,
                                        NULL);
1286 1287
        color.red = 1.0;
        color.blue = 1.0;
1288
        color.green = 0;
1289 1290
        color.alpha = 1.0;
        gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (tmp), &color);
1291 1292 1293 1294 1295
        displayed_row_changed (GTK_COMBO_BOX (combobox), GTK_CELL_VIEW (tmp));
        g_signal_connect (combobox, "changed", G_CALLBACK (displayed_row_changed), tmp); 
           
        gtk_container_add (GTK_CONTAINER (combobox), tmp);

1296 1297 1298 1299
        /* GtkComboBox tree */
        tmp = gtk_frame_new ("GtkComboBox (tree)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1300
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_tree_blaat ();
        combobox = gtk_combo_box_new_with_model (model);
	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "pixbuf", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
					      is_separator, NULL, NULL);
						
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
#if 0
	g_timeout_add (1000, (GSourceFunc) animation_timer, model);
#endif
1340 1341 1342 1343 1344

        /* GtkComboBox (grid mode) */
        tmp = gtk_frame_new ("GtkComboBox (grid mode)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1345
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1346 1347 1348 1349 1350 1351 1352 1353
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        comboboxgrid = create_combo_box_grid_demo ();
        gtk_box_pack_start (GTK_BOX (boom), comboboxgrid, FALSE, FALSE, 0);


        /* GtkComboBoxEntry */
1354
        tmp = gtk_frame_new ("GtkComboBox with entry");
1355 1356
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1357
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1358 1359 1360
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

1361 1362
        comboboxtext = gtk_combo_box_text_new_with_entry ();
        setup_combo_entry (GTK_COMBO_BOX_TEXT (comboboxtext));
1363 1364
        gtk_container_add (GTK_CONTAINER (boom), comboboxtext);

1365 1366 1367 1368 1369

        /* Phylogenetic tree */
        tmp = gtk_frame_new ("What are you ?");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1370
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_phylogenetic_tree ();
        combobox = gtk_combo_box_new_with_model (model);
	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 0,
                                        NULL);
	
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);

        /* Capitals */
        tmp = gtk_frame_new ("Where are you ?");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1394
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1395 1396 1397 1398
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_capital_tree ();
1399
	combobox = gtk_combo_box_new_with_model (model);
1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419
	gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);
        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    capital_sensitive,
					    NULL, NULL);
	path = gtk_tree_path_new_from_indices (0, 8, -1);
	gtk_tree_model_get_iter (model, &iter, path);
	gtk_tree_path_free (path);
        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);

#if 1
1420
	gdk_threads_add_timeout (1000, (GSourceFunc) capital_animation, model);
1421 1422
#endif

1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457
        /* Aligned Food */
        tmp = gtk_frame_new ("Hungry ?");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_food_list ();
	combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

	area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (combobox));

        renderer = gtk_cell_renderer_text_new ();
	gtk_cell_area_add_with_properties (area, renderer, 
					   "align", TRUE, 
					   "expand", TRUE, 
					   NULL);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 0,
                                        NULL);

        renderer = gtk_cell_renderer_text_new ();
	gtk_cell_area_add_with_properties (area, renderer, 
					   "align", TRUE, 
					   "expand", TRUE, 
					   NULL);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);

        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);

1458 1459 1460 1461
	/* Ellipsizing growing combos */
        tmp = gtk_frame_new ("Unconstrained Menu");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

1462
        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

	model = create_list_long ();
	combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);
        renderer = gtk_cell_renderer_text_new ();
	g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);

        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 0, NULL);
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
	gtk_combo_box_set_popup_fixed_width (GTK_COMBO_BOX (combobox), FALSE);
1478

1479 1480 1481 1482 1483 1484 1485 1486 1487
        gtk_widget_show_all (window);

        gtk_main ();

        return 0;
}

/* vim:expandtab
 */