TreeDragSource stack



This is the drag_data_get I think I mentioned before but didn't post,
it's a usual one for an interface implementable in perl.

--- GtkTreeDnd.xs       08 Oct 2008 09:41:01 +1100      1.12
+++ GtkTreeDnd.xs       08 Oct 2008 09:41:34 +1100      
@@ -148,7 +148,7 @@
 gtk_tree_drag_source_drag_data_get (GtkTreeDragSource *drag_source, GtkTreePath *path, GtkSelectionData 
*selection_data = NULL)
     PREINIT:
        SV *ret = &PL_sv_undef;
-    PPCODE:
+    CODE:
        if (selection_data) {
                if (gtk_tree_drag_source_drag_data_get (drag_source, path,
                                                        selection_data))
@@ -162,7 +162,8 @@
                                                        &new_selection_data))
                        ret = sv_2mortal (newSVGtkSelectionData_copy (&new_selection_data));
        }
-       PUSHs (ret);
+       ST(0) = ret;
+       XSRETURN(1);
 
 MODULE = Gtk2::TreeDnd PACKAGE = Gtk2::TreeDragDest    PREFIX = gtk_tree_drag_dest_
 
@@ -206,6 +207,8 @@
 
 ## gboolean gtk_tree_get_row_drag_data (GtkSelectionData *selection_data, GtkTreeModel **tree_model, 
GtkTreePath **path)
 =for apidoc
+If $selection_data is not type GTK_TREE_MODEL_ROW then the return is
+an empty list.
 =for signature (tree_model, path) = $selection_data->get_row_drag_data
 =cut
 void
#!/usr/bin/perl -w
use strict;
use Gtk2::TestHelper
  tests => 7,
  noinit => 1;

# GtkTreeDragSource drag_data_get()
#
{ my $list = Gtk2::ListStore->new('Glib::String');
  $list->insert_with_values (0, 0=>'foo');
  $list->insert_with_values (1, 0=>'bar');

  # one arg returning new GtkSelectionData
  my $seldata = $list->drag_data_get (Gtk2::TreePath->new_from_indices(0));
  isa_ok($seldata, 'Gtk2::SelectionData');
  my ($model, $path) = $seldata->get_row_drag_data;
  is ($model, $list);
  is_deeply ([ 0 ], [ $path->get_indices ]);

  # storing to existing GtkSelectionData
  $list->drag_data_get (Gtk2::TreePath->new_from_indices(1), $seldata);
  ($model, $path) = $seldata->get_row_drag_data;
  is ($model, $list);
  is_deeply ([ 1 ], [ $path->get_indices ]);

  # check mortalizing
  require Scalar::Util;
  Scalar::Util::weaken ($seldata); is ($seldata, undef);
  $model = undef;
  Scalar::Util::weaken ($list);    is ($list, undef);
}

exit 0;
__END__


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