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 glib::StaticType;
11 use glib::Value;
12 use glib_sys;
13 use gobject_sys;
14 use gtk;
15 use handy_sys;
16 use std::boxed::Box as Box_;
17 use std::fmt;
18 use std::mem::transmute;
19 
20 glib_wrapper! {
21     pub struct Keypad(Object<handy_sys::HdyKeypad, handy_sys::HdyKeypadClass, KeypadClass>) @extends gtk::Grid, gtk::Container, gtk::Widget, @implements gtk::Orientable;
22 
23     match fn {
24         get_type => || handy_sys::hdy_keypad_get_type(),
25     }
26 }
27 
28 impl Keypad {
new(only_digits: bool, show_symbols: bool) -> Keypad29     pub fn new(only_digits: bool, show_symbols: bool) -> Keypad {
30         assert_initialized_main_thread!();
31         unsafe {
32             gtk::Widget::from_glib_none(handy_sys::hdy_keypad_new(only_digits.to_glib(), show_symbols.to_glib())).unsafe_cast()
33         }
34     }
35 }
36 
37 pub const NONE_KEYPAD: Option<&Keypad> = None;
38 
39 pub trait KeypadExt: 'static {
get_entry(&self) -> Option<gtk::Widget>40     fn get_entry(&self) -> Option<gtk::Widget>;
41 
set_entry<P: IsA<gtk::Entry>>(&self, entry: &P)42     fn set_entry<P: IsA<gtk::Entry>>(&self, entry: &P);
43 
set_left_action<P: IsA<gtk::Widget>>(&self, widget: &P)44     fn set_left_action<P: IsA<gtk::Widget>>(&self, widget: &P);
45 
set_right_action<P: IsA<gtk::Widget>>(&self, widget: &P)46     fn set_right_action<P: IsA<gtk::Widget>>(&self, widget: &P);
47 
show_symbols(&self, visible: bool)48     fn show_symbols(&self, visible: bool);
49 
get_property_only_digits(&self) -> bool50     fn get_property_only_digits(&self) -> bool;
51 
set_property_only_digits(&self, only_digits: bool)52     fn set_property_only_digits(&self, only_digits: bool);
53 
get_property_show_symbols(&self) -> bool54     fn get_property_show_symbols(&self) -> bool;
55 
set_property_show_symbols(&self, show_symbols: bool)56     fn set_property_show_symbols(&self, show_symbols: bool);
57 
connect_property_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId58     fn connect_property_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
59 
connect_property_left_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId60     fn connect_property_left_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
61 
connect_property_only_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId62     fn connect_property_only_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
63 
connect_property_right_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId64     fn connect_property_right_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
65 
connect_property_show_symbols_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId66     fn connect_property_show_symbols_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
67 }
68 
69 impl<O: IsA<Keypad>> KeypadExt for O {
get_entry(&self) -> Option<gtk::Widget>70     fn get_entry(&self) -> Option<gtk::Widget> {
71         unsafe {
72             from_glib_none(handy_sys::hdy_keypad_get_entry(self.as_ref().to_glib_none().0))
73         }
74     }
75 
set_entry<P: IsA<gtk::Entry>>(&self, entry: &P)76     fn set_entry<P: IsA<gtk::Entry>>(&self, entry: &P) {
77         unsafe {
78             handy_sys::hdy_keypad_set_entry(self.as_ref().to_glib_none().0, entry.as_ref().to_glib_none().0);
79         }
80     }
81 
set_left_action<P: IsA<gtk::Widget>>(&self, widget: &P)82     fn set_left_action<P: IsA<gtk::Widget>>(&self, widget: &P) {
83         unsafe {
84             handy_sys::hdy_keypad_set_left_action(self.as_ref().to_glib_none().0, widget.as_ref().to_glib_none().0);
85         }
86     }
87 
set_right_action<P: IsA<gtk::Widget>>(&self, widget: &P)88     fn set_right_action<P: IsA<gtk::Widget>>(&self, widget: &P) {
89         unsafe {
90             handy_sys::hdy_keypad_set_right_action(self.as_ref().to_glib_none().0, widget.as_ref().to_glib_none().0);
91         }
92     }
93 
show_symbols(&self, visible: bool)94     fn show_symbols(&self, visible: bool) {
95         unsafe {
96             handy_sys::hdy_keypad_show_symbols(self.as_ref().to_glib_none().0, visible.to_glib());
97         }
98     }
99 
get_property_only_digits(&self) -> bool100     fn get_property_only_digits(&self) -> bool {
101         unsafe {
102             let mut value = Value::from_type(<bool as StaticType>::static_type());
103             gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"only-digits\0".as_ptr() as *const _, value.to_glib_none_mut().0);
104             value.get().expect("Return Value for property `only-digits` getter").unwrap()
105         }
106     }
107 
set_property_only_digits(&self, only_digits: bool)108     fn set_property_only_digits(&self, only_digits: bool) {
109         unsafe {
110             gobject_sys::g_object_set_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"only-digits\0".as_ptr() as *const _, Value::from(&only_digits).to_glib_none().0);
111         }
112     }
113 
get_property_show_symbols(&self) -> bool114     fn get_property_show_symbols(&self) -> bool {
115         unsafe {
116             let mut value = Value::from_type(<bool as StaticType>::static_type());
117             gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"show-symbols\0".as_ptr() as *const _, value.to_glib_none_mut().0);
118             value.get().expect("Return Value for property `show-symbols` getter").unwrap()
119         }
120     }
121 
set_property_show_symbols(&self, show_symbols: bool)122     fn set_property_show_symbols(&self, show_symbols: bool) {
123         unsafe {
124             gobject_sys::g_object_set_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"show-symbols\0".as_ptr() as *const _, Value::from(&show_symbols).to_glib_none().0);
125         }
126     }
127 
connect_property_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId128     fn connect_property_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
129         unsafe extern "C" fn notify_entry_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyKeypad, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
130             where P: IsA<Keypad>
131         {
132             let f: &F = &*(f as *const F);
133             f(&Keypad::from_glib_borrow(this).unsafe_cast())
134         }
135         unsafe {
136             let f: Box_<F> = Box_::new(f);
137             connect_raw(self.as_ptr() as *mut _, b"notify::entry\0".as_ptr() as *const _,
138                 Some(transmute(notify_entry_trampoline::<Self, F> as usize)), Box_::into_raw(f))
139         }
140     }
141 
connect_property_left_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId142     fn connect_property_left_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
143         unsafe extern "C" fn notify_left_action_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyKeypad, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
144             where P: IsA<Keypad>
145         {
146             let f: &F = &*(f as *const F);
147             f(&Keypad::from_glib_borrow(this).unsafe_cast())
148         }
149         unsafe {
150             let f: Box_<F> = Box_::new(f);
151             connect_raw(self.as_ptr() as *mut _, b"notify::left-action\0".as_ptr() as *const _,
152                 Some(transmute(notify_left_action_trampoline::<Self, F> as usize)), Box_::into_raw(f))
153         }
154     }
155 
connect_property_only_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId156     fn connect_property_only_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
157         unsafe extern "C" fn notify_only_digits_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyKeypad, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
158             where P: IsA<Keypad>
159         {
160             let f: &F = &*(f as *const F);
161             f(&Keypad::from_glib_borrow(this).unsafe_cast())
162         }
163         unsafe {
164             let f: Box_<F> = Box_::new(f);
165             connect_raw(self.as_ptr() as *mut _, b"notify::only-digits\0".as_ptr() as *const _,
166                 Some(transmute(notify_only_digits_trampoline::<Self, F> as usize)), Box_::into_raw(f))
167         }
168     }
169 
connect_property_right_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId170     fn connect_property_right_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
171         unsafe extern "C" fn notify_right_action_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyKeypad, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
172             where P: IsA<Keypad>
173         {
174             let f: &F = &*(f as *const F);
175             f(&Keypad::from_glib_borrow(this).unsafe_cast())
176         }
177         unsafe {
178             let f: Box_<F> = Box_::new(f);
179             connect_raw(self.as_ptr() as *mut _, b"notify::right-action\0".as_ptr() as *const _,
180                 Some(transmute(notify_right_action_trampoline::<Self, F> as usize)), Box_::into_raw(f))
181         }
182     }
183 
connect_property_show_symbols_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId184     fn connect_property_show_symbols_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
185         unsafe extern "C" fn notify_show_symbols_trampoline<P, F: Fn(&P) + 'static>(this: *mut handy_sys::HdyKeypad, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
186             where P: IsA<Keypad>
187         {
188             let f: &F = &*(f as *const F);
189             f(&Keypad::from_glib_borrow(this).unsafe_cast())
190         }
191         unsafe {
192             let f: Box_<F> = Box_::new(f);
193             connect_raw(self.as_ptr() as *mut _, b"notify::show-symbols\0".as_ptr() as *const _,
194                 Some(transmute(notify_show_symbols_trampoline::<Self, F> as usize)), Box_::into_raw(f))
195         }
196     }
197 }
198 
199 impl fmt::Display for Keypad {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result200     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
201         write!(f, "Keypad")
202     }
203 }
204