webkit2gtk/auto/
file_chooser_request.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files.git)
3// DO NOT EDIT
4
5use glib::object::Cast;
6use glib::object::IsA;
7use glib::signal::connect_raw;
8use glib::signal::SignalHandlerId;
9use glib::translate::*;
10use glib::StaticType;
11use std::boxed::Box as Box_;
12use std::fmt;
13use std::mem::transmute;
14
15glib::wrapper! {
16    #[doc(alias = "WebKitFileChooserRequest")]
17    pub struct FileChooserRequest(Object<ffi::WebKitFileChooserRequest, ffi::WebKitFileChooserRequestClass>);
18
19    match fn {
20        type_ => || ffi::webkit_file_chooser_request_get_type(),
21    }
22}
23
24pub const NONE_FILE_CHOOSER_REQUEST: Option<&FileChooserRequest> = None;
25
26pub trait FileChooserRequestExt: 'static {
27    #[doc(alias = "webkit_file_chooser_request_cancel")]
28    fn cancel(&self);
29
30    #[doc(alias = "webkit_file_chooser_request_get_mime_types")]
31    #[doc(alias = "get_mime_types")]
32    fn mime_types(&self) -> Vec<glib::GString>;
33
34    #[doc(alias = "webkit_file_chooser_request_get_mime_types_filter")]
35    #[doc(alias = "get_mime_types_filter")]
36    fn mime_types_filter(&self) -> Option<gtk::FileFilter>;
37
38    #[doc(alias = "webkit_file_chooser_request_get_select_multiple")]
39    #[doc(alias = "get_select_multiple")]
40    fn selects_multiple(&self) -> bool;
41
42    #[doc(alias = "webkit_file_chooser_request_get_selected_files")]
43    #[doc(alias = "get_selected_files")]
44    fn selected_files(&self) -> Vec<glib::GString>;
45
46    #[doc(alias = "webkit_file_chooser_request_select_files")]
47    fn select_files(&self, files: &[&str]);
48
49    fn filter(&self) -> Option<gtk::FileFilter>;
50
51    #[doc(alias = "filter")]
52    fn connect_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
53
54    #[doc(alias = "mime-types")]
55    fn connect_mime_types_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
56
57    #[doc(alias = "select-multiple")]
58    fn connect_select_multiple_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
59
60    #[doc(alias = "selected-files")]
61    fn connect_selected_files_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
62}
63
64impl<O: IsA<FileChooserRequest>> FileChooserRequestExt for O {
65    fn cancel(&self) {
66        unsafe {
67            ffi::webkit_file_chooser_request_cancel(self.as_ref().to_glib_none().0);
68        }
69    }
70
71    fn mime_types(&self) -> Vec<glib::GString> {
72        unsafe {
73            FromGlibPtrContainer::from_glib_none(ffi::webkit_file_chooser_request_get_mime_types(self.as_ref().to_glib_none().0))
74        }
75    }
76
77    fn mime_types_filter(&self) -> Option<gtk::FileFilter> {
78        unsafe {
79            from_glib_none(ffi::webkit_file_chooser_request_get_mime_types_filter(self.as_ref().to_glib_none().0))
80        }
81    }
82
83    fn selects_multiple(&self) -> bool {
84        unsafe {
85            from_glib(ffi::webkit_file_chooser_request_get_select_multiple(self.as_ref().to_glib_none().0))
86        }
87    }
88
89    fn selected_files(&self) -> Vec<glib::GString> {
90        unsafe {
91            FromGlibPtrContainer::from_glib_none(ffi::webkit_file_chooser_request_get_selected_files(self.as_ref().to_glib_none().0))
92        }
93    }
94
95    fn select_files(&self, files: &[&str]) {
96        unsafe {
97            ffi::webkit_file_chooser_request_select_files(self.as_ref().to_glib_none().0, files.to_glib_none().0);
98        }
99    }
100
101    fn filter(&self) -> Option<gtk::FileFilter> {
102        unsafe {
103            let mut value = glib::Value::from_type(<gtk::FileFilter as StaticType>::static_type());
104            glib::gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"filter\0".as_ptr() as *const _, value.to_glib_none_mut().0);
105            value.get().expect("Return Value for property `filter` getter")
106        }
107    }
108
109    fn connect_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
110        unsafe extern "C" fn notify_filter_trampoline<P: IsA<FileChooserRequest>, F: Fn(&P) + 'static>(this: *mut ffi::WebKitFileChooserRequest, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
111            let f: &F = &*(f as *const F);
112            f(FileChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
113        }
114        unsafe {
115            let f: Box_<F> = Box_::new(f);
116            connect_raw(self.as_ptr() as *mut _, b"notify::filter\0".as_ptr() as *const _,
117                Some(transmute::<_, unsafe extern "C" fn()>(notify_filter_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
118        }
119    }
120
121    fn connect_mime_types_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
122        unsafe extern "C" fn notify_mime_types_trampoline<P: IsA<FileChooserRequest>, F: Fn(&P) + 'static>(this: *mut ffi::WebKitFileChooserRequest, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
123            let f: &F = &*(f as *const F);
124            f(FileChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
125        }
126        unsafe {
127            let f: Box_<F> = Box_::new(f);
128            connect_raw(self.as_ptr() as *mut _, b"notify::mime-types\0".as_ptr() as *const _,
129                Some(transmute::<_, unsafe extern "C" fn()>(notify_mime_types_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
130        }
131    }
132
133    fn connect_select_multiple_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
134        unsafe extern "C" fn notify_select_multiple_trampoline<P: IsA<FileChooserRequest>, F: Fn(&P) + 'static>(this: *mut ffi::WebKitFileChooserRequest, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
135            let f: &F = &*(f as *const F);
136            f(FileChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
137        }
138        unsafe {
139            let f: Box_<F> = Box_::new(f);
140            connect_raw(self.as_ptr() as *mut _, b"notify::select-multiple\0".as_ptr() as *const _,
141                Some(transmute::<_, unsafe extern "C" fn()>(notify_select_multiple_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
142        }
143    }
144
145    fn connect_selected_files_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
146        unsafe extern "C" fn notify_selected_files_trampoline<P: IsA<FileChooserRequest>, F: Fn(&P) + 'static>(this: *mut ffi::WebKitFileChooserRequest, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
147            let f: &F = &*(f as *const F);
148            f(FileChooserRequest::from_glib_borrow(this).unsafe_cast_ref())
149        }
150        unsafe {
151            let f: Box_<F> = Box_::new(f);
152            connect_raw(self.as_ptr() as *mut _, b"notify::selected-files\0".as_ptr() as *const _,
153                Some(transmute::<_, unsafe extern "C" fn()>(notify_selected_files_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
154        }
155    }
156}
157
158impl fmt::Display for FileChooserRequest {
159    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
160        f.write_str("FileChooserRequest")
161    }
162}