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::Unit; 6 use glib::translate::*; 7 use std::ptr; 8 9 glib::wrapper! { 10 #[derive(Debug, PartialOrd, Ord, Hash)] 11 pub struct PaperSize(Boxed<ffi::GtkPaperSize>); 12 13 match fn { 14 copy => |ptr| ffi::gtk_paper_size_copy(mut_override(ptr)), 15 free => |ptr| ffi::gtk_paper_size_free(ptr), 16 type_ => || ffi::gtk_paper_size_get_type(), 17 } 18 } 19 20 impl PaperSize { 21 #[doc(alias = "gtk_paper_size_new")] new(name: Option<&str>) -> PaperSize22 pub fn new(name: Option<&str>) -> PaperSize { 23 assert_initialized_main_thread!(); 24 unsafe { from_glib_full(ffi::gtk_paper_size_new(name.to_glib_none().0)) } 25 } 26 27 #[doc(alias = "gtk_paper_size_new_custom")] new_custom( name: &str, display_name: &str, width: f64, height: f64, unit: Unit, ) -> PaperSize28 pub fn new_custom( 29 name: &str, 30 display_name: &str, 31 width: f64, 32 height: f64, 33 unit: Unit, 34 ) -> PaperSize { 35 assert_initialized_main_thread!(); 36 unsafe { 37 from_glib_full(ffi::gtk_paper_size_new_custom( 38 name.to_glib_none().0, 39 display_name.to_glib_none().0, 40 width, 41 height, 42 unit.into_glib(), 43 )) 44 } 45 } 46 47 #[cfg(any(feature = "v3_22", feature = "dox"))] 48 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 49 #[doc(alias = "gtk_paper_size_new_from_gvariant")] 50 #[doc(alias = "new_from_gvariant")] from_gvariant(variant: &glib::Variant) -> PaperSize51 pub fn from_gvariant(variant: &glib::Variant) -> PaperSize { 52 assert_initialized_main_thread!(); 53 unsafe { 54 from_glib_full(ffi::gtk_paper_size_new_from_gvariant( 55 variant.to_glib_none().0, 56 )) 57 } 58 } 59 60 #[doc(alias = "gtk_paper_size_new_from_ipp")] 61 #[doc(alias = "new_from_ipp")] from_ipp(ipp_name: &str, width: f64, height: f64) -> PaperSize62 pub fn from_ipp(ipp_name: &str, width: f64, height: f64) -> PaperSize { 63 assert_initialized_main_thread!(); 64 unsafe { 65 from_glib_full(ffi::gtk_paper_size_new_from_ipp( 66 ipp_name.to_glib_none().0, 67 width, 68 height, 69 )) 70 } 71 } 72 73 #[doc(alias = "gtk_paper_size_new_from_key_file")] 74 #[doc(alias = "new_from_key_file")] from_key_file( key_file: &glib::KeyFile, group_name: Option<&str>, ) -> Result<PaperSize, glib::Error>75 pub fn from_key_file( 76 key_file: &glib::KeyFile, 77 group_name: Option<&str>, 78 ) -> Result<PaperSize, glib::Error> { 79 assert_initialized_main_thread!(); 80 unsafe { 81 let mut error = ptr::null_mut(); 82 let ret = ffi::gtk_paper_size_new_from_key_file( 83 key_file.to_glib_none().0, 84 group_name.to_glib_none().0, 85 &mut error, 86 ); 87 if error.is_null() { 88 Ok(from_glib_full(ret)) 89 } else { 90 Err(from_glib_full(error)) 91 } 92 } 93 } 94 95 #[doc(alias = "gtk_paper_size_new_from_ppd")] 96 #[doc(alias = "new_from_ppd")] from_ppd(ppd_name: &str, ppd_display_name: &str, width: f64, height: f64) -> PaperSize97 pub fn from_ppd(ppd_name: &str, ppd_display_name: &str, width: f64, height: f64) -> PaperSize { 98 assert_initialized_main_thread!(); 99 unsafe { 100 from_glib_full(ffi::gtk_paper_size_new_from_ppd( 101 ppd_name.to_glib_none().0, 102 ppd_display_name.to_glib_none().0, 103 width, 104 height, 105 )) 106 } 107 } 108 109 #[doc(alias = "gtk_paper_size_get_default_bottom_margin")] 110 #[doc(alias = "get_default_bottom_margin")] default_bottom_margin(&self, unit: Unit) -> f64111 pub fn default_bottom_margin(&self, unit: Unit) -> f64 { 112 unsafe { 113 ffi::gtk_paper_size_get_default_bottom_margin( 114 mut_override(self.to_glib_none().0), 115 unit.into_glib(), 116 ) 117 } 118 } 119 120 #[doc(alias = "gtk_paper_size_get_default_left_margin")] 121 #[doc(alias = "get_default_left_margin")] default_left_margin(&self, unit: Unit) -> f64122 pub fn default_left_margin(&self, unit: Unit) -> f64 { 123 unsafe { 124 ffi::gtk_paper_size_get_default_left_margin( 125 mut_override(self.to_glib_none().0), 126 unit.into_glib(), 127 ) 128 } 129 } 130 131 #[doc(alias = "gtk_paper_size_get_default_right_margin")] 132 #[doc(alias = "get_default_right_margin")] default_right_margin(&self, unit: Unit) -> f64133 pub fn default_right_margin(&self, unit: Unit) -> f64 { 134 unsafe { 135 ffi::gtk_paper_size_get_default_right_margin( 136 mut_override(self.to_glib_none().0), 137 unit.into_glib(), 138 ) 139 } 140 } 141 142 #[doc(alias = "gtk_paper_size_get_default_top_margin")] 143 #[doc(alias = "get_default_top_margin")] default_top_margin(&self, unit: Unit) -> f64144 pub fn default_top_margin(&self, unit: Unit) -> f64 { 145 unsafe { 146 ffi::gtk_paper_size_get_default_top_margin( 147 mut_override(self.to_glib_none().0), 148 unit.into_glib(), 149 ) 150 } 151 } 152 153 #[doc(alias = "gtk_paper_size_get_display_name")] 154 #[doc(alias = "get_display_name")] display_name(&self) -> Option<glib::GString>155 pub fn display_name(&self) -> Option<glib::GString> { 156 unsafe { 157 from_glib_none(ffi::gtk_paper_size_get_display_name(mut_override( 158 self.to_glib_none().0, 159 ))) 160 } 161 } 162 163 #[doc(alias = "gtk_paper_size_get_height")] 164 #[doc(alias = "get_height")] height(&self, unit: Unit) -> f64165 pub fn height(&self, unit: Unit) -> f64 { 166 unsafe { 167 ffi::gtk_paper_size_get_height(mut_override(self.to_glib_none().0), unit.into_glib()) 168 } 169 } 170 171 #[doc(alias = "gtk_paper_size_get_name")] 172 #[doc(alias = "get_name")] name(&self) -> Option<glib::GString>173 pub fn name(&self) -> Option<glib::GString> { 174 unsafe { 175 from_glib_none(ffi::gtk_paper_size_get_name(mut_override( 176 self.to_glib_none().0, 177 ))) 178 } 179 } 180 181 #[doc(alias = "gtk_paper_size_get_ppd_name")] 182 #[doc(alias = "get_ppd_name")] ppd_name(&self) -> Option<glib::GString>183 pub fn ppd_name(&self) -> Option<glib::GString> { 184 unsafe { 185 from_glib_none(ffi::gtk_paper_size_get_ppd_name(mut_override( 186 self.to_glib_none().0, 187 ))) 188 } 189 } 190 191 #[doc(alias = "gtk_paper_size_get_width")] 192 #[doc(alias = "get_width")] width(&self, unit: Unit) -> f64193 pub fn width(&self, unit: Unit) -> f64 { 194 unsafe { 195 ffi::gtk_paper_size_get_width(mut_override(self.to_glib_none().0), unit.into_glib()) 196 } 197 } 198 199 #[doc(alias = "gtk_paper_size_is_custom")] is_custom(&self) -> bool200 pub fn is_custom(&self) -> bool { 201 unsafe { 202 from_glib(ffi::gtk_paper_size_is_custom(mut_override( 203 self.to_glib_none().0, 204 ))) 205 } 206 } 207 208 #[doc(alias = "gtk_paper_size_is_equal")] is_equal(&self, size2: &PaperSize) -> bool209 fn is_equal(&self, size2: &PaperSize) -> bool { 210 unsafe { 211 from_glib(ffi::gtk_paper_size_is_equal( 212 mut_override(self.to_glib_none().0), 213 mut_override(size2.to_glib_none().0), 214 )) 215 } 216 } 217 218 #[doc(alias = "gtk_paper_size_is_ipp")] is_ipp(&self) -> bool219 pub fn is_ipp(&self) -> bool { 220 unsafe { 221 from_glib(ffi::gtk_paper_size_is_ipp(mut_override( 222 self.to_glib_none().0, 223 ))) 224 } 225 } 226 227 #[doc(alias = "gtk_paper_size_set_size")] set_size(&mut self, width: f64, height: f64, unit: Unit)228 pub fn set_size(&mut self, width: f64, height: f64, unit: Unit) { 229 unsafe { 230 ffi::gtk_paper_size_set_size( 231 self.to_glib_none_mut().0, 232 width, 233 height, 234 unit.into_glib(), 235 ); 236 } 237 } 238 239 #[cfg(any(feature = "v3_22", feature = "dox"))] 240 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 241 #[doc(alias = "gtk_paper_size_to_gvariant")] to_gvariant(&mut self) -> Option<glib::Variant>242 pub fn to_gvariant(&mut self) -> Option<glib::Variant> { 243 unsafe { from_glib_none(ffi::gtk_paper_size_to_gvariant(self.to_glib_none_mut().0)) } 244 } 245 246 #[doc(alias = "gtk_paper_size_to_key_file")] to_key_file(&mut self, key_file: &glib::KeyFile, group_name: &str)247 pub fn to_key_file(&mut self, key_file: &glib::KeyFile, group_name: &str) { 248 unsafe { 249 ffi::gtk_paper_size_to_key_file( 250 self.to_glib_none_mut().0, 251 key_file.to_glib_none().0, 252 group_name.to_glib_none().0, 253 ); 254 } 255 } 256 257 #[doc(alias = "gtk_paper_size_get_default")] 258 #[doc(alias = "get_default")] default() -> Option<glib::GString>259 pub fn default() -> Option<glib::GString> { 260 assert_initialized_main_thread!(); 261 unsafe { from_glib_none(ffi::gtk_paper_size_get_default()) } 262 } 263 264 #[doc(alias = "gtk_paper_size_get_paper_sizes")] 265 #[doc(alias = "get_paper_sizes")] paper_sizes(include_custom: bool) -> Vec<PaperSize>266 pub fn paper_sizes(include_custom: bool) -> Vec<PaperSize> { 267 assert_initialized_main_thread!(); 268 unsafe { 269 FromGlibPtrContainer::from_glib_full(ffi::gtk_paper_size_get_paper_sizes( 270 include_custom.into_glib(), 271 )) 272 } 273 } 274 } 275 276 impl PartialEq for PaperSize { 277 #[inline] eq(&self, other: &Self) -> bool278 fn eq(&self, other: &Self) -> bool { 279 self.is_equal(other) 280 } 281 } 282 283 impl Eq for PaperSize {} 284