1 // This file was generated by gir (https://github.com/gtk-rs/gir)
2 // from gir-files (https://github.com/gtk-rs/gir-files)
3 // DO NOT EDIT
4 
5 use glib::object::Cast;
6 use glib::object::IsA;
7 use glib::signal::connect_raw;
8 use glib::signal::SignalHandlerId;
9 use glib::translate::*;
10 use std::boxed::Box as Box_;
11 use std::fmt;
12 use std::mem::transmute;
13 
14 glib::wrapper! {
15     #[doc(alias = "GtkAccelGroup")]
16     pub struct AccelGroup(Object<ffi::GtkAccelGroup, ffi::GtkAccelGroupClass>);
17 
18     match fn {
19         type_ => || ffi::gtk_accel_group_get_type(),
20     }
21 }
22 
23 impl AccelGroup {
24     #[doc(alias = "gtk_accel_group_new")]
new() -> AccelGroup25     pub fn new() -> AccelGroup {
26         assert_initialized_main_thread!();
27         unsafe { from_glib_full(ffi::gtk_accel_group_new()) }
28     }
29 
30     #[doc(alias = "gtk_accel_group_from_accel_closure")]
from_accel_closure(closure: &glib::Closure) -> Option<AccelGroup>31     pub fn from_accel_closure(closure: &glib::Closure) -> Option<AccelGroup> {
32         assert_initialized_main_thread!();
33         unsafe {
34             from_glib_none(ffi::gtk_accel_group_from_accel_closure(
35                 closure.to_glib_none().0,
36             ))
37         }
38     }
39 }
40 
41 impl Default for AccelGroup {
default() -> Self42     fn default() -> Self {
43         Self::new()
44     }
45 }
46 
47 pub const NONE_ACCEL_GROUP: Option<&AccelGroup> = None;
48 
49 pub trait AccelGroupExt: 'static {
50     #[doc(alias = "gtk_accel_group_activate")]
activate<P: IsA<glib::Object>>( &self, accel_quark: glib::Quark, acceleratable: &P, accel_key: u32, accel_mods: gdk::ModifierType, ) -> bool51     fn activate<P: IsA<glib::Object>>(
52         &self,
53         accel_quark: glib::Quark,
54         acceleratable: &P,
55         accel_key: u32,
56         accel_mods: gdk::ModifierType,
57     ) -> bool;
58 
59     #[doc(alias = "gtk_accel_group_disconnect")]
disconnect(&self, closure: Option<&glib::Closure>) -> bool60     fn disconnect(&self, closure: Option<&glib::Closure>) -> bool;
61 
62     #[doc(alias = "gtk_accel_group_disconnect_key")]
disconnect_key(&self, accel_key: u32, accel_mods: gdk::ModifierType) -> bool63     fn disconnect_key(&self, accel_key: u32, accel_mods: gdk::ModifierType) -> bool;
64 
65     //#[doc(alias = "gtk_accel_group_find")]
66     //fn find(&self, find_func: /*Unimplemented*/FnMut(/*Ignored*/AccelKey, &glib::Closure) -> bool, data: /*Unimplemented*/Option<Fundamental: Pointer>) -> /*Ignored*/Option<AccelKey>;
67 
68     #[doc(alias = "gtk_accel_group_get_is_locked")]
69     #[doc(alias = "get_is_locked")]
is_locked(&self) -> bool70     fn is_locked(&self) -> bool;
71 
72     #[doc(alias = "gtk_accel_group_get_modifier_mask")]
73     #[doc(alias = "get_modifier_mask")]
modifier_mask(&self) -> gdk::ModifierType74     fn modifier_mask(&self) -> gdk::ModifierType;
75 
76     #[doc(alias = "gtk_accel_group_lock")]
lock(&self)77     fn lock(&self);
78 
79     #[doc(alias = "gtk_accel_group_unlock")]
unlock(&self)80     fn unlock(&self);
81 
82     #[doc(alias = "accel-activate")]
connect_accel_activate< F: Fn(&Self, &glib::Object, u32, gdk::ModifierType) -> bool + 'static, >( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId83     fn connect_accel_activate<
84         F: Fn(&Self, &glib::Object, u32, gdk::ModifierType) -> bool + 'static,
85     >(
86         &self,
87         detail: Option<&str>,
88         f: F,
89     ) -> SignalHandlerId;
90 
91     #[doc(alias = "accel-changed")]
connect_accel_changed<F: Fn(&Self, u32, gdk::ModifierType, &glib::Closure) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId92     fn connect_accel_changed<F: Fn(&Self, u32, gdk::ModifierType, &glib::Closure) + 'static>(
93         &self,
94         detail: Option<&str>,
95         f: F,
96     ) -> SignalHandlerId;
97 
98     #[doc(alias = "is-locked")]
connect_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId99     fn connect_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
100 
101     #[doc(alias = "modifier-mask")]
connect_modifier_mask_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId102     fn connect_modifier_mask_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
103 }
104 
105 impl<O: IsA<AccelGroup>> AccelGroupExt for O {
activate<P: IsA<glib::Object>>( &self, accel_quark: glib::Quark, acceleratable: &P, accel_key: u32, accel_mods: gdk::ModifierType, ) -> bool106     fn activate<P: IsA<glib::Object>>(
107         &self,
108         accel_quark: glib::Quark,
109         acceleratable: &P,
110         accel_key: u32,
111         accel_mods: gdk::ModifierType,
112     ) -> bool {
113         unsafe {
114             from_glib(ffi::gtk_accel_group_activate(
115                 self.as_ref().to_glib_none().0,
116                 accel_quark.into_glib(),
117                 acceleratable.as_ref().to_glib_none().0,
118                 accel_key,
119                 accel_mods.into_glib(),
120             ))
121         }
122     }
123 
disconnect(&self, closure: Option<&glib::Closure>) -> bool124     fn disconnect(&self, closure: Option<&glib::Closure>) -> bool {
125         unsafe {
126             from_glib(ffi::gtk_accel_group_disconnect(
127                 self.as_ref().to_glib_none().0,
128                 closure.to_glib_none().0,
129             ))
130         }
131     }
132 
disconnect_key(&self, accel_key: u32, accel_mods: gdk::ModifierType) -> bool133     fn disconnect_key(&self, accel_key: u32, accel_mods: gdk::ModifierType) -> bool {
134         unsafe {
135             from_glib(ffi::gtk_accel_group_disconnect_key(
136                 self.as_ref().to_glib_none().0,
137                 accel_key,
138                 accel_mods.into_glib(),
139             ))
140         }
141     }
142 
143     //fn find(&self, find_func: /*Unimplemented*/FnMut(/*Ignored*/AccelKey, &glib::Closure) -> bool, data: /*Unimplemented*/Option<Fundamental: Pointer>) -> /*Ignored*/Option<AccelKey> {
144     //    unsafe { TODO: call ffi:gtk_accel_group_find() }
145     //}
146 
is_locked(&self) -> bool147     fn is_locked(&self) -> bool {
148         unsafe {
149             from_glib(ffi::gtk_accel_group_get_is_locked(
150                 self.as_ref().to_glib_none().0,
151             ))
152         }
153     }
154 
modifier_mask(&self) -> gdk::ModifierType155     fn modifier_mask(&self) -> gdk::ModifierType {
156         unsafe {
157             from_glib(ffi::gtk_accel_group_get_modifier_mask(
158                 self.as_ref().to_glib_none().0,
159             ))
160         }
161     }
162 
lock(&self)163     fn lock(&self) {
164         unsafe {
165             ffi::gtk_accel_group_lock(self.as_ref().to_glib_none().0);
166         }
167     }
168 
unlock(&self)169     fn unlock(&self) {
170         unsafe {
171             ffi::gtk_accel_group_unlock(self.as_ref().to_glib_none().0);
172         }
173     }
174 
connect_accel_activate< F: Fn(&Self, &glib::Object, u32, gdk::ModifierType) -> bool + 'static, >( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId175     fn connect_accel_activate<
176         F: Fn(&Self, &glib::Object, u32, gdk::ModifierType) -> bool + 'static,
177     >(
178         &self,
179         detail: Option<&str>,
180         f: F,
181     ) -> SignalHandlerId {
182         unsafe extern "C" fn accel_activate_trampoline<
183             P: IsA<AccelGroup>,
184             F: Fn(&P, &glib::Object, u32, gdk::ModifierType) -> bool + 'static,
185         >(
186             this: *mut ffi::GtkAccelGroup,
187             acceleratable: *mut glib::gobject_ffi::GObject,
188             keyval: libc::c_uint,
189             modifier: gdk::ffi::GdkModifierType,
190             f: glib::ffi::gpointer,
191         ) -> glib::ffi::gboolean {
192             let f: &F = &*(f as *const F);
193             f(
194                 AccelGroup::from_glib_borrow(this).unsafe_cast_ref(),
195                 &from_glib_borrow(acceleratable),
196                 keyval,
197                 from_glib(modifier),
198             )
199             .into_glib()
200         }
201         unsafe {
202             let f: Box_<F> = Box_::new(f);
203             let detailed_signal_name = detail.map(|name| format!("accel-activate::{}\0", name));
204             let signal_name: &[u8] = detailed_signal_name
205                 .as_ref()
206                 .map_or(&b"accel-activate\0"[..], |n| n.as_bytes());
207             connect_raw(
208                 self.as_ptr() as *mut _,
209                 signal_name.as_ptr() as *const _,
210                 Some(transmute::<_, unsafe extern "C" fn()>(
211                     accel_activate_trampoline::<Self, F> as *const (),
212                 )),
213                 Box_::into_raw(f),
214             )
215         }
216     }
217 
connect_accel_changed<F: Fn(&Self, u32, gdk::ModifierType, &glib::Closure) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId218     fn connect_accel_changed<F: Fn(&Self, u32, gdk::ModifierType, &glib::Closure) + 'static>(
219         &self,
220         detail: Option<&str>,
221         f: F,
222     ) -> SignalHandlerId {
223         unsafe extern "C" fn accel_changed_trampoline<
224             P: IsA<AccelGroup>,
225             F: Fn(&P, u32, gdk::ModifierType, &glib::Closure) + 'static,
226         >(
227             this: *mut ffi::GtkAccelGroup,
228             keyval: libc::c_uint,
229             modifier: gdk::ffi::GdkModifierType,
230             accel_closure: *mut glib::gobject_ffi::GClosure,
231             f: glib::ffi::gpointer,
232         ) {
233             let f: &F = &*(f as *const F);
234             f(
235                 AccelGroup::from_glib_borrow(this).unsafe_cast_ref(),
236                 keyval,
237                 from_glib(modifier),
238                 &from_glib_borrow(accel_closure),
239             )
240         }
241         unsafe {
242             let f: Box_<F> = Box_::new(f);
243             let detailed_signal_name = detail.map(|name| format!("accel-changed::{}\0", name));
244             let signal_name: &[u8] = detailed_signal_name
245                 .as_ref()
246                 .map_or(&b"accel-changed\0"[..], |n| n.as_bytes());
247             connect_raw(
248                 self.as_ptr() as *mut _,
249                 signal_name.as_ptr() as *const _,
250                 Some(transmute::<_, unsafe extern "C" fn()>(
251                     accel_changed_trampoline::<Self, F> as *const (),
252                 )),
253                 Box_::into_raw(f),
254             )
255         }
256     }
257 
connect_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId258     fn connect_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
259         unsafe extern "C" fn notify_is_locked_trampoline<
260             P: IsA<AccelGroup>,
261             F: Fn(&P) + 'static,
262         >(
263             this: *mut ffi::GtkAccelGroup,
264             _param_spec: glib::ffi::gpointer,
265             f: glib::ffi::gpointer,
266         ) {
267             let f: &F = &*(f as *const F);
268             f(AccelGroup::from_glib_borrow(this).unsafe_cast_ref())
269         }
270         unsafe {
271             let f: Box_<F> = Box_::new(f);
272             connect_raw(
273                 self.as_ptr() as *mut _,
274                 b"notify::is-locked\0".as_ptr() as *const _,
275                 Some(transmute::<_, unsafe extern "C" fn()>(
276                     notify_is_locked_trampoline::<Self, F> as *const (),
277                 )),
278                 Box_::into_raw(f),
279             )
280         }
281     }
282 
connect_modifier_mask_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId283     fn connect_modifier_mask_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
284         unsafe extern "C" fn notify_modifier_mask_trampoline<
285             P: IsA<AccelGroup>,
286             F: Fn(&P) + 'static,
287         >(
288             this: *mut ffi::GtkAccelGroup,
289             _param_spec: glib::ffi::gpointer,
290             f: glib::ffi::gpointer,
291         ) {
292             let f: &F = &*(f as *const F);
293             f(AccelGroup::from_glib_borrow(this).unsafe_cast_ref())
294         }
295         unsafe {
296             let f: Box_<F> = Box_::new(f);
297             connect_raw(
298                 self.as_ptr() as *mut _,
299                 b"notify::modifier-mask\0".as_ptr() as *const _,
300                 Some(transmute::<_, unsafe extern "C" fn()>(
301                     notify_modifier_mask_trampoline::<Self, F> as *const (),
302                 )),
303                 Box_::into_raw(f),
304             )
305         }
306     }
307 }
308 
309 impl fmt::Display for AccelGroup {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result310     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
311         f.write_str("AccelGroup")
312     }
313 }
314