Thursday, December 18, 2008

Glade GtkComboBox Bug: Revisited

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

When creating a widget for GtkComboBox, we need to set at least one entry. This because Glade will not generate xml's property to interface's file by default (in this case a bug). Say you entry is "Bug" string. Then in our 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... ;)