gtk/auto/
level_bar.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::GString;
12use glib::StaticType;
13use glib::ToValue;
14use glib_sys;
15use gtk_sys;
16use libc;
17use std::boxed::Box as Box_;
18use std::fmt;
19use std::mem;
20use std::mem::transmute;
21use Align;
22use Buildable;
23use Container;
24use LevelBarMode;
25use Orientable;
26use Widget;
27
28glib_wrapper! {
29    pub struct LevelBar(Object<gtk_sys::GtkLevelBar, gtk_sys::GtkLevelBarClass, LevelBarClass>) @extends Widget, @implements Buildable, Orientable;
30
31    match fn {
32        get_type => || gtk_sys::gtk_level_bar_get_type(),
33    }
34}
35
36impl LevelBar {
37    pub fn new() -> LevelBar {
38        assert_initialized_main_thread!();
39        unsafe { Widget::from_glib_none(gtk_sys::gtk_level_bar_new()).unsafe_cast() }
40    }
41
42    pub fn new_for_interval(min_value: f64, max_value: f64) -> LevelBar {
43        assert_initialized_main_thread!();
44        unsafe {
45            Widget::from_glib_none(gtk_sys::gtk_level_bar_new_for_interval(
46                min_value, max_value,
47            ))
48            .unsafe_cast()
49        }
50    }
51}
52
53impl Default for LevelBar {
54    fn default() -> Self {
55        Self::new()
56    }
57}
58
59pub struct LevelBarBuilder {
60    inverted: Option<bool>,
61    max_value: Option<f64>,
62    min_value: Option<f64>,
63    mode: Option<LevelBarMode>,
64    value: Option<f64>,
65    app_paintable: Option<bool>,
66    can_default: Option<bool>,
67    can_focus: Option<bool>,
68    events: Option<gdk::EventMask>,
69    expand: Option<bool>,
70    #[cfg(any(feature = "v3_20", feature = "dox"))]
71    focus_on_click: Option<bool>,
72    halign: Option<Align>,
73    has_default: Option<bool>,
74    has_focus: Option<bool>,
75    has_tooltip: Option<bool>,
76    height_request: Option<i32>,
77    hexpand: Option<bool>,
78    hexpand_set: Option<bool>,
79    is_focus: Option<bool>,
80    margin: Option<i32>,
81    margin_bottom: Option<i32>,
82    margin_end: Option<i32>,
83    margin_start: Option<i32>,
84    margin_top: Option<i32>,
85    name: Option<String>,
86    no_show_all: Option<bool>,
87    opacity: Option<f64>,
88    parent: Option<Container>,
89    receives_default: Option<bool>,
90    sensitive: Option<bool>,
91    //style: /*Unknown type*/,
92    tooltip_markup: Option<String>,
93    tooltip_text: Option<String>,
94    valign: Option<Align>,
95    vexpand: Option<bool>,
96    vexpand_set: Option<bool>,
97    visible: Option<bool>,
98    width_request: Option<i32>,
99}
100
101impl LevelBarBuilder {
102    pub fn new() -> Self {
103        Self {
104            inverted: None,
105            max_value: None,
106            min_value: None,
107            mode: None,
108            value: None,
109            app_paintable: None,
110            can_default: None,
111            can_focus: None,
112            events: None,
113            expand: None,
114            #[cfg(any(feature = "v3_20", feature = "dox"))]
115            focus_on_click: None,
116            halign: None,
117            has_default: None,
118            has_focus: None,
119            has_tooltip: None,
120            height_request: None,
121            hexpand: None,
122            hexpand_set: None,
123            is_focus: None,
124            margin: None,
125            margin_bottom: None,
126            margin_end: None,
127            margin_start: None,
128            margin_top: None,
129            name: None,
130            no_show_all: None,
131            opacity: None,
132            parent: None,
133            receives_default: None,
134            sensitive: None,
135            tooltip_markup: None,
136            tooltip_text: None,
137            valign: None,
138            vexpand: None,
139            vexpand_set: None,
140            visible: None,
141            width_request: None,
142        }
143    }
144
145    pub fn build(self) -> LevelBar {
146        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
147        if let Some(ref inverted) = self.inverted {
148            properties.push(("inverted", inverted));
149        }
150        if let Some(ref max_value) = self.max_value {
151            properties.push(("max-value", max_value));
152        }
153        if let Some(ref min_value) = self.min_value {
154            properties.push(("min-value", min_value));
155        }
156        if let Some(ref mode) = self.mode {
157            properties.push(("mode", mode));
158        }
159        if let Some(ref value) = self.value {
160            properties.push(("value", value));
161        }
162        if let Some(ref app_paintable) = self.app_paintable {
163            properties.push(("app-paintable", app_paintable));
164        }
165        if let Some(ref can_default) = self.can_default {
166            properties.push(("can-default", can_default));
167        }
168        if let Some(ref can_focus) = self.can_focus {
169            properties.push(("can-focus", can_focus));
170        }
171        if let Some(ref events) = self.events {
172            properties.push(("events", events));
173        }
174        if let Some(ref expand) = self.expand {
175            properties.push(("expand", expand));
176        }
177        #[cfg(any(feature = "v3_20", feature = "dox"))]
178        {
179            if let Some(ref focus_on_click) = self.focus_on_click {
180                properties.push(("focus-on-click", focus_on_click));
181            }
182        }
183        if let Some(ref halign) = self.halign {
184            properties.push(("halign", halign));
185        }
186        if let Some(ref has_default) = self.has_default {
187            properties.push(("has-default", has_default));
188        }
189        if let Some(ref has_focus) = self.has_focus {
190            properties.push(("has-focus", has_focus));
191        }
192        if let Some(ref has_tooltip) = self.has_tooltip {
193            properties.push(("has-tooltip", has_tooltip));
194        }
195        if let Some(ref height_request) = self.height_request {
196            properties.push(("height-request", height_request));
197        }
198        if let Some(ref hexpand) = self.hexpand {
199            properties.push(("hexpand", hexpand));
200        }
201        if let Some(ref hexpand_set) = self.hexpand_set {
202            properties.push(("hexpand-set", hexpand_set));
203        }
204        if let Some(ref is_focus) = self.is_focus {
205            properties.push(("is-focus", is_focus));
206        }
207        if let Some(ref margin) = self.margin {
208            properties.push(("margin", margin));
209        }
210        if let Some(ref margin_bottom) = self.margin_bottom {
211            properties.push(("margin-bottom", margin_bottom));
212        }
213        if let Some(ref margin_end) = self.margin_end {
214            properties.push(("margin-end", margin_end));
215        }
216        if let Some(ref margin_start) = self.margin_start {
217            properties.push(("margin-start", margin_start));
218        }
219        if let Some(ref margin_top) = self.margin_top {
220            properties.push(("margin-top", margin_top));
221        }
222        if let Some(ref name) = self.name {
223            properties.push(("name", name));
224        }
225        if let Some(ref no_show_all) = self.no_show_all {
226            properties.push(("no-show-all", no_show_all));
227        }
228        if let Some(ref opacity) = self.opacity {
229            properties.push(("opacity", opacity));
230        }
231        if let Some(ref parent) = self.parent {
232            properties.push(("parent", parent));
233        }
234        if let Some(ref receives_default) = self.receives_default {
235            properties.push(("receives-default", receives_default));
236        }
237        if let Some(ref sensitive) = self.sensitive {
238            properties.push(("sensitive", sensitive));
239        }
240        if let Some(ref tooltip_markup) = self.tooltip_markup {
241            properties.push(("tooltip-markup", tooltip_markup));
242        }
243        if let Some(ref tooltip_text) = self.tooltip_text {
244            properties.push(("tooltip-text", tooltip_text));
245        }
246        if let Some(ref valign) = self.valign {
247            properties.push(("valign", valign));
248        }
249        if let Some(ref vexpand) = self.vexpand {
250            properties.push(("vexpand", vexpand));
251        }
252        if let Some(ref vexpand_set) = self.vexpand_set {
253            properties.push(("vexpand-set", vexpand_set));
254        }
255        if let Some(ref visible) = self.visible {
256            properties.push(("visible", visible));
257        }
258        if let Some(ref width_request) = self.width_request {
259            properties.push(("width-request", width_request));
260        }
261        glib::Object::new(LevelBar::static_type(), &properties)
262            .expect("object new")
263            .downcast()
264            .expect("downcast")
265    }
266
267    pub fn inverted(mut self, inverted: bool) -> Self {
268        self.inverted = Some(inverted);
269        self
270    }
271
272    pub fn max_value(mut self, max_value: f64) -> Self {
273        self.max_value = Some(max_value);
274        self
275    }
276
277    pub fn min_value(mut self, min_value: f64) -> Self {
278        self.min_value = Some(min_value);
279        self
280    }
281
282    pub fn mode(mut self, mode: LevelBarMode) -> Self {
283        self.mode = Some(mode);
284        self
285    }
286
287    pub fn value(mut self, value: f64) -> Self {
288        self.value = Some(value);
289        self
290    }
291
292    pub fn app_paintable(mut self, app_paintable: bool) -> Self {
293        self.app_paintable = Some(app_paintable);
294        self
295    }
296
297    pub fn can_default(mut self, can_default: bool) -> Self {
298        self.can_default = Some(can_default);
299        self
300    }
301
302    pub fn can_focus(mut self, can_focus: bool) -> Self {
303        self.can_focus = Some(can_focus);
304        self
305    }
306
307    pub fn events(mut self, events: gdk::EventMask) -> Self {
308        self.events = Some(events);
309        self
310    }
311
312    pub fn expand(mut self, expand: bool) -> Self {
313        self.expand = Some(expand);
314        self
315    }
316
317    #[cfg(any(feature = "v3_20", feature = "dox"))]
318    pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
319        self.focus_on_click = Some(focus_on_click);
320        self
321    }
322
323    pub fn halign(mut self, halign: Align) -> Self {
324        self.halign = Some(halign);
325        self
326    }
327
328    pub fn has_default(mut self, has_default: bool) -> Self {
329        self.has_default = Some(has_default);
330        self
331    }
332
333    pub fn has_focus(mut self, has_focus: bool) -> Self {
334        self.has_focus = Some(has_focus);
335        self
336    }
337
338    pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
339        self.has_tooltip = Some(has_tooltip);
340        self
341    }
342
343    pub fn height_request(mut self, height_request: i32) -> Self {
344        self.height_request = Some(height_request);
345        self
346    }
347
348    pub fn hexpand(mut self, hexpand: bool) -> Self {
349        self.hexpand = Some(hexpand);
350        self
351    }
352
353    pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
354        self.hexpand_set = Some(hexpand_set);
355        self
356    }
357
358    pub fn is_focus(mut self, is_focus: bool) -> Self {
359        self.is_focus = Some(is_focus);
360        self
361    }
362
363    pub fn margin(mut self, margin: i32) -> Self {
364        self.margin = Some(margin);
365        self
366    }
367
368    pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
369        self.margin_bottom = Some(margin_bottom);
370        self
371    }
372
373    pub fn margin_end(mut self, margin_end: i32) -> Self {
374        self.margin_end = Some(margin_end);
375        self
376    }
377
378    pub fn margin_start(mut self, margin_start: i32) -> Self {
379        self.margin_start = Some(margin_start);
380        self
381    }
382
383    pub fn margin_top(mut self, margin_top: i32) -> Self {
384        self.margin_top = Some(margin_top);
385        self
386    }
387
388    pub fn name(mut self, name: &str) -> Self {
389        self.name = Some(name.to_string());
390        self
391    }
392
393    pub fn no_show_all(mut self, no_show_all: bool) -> Self {
394        self.no_show_all = Some(no_show_all);
395        self
396    }
397
398    pub fn opacity(mut self, opacity: f64) -> Self {
399        self.opacity = Some(opacity);
400        self
401    }
402
403    pub fn parent(mut self, parent: &Container) -> Self {
404        self.parent = Some(parent.clone());
405        self
406    }
407
408    pub fn receives_default(mut self, receives_default: bool) -> Self {
409        self.receives_default = Some(receives_default);
410        self
411    }
412
413    pub fn sensitive(mut self, sensitive: bool) -> Self {
414        self.sensitive = Some(sensitive);
415        self
416    }
417
418    pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
419        self.tooltip_markup = Some(tooltip_markup.to_string());
420        self
421    }
422
423    pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
424        self.tooltip_text = Some(tooltip_text.to_string());
425        self
426    }
427
428    pub fn valign(mut self, valign: Align) -> Self {
429        self.valign = Some(valign);
430        self
431    }
432
433    pub fn vexpand(mut self, vexpand: bool) -> Self {
434        self.vexpand = Some(vexpand);
435        self
436    }
437
438    pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
439        self.vexpand_set = Some(vexpand_set);
440        self
441    }
442
443    pub fn visible(mut self, visible: bool) -> Self {
444        self.visible = Some(visible);
445        self
446    }
447
448    pub fn width_request(mut self, width_request: i32) -> Self {
449        self.width_request = Some(width_request);
450        self
451    }
452}
453
454pub const NONE_LEVEL_BAR: Option<&LevelBar> = None;
455
456pub trait LevelBarExt: 'static {
457    fn add_offset_value(&self, name: &str, value: f64);
458
459    fn get_inverted(&self) -> bool;
460
461    fn get_max_value(&self) -> f64;
462
463    fn get_min_value(&self) -> f64;
464
465    fn get_mode(&self) -> LevelBarMode;
466
467    fn get_offset_value(&self, name: Option<&str>) -> Option<f64>;
468
469    fn get_value(&self) -> f64;
470
471    fn remove_offset_value(&self, name: Option<&str>);
472
473    fn set_inverted(&self, inverted: bool);
474
475    fn set_max_value(&self, value: f64);
476
477    fn set_min_value(&self, value: f64);
478
479    fn set_mode(&self, mode: LevelBarMode);
480
481    fn set_value(&self, value: f64);
482
483    fn connect_offset_changed<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId;
484
485    fn connect_property_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
486
487    fn connect_property_max_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
488
489    fn connect_property_min_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
490
491    fn connect_property_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
492
493    fn connect_property_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
494}
495
496impl<O: IsA<LevelBar>> LevelBarExt for O {
497    fn add_offset_value(&self, name: &str, value: f64) {
498        unsafe {
499            gtk_sys::gtk_level_bar_add_offset_value(
500                self.as_ref().to_glib_none().0,
501                name.to_glib_none().0,
502                value,
503            );
504        }
505    }
506
507    fn get_inverted(&self) -> bool {
508        unsafe {
509            from_glib(gtk_sys::gtk_level_bar_get_inverted(
510                self.as_ref().to_glib_none().0,
511            ))
512        }
513    }
514
515    fn get_max_value(&self) -> f64 {
516        unsafe { gtk_sys::gtk_level_bar_get_max_value(self.as_ref().to_glib_none().0) }
517    }
518
519    fn get_min_value(&self) -> f64 {
520        unsafe { gtk_sys::gtk_level_bar_get_min_value(self.as_ref().to_glib_none().0) }
521    }
522
523    fn get_mode(&self) -> LevelBarMode {
524        unsafe {
525            from_glib(gtk_sys::gtk_level_bar_get_mode(
526                self.as_ref().to_glib_none().0,
527            ))
528        }
529    }
530
531    fn get_offset_value(&self, name: Option<&str>) -> Option<f64> {
532        unsafe {
533            let mut value = mem::uninitialized();
534            let ret = from_glib(gtk_sys::gtk_level_bar_get_offset_value(
535                self.as_ref().to_glib_none().0,
536                name.to_glib_none().0,
537                &mut value,
538            ));
539            if ret {
540                Some(value)
541            } else {
542                None
543            }
544        }
545    }
546
547    fn get_value(&self) -> f64 {
548        unsafe { gtk_sys::gtk_level_bar_get_value(self.as_ref().to_glib_none().0) }
549    }
550
551    fn remove_offset_value(&self, name: Option<&str>) {
552        unsafe {
553            gtk_sys::gtk_level_bar_remove_offset_value(
554                self.as_ref().to_glib_none().0,
555                name.to_glib_none().0,
556            );
557        }
558    }
559
560    fn set_inverted(&self, inverted: bool) {
561        unsafe {
562            gtk_sys::gtk_level_bar_set_inverted(self.as_ref().to_glib_none().0, inverted.to_glib());
563        }
564    }
565
566    fn set_max_value(&self, value: f64) {
567        unsafe {
568            gtk_sys::gtk_level_bar_set_max_value(self.as_ref().to_glib_none().0, value);
569        }
570    }
571
572    fn set_min_value(&self, value: f64) {
573        unsafe {
574            gtk_sys::gtk_level_bar_set_min_value(self.as_ref().to_glib_none().0, value);
575        }
576    }
577
578    fn set_mode(&self, mode: LevelBarMode) {
579        unsafe {
580            gtk_sys::gtk_level_bar_set_mode(self.as_ref().to_glib_none().0, mode.to_glib());
581        }
582    }
583
584    fn set_value(&self, value: f64) {
585        unsafe {
586            gtk_sys::gtk_level_bar_set_value(self.as_ref().to_glib_none().0, value);
587        }
588    }
589
590    fn connect_offset_changed<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
591        unsafe extern "C" fn offset_changed_trampoline<P, F: Fn(&P, &str) + 'static>(
592            this: *mut gtk_sys::GtkLevelBar,
593            name: *mut libc::c_char,
594            f: glib_sys::gpointer,
595        ) where
596            P: IsA<LevelBar>,
597        {
598            let f: &F = &*(f as *const F);
599            f(
600                &LevelBar::from_glib_borrow(this).unsafe_cast(),
601                &GString::from_glib_borrow(name),
602            )
603        }
604        unsafe {
605            let f: Box_<F> = Box_::new(f);
606            connect_raw(
607                self.as_ptr() as *mut _,
608                b"offset-changed\0".as_ptr() as *const _,
609                Some(transmute(offset_changed_trampoline::<Self, F> as usize)),
610                Box_::into_raw(f),
611            )
612        }
613    }
614
615    fn connect_property_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
616        unsafe extern "C" fn notify_inverted_trampoline<P, F: Fn(&P) + 'static>(
617            this: *mut gtk_sys::GtkLevelBar,
618            _param_spec: glib_sys::gpointer,
619            f: glib_sys::gpointer,
620        ) where
621            P: IsA<LevelBar>,
622        {
623            let f: &F = &*(f as *const F);
624            f(&LevelBar::from_glib_borrow(this).unsafe_cast())
625        }
626        unsafe {
627            let f: Box_<F> = Box_::new(f);
628            connect_raw(
629                self.as_ptr() as *mut _,
630                b"notify::inverted\0".as_ptr() as *const _,
631                Some(transmute(notify_inverted_trampoline::<Self, F> as usize)),
632                Box_::into_raw(f),
633            )
634        }
635    }
636
637    fn connect_property_max_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
638        unsafe extern "C" fn notify_max_value_trampoline<P, F: Fn(&P) + 'static>(
639            this: *mut gtk_sys::GtkLevelBar,
640            _param_spec: glib_sys::gpointer,
641            f: glib_sys::gpointer,
642        ) where
643            P: IsA<LevelBar>,
644        {
645            let f: &F = &*(f as *const F);
646            f(&LevelBar::from_glib_borrow(this).unsafe_cast())
647        }
648        unsafe {
649            let f: Box_<F> = Box_::new(f);
650            connect_raw(
651                self.as_ptr() as *mut _,
652                b"notify::max-value\0".as_ptr() as *const _,
653                Some(transmute(notify_max_value_trampoline::<Self, F> as usize)),
654                Box_::into_raw(f),
655            )
656        }
657    }
658
659    fn connect_property_min_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
660        unsafe extern "C" fn notify_min_value_trampoline<P, F: Fn(&P) + 'static>(
661            this: *mut gtk_sys::GtkLevelBar,
662            _param_spec: glib_sys::gpointer,
663            f: glib_sys::gpointer,
664        ) where
665            P: IsA<LevelBar>,
666        {
667            let f: &F = &*(f as *const F);
668            f(&LevelBar::from_glib_borrow(this).unsafe_cast())
669        }
670        unsafe {
671            let f: Box_<F> = Box_::new(f);
672            connect_raw(
673                self.as_ptr() as *mut _,
674                b"notify::min-value\0".as_ptr() as *const _,
675                Some(transmute(notify_min_value_trampoline::<Self, F> as usize)),
676                Box_::into_raw(f),
677            )
678        }
679    }
680
681    fn connect_property_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
682        unsafe extern "C" fn notify_mode_trampoline<P, F: Fn(&P) + 'static>(
683            this: *mut gtk_sys::GtkLevelBar,
684            _param_spec: glib_sys::gpointer,
685            f: glib_sys::gpointer,
686        ) where
687            P: IsA<LevelBar>,
688        {
689            let f: &F = &*(f as *const F);
690            f(&LevelBar::from_glib_borrow(this).unsafe_cast())
691        }
692        unsafe {
693            let f: Box_<F> = Box_::new(f);
694            connect_raw(
695                self.as_ptr() as *mut _,
696                b"notify::mode\0".as_ptr() as *const _,
697                Some(transmute(notify_mode_trampoline::<Self, F> as usize)),
698                Box_::into_raw(f),
699            )
700        }
701    }
702
703    fn connect_property_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
704        unsafe extern "C" fn notify_value_trampoline<P, F: Fn(&P) + 'static>(
705            this: *mut gtk_sys::GtkLevelBar,
706            _param_spec: glib_sys::gpointer,
707            f: glib_sys::gpointer,
708        ) where
709            P: IsA<LevelBar>,
710        {
711            let f: &F = &*(f as *const F);
712            f(&LevelBar::from_glib_borrow(this).unsafe_cast())
713        }
714        unsafe {
715            let f: Box_<F> = Box_::new(f);
716            connect_raw(
717                self.as_ptr() as *mut _,
718                b"notify::value\0".as_ptr() as *const _,
719                Some(transmute(notify_value_trampoline::<Self, F> as usize)),
720                Box_::into_raw(f),
721            )
722        }
723    }
724}
725
726impl fmt::Display for LevelBar {
727    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
728        write!(f, "LevelBar")
729    }
730}