After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 470243 - Doesn't convert Comboboxes properly
Doesn't convert Comboboxes properly
Status: RESOLVED NOTABUG
Product: gtk+
Classification: Platform
Component: Class: GtkBuilder
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GtkBuilder maintainers
GtkBuilder maintainers
Depends on:
Blocks:
 
 
Reported: 2007-08-25 17:08 UTC by Bastien Nocera
Modified: 2007-08-25 18:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Bastien Nocera 2007-08-25 17:08:00 UTC
In totem.glade:
		<widget class="GtkComboBox" id="tpw_visuals_type_combobox">
		  <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>

In totem.ui:
	        <object class="GtkListStore" id="tpw_visuals_type_liststore">
                                <columns>
                                  <column type="gchararray"/>
                                </columns>
                                <data>
                                </data>
                              </object>
		<object class="GtkComboBox" id="tpw_visuals_type_combobox">
		  <property name="visible">True</property>
		  <property name="add_tearoffs">False</property>
		  <property name="focus_on_click">True</property>
		  <property name="model">tpw_visuals_type_liststore</property>
		  <signal name="changed" handler="visual_menu_changed"/>
		</object>


With the glade file, a text cell renderer was created automatically, so that it was enough to do:
gtk_combo_box_append_text (combobox, text);
to add new items to the list.

With GtkBuilder, I need to add a text cell renderer to the combobox myself, as done in gtk_combo_box_new_text().

What would I need to do to add the text cell renderer to the combobox in the .ui file?
Comment 1 Johan (not receiving bugmail) Dahlin 2007-08-25 17:15:27 UTC
GtkBuilder has the policy of trying to do as little as possible implicitly, that incluses creating cell renderers behind your back.
GtkComboBox implements the custom tag 'attribute' in GtkBuildable interface.

It should be enough by adding;

<attributes>
  <attribute name="text">0</attribute>
</attributes>

Check the test_combo_box function in buildertest.c for a complete example:

http://svn.gnome.org/viewcvs/gtk+/trunk/tests/buildertest.c?view=markup

Does this address your problems?




Comment 2 Bastien Nocera 2007-08-25 17:35:07 UTC
Works great.

But if the GtkComboBoxes in glade were really text combo boxes, the convert tool should add those lines automatically to the .ui, right?
Comment 3 Johan (not receiving bugmail) Dahlin 2007-08-25 18:34:34 UTC
Yes, definitely. It was an oversight.
Comment 4 Johan (not receiving bugmail) Dahlin 2007-08-25 18:46:49 UTC
Actually, it does add a GtkListStore and a GtkCellRendererText renderer, but only iff there's an items property.

You must have converted that file using an older version of the converter script, if not reopen the bug and attach the file which the converter script (from trunk) fails to convert.