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 670575 - GtkSeparatorMenuItem looks wrong
GtkSeparatorMenuItem looks wrong
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-02-22 03:25 UTC by drcouzelis
Modified: 2012-06-26 04:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
C version looks correct (1.17 KB, text/x-csrc)
2012-02-22 03:25 UTC, drcouzelis
  Details
Python version looks incorrect (573 bytes, text/x-python)
2012-02-22 03:25 UTC, drcouzelis
  Details
Only passes "label" in the Gtk.MenuItem constructor if it is set. (1.20 KB, patch)
2012-06-25 16:21 UTC, Micah Carrick
none Details | Review

Description drcouzelis 2012-02-22 03:25:00 UTC
Created attachment 208178 [details]
C version looks correct

The GtkSeparatorMenuItem widgets in the menubar look wrong. There should be a horizontal line separating the menu items, but instead, there is only an empty space. In other words, there's a space separating the two menu items, but there's no horizontal line.

I'm using Gtk 3.2.3 and Python 3.2.2. I'm using the default Gtk theme.

I don't see this problem when using Gtk in C. I'll attach two example applications: one in C and one in Python. I wrote them to be as similar to each other as possible. The C version displays correctly and the Python version displays incorrectly.

Thank you.
Comment 1 drcouzelis 2012-02-22 03:25:41 UTC
Created attachment 208179 [details]
Python version looks incorrect
Comment 2 johnp 2012-02-22 16:55:35 UTC
Workaround for now is to use Gtk.SeparatorMenuItem.new().  This is weird because gtk_seperator_menu_item_new uses g_object_new to create the object so behaviour should be the same.  There is definitely a bug somewhere.
Comment 3 Tomeu Vizoso 2012-02-22 17:46:49 UTC
Wonder if it has to do with overrides.
Comment 4 Martin Pitt 2012-02-27 07:27:13 UTC
I tried this here with both Python 2.7.2 and Python 3.2.2, with pygobject 3.1.1 and GTK 3.3.16 and it works fine. I see the separator even with Gtk.SeparatorMenuItem(), but also with Gtk.SeparatorMenuItem().

gtk_separator_menu_item_new() does not do anything magic, just calls g_object_new(), so the reason is not the GObject vs. the real constructor, and there is no override. The constructor also did not change since GTK 3.2.

So I'm afraid I cannot reproduce this.
Comment 5 Martin Pitt 2012-04-23 06:38:08 UTC
Can reproduce with pygobject 3.2.0.
Comment 6 Micah Carrick 2012-06-25 16:21:01 UTC
Created attachment 217225 [details] [review]
Only passes "label" in the Gtk.MenuItem constructor if it is set.
Comment 7 Micah Carrick 2012-06-25 16:21:15 UTC
I can reproduce and I have a proposed fix.

Anytime the "label" or "use-underline" properties are accessed in GtkMenuItem it calls gtk_menu_item_ensure_label() which creates the child GtkAccelLabel widget. It only renders the menu item as a separator if there is no child widget. 

The override for Gtk.MenuItem passes `None` for the "label" which results in an empty GtkAccelLabel being created for the label. Thus the widget is not drawn as a separator since it has a child. The same effect happens if you try to get the "label" property on a GtkSeparatorMenuItem (in Python or C).

The Gtk.SeparatorMenuItem.new() function obviously does not touch "label" so it works.

I'm not sure if this is the *right* fix, but, only using the "label" keyword argument property if it is actually set in the Gtk.MenuItem override seems to work. I'll attached a patch
Comment 8 Martin Pitt 2012-06-26 04:11:49 UTC
Nice catch, thank you! Committed.