gtk/auto/
check_button.rs

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
5use gdk;
6use glib::object::Cast;
7use glib::translate::*;
8use glib::StaticType;
9use glib::ToValue;
10use gtk_sys;
11use std::fmt;
12use Actionable;
13use Align;
14use Bin;
15use Buildable;
16use Button;
17use Container;
18use PositionType;
19use ReliefStyle;
20use ResizeMode;
21use ToggleButton;
22use Widget;
23
24glib_wrapper! {
25    pub struct CheckButton(Object<gtk_sys::GtkCheckButton, gtk_sys::GtkCheckButtonClass, CheckButtonClass>) @extends ToggleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable;
26
27    match fn {
28        get_type => || gtk_sys::gtk_check_button_get_type(),
29    }
30}
31
32impl CheckButton {
33    pub fn new() -> CheckButton {
34        assert_initialized_main_thread!();
35        unsafe { Widget::from_glib_none(gtk_sys::gtk_check_button_new()).unsafe_cast() }
36    }
37
38    pub fn new_with_label(label: &str) -> CheckButton {
39        assert_initialized_main_thread!();
40        unsafe {
41            Widget::from_glib_none(gtk_sys::gtk_check_button_new_with_label(
42                label.to_glib_none().0,
43            ))
44            .unsafe_cast()
45        }
46    }
47
48    pub fn new_with_mnemonic(label: &str) -> CheckButton {
49        assert_initialized_main_thread!();
50        unsafe {
51            Widget::from_glib_none(gtk_sys::gtk_check_button_new_with_mnemonic(
52                label.to_glib_none().0,
53            ))
54            .unsafe_cast()
55        }
56    }
57}
58
59impl Default for CheckButton {
60    fn default() -> Self {
61        Self::new()
62    }
63}
64
65pub struct CheckButtonBuilder {
66    active: Option<bool>,
67    draw_indicator: Option<bool>,
68    inconsistent: Option<bool>,
69    always_show_image: Option<bool>,
70    image: Option<Widget>,
71    image_position: Option<PositionType>,
72    label: Option<String>,
73    relief: Option<ReliefStyle>,
74    use_underline: Option<bool>,
75    border_width: Option<u32>,
76    child: Option<Widget>,
77    resize_mode: Option<ResizeMode>,
78    app_paintable: Option<bool>,
79    can_default: Option<bool>,
80    can_focus: Option<bool>,
81    events: Option<gdk::EventMask>,
82    expand: Option<bool>,
83    #[cfg(any(feature = "v3_20", feature = "dox"))]
84    focus_on_click: Option<bool>,
85    halign: Option<Align>,
86    has_default: Option<bool>,
87    has_focus: Option<bool>,
88    has_tooltip: Option<bool>,
89    height_request: Option<i32>,
90    hexpand: Option<bool>,
91    hexpand_set: Option<bool>,
92    is_focus: Option<bool>,
93    margin: Option<i32>,
94    margin_bottom: Option<i32>,
95    margin_end: Option<i32>,
96    margin_start: Option<i32>,
97    margin_top: Option<i32>,
98    name: Option<String>,
99    no_show_all: Option<bool>,
100    opacity: Option<f64>,
101    parent: Option<Container>,
102    receives_default: Option<bool>,
103    sensitive: Option<bool>,
104    //style: /*Unknown type*/,
105    tooltip_markup: Option<String>,
106    tooltip_text: Option<String>,
107    valign: Option<Align>,
108    vexpand: Option<bool>,
109    vexpand_set: Option<bool>,
110    visible: Option<bool>,
111    width_request: Option<i32>,
112}
113
114impl CheckButtonBuilder {
115    pub fn new() -> Self {
116        Self {
117            active: None,
118            draw_indicator: None,
119            inconsistent: None,
120            always_show_image: None,
121            image: None,
122            image_position: None,
123            label: None,
124            relief: None,
125            use_underline: None,
126            border_width: None,
127            child: None,
128            resize_mode: None,
129            app_paintable: None,
130            can_default: None,
131            can_focus: None,
132            events: None,
133            expand: None,
134            #[cfg(any(feature = "v3_20", feature = "dox"))]
135            focus_on_click: None,
136            halign: None,
137            has_default: None,
138            has_focus: None,
139            has_tooltip: None,
140            height_request: None,
141            hexpand: None,
142            hexpand_set: None,
143            is_focus: None,
144            margin: None,
145            margin_bottom: None,
146            margin_end: None,
147            margin_start: None,
148            margin_top: None,
149            name: None,
150            no_show_all: None,
151            opacity: None,
152            parent: None,
153            receives_default: None,
154            sensitive: None,
155            tooltip_markup: None,
156            tooltip_text: None,
157            valign: None,
158            vexpand: None,
159            vexpand_set: None,
160            visible: None,
161            width_request: None,
162        }
163    }
164
165    pub fn build(self) -> CheckButton {
166        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
167        if let Some(ref active) = self.active {
168            properties.push(("active", active));
169        }
170        if let Some(ref draw_indicator) = self.draw_indicator {
171            properties.push(("draw-indicator", draw_indicator));
172        }
173        if let Some(ref inconsistent) = self.inconsistent {
174            properties.push(("inconsistent", inconsistent));
175        }
176        if let Some(ref always_show_image) = self.always_show_image {
177            properties.push(("always-show-image", always_show_image));
178        }
179        if let Some(ref image) = self.image {
180            properties.push(("image", image));
181        }
182        if let Some(ref image_position) = self.image_position {
183            properties.push(("image-position", image_position));
184        }
185        if let Some(ref label) = self.label {
186            properties.push(("label", label));
187        }
188        if let Some(ref relief) = self.relief {
189            properties.push(("relief", relief));
190        }
191        if let Some(ref use_underline) = self.use_underline {
192            properties.push(("use-underline", use_underline));
193        }
194        if let Some(ref border_width) = self.border_width {
195            properties.push(("border-width", border_width));
196        }
197        if let Some(ref child) = self.child {
198            properties.push(("child", child));
199        }
200        if let Some(ref resize_mode) = self.resize_mode {
201            properties.push(("resize-mode", resize_mode));
202        }
203        if let Some(ref app_paintable) = self.app_paintable {
204            properties.push(("app-paintable", app_paintable));
205        }
206        if let Some(ref can_default) = self.can_default {
207            properties.push(("can-default", can_default));
208        }
209        if let Some(ref can_focus) = self.can_focus {
210            properties.push(("can-focus", can_focus));
211        }
212        if let Some(ref events) = self.events {
213            properties.push(("events", events));
214        }
215        if let Some(ref expand) = self.expand {
216            properties.push(("expand", expand));
217        }
218        #[cfg(any(feature = "v3_20", feature = "dox"))]
219        {
220            if let Some(ref focus_on_click) = self.focus_on_click {
221                properties.push(("focus-on-click", focus_on_click));
222            }
223        }
224        if let Some(ref halign) = self.halign {
225            properties.push(("halign", halign));
226        }
227        if let Some(ref has_default) = self.has_default {
228            properties.push(("has-default", has_default));
229        }
230        if let Some(ref has_focus) = self.has_focus {
231            properties.push(("has-focus", has_focus));
232        }
233        if let Some(ref has_tooltip) = self.has_tooltip {
234            properties.push(("has-tooltip", has_tooltip));
235        }
236        if let Some(ref height_request) = self.height_request {
237            properties.push(("height-request", height_request));
238        }
239        if let Some(ref hexpand) = self.hexpand {
240            properties.push(("hexpand", hexpand));
241        }
242        if let Some(ref hexpand_set) = self.hexpand_set {
243            properties.push(("hexpand-set", hexpand_set));
244        }
245        if let Some(ref is_focus) = self.is_focus {
246            properties.push(("is-focus", is_focus));
247        }
248        if let Some(ref margin) = self.margin {
249            properties.push(("margin", margin));
250        }
251        if let Some(ref margin_bottom) = self.margin_bottom {
252            properties.push(("margin-bottom", margin_bottom));
253        }
254        if let Some(ref margin_end) = self.margin_end {
255            properties.push(("margin-end", margin_end));
256        }
257        if let Some(ref margin_start) = self.margin_start {
258            properties.push(("margin-start", margin_start));
259        }
260        if let Some(ref margin_top) = self.margin_top {
261            properties.push(("margin-top", margin_top));
262        }
263        if let Some(ref name) = self.name {
264            properties.push(("name", name));
265        }
266        if let Some(ref no_show_all) = self.no_show_all {
267            properties.push(("no-show-all", no_show_all));
268        }
269        if let Some(ref opacity) = self.opacity {
270            properties.push(("opacity", opacity));
271        }
272        if let Some(ref parent) = self.parent {
273            properties.push(("parent", parent));
274        }
275        if let Some(ref receives_default) = self.receives_default {
276            properties.push(("receives-default", receives_default));
277        }
278        if let Some(ref sensitive) = self.sensitive {
279            properties.push(("sensitive", sensitive));
280        }
281        if let Some(ref tooltip_markup) = self.tooltip_markup {
282            properties.push(("tooltip-markup", tooltip_markup));
283        }
284        if let Some(ref tooltip_text) = self.tooltip_text {
285            properties.push(("tooltip-text", tooltip_text));
286        }
287        if let Some(ref valign) = self.valign {
288            properties.push(("valign", valign));
289        }
290        if let Some(ref vexpand) = self.vexpand {
291            properties.push(("vexpand", vexpand));
292        }
293        if let Some(ref vexpand_set) = self.vexpand_set {
294            properties.push(("vexpand-set", vexpand_set));
295        }
296        if let Some(ref visible) = self.visible {
297            properties.push(("visible", visible));
298        }
299        if let Some(ref width_request) = self.width_request {
300            properties.push(("width-request", width_request));
301        }
302        glib::Object::new(CheckButton::static_type(), &properties)
303            .expect("object new")
304            .downcast()
305            .expect("downcast")
306    }
307
308    pub fn active(mut self, active: bool) -> Self {
309        self.active = Some(active);
310        self
311    }
312
313    pub fn draw_indicator(mut self, draw_indicator: bool) -> Self {
314        self.draw_indicator = Some(draw_indicator);
315        self
316    }
317
318    pub fn inconsistent(mut self, inconsistent: bool) -> Self {
319        self.inconsistent = Some(inconsistent);
320        self
321    }
322
323    pub fn always_show_image(mut self, always_show_image: bool) -> Self {
324        self.always_show_image = Some(always_show_image);
325        self
326    }
327
328    pub fn image(mut self, image: &Widget) -> Self {
329        self.image = Some(image.clone());
330        self
331    }
332
333    pub fn image_position(mut self, image_position: PositionType) -> Self {
334        self.image_position = Some(image_position);
335        self
336    }
337
338    pub fn label(mut self, label: &str) -> Self {
339        self.label = Some(label.to_string());
340        self
341    }
342
343    pub fn relief(mut self, relief: ReliefStyle) -> Self {
344        self.relief = Some(relief);
345        self
346    }
347
348    pub fn use_underline(mut self, use_underline: bool) -> Self {
349        self.use_underline = Some(use_underline);
350        self
351    }
352
353    pub fn border_width(mut self, border_width: u32) -> Self {
354        self.border_width = Some(border_width);
355        self
356    }
357
358    pub fn child(mut self, child: &Widget) -> Self {
359        self.child = Some(child.clone());
360        self
361    }
362
363    pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
364        self.resize_mode = Some(resize_mode);
365        self
366    }
367
368    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
369        self.app_paintable = Some(app_paintable);
370        self
371    }
372
373    pub fn can_default(mut self, can_default: bool) -> Self {
374        self.can_default = Some(can_default);
375        self
376    }
377
378    pub fn can_focus(mut self, can_focus: bool) -> Self {
379        self.can_focus = Some(can_focus);
380        self
381    }
382
383    pub fn events(mut self, events: gdk::EventMask) -> Self {
384        self.events = Some(events);
385        self
386    }
387
388    pub fn expand(mut self, expand: bool) -> Self {
389        self.expand = Some(expand);
390        self
391    }
392
393    #[cfg(any(feature = "v3_20", feature = "dox"))]
394    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
395        self.focus_on_click = Some(focus_on_click);
396        self
397    }
398
399    pub fn halign(mut self, halign: Align) -> Self {
400        self.halign = Some(halign);
401        self
402    }
403
404    pub fn has_default(mut self, has_default: bool) -> Self {
405        self.has_default = Some(has_default);
406        self
407    }
408
409    pub fn has_focus(mut self, has_focus: bool) -> Self {
410        self.has_focus = Some(has_focus);
411        self
412    }
413
414    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
415        self.has_tooltip = Some(has_tooltip);
416        self
417    }
418
419    pub fn height_request(mut self, height_request: i32) -> Self {
420        self.height_request = Some(height_request);
421        self
422    }
423
424    pub fn hexpand(mut self, hexpand: bool) -> Self {
425        self.hexpand = Some(hexpand);
426        self
427    }
428
429    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
430        self.hexpand_set = Some(hexpand_set);
431        self
432    }
433
434    pub fn is_focus(mut self, is_focus: bool) -> Self {
435        self.is_focus = Some(is_focus);
436        self
437    }
438
439    pub fn margin(mut self, margin: i32) -> Self {
440        self.margin = Some(margin);
441        self
442    }
443
444    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
445        self.margin_bottom = Some(margin_bottom);
446        self
447    }
448
449    pub fn margin_end(mut self, margin_end: i32) -> Self {
450        self.margin_end = Some(margin_end);
451        self
452    }
453
454    pub fn margin_start(mut self, margin_start: i32) -> Self {
455        self.margin_start = Some(margin_start);
456        self
457    }
458
459    pub fn margin_top(mut self, margin_top: i32) -> Self {
460        self.margin_top = Some(margin_top);
461        self
462    }
463
464    pub fn name(mut self, name: &str) -> Self {
465        self.name = Some(name.to_string());
466        self
467    }
468
469    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
470        self.no_show_all = Some(no_show_all);
471        self
472    }
473
474    pub fn opacity(mut self, opacity: f64) -> Self {
475        self.opacity = Some(opacity);
476        self
477    }
478
479    pub fn parent(mut self, parent: &Container) -> Self {
480        self.parent = Some(parent.clone());
481        self
482    }
483
484    pub fn receives_default(mut self, receives_default: bool) -> Self {
485        self.receives_default = Some(receives_default);
486        self
487    }
488
489    pub fn sensitive(mut self, sensitive: bool) -> Self {
490        self.sensitive = Some(sensitive);
491        self
492    }
493
494    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
495        self.tooltip_markup = Some(tooltip_markup.to_string());
496        self
497    }
498
499    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
500        self.tooltip_text = Some(tooltip_text.to_string());
501        self
502    }
503
504    pub fn valign(mut self, valign: Align) -> Self {
505        self.valign = Some(valign);
506        self
507    }
508
509    pub fn vexpand(mut self, vexpand: bool) -> Self {
510        self.vexpand = Some(vexpand);
511        self
512    }
513
514    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
515        self.vexpand_set = Some(vexpand_set);
516        self
517    }
518
519    pub fn visible(mut self, visible: bool) -> Self {
520        self.visible = Some(visible);
521        self
522    }
523
524    pub fn width_request(mut self, width_request: i32) -> Self {
525        self.width_request = Some(width_request);
526        self
527    }
528}
529
530pub const NONE_CHECK_BUTTON: Option<&CheckButton> = None;
531
532impl fmt::Display for CheckButton {
533    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
534        write!(f, "CheckButton")
535    }
536}