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 
5 use crate::CellArea;
6 use crate::CellRenderer;
7 use crate::TreeIter;
8 use crate::TreeModel;
9 use glib::object::IsA;
10 use glib::translate::*;
11 use std::boxed::Box as Box_;
12 use std::fmt;
13 
14 glib::wrapper! {
15     #[doc(alias = "GtkCellLayout")]
16     pub struct CellLayout(Interface<ffi::GtkCellLayout, ffi::GtkCellLayoutIface>);
17 
18     match fn {
19         type_ => || ffi::gtk_cell_layout_get_type(),
20     }
21 }
22 
23 pub const NONE_CELL_LAYOUT: Option<&CellLayout> = None;
24 
25 pub trait CellLayoutExt: 'static {
26     #[doc(alias = "gtk_cell_layout_add_attribute")]
add_attribute<P: IsA<CellRenderer>>(&self, cell: &P, attribute: &str, column: i32)27     fn add_attribute<P: IsA<CellRenderer>>(&self, cell: &P, attribute: &str, column: i32);
28 
29     #[doc(alias = "gtk_cell_layout_clear")]
clear(&self)30     fn clear(&self);
31 
32     #[doc(alias = "gtk_cell_layout_clear_attributes")]
clear_attributes<P: IsA<CellRenderer>>(&self, cell: &P)33     fn clear_attributes<P: IsA<CellRenderer>>(&self, cell: &P);
34 
35     #[doc(alias = "gtk_cell_layout_get_area")]
36     #[doc(alias = "get_area")]
area(&self) -> Option<CellArea>37     fn area(&self) -> Option<CellArea>;
38 
39     #[doc(alias = "gtk_cell_layout_get_cells")]
40     #[doc(alias = "get_cells")]
cells(&self) -> Vec<CellRenderer>41     fn cells(&self) -> Vec<CellRenderer>;
42 
43     #[doc(alias = "gtk_cell_layout_pack_end")]
pack_end<P: IsA<CellRenderer>>(&self, cell: &P, expand: bool)44     fn pack_end<P: IsA<CellRenderer>>(&self, cell: &P, expand: bool);
45 
46     #[doc(alias = "gtk_cell_layout_pack_start")]
pack_start<P: IsA<CellRenderer>>(&self, cell: &P, expand: bool)47     fn pack_start<P: IsA<CellRenderer>>(&self, cell: &P, expand: bool);
48 
49     #[doc(alias = "gtk_cell_layout_reorder")]
reorder<P: IsA<CellRenderer>>(&self, cell: &P, position: i32)50     fn reorder<P: IsA<CellRenderer>>(&self, cell: &P, position: i32);
51 
52     //#[doc(alias = "gtk_cell_layout_set_attributes")]
53     //fn set_attributes<P: IsA<CellRenderer>>(&self, cell: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
54 
55     #[doc(alias = "gtk_cell_layout_set_cell_data_func")]
set_cell_data_func<P: IsA<CellRenderer>>( &self, cell: &P, func: Option<Box_<dyn Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>>, )56     fn set_cell_data_func<P: IsA<CellRenderer>>(
57         &self,
58         cell: &P,
59         func: Option<Box_<dyn Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>>,
60     );
61 }
62 
63 impl<O: IsA<CellLayout>> CellLayoutExt for O {
add_attribute<P: IsA<CellRenderer>>(&self, cell: &P, attribute: &str, column: i32)64     fn add_attribute<P: IsA<CellRenderer>>(&self, cell: &P, attribute: &str, column: i32) {
65         unsafe {
66             ffi::gtk_cell_layout_add_attribute(
67                 self.as_ref().to_glib_none().0,
68                 cell.as_ref().to_glib_none().0,
69                 attribute.to_glib_none().0,
70                 column,
71             );
72         }
73     }
74 
clear(&self)75     fn clear(&self) {
76         unsafe {
77             ffi::gtk_cell_layout_clear(self.as_ref().to_glib_none().0);
78         }
79     }
80 
clear_attributes<P: IsA<CellRenderer>>(&self, cell: &P)81     fn clear_attributes<P: IsA<CellRenderer>>(&self, cell: &P) {
82         unsafe {
83             ffi::gtk_cell_layout_clear_attributes(
84                 self.as_ref().to_glib_none().0,
85                 cell.as_ref().to_glib_none().0,
86             );
87         }
88     }
89 
area(&self) -> Option<CellArea>90     fn area(&self) -> Option<CellArea> {
91         unsafe {
92             from_glib_none(ffi::gtk_cell_layout_get_area(
93                 self.as_ref().to_glib_none().0,
94             ))
95         }
96     }
97 
cells(&self) -> Vec<CellRenderer>98     fn cells(&self) -> Vec<CellRenderer> {
99         unsafe {
100             FromGlibPtrContainer::from_glib_container(ffi::gtk_cell_layout_get_cells(
101                 self.as_ref().to_glib_none().0,
102             ))
103         }
104     }
105 
pack_end<P: IsA<CellRenderer>>(&self, cell: &P, expand: bool)106     fn pack_end<P: IsA<CellRenderer>>(&self, cell: &P, expand: bool) {
107         unsafe {
108             ffi::gtk_cell_layout_pack_end(
109                 self.as_ref().to_glib_none().0,
110                 cell.as_ref().to_glib_none().0,
111                 expand.into_glib(),
112             );
113         }
114     }
115 
pack_start<P: IsA<CellRenderer>>(&self, cell: &P, expand: bool)116     fn pack_start<P: IsA<CellRenderer>>(&self, cell: &P, expand: bool) {
117         unsafe {
118             ffi::gtk_cell_layout_pack_start(
119                 self.as_ref().to_glib_none().0,
120                 cell.as_ref().to_glib_none().0,
121                 expand.into_glib(),
122             );
123         }
124     }
125 
reorder<P: IsA<CellRenderer>>(&self, cell: &P, position: i32)126     fn reorder<P: IsA<CellRenderer>>(&self, cell: &P, position: i32) {
127         unsafe {
128             ffi::gtk_cell_layout_reorder(
129                 self.as_ref().to_glib_none().0,
130                 cell.as_ref().to_glib_none().0,
131                 position,
132             );
133         }
134     }
135 
136     //fn set_attributes<P: IsA<CellRenderer>>(&self, cell: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
137     //    unsafe { TODO: call ffi:gtk_cell_layout_set_attributes() }
138     //}
139 
set_cell_data_func<P: IsA<CellRenderer>>( &self, cell: &P, func: Option<Box_<dyn Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>>, )140     fn set_cell_data_func<P: IsA<CellRenderer>>(
141         &self,
142         cell: &P,
143         func: Option<Box_<dyn Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>>,
144     ) {
145         let func_data: Box_<
146             Option<Box_<dyn Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>>,
147         > = Box_::new(func);
148         unsafe extern "C" fn func_func<P: IsA<CellRenderer>>(
149             cell_layout: *mut ffi::GtkCellLayout,
150             cell: *mut ffi::GtkCellRenderer,
151             tree_model: *mut ffi::GtkTreeModel,
152             iter: *mut ffi::GtkTreeIter,
153             data: glib::ffi::gpointer,
154         ) {
155             let cell_layout = from_glib_borrow(cell_layout);
156             let cell = from_glib_borrow(cell);
157             let tree_model = from_glib_borrow(tree_model);
158             let iter = from_glib_borrow(iter);
159             let callback: &Option<
160                 Box_<dyn Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>,
161             > = &*(data as *mut _);
162             if let Some(ref callback) = *callback {
163                 callback(&cell_layout, &cell, &tree_model, &iter)
164             } else {
165                 panic!("cannot get closure...")
166             };
167         }
168         let func = if func_data.is_some() {
169             Some(func_func::<P> as _)
170         } else {
171             None
172         };
173         unsafe extern "C" fn destroy_func<P: IsA<CellRenderer>>(data: glib::ffi::gpointer) {
174             let _callback: Box_<
175                 Option<Box_<dyn Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>>,
176             > = Box_::from_raw(data as *mut _);
177         }
178         let destroy_call4 = Some(destroy_func::<P> as _);
179         let super_callback0: Box_<
180             Option<Box_<dyn Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>>,
181         > = func_data;
182         unsafe {
183             ffi::gtk_cell_layout_set_cell_data_func(
184                 self.as_ref().to_glib_none().0,
185                 cell.as_ref().to_glib_none().0,
186                 func,
187                 Box_::into_raw(super_callback0) as *mut _,
188                 destroy_call4,
189             );
190         }
191     }
192 }
193 
194 impl fmt::Display for CellLayout {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result195     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
196         f.write_str("CellLayout")
197     }
198 }
199