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