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 639945 - Gtk.Widget does not have drag_* methods (but in pygtk it did)
Gtk.Widget does not have drag_* methods (but in pygtk it did)
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2011-01-19 13:48 UTC by Laszlo Pandy
Modified: 2015-02-07 16:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[GI] Add Gtk.drag_* functions as methods on Gtk.Widget override (for compatibility with pygtk). (5.38 KB, patch)
2011-01-19 13:48 UTC, Laszlo Pandy
accepted-commit_now Details | Review
Add (method) overrides (5.42 KB, patch)
2011-01-21 17:09 UTC, Tomeu Vizoso
reviewed Details | Review
Add (method) overrides (7.79 KB, patch)
2011-01-28 11:25 UTC, Tomeu Vizoso
committed Details | Review

Description Laszlo Pandy 2011-01-19 13:48:56 UTC
None of the drag_* methods are available on Gtk.Widget. Instead they are static methods which take a widget as the first parameter.

For example in pygtk:
mywidget.drag_dest_set(...)

Currently in GI PyGObject:
Gtk.drag_dest_set(mywidget, ...)

An override for these drag_* methods should be created so they are available on the Gtk.Widget instance.
Comment 1 Laszlo Pandy 2011-01-19 13:48:59 UTC
Created attachment 178721 [details] [review]
[GI] Add Gtk.drag_* functions as methods on Gtk.Widget override (for compatibility with pygtk).

For example: Gtk.drag_source_set(mywidget, ...) now becomes mywidget.drag_source_set(...). This is closer to the old pygtk api.
Comment 2 Tomeu Vizoso 2011-01-20 09:34:10 UTC
Hmm, if g-i had a (method) annotation, this would get fixed for all bindings without having to do overrides.

This is related to https://bugzilla.gnome.org/show_bug.cgi?id=561264
Comment 3 Laszlo Pandy 2011-01-20 10:28:16 UTC
Yes, (method) would be the preferred way to fix this. If that happens I can change the patch because my patch also includes a test for these methods.
Comment 4 Tomeu Vizoso 2011-01-21 16:38:22 UTC
This should really be fixed in the typelib, so all bindings benefit.
Comment 5 Tomeu Vizoso 2011-01-21 17:09:27 UTC
Created attachment 178972 [details] [review]
Add (method) overrides

So methods such as gtk_drag_dest_set() can be put inside Gtk.Widget
Comment 6 Colin Walters 2011-01-21 19:54:28 UTC
Review of attachment 178972 [details] [review]:

::: giscanner/maintransformer.py
@@ +948,2 @@
         target.methods.append(func)
+

While I know there's some duplicate code, I think it's weird to have the handling for when we *know* a function is already a method be handled in _pair_method, especially because at that point we will have already e.g. tried to call _pair_constructor().

I think this would be better to do like:

def _pair_function():
  if is_method:
    _set_up_stuff_for_method()
  else
    _pair_constructor()
    _pair_function()
    _pair_static()

And in _pair_function() call the common _set_up_stuff_for_method() which basically does:

        func.instance_parameter = func.parameters.pop(0)
        subsym_idx = func.symbol.find(subsymbol)
        self._namespace.float(func)
        func.name = func.symbol[(subsym_idx + len(uscored_prefix) + 1):]
        target.methods.append(func)
Comment 7 Tomeu Vizoso 2011-01-28 11:25:01 UTC
Created attachment 179501 [details] [review]
Add (method) overrides

So methods such as gtk_drag_dest_set() can be put inside Gtk.Widget

Split setting up the method and getting the uscored_prefix to separate functions.
Comment 8 Colin Walters 2011-02-02 15:02:06 UTC
Review of attachment 179501 [details] [review]:

This looks OK, I guess my concern here is it feels like a one-off for the legacy gtkdrag.h stuff.  But OK, better than the alternative.
Comment 9 Tomeu Vizoso 2011-02-02 15:18:01 UTC
Attachment 179501 [details] pushed as 09bca85 - Add (method) overrides
Comment 10 Martin Pitt 2011-02-02 16:54:18 UTC
Now that the g-i fix has landed (thanks Tomeu!) I fixed the overrides in GTK:

http://git.gnome.org/browse/gtk+/commit/?id=1bd36ce72365408ed768ba2d4ec50edd9321283f
Comment 11 Laszlo Pandy 2011-02-03 14:24:32 UTC
I've added the (method) attribute for a few drag_* functions Martin missed, as well as gtk_grab_add() and gtk_grab_remove().

http://git.gnome.org/browse/gtk+/commit/?id=295c2fe8d157d67e390fa3819856c7d2d4c4e7a1
http://git.gnome.org/browse/gtk+/commit/?id=395b13bbcef1e4b9cda2fb2c3883998f6457ea66
Comment 12 Laszlo Pandy 2011-02-03 14:50:46 UTC
Now that all methods are annotated as such, I have committed the tests for pygobject introspection from my original patch on this bug. It checks that all the drag_* methods exist on Gtk widgets and are callable.

http://git.gnome.org/browse/pygobject/commit/?id=2660be1f227be7a53092483bc9d8ead1bd1fb266
Comment 13 André Klapper 2015-02-07 16:56:24 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]