I'm tinkering with a DRAG_DATA_GET in a custom treemodel implementing
TreeDragSource and though to fill the Gtk2::SelectionData using one of
my sub-objects (or it if possible, and myself if not).
Could the drag_data_get method take a selectiondata object which to
write to, instead of always making a new one? Per below, umm err tested
only a little bit.
--- GtkTreeDnd.xs 12 Jul 2005 08:39:21 +1000 1.9
+++ GtkTreeDnd.xs 09 Jul 2008 09:04:59 +1000
@@ -136,20 +136,29 @@
GtkTreeDragSource *drag_source
GtkTreePath *path
+=for apidoc
+Get selection data from a drag source. The data is written to
+$selection_data, or if $selection_data is not given then to a newly
+created Gtk2::SelectionData object. On success the return is the
+given or new object, or on failure the return is undef.
+=cut
### gboolean gtk_tree_drag_source_drag_data_get (GtkTreeDragSource *drag_source, GtkTreePath *path, GtkSelectionData *selection_data)
-GtkSelectionData_copy *
-gtk_tree_drag_source_drag_data_get (drag_source, path)
- GtkTreeDragSource *drag_source
- GtkTreePath *path
+void
+gtk_tree_drag_source_drag_data_get (GtkTreeDragSource *drag_source, GtkTreePath *path, GtkSelectionData *selection_data = NULL)
PREINIT:
- GtkSelectionData selection_data;
- CODE:
- if (!gtk_tree_drag_source_drag_data_get (drag_source, path,
- &selection_data))
- XSRETURN_UNDEF;
- RETVAL = &selection_data;
- OUTPUT:
- RETVAL
+ SV *ret = &PL_sv_undef;
+ PPCODE:
+ if (selection_data) {
+ if (gtk_tree_drag_source_drag_data_get (drag_source, path,
+ selection_data))
+ ret = ST(2);
+ } else {
+ GtkSelectionData new_selection_data;
+ if (gtk_tree_drag_source_drag_data_get (drag_source, path,
+ &new_selection_data))
+ ret = sv_2mortal (newSVGtkSelectionData_copy (&new_selection_data));
+ }
+ PUSHs (ret);
MODULE = Gtk2::TreeDnd PACKAGE = Gtk2::TreeDragDest PREFIX = gtk_tree_drag_dest_
_______________________________________________
gtk-perl-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list