1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#!/usr/bin/perl -w
use strict;
use Gtk2::TestHelper tests => 6;
# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/GtkDnd.t,v 1.16 2006/08/07 18:36:04 kaffeetisch Exp $
my $button = Gtk2::Button -> new("Bla");
my $window = Gtk2::Window -> new();
$window -> add($button);
$window -> realize();
$button -> realize();
# Dest ########################################################################
$button -> drag_dest_set("all", "copy",
{ target => "BITMAP", info => 23 },
{ target => "STRING", flags => ["same-app", "same-widget"], info => 42 }
);
my $list = $button -> drag_dest_get_target_list();
$button -> drag_dest_set_target_list(undef);
$button -> drag_dest_set_target_list($list);
is($list -> find(Gtk2::Gdk -> TARGET_BITMAP), 23);
is($list -> find(Gtk2::Gdk -> TARGET_STRING), 42);
my $pixbuf = Gtk2::Gdk::Pixbuf -> new("rgb", 0, 8, 10, 10);
my $event = Gtk2::Gdk::Event -> new("button-press");
my $context = Gtk2::Drag -> begin($button, $list, "default", 1, $event);
SKIP: {
skip "context test", 1 unless defined $context;
isa_ok($context, "Gtk2::Gdk::DragContext");
}
$context = $button -> drag_begin($list, "default", 1, $event);
SKIP: {
skip "context test", 1 unless defined $context;
isa_ok($context, "Gtk2::Gdk::DragContext");
}
if (defined($context)) {
# warn $button -> drag_dest_find_target($context, $list);
# $context -> finish(1, 0, 0);
# $button -> drag_get_data($context, Gtk2::Gdk -> TARGET_STRING, 0);
# warn $context -> get_source_widget();
$context -> set_icon_widget($window, 5, 5);
my $pixmap = Gtk2::Gdk::Pixmap->new ($window->window, 16, 16, -1);
$context -> set_icon_pixmap($pixmap->get_colormap, $pixmap, undef, 5, 5);
my $mask = Gtk2::Gdk::Pixmap->new ($window->window, 16, 16, 1);
$context -> set_icon_pixmap($pixmap->get_colormap, $pixmap, $mask, 5, 5);
$context -> set_icon_pixbuf($pixbuf, 5, 5);
$context -> set_icon_stock("gtk-add", 5, 5);
$context -> set_icon_default();
SKIP: {
skip "new 2.8 stuff", 0
unless Gtk2 -> CHECK_VERSION(2, 8, 0);
$context -> set_icon_name("gtk-add", 5, 5);
}
}
is($button -> drag_check_threshold(5, 5, 100, 100), 1);
$button -> drag_highlight();
$button -> drag_unhighlight();
$button -> drag_dest_set_proxy($window -> window(), "xdnd", 0);
SKIP: {
skip("2.6 stuff", 0)
unless Gtk2 -> CHECK_VERSION(2, 6, 0);
$button -> drag_dest_add_text_targets();
$button -> drag_dest_add_image_targets();
$button -> drag_dest_add_uri_targets();
}
SKIP: {
skip("2.10 stuff", 1)
unless Gtk2 -> CHECK_VERSION(2, 10, 0);
$button -> drag_dest_set_track_motion(FALSE);
ok(!$button -> drag_dest_get_track_motion());
}
$button -> drag_dest_unset();
# Source ######################################################################
$button -> drag_source_set("shift-mask", "copy",
{ target => "BITMAP", info => 23 },
{ target => "STRING", flags => ["same-app", "same-widget"], info => 42 }
);
# $button -> drag_source_set_icon(...);
$button -> drag_source_set_icon_pixbuf($pixbuf);
$button -> drag_source_set_icon_stock("gtk-quit");
SKIP: {
skip("drag_source_[sg]et_target_list is new in 2.4", 0)
unless Gtk2->CHECK_VERSION (2, 4, 0);
$list = $button -> drag_source_get_target_list();
$button -> drag_source_set_target_list(undef);
$button -> drag_source_set_target_list($list);
}
SKIP: {
skip("2.6 stuff", 0)
unless Gtk2 -> CHECK_VERSION(2, 6, 0);
$button -> drag_source_add_text_targets();
$button -> drag_source_add_image_targets();
$button -> drag_source_add_uri_targets();
}
SKIP: {
skip("2.8 stuff", 0)
unless Gtk2 -> CHECK_VERSION(2, 8, 0);
$button -> drag_source_set_icon_name("gtk-ok");
}
$button -> drag_source_unset();
__END__
Copyright (C) 2003-2006 by the gtk2-perl team (see the file AUTHORS for
the full list). See LICENSE for more information.
|