[Glade-users] GtkComboBox question.

On Mon, 16 Feb 2009 16:57:01 -0500, Steve Blackwell <zephod at cfl.rr.com> wrote:
In this message:


Carlos Pereira says that "It seems that comboboxes made with glade are
not created with gtk_combo_box_new_text()"

which means, according to the GTK+ reference manual, means that
gtk_combo_box_insert_text() won't work.

Is this still the case and if so is there a workaround? I'm using Glade
3.4.5 on a Fedora F9.


I had the same problem.  I got around it by putting an dummy entry into the "Items" property for the combobox 
in glade.  Something like "eraseme" works just fine.  Having an entry in that property causes the combobox to 
be created with gtk_combo_box_new_text().

Then in my code, I simply erase this entry and put in the values that I really want.

    gtk_combo_box_remove_text (GTK_COMBO_BOX (cbo_yogurt), 0);  /* Gets rid of the "eraseme" value. */
    gtk_combo_box_append_text (GTK_COMBO_BOX (cbo_yogurt), "Vanilla");
    gtk_combo_box_append_text (GTK_COMBO_BOX (cbo_yogurt), "Strawberry");

Note that, in this example, I've hard-coded the "Vanilla" and "Strawberry" values.  If this was really my 
desire, it would certainly be easier to just specify them using Glade.  In reality, I read the values from a 
file and add them using the gtk_combo_box_append_text() function in a loop.

I hope this helps.

Charlie Brune

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