Re: wrong binding of binding of Gtk2::StatusIcon->position_menu() ?

On Sep 6, 2007, at 3:06 PM, Torsten Schoenfeld wrote:

Now that I look at some code and documentation, though, I see that the
callback marshaller is probably in error to pass the x, y pair.  The
docs clearly say that "[t]his is an output parameter" for x and y.

If you look at gtk_menu_popup(), however, the function calculates a decent starting value for x and y before passing their addresses to the caller's position callback. As written, the callback marshaler will preserve the values that were passed in if the callback does not modify them, same as a C function would. I have a vague recollection of trying to retain that behavior for compatibility with some C code i had around at the time.

Any suggestions for a solution?

It's far too late to change the callback marshaler in GtkMenu.xs, as it has been that way pretty much since the function was first bound.

I'd say that for Gtk2::StatusIcon::position_menu(), we can make the x and y arguments optional. User code calling it directly needn't pass the arguments, but the function will still accept them for compatibility with any existing code, including the callback marshaler. E.g.,

=for apidoc
=for signature (x, y, push_in) = Gtk2::StatusIcon::position_menu (menu, icon) =for signature (x, y, push_in) = Gtk2::StatusIcon::position_menu (menu, x, y, icon)
=for arg icon (Gtk2::StatusIcon)
This function takes four arguments so that it may be passed directly as the menu position callback to Gtk2::Menu::popup(), which passes in initial x and y values for historical reasons. Otherwise, you need only pass two arguments.
gtk_status_icon_position_menu (GtkMenu *menu, ...)
        gboolean push_in;
        gint x, y;
        GtkStatusIcon *icon;
        if (items == 4) {
                /* Compatibility mode */
                x = (gint) SvIV (ST (1));
                y = (gint) SvIV (ST (2));
                icon = SvGtkStatusIcon (ST (3));
        } else
                icon = SvGtkStatusIcon (ST (1));
        gtk_status_icon_position_menu (menu, &x, &y, &push_in, icon);
        EXTEND (sp, 3);
        PUSHs (sv_2mortal (newSViv (x)));
        PUSHs (sv_2mortal (newSViv (y)));
        PUSHs (sv_2mortal (newSVuv (push_in)));

Doing a good job around here is like wetting your pants in a dark suit; you get a warm feeling, but no one notices.
  -- unknown

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]