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 crate::Align;
6 use crate::BaselinePosition;
7 use crate::Box;
8 use crate::Buildable;
9 use crate::Container;
10 use crate::Orientable;
11 use crate::Orientation;
12 use crate::ResizeMode;
13 use crate::Widget;
14 use glib::object::Cast;
15 use glib::object::IsA;
16 use glib::object::ObjectType as ObjectType_;
17 use glib::signal::connect_raw;
18 use glib::signal::SignalHandlerId;
19 use glib::translate::*;
20 use glib::StaticType;
21 use glib::ToValue;
22 use std::boxed::Box as Box_;
23 use std::fmt;
24 use std::mem::transmute;
25 
26 glib::wrapper! {
27     #[doc(alias = "GtkShortcutLabel")]
28     pub struct ShortcutLabel(Object<ffi::GtkShortcutLabel, ffi::GtkShortcutLabelClass>) @extends Box, Container, Widget, @implements Buildable, Orientable;
29 
30     match fn {
31         type_ => || ffi::gtk_shortcut_label_get_type(),
32     }
33 }
34 
35 impl ShortcutLabel {
36     #[doc(alias = "gtk_shortcut_label_new")]
new(accelerator: &str) -> ShortcutLabel37     pub fn new(accelerator: &str) -> ShortcutLabel {
38         assert_initialized_main_thread!();
39         unsafe {
40             Widget::from_glib_none(ffi::gtk_shortcut_label_new(accelerator.to_glib_none().0))
41                 .unsafe_cast()
42         }
43     }
44 
45     // rustdoc-stripper-ignore-next
46     /// Creates a new builder-pattern struct instance to construct [`ShortcutLabel`] objects.
47     ///
48     /// This method returns an instance of [`ShortcutLabelBuilder`] which can be used to create [`ShortcutLabel`] objects.
builder() -> ShortcutLabelBuilder49     pub fn builder() -> ShortcutLabelBuilder {
50         ShortcutLabelBuilder::default()
51     }
52 
53     #[doc(alias = "gtk_shortcut_label_get_accelerator")]
54     #[doc(alias = "get_accelerator")]
accelerator(&self) -> Option<glib::GString>55     pub fn accelerator(&self) -> Option<glib::GString> {
56         unsafe {
57             from_glib_none(ffi::gtk_shortcut_label_get_accelerator(
58                 self.to_glib_none().0,
59             ))
60         }
61     }
62 
63     #[doc(alias = "gtk_shortcut_label_get_disabled_text")]
64     #[doc(alias = "get_disabled_text")]
disabled_text(&self) -> Option<glib::GString>65     pub fn disabled_text(&self) -> Option<glib::GString> {
66         unsafe {
67             from_glib_none(ffi::gtk_shortcut_label_get_disabled_text(
68                 self.to_glib_none().0,
69             ))
70         }
71     }
72 
73     #[doc(alias = "gtk_shortcut_label_set_accelerator")]
set_accelerator(&self, accelerator: &str)74     pub fn set_accelerator(&self, accelerator: &str) {
75         unsafe {
76             ffi::gtk_shortcut_label_set_accelerator(
77                 self.to_glib_none().0,
78                 accelerator.to_glib_none().0,
79             );
80         }
81     }
82 
83     #[doc(alias = "gtk_shortcut_label_set_disabled_text")]
set_disabled_text(&self, disabled_text: &str)84     pub fn set_disabled_text(&self, disabled_text: &str) {
85         unsafe {
86             ffi::gtk_shortcut_label_set_disabled_text(
87                 self.to_glib_none().0,
88                 disabled_text.to_glib_none().0,
89             );
90         }
91     }
92 
93     #[cfg(any(feature = "v3_22", feature = "dox"))]
94     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
95     #[doc(alias = "accelerator")]
connect_accelerator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId96     pub fn connect_accelerator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
97         unsafe extern "C" fn notify_accelerator_trampoline<F: Fn(&ShortcutLabel) + 'static>(
98             this: *mut ffi::GtkShortcutLabel,
99             _param_spec: glib::ffi::gpointer,
100             f: glib::ffi::gpointer,
101         ) {
102             let f: &F = &*(f as *const F);
103             f(&from_glib_borrow(this))
104         }
105         unsafe {
106             let f: Box_<F> = Box_::new(f);
107             connect_raw(
108                 self.as_ptr() as *mut _,
109                 b"notify::accelerator\0".as_ptr() as *const _,
110                 Some(transmute::<_, unsafe extern "C" fn()>(
111                     notify_accelerator_trampoline::<F> as *const (),
112                 )),
113                 Box_::into_raw(f),
114             )
115         }
116     }
117 
118     #[cfg(any(feature = "v3_22", feature = "dox"))]
119     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
120     #[doc(alias = "disabled-text")]
connect_disabled_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId121     pub fn connect_disabled_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
122         unsafe extern "C" fn notify_disabled_text_trampoline<F: Fn(&ShortcutLabel) + 'static>(
123             this: *mut ffi::GtkShortcutLabel,
124             _param_spec: glib::ffi::gpointer,
125             f: glib::ffi::gpointer,
126         ) {
127             let f: &F = &*(f as *const F);
128             f(&from_glib_borrow(this))
129         }
130         unsafe {
131             let f: Box_<F> = Box_::new(f);
132             connect_raw(
133                 self.as_ptr() as *mut _,
134                 b"notify::disabled-text\0".as_ptr() as *const _,
135                 Some(transmute::<_, unsafe extern "C" fn()>(
136                     notify_disabled_text_trampoline::<F> as *const (),
137                 )),
138                 Box_::into_raw(f),
139             )
140         }
141     }
142 }
143 
144 #[derive(Clone, Default)]
145 // rustdoc-stripper-ignore-next
146 /// A [builder-pattern] type to construct [`ShortcutLabel`] objects.
147 ///
148 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
149 pub struct ShortcutLabelBuilder {
150     #[cfg(any(feature = "v3_22", feature = "dox"))]
151     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
152     accelerator: Option<String>,
153     #[cfg(any(feature = "v3_22", feature = "dox"))]
154     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
155     disabled_text: Option<String>,
156     baseline_position: Option<BaselinePosition>,
157     homogeneous: Option<bool>,
158     spacing: Option<i32>,
159     border_width: Option<u32>,
160     child: Option<Widget>,
161     resize_mode: Option<ResizeMode>,
162     app_paintable: Option<bool>,
163     can_default: Option<bool>,
164     can_focus: Option<bool>,
165     events: Option<gdk::EventMask>,
166     expand: Option<bool>,
167     #[cfg(any(feature = "v3_20", feature = "dox"))]
168     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
169     focus_on_click: Option<bool>,
170     halign: Option<Align>,
171     has_default: Option<bool>,
172     has_focus: Option<bool>,
173     has_tooltip: Option<bool>,
174     height_request: Option<i32>,
175     hexpand: Option<bool>,
176     hexpand_set: Option<bool>,
177     is_focus: Option<bool>,
178     margin: Option<i32>,
179     margin_bottom: Option<i32>,
180     margin_end: Option<i32>,
181     margin_start: Option<i32>,
182     margin_top: Option<i32>,
183     name: Option<String>,
184     no_show_all: Option<bool>,
185     opacity: Option<f64>,
186     parent: Option<Container>,
187     receives_default: Option<bool>,
188     sensitive: Option<bool>,
189     tooltip_markup: Option<String>,
190     tooltip_text: Option<String>,
191     valign: Option<Align>,
192     vexpand: Option<bool>,
193     vexpand_set: Option<bool>,
194     visible: Option<bool>,
195     width_request: Option<i32>,
196     orientation: Option<Orientation>,
197 }
198 
199 impl ShortcutLabelBuilder {
200     // rustdoc-stripper-ignore-next
201     /// Create a new [`ShortcutLabelBuilder`].
new() -> Self202     pub fn new() -> Self {
203         Self::default()
204     }
205 
206     // rustdoc-stripper-ignore-next
207     /// Build the [`ShortcutLabel`].
build(self) -> ShortcutLabel208     pub fn build(self) -> ShortcutLabel {
209         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
210         #[cfg(any(feature = "v3_22", feature = "dox"))]
211         if let Some(ref accelerator) = self.accelerator {
212             properties.push(("accelerator", accelerator));
213         }
214         #[cfg(any(feature = "v3_22", feature = "dox"))]
215         if let Some(ref disabled_text) = self.disabled_text {
216             properties.push(("disabled-text", disabled_text));
217         }
218         if let Some(ref baseline_position) = self.baseline_position {
219             properties.push(("baseline-position", baseline_position));
220         }
221         if let Some(ref homogeneous) = self.homogeneous {
222             properties.push(("homogeneous", homogeneous));
223         }
224         if let Some(ref spacing) = self.spacing {
225             properties.push(("spacing", spacing));
226         }
227         if let Some(ref border_width) = self.border_width {
228             properties.push(("border-width", border_width));
229         }
230         if let Some(ref child) = self.child {
231             properties.push(("child", child));
232         }
233         if let Some(ref resize_mode) = self.resize_mode {
234             properties.push(("resize-mode", resize_mode));
235         }
236         if let Some(ref app_paintable) = self.app_paintable {
237             properties.push(("app-paintable", app_paintable));
238         }
239         if let Some(ref can_default) = self.can_default {
240             properties.push(("can-default", can_default));
241         }
242         if let Some(ref can_focus) = self.can_focus {
243             properties.push(("can-focus", can_focus));
244         }
245         if let Some(ref events) = self.events {
246             properties.push(("events", events));
247         }
248         if let Some(ref expand) = self.expand {
249             properties.push(("expand", expand));
250         }
251         #[cfg(any(feature = "v3_20", feature = "dox"))]
252         if let Some(ref focus_on_click) = self.focus_on_click {
253             properties.push(("focus-on-click", focus_on_click));
254         }
255         if let Some(ref halign) = self.halign {
256             properties.push(("halign", halign));
257         }
258         if let Some(ref has_default) = self.has_default {
259             properties.push(("has-default", has_default));
260         }
261         if let Some(ref has_focus) = self.has_focus {
262             properties.push(("has-focus", has_focus));
263         }
264         if let Some(ref has_tooltip) = self.has_tooltip {
265             properties.push(("has-tooltip", has_tooltip));
266         }
267         if let Some(ref height_request) = self.height_request {
268             properties.push(("height-request", height_request));
269         }
270         if let Some(ref hexpand) = self.hexpand {
271             properties.push(("hexpand", hexpand));
272         }
273         if let Some(ref hexpand_set) = self.hexpand_set {
274             properties.push(("hexpand-set", hexpand_set));
275         }
276         if let Some(ref is_focus) = self.is_focus {
277             properties.push(("is-focus", is_focus));
278         }
279         if let Some(ref margin) = self.margin {
280             properties.push(("margin", margin));
281         }
282         if let Some(ref margin_bottom) = self.margin_bottom {
283             properties.push(("margin-bottom", margin_bottom));
284         }
285         if let Some(ref margin_end) = self.margin_end {
286             properties.push(("margin-end", margin_end));
287         }
288         if let Some(ref margin_start) = self.margin_start {
289             properties.push(("margin-start", margin_start));
290         }
291         if let Some(ref margin_top) = self.margin_top {
292             properties.push(("margin-top", margin_top));
293         }
294         if let Some(ref name) = self.name {
295             properties.push(("name", name));
296         }
297         if let Some(ref no_show_all) = self.no_show_all {
298             properties.push(("no-show-all", no_show_all));
299         }
300         if let Some(ref opacity) = self.opacity {
301             properties.push(("opacity", opacity));
302         }
303         if let Some(ref parent) = self.parent {
304             properties.push(("parent", parent));
305         }
306         if let Some(ref receives_default) = self.receives_default {
307             properties.push(("receives-default", receives_default));
308         }
309         if let Some(ref sensitive) = self.sensitive {
310             properties.push(("sensitive", sensitive));
311         }
312         if let Some(ref tooltip_markup) = self.tooltip_markup {
313             properties.push(("tooltip-markup", tooltip_markup));
314         }
315         if let Some(ref tooltip_text) = self.tooltip_text {
316             properties.push(("tooltip-text", tooltip_text));
317         }
318         if let Some(ref valign) = self.valign {
319             properties.push(("valign", valign));
320         }
321         if let Some(ref vexpand) = self.vexpand {
322             properties.push(("vexpand", vexpand));
323         }
324         if let Some(ref vexpand_set) = self.vexpand_set {
325             properties.push(("vexpand-set", vexpand_set));
326         }
327         if let Some(ref visible) = self.visible {
328             properties.push(("visible", visible));
329         }
330         if let Some(ref width_request) = self.width_request {
331             properties.push(("width-request", width_request));
332         }
333         if let Some(ref orientation) = self.orientation {
334             properties.push(("orientation", orientation));
335         }
336         glib::Object::new::<ShortcutLabel>(&properties)
337             .expect("Failed to create an instance of ShortcutLabel")
338     }
339 
340     #[cfg(any(feature = "v3_22", feature = "dox"))]
341     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
accelerator(mut self, accelerator: &str) -> Self342     pub fn accelerator(mut self, accelerator: &str) -> Self {
343         self.accelerator = Some(accelerator.to_string());
344         self
345     }
346 
347     #[cfg(any(feature = "v3_22", feature = "dox"))]
348     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
disabled_text(mut self, disabled_text: &str) -> Self349     pub fn disabled_text(mut self, disabled_text: &str) -> Self {
350         self.disabled_text = Some(disabled_text.to_string());
351         self
352     }
353 
baseline_position(mut self, baseline_position: BaselinePosition) -> Self354     pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self {
355         self.baseline_position = Some(baseline_position);
356         self
357     }
358 
homogeneous(mut self, homogeneous: bool) -> Self359     pub fn homogeneous(mut self, homogeneous: bool) -> Self {
360         self.homogeneous = Some(homogeneous);
361         self
362     }
363 
spacing(mut self, spacing: i32) -> Self364     pub fn spacing(mut self, spacing: i32) -> Self {
365         self.spacing = Some(spacing);
366         self
367     }
368 
border_width(mut self, border_width: u32) -> Self369     pub fn border_width(mut self, border_width: u32) -> Self {
370         self.border_width = Some(border_width);
371         self
372     }
373 
child<P: IsA<Widget>>(mut self, child: &P) -> Self374     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
375         self.child = Some(child.clone().upcast());
376         self
377     }
378 
resize_mode(mut self, resize_mode: ResizeMode) -> Self379     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
380         self.resize_mode = Some(resize_mode);
381         self
382     }
383 
app_paintable(mut self, app_paintable: bool) -> Self384     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
385         self.app_paintable = Some(app_paintable);
386         self
387     }
388 
can_default(mut self, can_default: bool) -> Self389     pub fn can_default(mut self, can_default: bool) -> Self {
390         self.can_default = Some(can_default);
391         self
392     }
393 
can_focus(mut self, can_focus: bool) -> Self394     pub fn can_focus(mut self, can_focus: bool) -> Self {
395         self.can_focus = Some(can_focus);
396         self
397     }
398 
events(mut self, events: gdk::EventMask) -> Self399     pub fn events(mut self, events: gdk::EventMask) -> Self {
400         self.events = Some(events);
401         self
402     }
403 
expand(mut self, expand: bool) -> Self404     pub fn expand(mut self, expand: bool) -> Self {
405         self.expand = Some(expand);
406         self
407     }
408 
409     #[cfg(any(feature = "v3_20", feature = "dox"))]
410     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
focus_on_click(mut self, focus_on_click: bool) -> Self411     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
412         self.focus_on_click = Some(focus_on_click);
413         self
414     }
415 
halign(mut self, halign: Align) -> Self416     pub fn halign(mut self, halign: Align) -> Self {
417         self.halign = Some(halign);
418         self
419     }
420 
has_default(mut self, has_default: bool) -> Self421     pub fn has_default(mut self, has_default: bool) -> Self {
422         self.has_default = Some(has_default);
423         self
424     }
425 
has_focus(mut self, has_focus: bool) -> Self426     pub fn has_focus(mut self, has_focus: bool) -> Self {
427         self.has_focus = Some(has_focus);
428         self
429     }
430 
has_tooltip(mut self, has_tooltip: bool) -> Self431     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
432         self.has_tooltip = Some(has_tooltip);
433         self
434     }
435 
height_request(mut self, height_request: i32) -> Self436     pub fn height_request(mut self, height_request: i32) -> Self {
437         self.height_request = Some(height_request);
438         self
439     }
440 
hexpand(mut self, hexpand: bool) -> Self441     pub fn hexpand(mut self, hexpand: bool) -> Self {
442         self.hexpand = Some(hexpand);
443         self
444     }
445 
hexpand_set(mut self, hexpand_set: bool) -> Self446     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
447         self.hexpand_set = Some(hexpand_set);
448         self
449     }
450 
is_focus(mut self, is_focus: bool) -> Self451     pub fn is_focus(mut self, is_focus: bool) -> Self {
452         self.is_focus = Some(is_focus);
453         self
454     }
455 
margin(mut self, margin: i32) -> Self456     pub fn margin(mut self, margin: i32) -> Self {
457         self.margin = Some(margin);
458         self
459     }
460 
margin_bottom(mut self, margin_bottom: i32) -> Self461     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
462         self.margin_bottom = Some(margin_bottom);
463         self
464     }
465 
margin_end(mut self, margin_end: i32) -> Self466     pub fn margin_end(mut self, margin_end: i32) -> Self {
467         self.margin_end = Some(margin_end);
468         self
469     }
470 
margin_start(mut self, margin_start: i32) -> Self471     pub fn margin_start(mut self, margin_start: i32) -> Self {
472         self.margin_start = Some(margin_start);
473         self
474     }
475 
margin_top(mut self, margin_top: i32) -> Self476     pub fn margin_top(mut self, margin_top: i32) -> Self {
477         self.margin_top = Some(margin_top);
478         self
479     }
480 
name(mut self, name: &str) -> Self481     pub fn name(mut self, name: &str) -> Self {
482         self.name = Some(name.to_string());
483         self
484     }
485 
no_show_all(mut self, no_show_all: bool) -> Self486     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
487         self.no_show_all = Some(no_show_all);
488         self
489     }
490 
opacity(mut self, opacity: f64) -> Self491     pub fn opacity(mut self, opacity: f64) -> Self {
492         self.opacity = Some(opacity);
493         self
494     }
495 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self496     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
497         self.parent = Some(parent.clone().upcast());
498         self
499     }
500 
receives_default(mut self, receives_default: bool) -> Self501     pub fn receives_default(mut self, receives_default: bool) -> Self {
502         self.receives_default = Some(receives_default);
503         self
504     }
505 
sensitive(mut self, sensitive: bool) -> Self506     pub fn sensitive(mut self, sensitive: bool) -> Self {
507         self.sensitive = Some(sensitive);
508         self
509     }
510 
tooltip_markup(mut self, tooltip_markup: &str) -> Self511     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
512         self.tooltip_markup = Some(tooltip_markup.to_string());
513         self
514     }
515 
tooltip_text(mut self, tooltip_text: &str) -> Self516     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
517         self.tooltip_text = Some(tooltip_text.to_string());
518         self
519     }
520 
valign(mut self, valign: Align) -> Self521     pub fn valign(mut self, valign: Align) -> Self {
522         self.valign = Some(valign);
523         self
524     }
525 
vexpand(mut self, vexpand: bool) -> Self526     pub fn vexpand(mut self, vexpand: bool) -> Self {
527         self.vexpand = Some(vexpand);
528         self
529     }
530 
vexpand_set(mut self, vexpand_set: bool) -> Self531     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
532         self.vexpand_set = Some(vexpand_set);
533         self
534     }
535 
visible(mut self, visible: bool) -> Self536     pub fn visible(mut self, visible: bool) -> Self {
537         self.visible = Some(visible);
538         self
539     }
540 
width_request(mut self, width_request: i32) -> Self541     pub fn width_request(mut self, width_request: i32) -> Self {
542         self.width_request = Some(width_request);
543         self
544     }
545 
orientation(mut self, orientation: Orientation) -> Self546     pub fn orientation(mut self, orientation: Orientation) -> Self {
547         self.orientation = Some(orientation);
548         self
549     }
550 }
551 
552 impl fmt::Display for ShortcutLabel {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result553     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
554         f.write_str("ShortcutLabel")
555     }
556 }
557