webkit2gtk/auto/
file_chooser_request.rs1use glib::{
6 prelude::*,
7 signal::{connect_raw, SignalHandlerId},
8 translate::*,
9};
10use std::boxed::Box as Box_;
11
12glib::wrapper! {
13 #[doc(alias = "WebKitFileChooserRequest")]
14 pub struct FileChooserRequest(Object<ffi::WebKitFileChooserRequest, ffi::WebKitFileChooserRequestClass>);
15
16 match fn {
17 type_ => || ffi::webkit_file_chooser_request_get_type(),
18 }
19}
20
21impl FileChooserRequest {
22 pub const NONE: Option<&'static FileChooserRequest> = None;
23}
24
25mod sealed {
26 pub trait Sealed {}
27 impl<T: super::IsA<super::FileChooserRequest>> Sealed for T {}
28}
29
30pub trait FileChooserRequestExt: IsA<FileChooserRequest> + sealed::Sealed + 'static {
31 #[doc(alias = "webkit_file_chooser_request_cancel")]
32 fn cancel(&self) {
33 unsafe {
34 ffi::webkit_file_chooser_request_cancel(self.as_ref().to_glib_none().0);
35 }
36 }
37
38 #[doc(alias = "webkit_file_chooser_request_get_mime_types")]
39 #[doc(alias = "get_mime_types")]
40 fn mime_types(&self) -> Vec<glib::GString> {
41 unsafe {
42 FromGlibPtrContainer::from_glib_none(ffi::webkit_file_chooser_request_get_mime_types(
43 self.as_ref().to_glib_none().0,
44 ))
45 }
46 }
47
48 #[doc(alias = "webkit_file_chooser_request_get_mime_types_filter")]
49 #[doc(alias = "get_mime_types_filter")]
50 fn mime_types_filter(&self) -> Option<gtk::FileFilter> {
51 unsafe {
52 from_glib_none(ffi::webkit_file_chooser_request_get_mime_types_filter(
53 self.as_ref().to_glib_none().0,
54 ))
55 }
56 }
57
58 #[doc(alias = "webkit_file_chooser_request_get_select_multiple")]
59 #[doc(alias = "get_select_multiple")]
60 fn selects_multiple(&self) -> bool {
61 unsafe {
62 from_glib(ffi::webkit_file_chooser_request_get_select_multiple(
63 self.as_ref().to_glib_none().0,
64 ))
65 }
66 }
67
68 #[doc(alias = "webkit_file_chooser_request_get_selected_files")]
69 #[doc(alias = "get_selected_files")]
70 fn selected_files(&self) -> Vec<glib::GString> {
71 unsafe {
72 FromGlibPtrContainer::from_glib_none(ffi::webkit_file_chooser_request_get_selected_files(
73 self.as_ref().to_glib_none().0,
74 ))
75 }
76 }
77
78 #[doc(alias = "webkit_file_chooser_request_select_files")]
79 fn select_files(&self, files: &[&str]) {
80 unsafe {
81 ffi::webkit_file_chooser_request_select_files(
82 self.as_ref().to_glib_none().0,
83 files.to_glib_none().0,
84 );
85 }
86 }
87
88 fn filter(&self) -> Option<gtk::FileFilter> {
89 ObjectExt::property(self.as_ref(), "filter")
90 }
91
92 #[doc(alias = "filter")]
93 fn connect_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
94 unsafe extern "C" fn notify_filter_trampoline<
95 P: IsA<FileChooserRequest>,
96 F: Fn(&P) + 'static,
97 >(
98 this: *mut ffi::WebKitFileChooserRequest,
99 _param_spec: glib::ffi::gpointer,
100 f: glib::ffi::gpointer,
101 ) {
102 let f: &F = &*(f as *const F);
103 f(FileChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
104 }
105 unsafe {
106 let f: Box_<F> = Box_::new(f);
107 connect_raw(
108 self.as_ptr() as *mut _,
109 b"notify::filter\0".as_ptr() as *const _,
110 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
111 notify_filter_trampoline::<Self, F> as *const (),
112 )),
113 Box_::into_raw(f),
114 )
115 }
116 }
117
118 #[doc(alias = "mime-types")]
119 fn connect_mime_types_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
120 unsafe extern "C" fn notify_mime_types_trampoline<
121 P: IsA<FileChooserRequest>,
122 F: Fn(&P) + 'static,
123 >(
124 this: *mut ffi::WebKitFileChooserRequest,
125 _param_spec: glib::ffi::gpointer,
126 f: glib::ffi::gpointer,
127 ) {
128 let f: &F = &*(f as *const F);
129 f(FileChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
130 }
131 unsafe {
132 let f: Box_<F> = Box_::new(f);
133 connect_raw(
134 self.as_ptr() as *mut _,
135 b"notify::mime-types\0".as_ptr() as *const _,
136 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
137 notify_mime_types_trampoline::<Self, F> as *const (),
138 )),
139 Box_::into_raw(f),
140 )
141 }
142 }
143
144 #[doc(alias = "select-multiple")]
145 fn connect_select_multiple_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
146 unsafe extern "C" fn notify_select_multiple_trampoline<
147 P: IsA<FileChooserRequest>,
148 F: Fn(&P) + 'static,
149 >(
150 this: *mut ffi::WebKitFileChooserRequest,
151 _param_spec: glib::ffi::gpointer,
152 f: glib::ffi::gpointer,
153 ) {
154 let f: &F = &*(f as *const F);
155 f(FileChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
156 }
157 unsafe {
158 let f: Box_<F> = Box_::new(f);
159 connect_raw(
160 self.as_ptr() as *mut _,
161 b"notify::select-multiple\0".as_ptr() as *const _,
162 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
163 notify_select_multiple_trampoline::<Self, F> as *const (),
164 )),
165 Box_::into_raw(f),
166 )
167 }
168 }
169
170 #[doc(alias = "selected-files")]
171 fn connect_selected_files_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
172 unsafe extern "C" fn notify_selected_files_trampoline<
173 P: IsA<FileChooserRequest>,
174 F: Fn(&P) + 'static,
175 >(
176 this: *mut ffi::WebKitFileChooserRequest,
177 _param_spec: glib::ffi::gpointer,
178 f: glib::ffi::gpointer,
179 ) {
180 let f: &F = &*(f as *const F);
181 f(FileChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
182 }
183 unsafe {
184 let f: Box_<F> = Box_::new(f);
185 connect_raw(
186 self.as_ptr() as *mut _,
187 b"notify::selected-files\0".as_ptr() as *const _,
188 Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
189 notify_selected_files_trampoline::<Self, F> as *const (),
190 )),
191 Box_::into_raw(f),
192 )
193 }
194 }
195}
196
197impl<O: IsA<FileChooserRequest>> FileChooserRequestExt for O {}