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::PageOrientation; 6 use crate::PaperSize; 7 use crate::Unit; 8 use glib::translate::*; 9 use std::fmt; 10 use std::ptr; 11 12 glib::wrapper! { 13 #[doc(alias = "GtkPageSetup")] 14 pub struct PageSetup(Object<ffi::GtkPageSetup>); 15 16 match fn { 17 type_ => || ffi::gtk_page_setup_get_type(), 18 } 19 } 20 21 impl PageSetup { 22 #[doc(alias = "gtk_page_setup_new")] new() -> PageSetup23 pub fn new() -> PageSetup { 24 assert_initialized_main_thread!(); 25 unsafe { from_glib_full(ffi::gtk_page_setup_new()) } 26 } 27 28 #[doc(alias = "gtk_page_setup_new_from_file")] 29 #[doc(alias = "new_from_file")] from_file<P: AsRef<std::path::Path>>(file_name: P) -> Result<PageSetup, glib::Error>30 pub fn from_file<P: AsRef<std::path::Path>>(file_name: P) -> Result<PageSetup, glib::Error> { 31 assert_initialized_main_thread!(); 32 unsafe { 33 let mut error = ptr::null_mut(); 34 let ret = 35 ffi::gtk_page_setup_new_from_file(file_name.as_ref().to_glib_none().0, &mut error); 36 if error.is_null() { 37 Ok(from_glib_full(ret)) 38 } else { 39 Err(from_glib_full(error)) 40 } 41 } 42 } 43 44 #[cfg(any(feature = "v3_22", feature = "dox"))] 45 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 46 #[doc(alias = "gtk_page_setup_new_from_gvariant")] 47 #[doc(alias = "new_from_gvariant")] from_gvariant(variant: &glib::Variant) -> PageSetup48 pub fn from_gvariant(variant: &glib::Variant) -> PageSetup { 49 assert_initialized_main_thread!(); 50 unsafe { 51 from_glib_full(ffi::gtk_page_setup_new_from_gvariant( 52 variant.to_glib_none().0, 53 )) 54 } 55 } 56 57 #[doc(alias = "gtk_page_setup_new_from_key_file")] 58 #[doc(alias = "new_from_key_file")] from_key_file( key_file: &glib::KeyFile, group_name: Option<&str>, ) -> Result<PageSetup, glib::Error>59 pub fn from_key_file( 60 key_file: &glib::KeyFile, 61 group_name: Option<&str>, 62 ) -> Result<PageSetup, glib::Error> { 63 assert_initialized_main_thread!(); 64 unsafe { 65 let mut error = ptr::null_mut(); 66 let ret = ffi::gtk_page_setup_new_from_key_file( 67 key_file.to_glib_none().0, 68 group_name.to_glib_none().0, 69 &mut error, 70 ); 71 if error.is_null() { 72 Ok(from_glib_full(ret)) 73 } else { 74 Err(from_glib_full(error)) 75 } 76 } 77 } 78 79 #[doc(alias = "gtk_page_setup_copy")] copy(&self) -> Option<PageSetup>80 pub fn copy(&self) -> Option<PageSetup> { 81 unsafe { from_glib_full(ffi::gtk_page_setup_copy(self.to_glib_none().0)) } 82 } 83 84 #[doc(alias = "gtk_page_setup_get_bottom_margin")] 85 #[doc(alias = "get_bottom_margin")] bottom_margin(&self, unit: Unit) -> f6486 pub fn bottom_margin(&self, unit: Unit) -> f64 { 87 unsafe { ffi::gtk_page_setup_get_bottom_margin(self.to_glib_none().0, unit.into_glib()) } 88 } 89 90 #[doc(alias = "gtk_page_setup_get_left_margin")] 91 #[doc(alias = "get_left_margin")] left_margin(&self, unit: Unit) -> f6492 pub fn left_margin(&self, unit: Unit) -> f64 { 93 unsafe { ffi::gtk_page_setup_get_left_margin(self.to_glib_none().0, unit.into_glib()) } 94 } 95 96 #[doc(alias = "gtk_page_setup_get_orientation")] 97 #[doc(alias = "get_orientation")] orientation(&self) -> PageOrientation98 pub fn orientation(&self) -> PageOrientation { 99 unsafe { from_glib(ffi::gtk_page_setup_get_orientation(self.to_glib_none().0)) } 100 } 101 102 #[doc(alias = "gtk_page_setup_get_page_height")] 103 #[doc(alias = "get_page_height")] page_height(&self, unit: Unit) -> f64104 pub fn page_height(&self, unit: Unit) -> f64 { 105 unsafe { ffi::gtk_page_setup_get_page_height(self.to_glib_none().0, unit.into_glib()) } 106 } 107 108 #[doc(alias = "gtk_page_setup_get_page_width")] 109 #[doc(alias = "get_page_width")] page_width(&self, unit: Unit) -> f64110 pub fn page_width(&self, unit: Unit) -> f64 { 111 unsafe { ffi::gtk_page_setup_get_page_width(self.to_glib_none().0, unit.into_glib()) } 112 } 113 114 #[doc(alias = "gtk_page_setup_get_paper_height")] 115 #[doc(alias = "get_paper_height")] paper_height(&self, unit: Unit) -> f64116 pub fn paper_height(&self, unit: Unit) -> f64 { 117 unsafe { ffi::gtk_page_setup_get_paper_height(self.to_glib_none().0, unit.into_glib()) } 118 } 119 120 #[doc(alias = "gtk_page_setup_get_paper_size")] 121 #[doc(alias = "get_paper_size")] paper_size(&self) -> PaperSize122 pub fn paper_size(&self) -> PaperSize { 123 unsafe { from_glib_none(ffi::gtk_page_setup_get_paper_size(self.to_glib_none().0)) } 124 } 125 126 #[doc(alias = "gtk_page_setup_get_paper_width")] 127 #[doc(alias = "get_paper_width")] paper_width(&self, unit: Unit) -> f64128 pub fn paper_width(&self, unit: Unit) -> f64 { 129 unsafe { ffi::gtk_page_setup_get_paper_width(self.to_glib_none().0, unit.into_glib()) } 130 } 131 132 #[doc(alias = "gtk_page_setup_get_right_margin")] 133 #[doc(alias = "get_right_margin")] right_margin(&self, unit: Unit) -> f64134 pub fn right_margin(&self, unit: Unit) -> f64 { 135 unsafe { ffi::gtk_page_setup_get_right_margin(self.to_glib_none().0, unit.into_glib()) } 136 } 137 138 #[doc(alias = "gtk_page_setup_get_top_margin")] 139 #[doc(alias = "get_top_margin")] top_margin(&self, unit: Unit) -> f64140 pub fn top_margin(&self, unit: Unit) -> f64 { 141 unsafe { ffi::gtk_page_setup_get_top_margin(self.to_glib_none().0, unit.into_glib()) } 142 } 143 144 #[doc(alias = "gtk_page_setup_load_file")] load_file<P: AsRef<std::path::Path>>(&self, file_name: P) -> Result<(), glib::Error>145 pub fn load_file<P: AsRef<std::path::Path>>(&self, file_name: P) -> Result<(), glib::Error> { 146 unsafe { 147 let mut error = ptr::null_mut(); 148 let _ = ffi::gtk_page_setup_load_file( 149 self.to_glib_none().0, 150 file_name.as_ref().to_glib_none().0, 151 &mut error, 152 ); 153 if error.is_null() { 154 Ok(()) 155 } else { 156 Err(from_glib_full(error)) 157 } 158 } 159 } 160 161 #[doc(alias = "gtk_page_setup_load_key_file")] load_key_file( &self, key_file: &glib::KeyFile, group_name: Option<&str>, ) -> Result<(), glib::Error>162 pub fn load_key_file( 163 &self, 164 key_file: &glib::KeyFile, 165 group_name: Option<&str>, 166 ) -> Result<(), glib::Error> { 167 unsafe { 168 let mut error = ptr::null_mut(); 169 let _ = ffi::gtk_page_setup_load_key_file( 170 self.to_glib_none().0, 171 key_file.to_glib_none().0, 172 group_name.to_glib_none().0, 173 &mut error, 174 ); 175 if error.is_null() { 176 Ok(()) 177 } else { 178 Err(from_glib_full(error)) 179 } 180 } 181 } 182 183 #[doc(alias = "gtk_page_setup_set_bottom_margin")] set_bottom_margin(&self, margin: f64, unit: Unit)184 pub fn set_bottom_margin(&self, margin: f64, unit: Unit) { 185 unsafe { 186 ffi::gtk_page_setup_set_bottom_margin(self.to_glib_none().0, margin, unit.into_glib()); 187 } 188 } 189 190 #[doc(alias = "gtk_page_setup_set_left_margin")] set_left_margin(&self, margin: f64, unit: Unit)191 pub fn set_left_margin(&self, margin: f64, unit: Unit) { 192 unsafe { 193 ffi::gtk_page_setup_set_left_margin(self.to_glib_none().0, margin, unit.into_glib()); 194 } 195 } 196 197 #[doc(alias = "gtk_page_setup_set_orientation")] set_orientation(&self, orientation: PageOrientation)198 pub fn set_orientation(&self, orientation: PageOrientation) { 199 unsafe { 200 ffi::gtk_page_setup_set_orientation(self.to_glib_none().0, orientation.into_glib()); 201 } 202 } 203 204 #[doc(alias = "gtk_page_setup_set_paper_size")] set_paper_size(&self, size: &PaperSize)205 pub fn set_paper_size(&self, size: &PaperSize) { 206 unsafe { 207 ffi::gtk_page_setup_set_paper_size( 208 self.to_glib_none().0, 209 mut_override(size.to_glib_none().0), 210 ); 211 } 212 } 213 214 #[doc(alias = "gtk_page_setup_set_paper_size_and_default_margins")] set_paper_size_and_default_margins(&self, size: &PaperSize)215 pub fn set_paper_size_and_default_margins(&self, size: &PaperSize) { 216 unsafe { 217 ffi::gtk_page_setup_set_paper_size_and_default_margins( 218 self.to_glib_none().0, 219 mut_override(size.to_glib_none().0), 220 ); 221 } 222 } 223 224 #[doc(alias = "gtk_page_setup_set_right_margin")] set_right_margin(&self, margin: f64, unit: Unit)225 pub fn set_right_margin(&self, margin: f64, unit: Unit) { 226 unsafe { 227 ffi::gtk_page_setup_set_right_margin(self.to_glib_none().0, margin, unit.into_glib()); 228 } 229 } 230 231 #[doc(alias = "gtk_page_setup_set_top_margin")] set_top_margin(&self, margin: f64, unit: Unit)232 pub fn set_top_margin(&self, margin: f64, unit: Unit) { 233 unsafe { 234 ffi::gtk_page_setup_set_top_margin(self.to_glib_none().0, margin, unit.into_glib()); 235 } 236 } 237 238 #[doc(alias = "gtk_page_setup_to_file")] to_file<P: AsRef<std::path::Path>>(&self, file_name: P) -> Result<(), glib::Error>239 pub fn to_file<P: AsRef<std::path::Path>>(&self, file_name: P) -> Result<(), glib::Error> { 240 unsafe { 241 let mut error = ptr::null_mut(); 242 let _ = ffi::gtk_page_setup_to_file( 243 self.to_glib_none().0, 244 file_name.as_ref().to_glib_none().0, 245 &mut error, 246 ); 247 if error.is_null() { 248 Ok(()) 249 } else { 250 Err(from_glib_full(error)) 251 } 252 } 253 } 254 255 #[cfg(any(feature = "v3_22", feature = "dox"))] 256 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 257 #[doc(alias = "gtk_page_setup_to_gvariant")] to_gvariant(&self) -> Option<glib::Variant>258 pub fn to_gvariant(&self) -> Option<glib::Variant> { 259 unsafe { from_glib_none(ffi::gtk_page_setup_to_gvariant(self.to_glib_none().0)) } 260 } 261 262 #[doc(alias = "gtk_page_setup_to_key_file")] to_key_file(&self, key_file: &glib::KeyFile, group_name: Option<&str>)263 pub fn to_key_file(&self, key_file: &glib::KeyFile, group_name: Option<&str>) { 264 unsafe { 265 ffi::gtk_page_setup_to_key_file( 266 self.to_glib_none().0, 267 key_file.to_glib_none().0, 268 group_name.to_glib_none().0, 269 ); 270 } 271 } 272 } 273 274 impl Default for PageSetup { default() -> Self275 fn default() -> Self { 276 Self::new() 277 } 278 } 279 280 impl fmt::Display for PageSetup { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result281 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 282 f.write_str("PageSetup") 283 } 284 } 285