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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::CellArea;
use crate::CellRenderer;
use crate::TreeIter;
use crate::TreeModel;
use glib::object::IsA;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;

glib::wrapper! {
    #[doc(alias = "GtkCellLayout")]
    pub struct CellLayout(Interface<ffi::GtkCellLayout, ffi::GtkCellLayoutIface>);

    match fn {
        type_ => || ffi::gtk_cell_layout_get_type(),
    }
}

impl CellLayout {
    pub const NONE: Option<&'static CellLayout> = None;
}

pub trait CellLayoutExt: 'static {
    #[doc(alias = "gtk_cell_layout_add_attribute")]
    fn add_attribute(&self, cell: &impl IsA<CellRenderer>, attribute: &str, column: i32);

    #[doc(alias = "gtk_cell_layout_clear")]
    fn clear(&self);

    #[doc(alias = "gtk_cell_layout_clear_attributes")]
    fn clear_attributes(&self, cell: &impl IsA<CellRenderer>);

    #[doc(alias = "gtk_cell_layout_get_area")]
    #[doc(alias = "get_area")]
    fn area(&self) -> Option<CellArea>;

    #[doc(alias = "gtk_cell_layout_get_cells")]
    #[doc(alias = "get_cells")]
    fn cells(&self) -> Vec<CellRenderer>;

    #[doc(alias = "gtk_cell_layout_pack_end")]
    fn pack_end(&self, cell: &impl IsA<CellRenderer>, expand: bool);

    #[doc(alias = "gtk_cell_layout_pack_start")]
    fn pack_start(&self, cell: &impl IsA<CellRenderer>, expand: bool);

    #[doc(alias = "gtk_cell_layout_reorder")]
    fn reorder(&self, cell: &impl IsA<CellRenderer>, position: i32);

    #[doc(alias = "gtk_cell_layout_set_cell_data_func")]
    fn set_cell_data_func<P: Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>(
        &self,
        cell: &impl IsA<CellRenderer>,
        func: P,
    );
}

impl<O: IsA<CellLayout>> CellLayoutExt for O {
    fn add_attribute(&self, cell: &impl IsA<CellRenderer>, attribute: &str, column: i32) {
        unsafe {
            ffi::gtk_cell_layout_add_attribute(
                self.as_ref().to_glib_none().0,
                cell.as_ref().to_glib_none().0,
                attribute.to_glib_none().0,
                column,
            );
        }
    }

    fn clear(&self) {
        unsafe {
            ffi::gtk_cell_layout_clear(self.as_ref().to_glib_none().0);
        }
    }

    fn clear_attributes(&self, cell: &impl IsA<CellRenderer>) {
        unsafe {
            ffi::gtk_cell_layout_clear_attributes(
                self.as_ref().to_glib_none().0,
                cell.as_ref().to_glib_none().0,
            );
        }
    }

    fn area(&self) -> Option<CellArea> {
        unsafe {
            from_glib_none(ffi::gtk_cell_layout_get_area(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn cells(&self) -> Vec<CellRenderer> {
        unsafe {
            FromGlibPtrContainer::from_glib_container(ffi::gtk_cell_layout_get_cells(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn pack_end(&self, cell: &impl IsA<CellRenderer>, expand: bool) {
        unsafe {
            ffi::gtk_cell_layout_pack_end(
                self.as_ref().to_glib_none().0,
                cell.as_ref().to_glib_none().0,
                expand.into_glib(),
            );
        }
    }

    fn pack_start(&self, cell: &impl IsA<CellRenderer>, expand: bool) {
        unsafe {
            ffi::gtk_cell_layout_pack_start(
                self.as_ref().to_glib_none().0,
                cell.as_ref().to_glib_none().0,
                expand.into_glib(),
            );
        }
    }

    fn reorder(&self, cell: &impl IsA<CellRenderer>, position: i32) {
        unsafe {
            ffi::gtk_cell_layout_reorder(
                self.as_ref().to_glib_none().0,
                cell.as_ref().to_glib_none().0,
                position,
            );
        }
    }

    fn set_cell_data_func<P: Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>(
        &self,
        cell: &impl IsA<CellRenderer>,
        func: P,
    ) {
        let func_data: Box_<P> = Box_::new(func);
        unsafe extern "C" fn func_func<
            P: Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static,
        >(
            cell_layout: *mut ffi::GtkCellLayout,
            cell: *mut ffi::GtkCellRenderer,
            tree_model: *mut ffi::GtkTreeModel,
            iter: *mut ffi::GtkTreeIter,
            data: glib::ffi::gpointer,
        ) {
            let cell_layout = from_glib_borrow(cell_layout);
            let cell = from_glib_borrow(cell);
            let tree_model = from_glib_borrow(tree_model);
            let iter = from_glib_borrow(iter);
            let callback: &P = &*(data as *mut _);
            (*callback)(&cell_layout, &cell, &tree_model, &iter);
        }
        let func = Some(func_func::<P> as _);
        unsafe extern "C" fn destroy_func<
            P: Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static,
        >(
            data: glib::ffi::gpointer,
        ) {
            let _callback: Box_<P> = Box_::from_raw(data as *mut _);
        }
        let destroy_call4 = Some(destroy_func::<P> as _);
        let super_callback0: Box_<P> = func_data;
        unsafe {
            ffi::gtk_cell_layout_set_cell_data_func(
                self.as_ref().to_glib_none().0,
                cell.as_ref().to_glib_none().0,
                func,
                Box_::into_raw(super_callback0) as *mut _,
                destroy_call4,
            );
        }
    }
}

impl fmt::Display for CellLayout {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("CellLayout")
    }
}