1use cairo;
2use gdk;
3use gdk_pixbuf;
4use gio;
5use glib::object::IsA;
6use glib::translate::*;
7use gtk_sys;
8use Widget;
9
10pub trait DragContextExtManual: 'static {
11 fn drag_finish(&self, success: bool, del: bool, time_: u32);
12
13 #[cfg(any(feature = "v3_16", feature = "dox"))]
14 fn drag_cancel(&self);
15
16 fn drag_get_source_widget(&self) -> Option<Widget>;
17
18 fn drag_set_icon_default(&self);
19
20 fn drag_set_icon_gicon<P: IsA<gio::Icon>>(&self, icon: &P, hot_x: i32, hot_y: i32);
21
22 fn drag_set_icon_name(&self, icon_name: &str, hot_x: i32, hot_y: i32);
23
24 fn drag_set_icon_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf, hot_x: i32, hot_y: i32);
25
26 fn drag_set_icon_stock(&self, stock_id: &str, hot_x: i32, hot_y: i32);
27
28 fn drag_set_icon_surface(&self, surface: &cairo::Surface);
29
30 fn drag_set_icon_widget<P: IsA<Widget>>(&self, widget: &P, hot_x: i32, hot_y: i32);
31}
32
33impl<O: IsA<gdk::DragContext>> DragContextExtManual for O {
34 fn drag_finish(&self, success: bool, del: bool, time_: u32) {
35 unsafe {
36 gtk_sys::gtk_drag_finish(
37 self.as_ref().to_glib_none().0,
38 success as i32,
39 del as i32,
40 time_,
41 )
42 };
43 }
44
45 #[cfg(any(feature = "v3_16", feature = "dox"))]
46 fn drag_cancel(&self) {
47 assert_initialized_main_thread!();
48 unsafe {
49 gtk_sys::gtk_drag_cancel(self.as_ref().to_glib_none().0);
50 }
51 }
52
53 fn drag_get_source_widget(&self) -> Option<Widget> {
54 assert_initialized_main_thread!();
55 unsafe {
56 from_glib_none(gtk_sys::gtk_drag_get_source_widget(
57 self.as_ref().to_glib_none().0,
58 ))
59 }
60 }
61
62 fn drag_set_icon_default(&self) {
63 assert_initialized_main_thread!();
64 unsafe {
65 gtk_sys::gtk_drag_set_icon_default(self.as_ref().to_glib_none().0);
66 }
67 }
68
69 fn drag_set_icon_gicon<P: IsA<gio::Icon>>(&self, icon: &P, hot_x: i32, hot_y: i32) {
70 assert_initialized_main_thread!();
71 unsafe {
72 gtk_sys::gtk_drag_set_icon_gicon(
73 self.as_ref().to_glib_none().0,
74 icon.as_ref().to_glib_none().0,
75 hot_x,
76 hot_y,
77 );
78 }
79 }
80
81 fn drag_set_icon_name(&self, icon_name: &str, hot_x: i32, hot_y: i32) {
82 assert_initialized_main_thread!();
83 unsafe {
84 gtk_sys::gtk_drag_set_icon_name(
85 self.as_ref().to_glib_none().0,
86 icon_name.to_glib_none().0,
87 hot_x,
88 hot_y,
89 );
90 }
91 }
92
93 fn drag_set_icon_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf, hot_x: i32, hot_y: i32) {
94 assert_initialized_main_thread!();
95 unsafe {
96 gtk_sys::gtk_drag_set_icon_pixbuf(
97 self.as_ref().to_glib_none().0,
98 pixbuf.to_glib_none().0,
99 hot_x,
100 hot_y,
101 );
102 }
103 }
104
105 fn drag_set_icon_stock(&self, stock_id: &str, hot_x: i32, hot_y: i32) {
106 assert_initialized_main_thread!();
107 unsafe {
108 gtk_sys::gtk_drag_set_icon_stock(
109 self.as_ref().to_glib_none().0,
110 stock_id.to_glib_none().0,
111 hot_x,
112 hot_y,
113 );
114 }
115 }
116
117 fn drag_set_icon_surface(&self, surface: &cairo::Surface) {
118 assert_initialized_main_thread!();
119 unsafe {
120 gtk_sys::gtk_drag_set_icon_surface(
121 self.as_ref().to_glib_none().0,
122 mut_override(surface.to_glib_none().0),
123 );
124 }
125 }
126
127 fn drag_set_icon_widget<P: IsA<Widget>>(&self, widget: &P, hot_x: i32, hot_y: i32) {
128 assert_initialized_main_thread!();
129 unsafe {
130 gtk_sys::gtk_drag_set_icon_widget(
131 self.as_ref().to_glib_none().0,
132 widget.as_ref().to_glib_none().0,
133 hot_x,
134 hot_y,
135 );
136 }
137 }
138}