1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// This file was generated by gir (4b09025) from gir-files (71d73f0)
// DO NOT EDIT

use SizeGroupMode;
use Widget;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use gobject_ffi;

glib_wrapper! {
    pub struct SizeGroup(Object<ffi::GtkSizeGroup>);

    match fn {
        get_type => || ffi::gtk_size_group_get_type(),
    }
}

impl SizeGroup {
    pub fn new(mode: SizeGroupMode) -> SizeGroup {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gtk_size_group_new(mode.to_glib()))
        }
    }
}

pub trait SizeGroupExt {
    fn add_widget<P: IsA<Widget>>(&self, widget: &P);

    fn get_ignore_hidden(&self) -> bool;

    fn get_mode(&self) -> SizeGroupMode;

    fn get_widgets(&self) -> Vec<Widget>;

    fn remove_widget<P: IsA<Widget>>(&self, widget: &P);

    fn set_ignore_hidden(&self, ignore_hidden: bool);

    fn set_mode(&self, mode: SizeGroupMode);
}

impl<O: IsA<SizeGroup>> SizeGroupExt for O {
    fn add_widget<P: IsA<Widget>>(&self, widget: &P) {
        unsafe {
            ffi::gtk_size_group_add_widget(self.to_glib_none().0, widget.to_glib_none().0);
        }
    }

    fn get_ignore_hidden(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_size_group_get_ignore_hidden(self.to_glib_none().0))
        }
    }

    fn get_mode(&self) -> SizeGroupMode {
        unsafe {
            from_glib(ffi::gtk_size_group_get_mode(self.to_glib_none().0))
        }
    }

    fn get_widgets(&self) -> Vec<Widget> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::gtk_size_group_get_widgets(self.to_glib_none().0))
        }
    }

    fn remove_widget<P: IsA<Widget>>(&self, widget: &P) {
        unsafe {
            ffi::gtk_size_group_remove_widget(self.to_glib_none().0, widget.to_glib_none().0);
        }
    }

    fn set_ignore_hidden(&self, ignore_hidden: bool) {
        unsafe {
            ffi::gtk_size_group_set_ignore_hidden(self.to_glib_none().0, ignore_hidden.to_glib());
        }
    }

    fn set_mode(&self, mode: SizeGroupMode) {
        unsafe {
            ffi::gtk_size_group_set_mode(self.to_glib_none().0, mode.to_glib());
        }
    }
}