Drag and Drop with GObject introspection



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

We recently did some experiments with porting PyGtk code to PyGi and
stumbled over the Drag and Drop handling. In PyGtk nothing more than the
following is required to allow a tree view to handle file drops:

> view = gtk.TreeView()
>
> view.drag_dest_set(
>     gtk.DEST_DEFAULT_ALL,
>     [('text/uri-list', 0, 0)],
>     gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE
> )

With PyGi the equivalent function seems to be Gtk.drag_dest_set() which
yields the following attempt:

> view = Gtk.TreeView()
> target = Gtk.TargetEntry()
> target.target = 'text/uri-list'
> target.flags = 0
> target.info = 0
> 
> Gtk.drag_dest_set(
>     view,
>     Gtk.DestDefaults.ALL,
>     target,
>     1,
>     Gdk.DragAction.COPY | Gdk.DragAction.MOVE
> )

However, the assignment of the target to the respective struct member
yields the following error:

> RuntimeError: unable to set value for field

Why does the assignment to "target" fail whereas "flags" and "info" are
fine?

The GTK docs describe the "targets" parameter of Gtk.drag_dest_set() as
follows:

> a pointer to an array of GtkTargetEntrys indicating the drop types that
> this widget will accept, or NULL.

However, there obviously are no pointers in Python. So how would one
specify multiple targets here? Specify None upon Gtk.drag_dest_set() and
separately modify the target list via Gtk.drag_dest_set_target_list()?
This however also fails right at the Gtk.drag_dest_set() call with None
as target and 0 as target count:

> TypeError: argument 2: Must be Gtk.TargetEntry, not NoneType

Simply specifying a list of targets also fails, no matter the content:

> TypeError: argument 2: Must be Gtk.TargetEntry, not list

Should I just file a bug report about Drag and Drop handling in PyGi in
general?


Regards, Mathias
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxgFUMACgkQYfUFJ3ewsJi57gCff2l4VYB751QnVMuwG+Hy9pAm
i6MAn3YBt1DzNbqXCv4ZpV+PnXsxE+16
=DLQH
-----END PGP SIGNATURE-----


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