[Glade-users] libglade - Associating a mode with an empty combo_box
- From: kbulgrien at worldnet.att.net (Kevin R. Bulgrien)
- Subject: [Glade-users] libglade - Associating a mode with an empty combo_box
- Date: Wed, 29 Aug 2007 00:16:17 -0500
Regarding the prior thread "(newbie) combobx and model"... found here:
http://lists.ximian.com/pipermail/glade-users/2007-May/003493.html
I have exactly the same difficulty the original poster spoke of, but do
not have a clue where to go after extensive Googling and reading of
articles.
$ glade-2 --version
Gnome glade-2 2.12.1
$ rpm -q lib64glade2.0_0
lib64glade2.0_0-2.6.0-1mdv2007.0
Problem: An empty combo box is created in a window using glade-2. No
items are placed in the combo box because it will be filled at run-time.
In the glade file a couple combo boxes look like this:
...
<child>
<widget class="GtkComboBox" id="config_combobox_faceset">
<property name="width_request">170</property>
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
...
<child>
<widget class="GtkComboBox" id="config_combobox_theme">
<property name="width_request">170</property>
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
...
When the window is first displayed, the behavior of the two empty combo boxes
is not identical. Consider:
model = gtk_combo_box_get_model(GTK_COMBO_BOX(config_combobox_faceset));
count = gtk_tree_model_iter_n_children(model, NULL);
model is returned non-null, and the combo_box is filled as expected, and one
might expect the same behavior from exactly the same code later on:
model = gtk_combo_box_get_model(GTK_COMBO_BOX(config_combobox_theme));
count = gtk_tree_model_iter_n_children(model, NULL);
But, in this case, model is NULL:
575 model = gtk_combo_box_get_model(GTK_COMBO_BOX(config_combobox_theme));
(gdb) step
583 count = gtk_tree_model_iter_n_children(model, NULL);
(gdb) print model
$1 = (GtkTreeModel *) 0x0
When line 583 executes, an error is thrown:
Gtk-CRITICAL **: gtk_tree_model_iter_n_children:
assertion `GTK_IS_TREE_MODEL (tree_model)' failed
Naturally, any attempt to populate combo box fails with additional errors.
The code may be forced to work by assigning a dummy value to the combo box in
glade-2, and by deleting the dummy entry prior to populating the combo box
with the appropriate data, but this seems a kludge as it appears there is an
inconsistency in how libglade handles empty combo boxes.
I tried applying a fix of the nature that appeared to be portrayed in various
locations, but namely:
http://scentric.net/tutorial/
Apparently I misunderstand the tutorial, as this does not work:
model = gtk_combo_box_get_model(GTK_COMBO_BOX(config_combobox_theme));
if (! model)
{
store = gtk_list_store_new(1, G_TYPE_STRING);
gtk_combo_box_set_model(GTK_COMBO_BOX(config_combobox_theme),
GTK_TREE_MODEL(store));
}
count = gtk_tree_model_iter_n_children(model, NULL);
Any ideas? The tutorial omits additional steps in this mini-example:
http://scentric.net/tutorial/sec-treeview.html#sec-treeview-connect-model
Perhaps I must add data to the store before using gtk_combo_box_set_model(),
and perhaps the model is not set up entirely since there is no reference to
a renderer, etc, and so set model ignores the requested operation?
Any help or hints appreciated. I've been digging on this for a few days,
and am about to just do it by filling a dummy value in via the xml file so
that libglade will have already create a model associated with the combo box
even though that forces me to empty the tree view before I populate it..
Thanks,
Kevin Bulgrien
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]