1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from 3 // from gir-files (https://github.com/gtk-rs/gir-files.git) 4 // DO NOT EDIT 5 6 use crate::HeaderBar; 7 use crate::HeaderGroupChild; 8 use glib::object::Cast; 9 use glib::object::IsA; 10 use glib::object::ObjectType as ObjectType_; 11 use glib::signal::connect_raw; 12 use glib::signal::SignalHandlerId; 13 use glib::translate::*; 14 use glib::StaticType; 15 use glib::ToValue; 16 use std::boxed::Box as Box_; 17 use std::fmt; 18 use std::mem::transmute; 19 20 glib::wrapper! { 21 #[doc(alias = "HdyHeaderGroup")] 22 pub struct HeaderGroup(Object<ffi::HdyHeaderGroup, ffi::HdyHeaderGroupClass>) @implements gtk::Buildable; 23 24 match fn { 25 type_ => || ffi::hdy_header_group_get_type(), 26 } 27 } 28 29 impl HeaderGroup { 30 #[doc(alias = "hdy_header_group_new")] new() -> HeaderGroup31 pub fn new() -> HeaderGroup { 32 assert_initialized_main_thread!(); 33 unsafe { from_glib_full(ffi::hdy_header_group_new()) } 34 } 35 36 // rustdoc-stripper-ignore-next 37 /// Creates a new builder-pattern struct instance to construct [`HeaderGroup`] objects. 38 /// 39 /// This method returns an instance of [`HeaderGroupBuilder`] which can be used to create [`HeaderGroup`] objects. builder() -> HeaderGroupBuilder40 pub fn builder() -> HeaderGroupBuilder { 41 HeaderGroupBuilder::default() 42 } 43 44 #[doc(alias = "hdy_header_group_add_gtk_header_bar")] add_gtk_header_bar<P: IsA<gtk::HeaderBar>>(&self, header_bar: &P)45 pub fn add_gtk_header_bar<P: IsA<gtk::HeaderBar>>(&self, header_bar: &P) { 46 unsafe { 47 ffi::hdy_header_group_add_gtk_header_bar( 48 self.to_glib_none().0, 49 header_bar.as_ref().to_glib_none().0, 50 ); 51 } 52 } 53 54 #[doc(alias = "hdy_header_group_add_header_bar")] add_header_bar<P: IsA<HeaderBar>>(&self, header_bar: &P)55 pub fn add_header_bar<P: IsA<HeaderBar>>(&self, header_bar: &P) { 56 unsafe { 57 ffi::hdy_header_group_add_header_bar( 58 self.to_glib_none().0, 59 header_bar.as_ref().to_glib_none().0, 60 ); 61 } 62 } 63 64 #[doc(alias = "hdy_header_group_add_header_group")] add_header_group(&self, header_group: &HeaderGroup)65 pub fn add_header_group(&self, header_group: &HeaderGroup) { 66 unsafe { 67 ffi::hdy_header_group_add_header_group( 68 self.to_glib_none().0, 69 header_group.to_glib_none().0, 70 ); 71 } 72 } 73 74 #[doc(alias = "hdy_header_group_get_children")] 75 #[doc(alias = "get_children")] children(&self) -> Vec<HeaderGroupChild>76 pub fn children(&self) -> Vec<HeaderGroupChild> { 77 unsafe { 78 FromGlibPtrContainer::from_glib_none(ffi::hdy_header_group_get_children( 79 self.to_glib_none().0, 80 )) 81 } 82 } 83 84 #[doc(alias = "hdy_header_group_get_decorate_all")] 85 #[doc(alias = "get_decorate_all")] is_decorate_all(&self) -> bool86 pub fn is_decorate_all(&self) -> bool { 87 unsafe { 88 from_glib(ffi::hdy_header_group_get_decorate_all( 89 self.to_glib_none().0, 90 )) 91 } 92 } 93 94 #[doc(alias = "hdy_header_group_remove_child")] remove_child(&self, child: &HeaderGroupChild)95 pub fn remove_child(&self, child: &HeaderGroupChild) { 96 unsafe { 97 ffi::hdy_header_group_remove_child(self.to_glib_none().0, child.to_glib_none().0); 98 } 99 } 100 101 #[doc(alias = "hdy_header_group_remove_gtk_header_bar")] remove_gtk_header_bar<P: IsA<gtk::HeaderBar>>(&self, header_bar: &P)102 pub fn remove_gtk_header_bar<P: IsA<gtk::HeaderBar>>(&self, header_bar: &P) { 103 unsafe { 104 ffi::hdy_header_group_remove_gtk_header_bar( 105 self.to_glib_none().0, 106 header_bar.as_ref().to_glib_none().0, 107 ); 108 } 109 } 110 111 #[doc(alias = "hdy_header_group_remove_header_bar")] remove_header_bar<P: IsA<HeaderBar>>(&self, header_bar: &P)112 pub fn remove_header_bar<P: IsA<HeaderBar>>(&self, header_bar: &P) { 113 unsafe { 114 ffi::hdy_header_group_remove_header_bar( 115 self.to_glib_none().0, 116 header_bar.as_ref().to_glib_none().0, 117 ); 118 } 119 } 120 121 #[doc(alias = "hdy_header_group_remove_header_group")] remove_header_group(&self, header_group: &HeaderGroup)122 pub fn remove_header_group(&self, header_group: &HeaderGroup) { 123 unsafe { 124 ffi::hdy_header_group_remove_header_group( 125 self.to_glib_none().0, 126 header_group.to_glib_none().0, 127 ); 128 } 129 } 130 131 #[doc(alias = "hdy_header_group_set_decorate_all")] set_decorate_all(&self, decorate_all: bool)132 pub fn set_decorate_all(&self, decorate_all: bool) { 133 unsafe { 134 ffi::hdy_header_group_set_decorate_all(self.to_glib_none().0, decorate_all.into_glib()); 135 } 136 } 137 138 #[doc(alias = "update-decoration-layouts")] connect_update_decoration_layouts<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId139 pub fn connect_update_decoration_layouts<F: Fn(&Self) + 'static>( 140 &self, 141 f: F, 142 ) -> SignalHandlerId { 143 unsafe extern "C" fn update_decoration_layouts_trampoline<F: Fn(&HeaderGroup) + 'static>( 144 this: *mut ffi::HdyHeaderGroup, 145 f: glib::ffi::gpointer, 146 ) { 147 let f: &F = &*(f as *const F); 148 f(&from_glib_borrow(this)) 149 } 150 unsafe { 151 let f: Box_<F> = Box_::new(f); 152 connect_raw( 153 self.as_ptr() as *mut _, 154 b"update-decoration-layouts\0".as_ptr() as *const _, 155 Some(transmute::<_, unsafe extern "C" fn()>( 156 update_decoration_layouts_trampoline::<F> as *const (), 157 )), 158 Box_::into_raw(f), 159 ) 160 } 161 } 162 163 #[doc(alias = "decorate-all")] connect_decorate_all_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId164 pub fn connect_decorate_all_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 165 unsafe extern "C" fn notify_decorate_all_trampoline<F: Fn(&HeaderGroup) + 'static>( 166 this: *mut ffi::HdyHeaderGroup, 167 _param_spec: glib::ffi::gpointer, 168 f: glib::ffi::gpointer, 169 ) { 170 let f: &F = &*(f as *const F); 171 f(&from_glib_borrow(this)) 172 } 173 unsafe { 174 let f: Box_<F> = Box_::new(f); 175 connect_raw( 176 self.as_ptr() as *mut _, 177 b"notify::decorate-all\0".as_ptr() as *const _, 178 Some(transmute::<_, unsafe extern "C" fn()>( 179 notify_decorate_all_trampoline::<F> as *const (), 180 )), 181 Box_::into_raw(f), 182 ) 183 } 184 } 185 } 186 187 impl Default for HeaderGroup { default() -> Self188 fn default() -> Self { 189 Self::new() 190 } 191 } 192 193 #[derive(Clone, Default)] 194 // rustdoc-stripper-ignore-next 195 /// A [builder-pattern] type to construct [`HeaderGroup`] objects. 196 /// 197 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 198 pub struct HeaderGroupBuilder { 199 decorate_all: Option<bool>, 200 } 201 202 impl HeaderGroupBuilder { 203 // rustdoc-stripper-ignore-next 204 /// Create a new [`HeaderGroupBuilder`]. new() -> Self205 pub fn new() -> Self { 206 Self::default() 207 } 208 209 // rustdoc-stripper-ignore-next 210 /// Build the [`HeaderGroup`]. build(self) -> HeaderGroup211 pub fn build(self) -> HeaderGroup { 212 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 213 if let Some(ref decorate_all) = self.decorate_all { 214 properties.push(("decorate-all", decorate_all)); 215 } 216 glib::Object::new::<HeaderGroup>(&properties) 217 .expect("Failed to create an instance of HeaderGroup") 218 } 219 decorate_all(mut self, decorate_all: bool) -> Self220 pub fn decorate_all(mut self, decorate_all: bool) -> Self { 221 self.decorate_all = Some(decorate_all); 222 self 223 } 224 } 225 226 impl fmt::Display for HeaderGroup { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result227 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 228 f.write_str("HeaderGroup") 229 } 230 } 231