Re: [gtk-list] Pixmap's in combo boxes

Ian King wrote:
> Hi,
> Does anybody know if it is possible to have anything other than just text
> (such as text with pixmaps) as an item in a GtkCombo widget.

Yes, you can use almost any widgets in the combo's drop-down list.
But you have to call gtk_combo_set_item_string() on the menuitems to set the
text to be displayed in the entry when they are selected.

I wrote some docs for GtkCombo which should be on


Example code from the docs:

  GtkWidget *combo, *item, *hbox, *arrow, *label;

    combo = gtk_combo_new ();

    item = gtk_list_item_new ();
    gtk_widget_show (item);

    /* You can put almost anything into the GtkListItem widget. Here we will use
       a horizontal box with an arrow and a label in it. */
    hbox = gtk_hbox_new (FALSE, 3);
    gtk_container_add (GTK_CONTAINER (item), hbox);
    gtk_widget_show (hbox);

    arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
    gtk_widget_show (arrow);
    gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0);

    label = gtk_label_new ("First Item");
    gtk_widget_show (label);
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

    /* You must set the string to display in the entry field when the item is
       selected. */
    gtk_combo_set_item_string (GTK_COMBO (combo), GTK_ITEM (item), "1st Item");

    /* Now we simply add the item to the combo's list. */
    gtk_container_add (GTK_CONTAINER (GTK_COMBO (combo)->list), item);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]