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::Buildable; 6 use crate::CellArea; 7 use crate::CellLayout; 8 use crate::CellRenderer; 9 use crate::Orientable; 10 use crate::Orientation; 11 use glib::object::Cast; 12 use glib::object::IsA; 13 use glib::signal::connect_raw; 14 use glib::signal::SignalHandlerId; 15 use glib::translate::*; 16 use glib::StaticType; 17 use glib::ToValue; 18 use std::boxed::Box as Box_; 19 use std::fmt; 20 use std::mem::transmute; 21 22 glib::wrapper! { 23 #[doc(alias = "GtkCellAreaBox")] 24 pub struct CellAreaBox(Object<ffi::GtkCellAreaBox, ffi::GtkCellAreaBoxClass>) @extends CellArea, @implements Buildable, CellLayout, Orientable; 25 26 match fn { 27 type_ => || ffi::gtk_cell_area_box_get_type(), 28 } 29 } 30 31 impl CellAreaBox { 32 #[doc(alias = "gtk_cell_area_box_new")] new() -> CellAreaBox33 pub fn new() -> CellAreaBox { 34 assert_initialized_main_thread!(); 35 unsafe { CellArea::from_glib_none(ffi::gtk_cell_area_box_new()).unsafe_cast() } 36 } 37 38 // rustdoc-stripper-ignore-next 39 /// Creates a new builder-pattern struct instance to construct [`CellAreaBox`] objects. 40 /// 41 /// This method returns an instance of [`CellAreaBoxBuilder`] which can be used to create [`CellAreaBox`] objects. builder() -> CellAreaBoxBuilder42 pub fn builder() -> CellAreaBoxBuilder { 43 CellAreaBoxBuilder::default() 44 } 45 } 46 47 impl Default for CellAreaBox { default() -> Self48 fn default() -> Self { 49 Self::new() 50 } 51 } 52 53 #[derive(Clone, Default)] 54 // rustdoc-stripper-ignore-next 55 /// A [builder-pattern] type to construct [`CellAreaBox`] objects. 56 /// 57 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 58 pub struct CellAreaBoxBuilder { 59 spacing: Option<i32>, 60 focus_cell: Option<CellRenderer>, 61 orientation: Option<Orientation>, 62 } 63 64 impl CellAreaBoxBuilder { 65 // rustdoc-stripper-ignore-next 66 /// Create a new [`CellAreaBoxBuilder`]. new() -> Self67 pub fn new() -> Self { 68 Self::default() 69 } 70 71 // rustdoc-stripper-ignore-next 72 /// Build the [`CellAreaBox`]. build(self) -> CellAreaBox73 pub fn build(self) -> CellAreaBox { 74 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 75 if let Some(ref spacing) = self.spacing { 76 properties.push(("spacing", spacing)); 77 } 78 if let Some(ref focus_cell) = self.focus_cell { 79 properties.push(("focus-cell", focus_cell)); 80 } 81 if let Some(ref orientation) = self.orientation { 82 properties.push(("orientation", orientation)); 83 } 84 glib::Object::new::<CellAreaBox>(&properties) 85 .expect("Failed to create an instance of CellAreaBox") 86 } 87 spacing(mut self, spacing: i32) -> Self88 pub fn spacing(mut self, spacing: i32) -> Self { 89 self.spacing = Some(spacing); 90 self 91 } 92 focus_cell<P: IsA<CellRenderer>>(mut self, focus_cell: &P) -> Self93 pub fn focus_cell<P: IsA<CellRenderer>>(mut self, focus_cell: &P) -> Self { 94 self.focus_cell = Some(focus_cell.clone().upcast()); 95 self 96 } 97 orientation(mut self, orientation: Orientation) -> Self98 pub fn orientation(mut self, orientation: Orientation) -> Self { 99 self.orientation = Some(orientation); 100 self 101 } 102 } 103 104 pub const NONE_CELL_AREA_BOX: Option<&CellAreaBox> = None; 105 106 pub trait CellAreaBoxExt: 'static { 107 #[doc(alias = "gtk_cell_area_box_get_spacing")] 108 #[doc(alias = "get_spacing")] spacing(&self) -> i32109 fn spacing(&self) -> i32; 110 111 #[doc(alias = "gtk_cell_area_box_pack_end")] pack_end<P: IsA<CellRenderer>>(&self, renderer: &P, expand: bool, align: bool, fixed: bool)112 fn pack_end<P: IsA<CellRenderer>>(&self, renderer: &P, expand: bool, align: bool, fixed: bool); 113 114 #[doc(alias = "gtk_cell_area_box_pack_start")] pack_start<P: IsA<CellRenderer>>( &self, renderer: &P, expand: bool, align: bool, fixed: bool, )115 fn pack_start<P: IsA<CellRenderer>>( 116 &self, 117 renderer: &P, 118 expand: bool, 119 align: bool, 120 fixed: bool, 121 ); 122 123 #[doc(alias = "gtk_cell_area_box_set_spacing")] set_spacing(&self, spacing: i32)124 fn set_spacing(&self, spacing: i32); 125 126 #[doc(alias = "spacing")] connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId127 fn connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 128 } 129 130 impl<O: IsA<CellAreaBox>> CellAreaBoxExt for O { spacing(&self) -> i32131 fn spacing(&self) -> i32 { 132 unsafe { ffi::gtk_cell_area_box_get_spacing(self.as_ref().to_glib_none().0) } 133 } 134 pack_end<P: IsA<CellRenderer>>(&self, renderer: &P, expand: bool, align: bool, fixed: bool)135 fn pack_end<P: IsA<CellRenderer>>(&self, renderer: &P, expand: bool, align: bool, fixed: bool) { 136 unsafe { 137 ffi::gtk_cell_area_box_pack_end( 138 self.as_ref().to_glib_none().0, 139 renderer.as_ref().to_glib_none().0, 140 expand.into_glib(), 141 align.into_glib(), 142 fixed.into_glib(), 143 ); 144 } 145 } 146 pack_start<P: IsA<CellRenderer>>( &self, renderer: &P, expand: bool, align: bool, fixed: bool, )147 fn pack_start<P: IsA<CellRenderer>>( 148 &self, 149 renderer: &P, 150 expand: bool, 151 align: bool, 152 fixed: bool, 153 ) { 154 unsafe { 155 ffi::gtk_cell_area_box_pack_start( 156 self.as_ref().to_glib_none().0, 157 renderer.as_ref().to_glib_none().0, 158 expand.into_glib(), 159 align.into_glib(), 160 fixed.into_glib(), 161 ); 162 } 163 } 164 set_spacing(&self, spacing: i32)165 fn set_spacing(&self, spacing: i32) { 166 unsafe { 167 ffi::gtk_cell_area_box_set_spacing(self.as_ref().to_glib_none().0, spacing); 168 } 169 } 170 connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId171 fn connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 172 unsafe extern "C" fn notify_spacing_trampoline<P: IsA<CellAreaBox>, F: Fn(&P) + 'static>( 173 this: *mut ffi::GtkCellAreaBox, 174 _param_spec: glib::ffi::gpointer, 175 f: glib::ffi::gpointer, 176 ) { 177 let f: &F = &*(f as *const F); 178 f(CellAreaBox::from_glib_borrow(this).unsafe_cast_ref()) 179 } 180 unsafe { 181 let f: Box_<F> = Box_::new(f); 182 connect_raw( 183 self.as_ptr() as *mut _, 184 b"notify::spacing\0".as_ptr() as *const _, 185 Some(transmute::<_, unsafe extern "C" fn()>( 186 notify_spacing_trampoline::<Self, F> as *const (), 187 )), 188 Box_::into_raw(f), 189 ) 190 } 191 } 192 } 193 194 impl fmt::Display for CellAreaBox { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result195 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 196 f.write_str("CellAreaBox") 197 } 198 } 199