gtk_combo_box_new_text vs gtk_combo_box_set_active



Hi,

I'm having some troubles initializing a combo box. The following bit of code shows what I'm doing:


GtkWidget *combo;

combo = gtk_combo_box_new_text ();
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Entry0");
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Entry1");
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Entry2");
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Entry3");
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 2);

and the last line causes:

GLib-GObject-WARNING **: invalid cast from `GtkLabel' to `GtkComboBox'
Gtk-CRITICAL **: gtk_combo_box_set_active: assertion `GTK_IS_COMBO_BOX (combo_box)' failed

and the combo box comes up empty. I can click it and pick one of my 4 selections and I can attach a callback that uses gtk_combo_box_get_active{,_text}() to get the index or the string, I just can't seem to set the active entry.

I'm sure this must be something silly I'm doing, but I'm not finding it.

This is gtk-2.6.4.

Thanks
-Dan




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