[Glade-users] GtkComboBox question.
Steve
zephod at cfl.rr.com
Tue Feb 17 22:18:17 EST 2009
---- John Coppens <john at jcoppens.com> wrote:
> On Mon, 16 Feb 2009 22:36:44 -0500
> Steve <zephod at cfl.rr.com> wrote:
>
> >
> > ---- John Coppens <john at jcoppens.com> wrote:
...
> > > Still, it is not very difficult to modify them, and add a simple
> > > GtkListStore with just one column to obtain the same funcionality.
> >
> > I'm a n00b at gtk programming so I need a little hand holding if you
> > could. I can create a GtkListStore and add data to it but how do I
> > associate the store with the combobox? Also, once this has been done,
> > how do I retrieve the data in the store given the widget id of the
> > combobox?
>
> Well, assigning the ListStore to the ComboBox is easy with
>
> gtk_combo_box_set_model
>
> Assuming you made a one column ListStore, that's all there is to it.
>
> Then afterward, you can use the selection of the model
> (gtk_tree_model_get_selection) to get at the item selected.
>
> It's not as easy as the ComboBoxText, but it does give you a better
> control on what happening.
Hmmm.... It clear to me that I have no idea what I'm doing. ]:-P
I have this code:
GtkListStore* store;
GtkWidget* device_selector;
device_selector = glade_xml_get_widget (
gxml,
"device_programming_combobox" );
store = gtk_list_store_new ( 1, G_TYPE_STRING );
gtk_tree_view_set_model ( (GtkTreeView *)device_selector,
(GtkTreeModel *)store );
but when I execute I get this:
Gtk-CRITICAL **: gtk_tree_view_set_model: assertion `GTK_IS_TREE_VIEW (tree_view)' failed
What's wrong with this?
Thanks,
Steve
More information about the Glade-users
mailing list