[Glade-users] Adding entries to a gtkcomboboxentry
Tristan Van Berkom
tristan.van.berkom at gmail.com
Sun Feb 5 14:48:05 EST 2006
Leo - wrote:
>I hope I do this right, first time mailing list user :)
>
>I'm designing an app with glade and is going to use a gtkcomboboxentry as a
>command input+command history part = The user edits the command in the
>"entry" part and when he/she presses enter the command gets executed and
>gets prepended in the history (popup menu part of the comboboxentry)
>
>How would I go on about prepending the neew command as a new row in the
>menu?
>I searched the gtk reference manual and found the function
>"gtk_combo_box_append_text"
>But when running the program with that command I get the errors
>
>(<unknown>:21581): Gtk-CRITICAL **: gtk_combo_box_append_text: assertion
>`GTK_IS_LIST_STORE (combo_box->priv->model)' failed
>
>There is a note attached to the gtk reference saying
>
>"Note that you can only use this function with combo boxes constructed with
>gtk_combo_box_new_text()."
>
>Could that be the problem?, that glade doesn't create the widget with that
>function?
>If I choose export and look in the c source there is the following part in
>the interface.c file:
>
> combo_result = gtk_combo_box_new_text ();
>
>So that shouldn't be the case should it?
>
>However, I am using glade through the glade-xml library and using the xml
>file and not the c source, could it be
>that the library generates/inits widgets differently?
>
>My crack at it:
>The widget data seems to be stored in a gtktreemodel, a widget I know
>nothing
>about, but which seems to have some append/prepend functions, only that
>they Invoke a third widget adding to the confusion.
>
>I would need help on understanding how to accomplish the above.
>
>Another person had a similar question:
>http://lists.ximian.com/pipermail/glade-users/2004-October/002215.html
>and got this answer:
>
>Look at the code for gtk_combo_box_new_text(). You just have to set upthe
>combo in a similar way and append_text() will work fine.
>That would be in the gtk source wouldn't it? If so how would I obtain it,
>find the special part, etc?
>
>
Heh,
you've definitly stumbled upon one or glade/libglade's wierder
glitches ;-)
glade-2 will allow you to set an "items" property (that I assume you
dont need to set since your items are completely dynamic).
libglade will create the GtkListStore and add the GtkCellRendererText
*if* there were any items in the glade file.
So the confusing bottom line is that, libglade will setup you combo-box
for regular gtk_combo_box_new_text() type interaction *if* there were any
items set in the glade file, otherwise you just get a naked combo-box and
you'll have to set it up yourself.
Cheers,
-Tristan
More information about the Glade-users
mailing list