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 650369 - GtkComboboxText is not properly initialized
GtkComboboxText is not properly initialized
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkComboBox
3.0.x
Other Linux
: Normal normal
: 3.4
Assigned To: gtk-bugs
gtk-bugs
Depends on: 612396
Blocks: 653579
 
 
Reported: 2011-05-17 03:53 UTC by Mathieu Bridon
Modified: 2014-11-14 02:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Mathieu Bridon 2011-05-17 03:53:05 UTC
I'm using PyGI on Fedora 15.

As I outlined on the mailing-list [0], there is a difference in behavior between using Gtk.ComboBoxText() and Gtk.ComboBoxText.new(). The former leads to a broken widget (see the email [0] for more details).

John suggested that this would be a bug in Gtk+ [1]
"""
I thought this was fixed in Gtk+ but it might just be another object that does its setup in the wrong place.  We use g_object_new to instantiate a gobject so if the gobject does any setup code in its constructor, that never gets run.  Constructors should be convenience methods.  All objects should set sane defaults in their init method.  I would file a bug on Gtk+ and just use the new constructor for now.
"""


[0] http://mail.gnome.org/archives/python-hackers-list/2011-May/msg00001.html
[1] http://mail.gnome.org/archives/python-hackers-list/2011-May/msg00007.html


Note: I chose component GtkComboBox for this bug as there isn't a GtkComboBoxText one.
Comment 1 Matthias Clasen 2011-05-17 10:54:36 UTC
All GtkComboBoxText constructors just use g_object_new themselves. So, if there is a problem here, you will have to do some more research what it is.
Comment 2 Kjell Ahlstedt 2011-06-29 13:51:09 UTC
Is this the same problem as the one described in bug 653579 (gtkmm, C++
language binding)?

gtk_combo_box_text_new() sets the GtkComboBox attributes entry-text-column=0,
id-column=1. A language binding (or any other user) that uses g_object_new()
will not set those attributes, unless they are included in g_object_new's
parameter list. They will get their default values as specified in GtkComboBox.

Wouldn't it be possible (and better) to set those attributes unconditionally in
gtk_combo_box_text_constructor()?
Comment 3 Claudio Saavedra 2011-06-29 20:16:52 UTC
I put a patch for this long ago in bug 612396.
Comment 4 Kjell Ahlstedt 2011-09-23 16:30:46 UTC
GtkBuilder creates widgets with g_object_newv().
See _gtk_builder_construct(). Therefore a GtkComboBoxText created by GtkBuilder
will not work properly unless the user sets entry-text-column = 0 and
id-column = 1. No user should have to do that.

See also this message to the gtkmm-list:
http://mail.gnome.org/archives/gtkmm-list/2011-September/msg00091.html
Comment 5 Luqman 2011-10-22 23:06:57 UTC
This bug is still present (at least with the libraries shipped with Ubuntu 11.10). I'm experiencing the same issues as Mathieu Bridon with using the gir gtk3 bindings. Kjell's workaround seems to work for now.
This bug should really at least have it's status changed from unconfirmed.
Comment 6 Kjell Ahlstedt 2012-01-03 15:32:14 UTC
The gtk+ bug 612396 has been fixed. Probably this bug is then also fixed.
I have checked
1. Gtk::ComboBoxText in gtkmm (the C++ binding) with the fix in bug 653579
   undone,
2. a simple example with Glade and Gtk::Builder (also C++).

This bug concerns problems with the Python binding. I don't work with Python.
Perhaps someone else can check if the Python problems are fixed, and close this
bug if they are.
Comment 7 Jean-François Fortin Tam 2012-03-04 03:15:12 UTC
Problems with python + gtkbuilder is still there, at least with pygtk 2.24.0 in Fedora 16.

In my .ui file I have the following:

<object class="GtkComboBoxText" id="text_align">
<property name="visible">True</property>
<property name="can_focus">False</property>
<items>
  <item translatable="yes">Left</item>
  <item translatable="yes">Center</item>
  <item translatable="yes">Right</item>
</items>
</object>

And in my python code I have this line:
    foo = self.builder.get_object("text_align")

Which crashes the thing with the following error:

  TypeError: Cannot create a consistent method resolution
  order (MRO) for bases GInterface, CellEditable, CellLayout
  **
  ERROR:pygobject.c:963:pygobject_new_full: assertion failed: (tp != NULL)
  Aborting


And then, if I try the workaround from comment #4 using glade, like so:

<object class="GtkComboBoxText" id="text_align">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<items>
  <item translatable="yes">Left</item>
  <item translatable="yes">Center</item>
  <item translatable="yes">Right</item>
</items>
</object>


... I get the following:


foo.py:90: GtkWarning: Unknown property: GtkComboBoxText.id-column
  self.builder.add_from_file(os.path.join(get_ui_dir(), "texteditor.ui"))
TypeError: Cannot create a consistent method resolution
order (MRO) for bases GInterface, CellEditable, CellLayout
**
ERROR:pygobject.c:963:pygobject_new_full: assertion failed: (tp != NULL)
Aborting


Let me know if there's something else I can try or additional information I can provide.
Comment 8 Kjell Ahlstedt 2012-07-09 15:17:11 UTC
The fix in gtk+ bug 612396 comment 67 is included in gtk+ version 3.4.
If there is a version of the Python binding based on gtk+ 3.4, it might be
worth testing if this bug has been fixed there. Or in the git master branch.

As I said in comment 6, I don't work with the Python binding. I leave such a
test to someone else.
Comment 9 Mathieu Bridon 2014-11-13 22:13:50 UTC
THis seems fixed, both with my original reproducer and with Jean François GtkBuilder example.

gtk3-3.14.4-1.fc21.x86_64
pygobject3-3.14.0-1.fc21.x86_64