libhandy/auto/
keypad.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14    #[doc(alias = "HdyKeypad")]
15    pub struct Keypad(Object<ffi::HdyKeypad, ffi::HdyKeypadClass>) @extends gtk::Bin, gtk::Container, gtk::Widget, @implements gtk::Buildable;
16
17    match fn {
18        type_ => || ffi::hdy_keypad_get_type(),
19    }
20}
21
22impl Keypad {
23    pub const NONE: Option<&'static Keypad> = None;
24
25    #[doc(alias = "hdy_keypad_new")]
26    pub fn new(symbols_visible: bool, letters_visible: bool) -> Keypad {
27        assert_initialized_main_thread!();
28        unsafe {
29            gtk::Widget::from_glib_none(ffi::hdy_keypad_new(
30                symbols_visible.into_glib(),
31                letters_visible.into_glib(),
32            ))
33            .unsafe_cast()
34        }
35    }
36
37    // rustdoc-stripper-ignore-next
38    /// Creates a new builder-pattern struct instance to construct [`Keypad`] objects.
39    ///
40    /// This method returns an instance of [`KeypadBuilder`](crate::builders::KeypadBuilder) which can be used to create [`Keypad`] objects.
41    pub fn builder() -> KeypadBuilder {
42        KeypadBuilder::new()
43    }
44}
45
46impl Default for Keypad {
47    fn default() -> Self {
48        glib::object::Object::new::<Self>()
49    }
50}
51
52// rustdoc-stripper-ignore-next
53/// A [builder-pattern] type to construct [`Keypad`] objects.
54///
55/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
56#[must_use = "The builder must be built to be used"]
57pub struct KeypadBuilder {
58    builder: glib::object::ObjectBuilder<'static, Keypad>,
59}
60
61impl KeypadBuilder {
62    fn new() -> Self {
63        Self {
64            builder: glib::object::Object::builder(),
65        }
66    }
67
68    pub fn column_spacing(self, column_spacing: u32) -> Self {
69        Self {
70            builder: self.builder.property("column-spacing", column_spacing),
71        }
72    }
73
74    pub fn end_action(self, end_action: &impl IsA<gtk::Widget>) -> Self {
75        Self {
76            builder: self
77                .builder
78                .property("end-action", end_action.clone().upcast()),
79        }
80    }
81
82    pub fn entry(self, entry: &impl IsA<gtk::Entry>) -> Self {
83        Self {
84            builder: self.builder.property("entry", entry.clone().upcast()),
85        }
86    }
87
88    pub fn letters_visible(self, letters_visible: bool) -> Self {
89        Self {
90            builder: self.builder.property("letters-visible", letters_visible),
91        }
92    }
93
94    pub fn row_spacing(self, row_spacing: u32) -> Self {
95        Self {
96            builder: self.builder.property("row-spacing", row_spacing),
97        }
98    }
99
100    pub fn start_action(self, start_action: &impl IsA<gtk::Widget>) -> Self {
101        Self {
102            builder: self
103                .builder
104                .property("start-action", start_action.clone().upcast()),
105        }
106    }
107
108    pub fn symbols_visible(self, symbols_visible: bool) -> Self {
109        Self {
110            builder: self.builder.property("symbols-visible", symbols_visible),
111        }
112    }
113
114    pub fn border_width(self, border_width: u32) -> Self {
115        Self {
116            builder: self.builder.property("border-width", border_width),
117        }
118    }
119
120    pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
121        Self {
122            builder: self.builder.property("child", child.clone().upcast()),
123        }
124    }
125
126    pub fn resize_mode(self, resize_mode: gtk::ResizeMode) -> Self {
127        Self {
128            builder: self.builder.property("resize-mode", resize_mode),
129        }
130    }
131
132    pub fn app_paintable(self, app_paintable: bool) -> Self {
133        Self {
134            builder: self.builder.property("app-paintable", app_paintable),
135        }
136    }
137
138    pub fn can_default(self, can_default: bool) -> Self {
139        Self {
140            builder: self.builder.property("can-default", can_default),
141        }
142    }
143
144    pub fn can_focus(self, can_focus: bool) -> Self {
145        Self {
146            builder: self.builder.property("can-focus", can_focus),
147        }
148    }
149
150    pub fn events(self, events: gdk::EventMask) -> Self {
151        Self {
152            builder: self.builder.property("events", events),
153        }
154    }
155
156    pub fn expand(self, expand: bool) -> Self {
157        Self {
158            builder: self.builder.property("expand", expand),
159        }
160    }
161
162    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
163        Self {
164            builder: self.builder.property("focus-on-click", focus_on_click),
165        }
166    }
167
168    pub fn halign(self, halign: gtk::Align) -> Self {
169        Self {
170            builder: self.builder.property("halign", halign),
171        }
172    }
173
174    pub fn has_default(self, has_default: bool) -> Self {
175        Self {
176            builder: self.builder.property("has-default", has_default),
177        }
178    }
179
180    pub fn has_focus(self, has_focus: bool) -> Self {
181        Self {
182            builder: self.builder.property("has-focus", has_focus),
183        }
184    }
185
186    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
187        Self {
188            builder: self.builder.property("has-tooltip", has_tooltip),
189        }
190    }
191
192    pub fn height_request(self, height_request: i32) -> Self {
193        Self {
194            builder: self.builder.property("height-request", height_request),
195        }
196    }
197
198    pub fn hexpand(self, hexpand: bool) -> Self {
199        Self {
200            builder: self.builder.property("hexpand", hexpand),
201        }
202    }
203
204    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
205        Self {
206            builder: self.builder.property("hexpand-set", hexpand_set),
207        }
208    }
209
210    pub fn is_focus(self, is_focus: bool) -> Self {
211        Self {
212            builder: self.builder.property("is-focus", is_focus),
213        }
214    }
215
216    pub fn margin(self, margin: i32) -> Self {
217        Self {
218            builder: self.builder.property("margin", margin),
219        }
220    }
221
222    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
223        Self {
224            builder: self.builder.property("margin-bottom", margin_bottom),
225        }
226    }
227
228    pub fn margin_end(self, margin_end: i32) -> Self {
229        Self {
230            builder: self.builder.property("margin-end", margin_end),
231        }
232    }
233
234    pub fn margin_start(self, margin_start: i32) -> Self {
235        Self {
236            builder: self.builder.property("margin-start", margin_start),
237        }
238    }
239
240    pub fn margin_top(self, margin_top: i32) -> Self {
241        Self {
242            builder: self.builder.property("margin-top", margin_top),
243        }
244    }
245
246    pub fn name(self, name: impl Into<glib::GString>) -> Self {
247        Self {
248            builder: self.builder.property("name", name.into()),
249        }
250    }
251
252    pub fn no_show_all(self, no_show_all: bool) -> Self {
253        Self {
254            builder: self.builder.property("no-show-all", no_show_all),
255        }
256    }
257
258    pub fn opacity(self, opacity: f64) -> Self {
259        Self {
260            builder: self.builder.property("opacity", opacity),
261        }
262    }
263
264    pub fn parent(self, parent: &impl IsA<gtk::Container>) -> Self {
265        Self {
266            builder: self.builder.property("parent", parent.clone().upcast()),
267        }
268    }
269
270    pub fn receives_default(self, receives_default: bool) -> Self {
271        Self {
272            builder: self.builder.property("receives-default", receives_default),
273        }
274    }
275
276    pub fn sensitive(self, sensitive: bool) -> Self {
277        Self {
278            builder: self.builder.property("sensitive", sensitive),
279        }
280    }
281
282    //pub fn style(self, style: &impl IsA</*Ignored*/gtk::Style>) -> Self {
283    //    Self { builder: self.builder.property("style", style.clone().upcast()), }
284    //}
285
286    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
287        Self {
288            builder: self
289                .builder
290                .property("tooltip-markup", tooltip_markup.into()),
291        }
292    }
293
294    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
295        Self {
296            builder: self.builder.property("tooltip-text", tooltip_text.into()),
297        }
298    }
299
300    pub fn valign(self, valign: gtk::Align) -> Self {
301        Self {
302            builder: self.builder.property("valign", valign),
303        }
304    }
305
306    pub fn vexpand(self, vexpand: bool) -> Self {
307        Self {
308            builder: self.builder.property("vexpand", vexpand),
309        }
310    }
311
312    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
313        Self {
314            builder: self.builder.property("vexpand-set", vexpand_set),
315        }
316    }
317
318    pub fn visible(self, visible: bool) -> Self {
319        Self {
320            builder: self.builder.property("visible", visible),
321        }
322    }
323
324    pub fn width_request(self, width_request: i32) -> Self {
325        Self {
326            builder: self.builder.property("width-request", width_request),
327        }
328    }
329
330    // rustdoc-stripper-ignore-next
331    /// Build the [`Keypad`].
332    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
333    pub fn build(self) -> Keypad {
334        self.builder.build()
335    }
336}
337
338mod sealed {
339    pub trait Sealed {}
340    impl<T: super::IsA<super::Keypad>> Sealed for T {}
341}
342
343pub trait KeypadExt: IsA<Keypad> + sealed::Sealed + 'static {
344    #[doc(alias = "hdy_keypad_get_column_spacing")]
345    #[doc(alias = "get_column_spacing")]
346    fn column_spacing(&self) -> u32 {
347        unsafe { ffi::hdy_keypad_get_column_spacing(self.as_ref().to_glib_none().0) }
348    }
349
350    #[doc(alias = "hdy_keypad_get_end_action")]
351    #[doc(alias = "get_end_action")]
352    fn end_action(&self) -> Option<gtk::Widget> {
353        unsafe {
354            from_glib_none(ffi::hdy_keypad_get_end_action(
355                self.as_ref().to_glib_none().0,
356            ))
357        }
358    }
359
360    #[doc(alias = "hdy_keypad_get_entry")]
361    #[doc(alias = "get_entry")]
362    fn entry(&self) -> Option<gtk::Entry> {
363        unsafe { from_glib_none(ffi::hdy_keypad_get_entry(self.as_ref().to_glib_none().0)) }
364    }
365
366    #[doc(alias = "hdy_keypad_get_letters_visible")]
367    #[doc(alias = "get_letters_visible")]
368    fn is_letters_visible(&self) -> bool {
369        unsafe {
370            from_glib(ffi::hdy_keypad_get_letters_visible(
371                self.as_ref().to_glib_none().0,
372            ))
373        }
374    }
375
376    #[doc(alias = "hdy_keypad_get_row_spacing")]
377    #[doc(alias = "get_row_spacing")]
378    fn row_spacing(&self) -> u32 {
379        unsafe { ffi::hdy_keypad_get_row_spacing(self.as_ref().to_glib_none().0) }
380    }
381
382    #[doc(alias = "hdy_keypad_get_start_action")]
383    #[doc(alias = "get_start_action")]
384    fn start_action(&self) -> Option<gtk::Widget> {
385        unsafe {
386            from_glib_none(ffi::hdy_keypad_get_start_action(
387                self.as_ref().to_glib_none().0,
388            ))
389        }
390    }
391
392    #[doc(alias = "hdy_keypad_get_symbols_visible")]
393    #[doc(alias = "get_symbols_visible")]
394    fn is_symbols_visible(&self) -> bool {
395        unsafe {
396            from_glib(ffi::hdy_keypad_get_symbols_visible(
397                self.as_ref().to_glib_none().0,
398            ))
399        }
400    }
401
402    #[doc(alias = "hdy_keypad_set_column_spacing")]
403    fn set_column_spacing(&self, spacing: u32) {
404        unsafe {
405            ffi::hdy_keypad_set_column_spacing(self.as_ref().to_glib_none().0, spacing);
406        }
407    }
408
409    #[doc(alias = "hdy_keypad_set_end_action")]
410    fn set_end_action(&self, end_action: Option<&impl IsA<gtk::Widget>>) {
411        unsafe {
412            ffi::hdy_keypad_set_end_action(
413                self.as_ref().to_glib_none().0,
414                end_action.map(|p| p.as_ref()).to_glib_none().0,
415            );
416        }
417    }
418
419    #[doc(alias = "hdy_keypad_set_entry")]
420    fn set_entry(&self, entry: Option<&impl IsA<gtk::Entry>>) {
421        unsafe {
422            ffi::hdy_keypad_set_entry(
423                self.as_ref().to_glib_none().0,
424                entry.map(|p| p.as_ref()).to_glib_none().0,
425            );
426        }
427    }
428
429    #[doc(alias = "hdy_keypad_set_letters_visible")]
430    fn set_letters_visible(&self, letters_visible: bool) {
431        unsafe {
432            ffi::hdy_keypad_set_letters_visible(
433                self.as_ref().to_glib_none().0,
434                letters_visible.into_glib(),
435            );
436        }
437    }
438
439    #[doc(alias = "hdy_keypad_set_row_spacing")]
440    fn set_row_spacing(&self, spacing: u32) {
441        unsafe {
442            ffi::hdy_keypad_set_row_spacing(self.as_ref().to_glib_none().0, spacing);
443        }
444    }
445
446    #[doc(alias = "hdy_keypad_set_start_action")]
447    fn set_start_action(&self, start_action: Option<&impl IsA<gtk::Widget>>) {
448        unsafe {
449            ffi::hdy_keypad_set_start_action(
450                self.as_ref().to_glib_none().0,
451                start_action.map(|p| p.as_ref()).to_glib_none().0,
452            );
453        }
454    }
455
456    #[doc(alias = "hdy_keypad_set_symbols_visible")]
457    fn set_symbols_visible(&self, symbols_visible: bool) {
458        unsafe {
459            ffi::hdy_keypad_set_symbols_visible(
460                self.as_ref().to_glib_none().0,
461                symbols_visible.into_glib(),
462            );
463        }
464    }
465
466    #[doc(alias = "column-spacing")]
467    fn connect_column_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
468        unsafe extern "C" fn notify_column_spacing_trampoline<
469            P: IsA<Keypad>,
470            F: Fn(&P) + 'static,
471        >(
472            this: *mut ffi::HdyKeypad,
473            _param_spec: glib::ffi::gpointer,
474            f: glib::ffi::gpointer,
475        ) {
476            let f: &F = &*(f as *const F);
477            f(Keypad::from_glib_borrow(this).unsafe_cast_ref())
478        }
479        unsafe {
480            let f: Box_<F> = Box_::new(f);
481            connect_raw(
482                self.as_ptr() as *mut _,
483                b"notify::column-spacing\0".as_ptr() as *const _,
484                Some(transmute::<_, unsafe extern "C" fn()>(
485                    notify_column_spacing_trampoline::<Self, F> as *const (),
486                )),
487                Box_::into_raw(f),
488            )
489        }
490    }
491
492    #[doc(alias = "end-action")]
493    fn connect_end_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
494        unsafe extern "C" fn notify_end_action_trampoline<P: IsA<Keypad>, F: Fn(&P) + 'static>(
495            this: *mut ffi::HdyKeypad,
496            _param_spec: glib::ffi::gpointer,
497            f: glib::ffi::gpointer,
498        ) {
499            let f: &F = &*(f as *const F);
500            f(Keypad::from_glib_borrow(this).unsafe_cast_ref())
501        }
502        unsafe {
503            let f: Box_<F> = Box_::new(f);
504            connect_raw(
505                self.as_ptr() as *mut _,
506                b"notify::end-action\0".as_ptr() as *const _,
507                Some(transmute::<_, unsafe extern "C" fn()>(
508                    notify_end_action_trampoline::<Self, F> as *const (),
509                )),
510                Box_::into_raw(f),
511            )
512        }
513    }
514
515    #[doc(alias = "entry")]
516    fn connect_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
517        unsafe extern "C" fn notify_entry_trampoline<P: IsA<Keypad>, F: Fn(&P) + 'static>(
518            this: *mut ffi::HdyKeypad,
519            _param_spec: glib::ffi::gpointer,
520            f: glib::ffi::gpointer,
521        ) {
522            let f: &F = &*(f as *const F);
523            f(Keypad::from_glib_borrow(this).unsafe_cast_ref())
524        }
525        unsafe {
526            let f: Box_<F> = Box_::new(f);
527            connect_raw(
528                self.as_ptr() as *mut _,
529                b"notify::entry\0".as_ptr() as *const _,
530                Some(transmute::<_, unsafe extern "C" fn()>(
531                    notify_entry_trampoline::<Self, F> as *const (),
532                )),
533                Box_::into_raw(f),
534            )
535        }
536    }
537
538    #[doc(alias = "letters-visible")]
539    fn connect_letters_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
540        unsafe extern "C" fn notify_letters_visible_trampoline<
541            P: IsA<Keypad>,
542            F: Fn(&P) + 'static,
543        >(
544            this: *mut ffi::HdyKeypad,
545            _param_spec: glib::ffi::gpointer,
546            f: glib::ffi::gpointer,
547        ) {
548            let f: &F = &*(f as *const F);
549            f(Keypad::from_glib_borrow(this).unsafe_cast_ref())
550        }
551        unsafe {
552            let f: Box_<F> = Box_::new(f);
553            connect_raw(
554                self.as_ptr() as *mut _,
555                b"notify::letters-visible\0".as_ptr() as *const _,
556                Some(transmute::<_, unsafe extern "C" fn()>(
557                    notify_letters_visible_trampoline::<Self, F> as *const (),
558                )),
559                Box_::into_raw(f),
560            )
561        }
562    }
563
564    #[doc(alias = "row-spacing")]
565    fn connect_row_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
566        unsafe extern "C" fn notify_row_spacing_trampoline<P: IsA<Keypad>, F: Fn(&P) + 'static>(
567            this: *mut ffi::HdyKeypad,
568            _param_spec: glib::ffi::gpointer,
569            f: glib::ffi::gpointer,
570        ) {
571            let f: &F = &*(f as *const F);
572            f(Keypad::from_glib_borrow(this).unsafe_cast_ref())
573        }
574        unsafe {
575            let f: Box_<F> = Box_::new(f);
576            connect_raw(
577                self.as_ptr() as *mut _,
578                b"notify::row-spacing\0".as_ptr() as *const _,
579                Some(transmute::<_, unsafe extern "C" fn()>(
580                    notify_row_spacing_trampoline::<Self, F> as *const (),
581                )),
582                Box_::into_raw(f),
583            )
584        }
585    }
586
587    #[doc(alias = "start-action")]
588    fn connect_start_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
589        unsafe extern "C" fn notify_start_action_trampoline<P: IsA<Keypad>, F: Fn(&P) + 'static>(
590            this: *mut ffi::HdyKeypad,
591            _param_spec: glib::ffi::gpointer,
592            f: glib::ffi::gpointer,
593        ) {
594            let f: &F = &*(f as *const F);
595            f(Keypad::from_glib_borrow(this).unsafe_cast_ref())
596        }
597        unsafe {
598            let f: Box_<F> = Box_::new(f);
599            connect_raw(
600                self.as_ptr() as *mut _,
601                b"notify::start-action\0".as_ptr() as *const _,
602                Some(transmute::<_, unsafe extern "C" fn()>(
603                    notify_start_action_trampoline::<Self, F> as *const (),
604                )),
605                Box_::into_raw(f),
606            )
607        }
608    }
609
610    #[doc(alias = "symbols-visible")]
611    fn connect_symbols_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
612        unsafe extern "C" fn notify_symbols_visible_trampoline<
613            P: IsA<Keypad>,
614            F: Fn(&P) + 'static,
615        >(
616            this: *mut ffi::HdyKeypad,
617            _param_spec: glib::ffi::gpointer,
618            f: glib::ffi::gpointer,
619        ) {
620            let f: &F = &*(f as *const F);
621            f(Keypad::from_glib_borrow(this).unsafe_cast_ref())
622        }
623        unsafe {
624            let f: Box_<F> = Box_::new(f);
625            connect_raw(
626                self.as_ptr() as *mut _,
627                b"notify::symbols-visible\0".as_ptr() as *const _,
628                Some(transmute::<_, unsafe extern "C" fn()>(
629                    notify_symbols_visible_trampoline::<Self, F> as *const (),
630                )),
631                Box_::into_raw(f),
632            )
633        }
634    }
635}
636
637impl<O: IsA<Keypad>> KeypadExt for O {}
638
639impl fmt::Display for Keypad {
640    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
641        f.write_str("Keypad")
642    }
643}