Thursday, December 18, 2008

Glade GtkComboBox Bug: Revisited

In the previous post, from ximian mailing lists discussing about a Glade GtkComboBox's bug. So let's make a simple task howto resolve this issue, not by Glade UI's coding sight, but less than 'tricky' lines appended into your code. This happen in version 3.4.3 and some minor versions below.

When creating a widget for GtkComboBox, we need to set at least one entry. This because Glade will not generate XML's property inside interface's file by default (in this case: a bug). Say your entry is "Bug" string. Then in your code:

GtkWidget *combobox;

combobox = glade_xml_get_widget (gladexml, "combobox");
/* remove our tricky entry, first entry */
gtk_combo_box_remove_text (GTK_COMBO_BOX (combobox), 0)

/* our combo box is now ready... */
gtk_combo_box_prepend_text (GTK_COMBO_BOX (combobox), "Hey");

Have a try, it was fixed at least for me ;)