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::Actionable;
6 use crate::Align;
7 use crate::Bin;
8 use crate::Buildable;
9 use crate::Button;
10 use crate::Container;
11 use crate::PositionType;
12 use crate::ReliefStyle;
13 use crate::ResizeMode;
14 use crate::ToggleButton;
15 use crate::Widget;
16 use glib::object::Cast;
17 use glib::object::IsA;
18 use glib::translate::*;
19 use glib::StaticType;
20 use glib::ToValue;
21 use std::fmt;
22 
23 glib::wrapper! {
24     #[doc(alias = "GtkCheckButton")]
25     pub struct CheckButton(Object<ffi::GtkCheckButton, ffi::GtkCheckButtonClass>) @extends ToggleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable;
26 
27     match fn {
28         type_ => || ffi::gtk_check_button_get_type(),
29     }
30 }
31 
32 impl CheckButton {
33     #[doc(alias = "gtk_check_button_new")]
new() -> CheckButton34     pub fn new() -> CheckButton {
35         assert_initialized_main_thread!();
36         unsafe { Widget::from_glib_none(ffi::gtk_check_button_new()).unsafe_cast() }
37     }
38 
39     #[doc(alias = "gtk_check_button_new_with_label")]
40     #[doc(alias = "new_with_label")]
with_label(label: &str) -> CheckButton41     pub fn with_label(label: &str) -> CheckButton {
42         assert_initialized_main_thread!();
43         unsafe {
44             Widget::from_glib_none(ffi::gtk_check_button_new_with_label(label.to_glib_none().0))
45                 .unsafe_cast()
46         }
47     }
48 
49     #[doc(alias = "gtk_check_button_new_with_mnemonic")]
50     #[doc(alias = "new_with_mnemonic")]
with_mnemonic(label: &str) -> CheckButton51     pub fn with_mnemonic(label: &str) -> CheckButton {
52         assert_initialized_main_thread!();
53         unsafe {
54             Widget::from_glib_none(ffi::gtk_check_button_new_with_mnemonic(
55                 label.to_glib_none().0,
56             ))
57             .unsafe_cast()
58         }
59     }
60 
61     // rustdoc-stripper-ignore-next
62     /// Creates a new builder-pattern struct instance to construct [`CheckButton`] objects.
63     ///
64     /// This method returns an instance of [`CheckButtonBuilder`] which can be used to create [`CheckButton`] objects.
builder() -> CheckButtonBuilder65     pub fn builder() -> CheckButtonBuilder {
66         CheckButtonBuilder::default()
67     }
68 }
69 
70 impl Default for CheckButton {
default() -> Self71     fn default() -> Self {
72         Self::new()
73     }
74 }
75 
76 #[derive(Clone, Default)]
77 // rustdoc-stripper-ignore-next
78 /// A [builder-pattern] type to construct [`CheckButton`] objects.
79 ///
80 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
81 pub struct CheckButtonBuilder {
82     active: Option<bool>,
83     draw_indicator: Option<bool>,
84     inconsistent: Option<bool>,
85     always_show_image: Option<bool>,
86     image: Option<Widget>,
87     image_position: Option<PositionType>,
88     label: Option<String>,
89     relief: Option<ReliefStyle>,
90     use_underline: Option<bool>,
91     border_width: Option<u32>,
92     child: Option<Widget>,
93     resize_mode: Option<ResizeMode>,
94     app_paintable: Option<bool>,
95     can_default: Option<bool>,
96     can_focus: Option<bool>,
97     events: Option<gdk::EventMask>,
98     expand: Option<bool>,
99     #[cfg(any(feature = "v3_20", feature = "dox"))]
100     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
101     focus_on_click: Option<bool>,
102     halign: Option<Align>,
103     has_default: Option<bool>,
104     has_focus: Option<bool>,
105     has_tooltip: Option<bool>,
106     height_request: Option<i32>,
107     hexpand: Option<bool>,
108     hexpand_set: Option<bool>,
109     is_focus: Option<bool>,
110     margin: Option<i32>,
111     margin_bottom: Option<i32>,
112     margin_end: Option<i32>,
113     margin_start: Option<i32>,
114     margin_top: Option<i32>,
115     name: Option<String>,
116     no_show_all: Option<bool>,
117     opacity: Option<f64>,
118     parent: Option<Container>,
119     receives_default: Option<bool>,
120     sensitive: Option<bool>,
121     tooltip_markup: Option<String>,
122     tooltip_text: Option<String>,
123     valign: Option<Align>,
124     vexpand: Option<bool>,
125     vexpand_set: Option<bool>,
126     visible: Option<bool>,
127     width_request: Option<i32>,
128     action_name: Option<String>,
129     action_target: Option<glib::Variant>,
130 }
131 
132 impl CheckButtonBuilder {
133     // rustdoc-stripper-ignore-next
134     /// Create a new [`CheckButtonBuilder`].
new() -> Self135     pub fn new() -> Self {
136         Self::default()
137     }
138 
139     // rustdoc-stripper-ignore-next
140     /// Build the [`CheckButton`].
build(self) -> CheckButton141     pub fn build(self) -> CheckButton {
142         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
143         if let Some(ref active) = self.active {
144             properties.push(("active", active));
145         }
146         if let Some(ref draw_indicator) = self.draw_indicator {
147             properties.push(("draw-indicator", draw_indicator));
148         }
149         if let Some(ref inconsistent) = self.inconsistent {
150             properties.push(("inconsistent", inconsistent));
151         }
152         if let Some(ref always_show_image) = self.always_show_image {
153             properties.push(("always-show-image", always_show_image));
154         }
155         if let Some(ref image) = self.image {
156             properties.push(("image", image));
157         }
158         if let Some(ref image_position) = self.image_position {
159             properties.push(("image-position", image_position));
160         }
161         if let Some(ref label) = self.label {
162             properties.push(("label", label));
163         }
164         if let Some(ref relief) = self.relief {
165             properties.push(("relief", relief));
166         }
167         if let Some(ref use_underline) = self.use_underline {
168             properties.push(("use-underline", use_underline));
169         }
170         if let Some(ref border_width) = self.border_width {
171             properties.push(("border-width", border_width));
172         }
173         if let Some(ref child) = self.child {
174             properties.push(("child", child));
175         }
176         if let Some(ref resize_mode) = self.resize_mode {
177             properties.push(("resize-mode", resize_mode));
178         }
179         if let Some(ref app_paintable) = self.app_paintable {
180             properties.push(("app-paintable", app_paintable));
181         }
182         if let Some(ref can_default) = self.can_default {
183             properties.push(("can-default", can_default));
184         }
185         if let Some(ref can_focus) = self.can_focus {
186             properties.push(("can-focus", can_focus));
187         }
188         if let Some(ref events) = self.events {
189             properties.push(("events", events));
190         }
191         if let Some(ref expand) = self.expand {
192             properties.push(("expand", expand));
193         }
194         #[cfg(any(feature = "v3_20", feature = "dox"))]
195         if let Some(ref focus_on_click) = self.focus_on_click {
196             properties.push(("focus-on-click", focus_on_click));
197         }
198         if let Some(ref halign) = self.halign {
199             properties.push(("halign", halign));
200         }
201         if let Some(ref has_default) = self.has_default {
202             properties.push(("has-default", has_default));
203         }
204         if let Some(ref has_focus) = self.has_focus {
205             properties.push(("has-focus", has_focus));
206         }
207         if let Some(ref has_tooltip) = self.has_tooltip {
208             properties.push(("has-tooltip", has_tooltip));
209         }
210         if let Some(ref height_request) = self.height_request {
211             properties.push(("height-request", height_request));
212         }
213         if let Some(ref hexpand) = self.hexpand {
214             properties.push(("hexpand", hexpand));
215         }
216         if let Some(ref hexpand_set) = self.hexpand_set {
217             properties.push(("hexpand-set", hexpand_set));
218         }
219         if let Some(ref is_focus) = self.is_focus {
220             properties.push(("is-focus", is_focus));
221         }
222         if let Some(ref margin) = self.margin {
223             properties.push(("margin", margin));
224         }
225         if let Some(ref margin_bottom) = self.margin_bottom {
226             properties.push(("margin-bottom", margin_bottom));
227         }
228         if let Some(ref margin_end) = self.margin_end {
229             properties.push(("margin-end", margin_end));
230         }
231         if let Some(ref margin_start) = self.margin_start {
232             properties.push(("margin-start", margin_start));
233         }
234         if let Some(ref margin_top) = self.margin_top {
235             properties.push(("margin-top", margin_top));
236         }
237         if let Some(ref name) = self.name {
238             properties.push(("name", name));
239         }
240         if let Some(ref no_show_all) = self.no_show_all {
241             properties.push(("no-show-all", no_show_all));
242         }
243         if let Some(ref opacity) = self.opacity {
244             properties.push(("opacity", opacity));
245         }
246         if let Some(ref parent) = self.parent {
247             properties.push(("parent", parent));
248         }
249         if let Some(ref receives_default) = self.receives_default {
250             properties.push(("receives-default", receives_default));
251         }
252         if let Some(ref sensitive) = self.sensitive {
253             properties.push(("sensitive", sensitive));
254         }
255         if let Some(ref tooltip_markup) = self.tooltip_markup {
256             properties.push(("tooltip-markup", tooltip_markup));
257         }
258         if let Some(ref tooltip_text) = self.tooltip_text {
259             properties.push(("tooltip-text", tooltip_text));
260         }
261         if let Some(ref valign) = self.valign {
262             properties.push(("valign", valign));
263         }
264         if let Some(ref vexpand) = self.vexpand {
265             properties.push(("vexpand", vexpand));
266         }
267         if let Some(ref vexpand_set) = self.vexpand_set {
268             properties.push(("vexpand-set", vexpand_set));
269         }
270         if let Some(ref visible) = self.visible {
271             properties.push(("visible", visible));
272         }
273         if let Some(ref width_request) = self.width_request {
274             properties.push(("width-request", width_request));
275         }
276         if let Some(ref action_name) = self.action_name {
277             properties.push(("action-name", action_name));
278         }
279         if let Some(ref action_target) = self.action_target {
280             properties.push(("action-target", action_target));
281         }
282         glib::Object::new::<CheckButton>(&properties)
283             .expect("Failed to create an instance of CheckButton")
284     }
285 
active(mut self, active: bool) -> Self286     pub fn active(mut self, active: bool) -> Self {
287         self.active = Some(active);
288         self
289     }
290 
draw_indicator(mut self, draw_indicator: bool) -> Self291     pub fn draw_indicator(mut self, draw_indicator: bool) -> Self {
292         self.draw_indicator = Some(draw_indicator);
293         self
294     }
295 
inconsistent(mut self, inconsistent: bool) -> Self296     pub fn inconsistent(mut self, inconsistent: bool) -> Self {
297         self.inconsistent = Some(inconsistent);
298         self
299     }
300 
always_show_image(mut self, always_show_image: bool) -> Self301     pub fn always_show_image(mut self, always_show_image: bool) -> Self {
302         self.always_show_image = Some(always_show_image);
303         self
304     }
305 
image<P: IsA<Widget>>(mut self, image: &P) -> Self306     pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self {
307         self.image = Some(image.clone().upcast());
308         self
309     }
310 
image_position(mut self, image_position: PositionType) -> Self311     pub fn image_position(mut self, image_position: PositionType) -> Self {
312         self.image_position = Some(image_position);
313         self
314     }
315 
label(mut self, label: &str) -> Self316     pub fn label(mut self, label: &str) -> Self {
317         self.label = Some(label.to_string());
318         self
319     }
320 
relief(mut self, relief: ReliefStyle) -> Self321     pub fn relief(mut self, relief: ReliefStyle) -> Self {
322         self.relief = Some(relief);
323         self
324     }
325 
use_underline(mut self, use_underline: bool) -> Self326     pub fn use_underline(mut self, use_underline: bool) -> Self {
327         self.use_underline = Some(use_underline);
328         self
329     }
330 
border_width(mut self, border_width: u32) -> Self331     pub fn border_width(mut self, border_width: u32) -> Self {
332         self.border_width = Some(border_width);
333         self
334     }
335 
child<P: IsA<Widget>>(mut self, child: &P) -> Self336     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
337         self.child = Some(child.clone().upcast());
338         self
339     }
340 
resize_mode(mut self, resize_mode: ResizeMode) -> Self341     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
342         self.resize_mode = Some(resize_mode);
343         self
344     }
345 
app_paintable(mut self, app_paintable: bool) -> Self346     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
347         self.app_paintable = Some(app_paintable);
348         self
349     }
350 
can_default(mut self, can_default: bool) -> Self351     pub fn can_default(mut self, can_default: bool) -> Self {
352         self.can_default = Some(can_default);
353         self
354     }
355 
can_focus(mut self, can_focus: bool) -> Self356     pub fn can_focus(mut self, can_focus: bool) -> Self {
357         self.can_focus = Some(can_focus);
358         self
359     }
360 
events(mut self, events: gdk::EventMask) -> Self361     pub fn events(mut self, events: gdk::EventMask) -> Self {
362         self.events = Some(events);
363         self
364     }
365 
expand(mut self, expand: bool) -> Self366     pub fn expand(mut self, expand: bool) -> Self {
367         self.expand = Some(expand);
368         self
369     }
370 
371     #[cfg(any(feature = "v3_20", feature = "dox"))]
372     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
focus_on_click(mut self, focus_on_click: bool) -> Self373     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
374         self.focus_on_click = Some(focus_on_click);
375         self
376     }
377 
halign(mut self, halign: Align) -> Self378     pub fn halign(mut self, halign: Align) -> Self {
379         self.halign = Some(halign);
380         self
381     }
382 
has_default(mut self, has_default: bool) -> Self383     pub fn has_default(mut self, has_default: bool) -> Self {
384         self.has_default = Some(has_default);
385         self
386     }
387 
has_focus(mut self, has_focus: bool) -> Self388     pub fn has_focus(mut self, has_focus: bool) -> Self {
389         self.has_focus = Some(has_focus);
390         self
391     }
392 
has_tooltip(mut self, has_tooltip: bool) -> Self393     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
394         self.has_tooltip = Some(has_tooltip);
395         self
396     }
397 
height_request(mut self, height_request: i32) -> Self398     pub fn height_request(mut self, height_request: i32) -> Self {
399         self.height_request = Some(height_request);
400         self
401     }
402 
hexpand(mut self, hexpand: bool) -> Self403     pub fn hexpand(mut self, hexpand: bool) -> Self {
404         self.hexpand = Some(hexpand);
405         self
406     }
407 
hexpand_set(mut self, hexpand_set: bool) -> Self408     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
409         self.hexpand_set = Some(hexpand_set);
410         self
411     }
412 
is_focus(mut self, is_focus: bool) -> Self413     pub fn is_focus(mut self, is_focus: bool) -> Self {
414         self.is_focus = Some(is_focus);
415         self
416     }
417 
margin(mut self, margin: i32) -> Self418     pub fn margin(mut self, margin: i32) -> Self {
419         self.margin = Some(margin);
420         self
421     }
422 
margin_bottom(mut self, margin_bottom: i32) -> Self423     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
424         self.margin_bottom = Some(margin_bottom);
425         self
426     }
427 
margin_end(mut self, margin_end: i32) -> Self428     pub fn margin_end(mut self, margin_end: i32) -> Self {
429         self.margin_end = Some(margin_end);
430         self
431     }
432 
margin_start(mut self, margin_start: i32) -> Self433     pub fn margin_start(mut self, margin_start: i32) -> Self {
434         self.margin_start = Some(margin_start);
435         self
436     }
437 
margin_top(mut self, margin_top: i32) -> Self438     pub fn margin_top(mut self, margin_top: i32) -> Self {
439         self.margin_top = Some(margin_top);
440         self
441     }
442 
name(mut self, name: &str) -> Self443     pub fn name(mut self, name: &str) -> Self {
444         self.name = Some(name.to_string());
445         self
446     }
447 
no_show_all(mut self, no_show_all: bool) -> Self448     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
449         self.no_show_all = Some(no_show_all);
450         self
451     }
452 
opacity(mut self, opacity: f64) -> Self453     pub fn opacity(mut self, opacity: f64) -> Self {
454         self.opacity = Some(opacity);
455         self
456     }
457 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self458     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
459         self.parent = Some(parent.clone().upcast());
460         self
461     }
462 
receives_default(mut self, receives_default: bool) -> Self463     pub fn receives_default(mut self, receives_default: bool) -> Self {
464         self.receives_default = Some(receives_default);
465         self
466     }
467 
sensitive(mut self, sensitive: bool) -> Self468     pub fn sensitive(mut self, sensitive: bool) -> Self {
469         self.sensitive = Some(sensitive);
470         self
471     }
472 
tooltip_markup(mut self, tooltip_markup: &str) -> Self473     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
474         self.tooltip_markup = Some(tooltip_markup.to_string());
475         self
476     }
477 
tooltip_text(mut self, tooltip_text: &str) -> Self478     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
479         self.tooltip_text = Some(tooltip_text.to_string());
480         self
481     }
482 
valign(mut self, valign: Align) -> Self483     pub fn valign(mut self, valign: Align) -> Self {
484         self.valign = Some(valign);
485         self
486     }
487 
vexpand(mut self, vexpand: bool) -> Self488     pub fn vexpand(mut self, vexpand: bool) -> Self {
489         self.vexpand = Some(vexpand);
490         self
491     }
492 
vexpand_set(mut self, vexpand_set: bool) -> Self493     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
494         self.vexpand_set = Some(vexpand_set);
495         self
496     }
497 
visible(mut self, visible: bool) -> Self498     pub fn visible(mut self, visible: bool) -> Self {
499         self.visible = Some(visible);
500         self
501     }
502 
width_request(mut self, width_request: i32) -> Self503     pub fn width_request(mut self, width_request: i32) -> Self {
504         self.width_request = Some(width_request);
505         self
506     }
507 
action_name(mut self, action_name: &str) -> Self508     pub fn action_name(mut self, action_name: &str) -> Self {
509         self.action_name = Some(action_name.to_string());
510         self
511     }
512 
action_target(mut self, action_target: &glib::Variant) -> Self513     pub fn action_target(mut self, action_target: &glib::Variant) -> Self {
514         self.action_target = Some(action_target.clone());
515         self
516     }
517 }
518 
519 pub const NONE_CHECK_BUTTON: Option<&CheckButton> = None;
520 
521 impl fmt::Display for CheckButton {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result522     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
523         f.write_str("CheckButton")
524     }
525 }
526