GNOME Bugzilla – Bug 645192
GtkMenuPositionFunc vs gtk_status_icon_position_menu
Last modified: 2012-09-04 14:12:42 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.)
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".)
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.