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