Re: [gtk-list] Pixmap's in combo boxes
- From: Damon Chaplin <damon karuna freeserve co uk>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Pixmap's in combo boxes
- Date: Wed, 13 Oct 1999 10:34:40 +0100
Ian King wrote:
> 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 developer.gnome.org.
Example code from the docs:
GtkWidget *combo, *item, *hbox, *arrow, *label;
combo = gtk_combo_new ();
item = gtk_list_item_new ();
/* 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);
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0);
label = gtk_label_new ("First Item");
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
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);
] [Thread Prev