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 645192 - GtkMenuPositionFunc vs gtk_status_icon_position_menu
GtkMenuPositionFunc vs gtk_status_icon_position_menu
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkStatusIcon
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-03-19 00:14 UTC by chrysn
Modified: 2012-09-04 14:12 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description chrysn 2011-03-19 00:14:04 UTC
there is a discrepancy between GtkMenuPositionFunc and gtk_status_icon_position_menu (the latter is intended to be dropped into the former's slot with a StatusIcon as user_data):

the push_in argument is labeled inout in gtkmenu.h (GtkMenuPositionFunc), but out in gtkstatusicon.c (gtk_status_icon_position_menu).

this becomes a problem in gir generated bindings, where it causes the functions not to "fit". (Gtk.StatusIcon.position_menu is called with (menu, push_in, my_icon) while expecting (menu, my_icon); it returns the correct (x, y, push_in) triple)

my problem with fixing it is that i'm not sure which is correct. it seems that it would be ok if the PositionFunc decided alone whether or not to set push_in, but it could just as well be passed a default value it would just pass on if it is not interested in changing it (one could argue that x and y should be inout as well in that case). the current implementation of gtk_menu_popup(_for_device) (or, rather, gtk_menu_position, from where the GtkMenuPositionFunc stored in priv->position_func is called) constantly sets pushed_in to FALSE before passing the pointer to the function. (x and y seem to be set to sensible values as well.)

a workaround exists and, for python, looks like this:

my_position_menu = lambda menu, push_in, userdata: Gtk.StatusIcon.position_menu(menu, userdata)

i can provide a patch for either solution (setting both to inout or out), i'd just need to know which way to go.

(finally, i should add that there seems to exist another problem later in popup menu positioning that causes the popup not to show at all unless i raise an exception from inside the GtkMenuPositionFunc, but that should be easier to debug once this is fixed.)
Comment 1 Torsten Schoenfeld 2012-04-21 18:33:28 UTC
All three parameters (x, y, push_in) are now consistently labeled as "out" in gtkmenu.h and gtkstatusicon.c.  So I think this report can be closed.

(But see bug 674537 for why I think x and y should be "inout".)
Comment 2 chrysn 2012-09-04 14:12:42 UTC
the function signatures match now, and it is possible to run a popup as

the_menu.popup(None, None, Gtk.StatusIcon.position_menu, the_icon, button, activate_time)

as it is intended.

the exception raising problem hinted at in the last paragraph seems to be fixed too by now; closing this.