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
137
138
139
140
141
142
143
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::Widget;
use glib::object::IsA;
use glib::translate::*;

pub trait DragContextExtManual: 'static {
    #[doc(alias = "gtk_drag_finish")]
    fn drag_finish(&self, success: bool, del: bool, time_: u32);

    #[doc(alias = "gtk_drag_cancel")]
    fn drag_cancel(&self);

    #[doc(alias = "gtk_drag_get_source_widget")]
    fn drag_get_source_widget(&self) -> Option<Widget>;

    #[doc(alias = "gtk_drag_set_icon_default")]
    fn drag_set_icon_default(&self);

    #[doc(alias = "gtk_drag_set_icon_gicon")]
    fn drag_set_icon_gicon<P: IsA<gio::Icon>>(&self, icon: &P, hot_x: i32, hot_y: i32);

    #[doc(alias = "gtk_drag_set_icon_name")]
    fn drag_set_icon_name(&self, icon_name: &str, hot_x: i32, hot_y: i32);

    #[doc(alias = "gtk_drag_set_icon_pixbuf")]
    fn drag_set_icon_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf, hot_x: i32, hot_y: i32);

    #[doc(alias = "gtk_drag_set_icon_stock")]
    fn drag_set_icon_stock(&self, stock_id: &str, hot_x: i32, hot_y: i32);

    #[doc(alias = "gtk_drag_set_icon_surface")]
    fn drag_set_icon_surface(&self, surface: &cairo::Surface);

    #[doc(alias = "gtk_drag_set_icon_widget")]
    fn drag_set_icon_widget<P: IsA<Widget>>(&self, widget: &P, hot_x: i32, hot_y: i32);
}

impl<O: IsA<gdk::DragContext>> DragContextExtManual for O {
    fn drag_finish(&self, success: bool, del: bool, time_: u32) {
        unsafe {
            ffi::gtk_drag_finish(
                self.as_ref().to_glib_none().0,
                success as i32,
                del as i32,
                time_,
            )
        };
    }

    fn drag_cancel(&self) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_drag_cancel(self.as_ref().to_glib_none().0);
        }
    }

    fn drag_get_source_widget(&self) -> Option<Widget> {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::gtk_drag_get_source_widget(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn drag_set_icon_default(&self) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_drag_set_icon_default(self.as_ref().to_glib_none().0);
        }
    }

    fn drag_set_icon_gicon<P: IsA<gio::Icon>>(&self, icon: &P, hot_x: i32, hot_y: i32) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_drag_set_icon_gicon(
                self.as_ref().to_glib_none().0,
                icon.as_ref().to_glib_none().0,
                hot_x,
                hot_y,
            );
        }
    }

    fn drag_set_icon_name(&self, icon_name: &str, hot_x: i32, hot_y: i32) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_drag_set_icon_name(
                self.as_ref().to_glib_none().0,
                icon_name.to_glib_none().0,
                hot_x,
                hot_y,
            );
        }
    }

    fn drag_set_icon_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf, hot_x: i32, hot_y: i32) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_drag_set_icon_pixbuf(
                self.as_ref().to_glib_none().0,
                pixbuf.to_glib_none().0,
                hot_x,
                hot_y,
            );
        }
    }

    fn drag_set_icon_stock(&self, stock_id: &str, hot_x: i32, hot_y: i32) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_drag_set_icon_stock(
                self.as_ref().to_glib_none().0,
                stock_id.to_glib_none().0,
                hot_x,
                hot_y,
            );
        }
    }

    fn drag_set_icon_surface(&self, surface: &cairo::Surface) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_drag_set_icon_surface(
                self.as_ref().to_glib_none().0,
                mut_override(surface.to_glib_none().0),
            );
        }
    }

    fn drag_set_icon_widget<P: IsA<Widget>>(&self, widget: &P, hot_x: i32, hot_y: i32) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_drag_set_icon_widget(
                self.as_ref().to_glib_none().0,
                widget.as_ref().to_glib_none().0,
                hot_x,
                hot_y,
            );
        }
    }
}