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; 6 use glib::translate::*; 7 use gtk_sys; 8 use std; 9 use std::fmt; 10 use std::ptr; 11 use PageOrientation; 12 use PaperSize; 13 use Unit; 14 15 glib_wrapper! { 16 pub struct PageSetup(Object<gtk_sys::GtkPageSetup, PageSetupClass>); 17 18 match fn { 19 get_type => || gtk_sys::gtk_page_setup_get_type(), 20 } 21 } 22 23 impl PageSetup { new() -> PageSetup24 pub fn new() -> PageSetup { 25 assert_initialized_main_thread!(); 26 unsafe { from_glib_full(gtk_sys::gtk_page_setup_new()) } 27 } 28 new_from_file<P: AsRef<std::path::Path>>( file_name: P, ) -> Result<PageSetup, glib::Error>29 pub fn new_from_file<P: AsRef<std::path::Path>>( 30 file_name: P, 31 ) -> Result<PageSetup, glib::Error> { 32 assert_initialized_main_thread!(); 33 unsafe { 34 let mut error = ptr::null_mut(); 35 let ret = gtk_sys::gtk_page_setup_new_from_file( 36 file_name.as_ref().to_glib_none().0, 37 &mut error, 38 ); 39 if error.is_null() { 40 Ok(from_glib_full(ret)) 41 } else { 42 Err(from_glib_full(error)) 43 } 44 } 45 } 46 47 #[cfg(any(feature = "v3_22", feature = "dox"))] new_from_gvariant(variant: &glib::Variant) -> PageSetup48 pub fn new_from_gvariant(variant: &glib::Variant) -> PageSetup { 49 assert_initialized_main_thread!(); 50 unsafe { 51 from_glib_full(gtk_sys::gtk_page_setup_new_from_gvariant( 52 variant.to_glib_none().0, 53 )) 54 } 55 } 56 new_from_key_file( key_file: &glib::KeyFile, group_name: Option<&str>, ) -> Result<PageSetup, glib::Error>57 pub fn new_from_key_file( 58 key_file: &glib::KeyFile, 59 group_name: Option<&str>, 60 ) -> Result<PageSetup, glib::Error> { 61 assert_initialized_main_thread!(); 62 unsafe { 63 let mut error = ptr::null_mut(); 64 let ret = gtk_sys::gtk_page_setup_new_from_key_file( 65 key_file.to_glib_none().0, 66 group_name.to_glib_none().0, 67 &mut error, 68 ); 69 if error.is_null() { 70 Ok(from_glib_full(ret)) 71 } else { 72 Err(from_glib_full(error)) 73 } 74 } 75 } 76 copy(&self) -> Option<PageSetup>77 pub fn copy(&self) -> Option<PageSetup> { 78 unsafe { from_glib_full(gtk_sys::gtk_page_setup_copy(self.to_glib_none().0)) } 79 } 80 get_bottom_margin(&self, unit: Unit) -> f6481 pub fn get_bottom_margin(&self, unit: Unit) -> f64 { 82 unsafe { gtk_sys::gtk_page_setup_get_bottom_margin(self.to_glib_none().0, unit.to_glib()) } 83 } 84 get_left_margin(&self, unit: Unit) -> f6485 pub fn get_left_margin(&self, unit: Unit) -> f64 { 86 unsafe { gtk_sys::gtk_page_setup_get_left_margin(self.to_glib_none().0, unit.to_glib()) } 87 } 88 get_orientation(&self) -> PageOrientation89 pub fn get_orientation(&self) -> PageOrientation { 90 unsafe { 91 from_glib(gtk_sys::gtk_page_setup_get_orientation( 92 self.to_glib_none().0, 93 )) 94 } 95 } 96 get_page_height(&self, unit: Unit) -> f6497 pub fn get_page_height(&self, unit: Unit) -> f64 { 98 unsafe { gtk_sys::gtk_page_setup_get_page_height(self.to_glib_none().0, unit.to_glib()) } 99 } 100 get_page_width(&self, unit: Unit) -> f64101 pub fn get_page_width(&self, unit: Unit) -> f64 { 102 unsafe { gtk_sys::gtk_page_setup_get_page_width(self.to_glib_none().0, unit.to_glib()) } 103 } 104 get_paper_height(&self, unit: Unit) -> f64105 pub fn get_paper_height(&self, unit: Unit) -> f64 { 106 unsafe { gtk_sys::gtk_page_setup_get_paper_height(self.to_glib_none().0, unit.to_glib()) } 107 } 108 get_paper_size(&self) -> PaperSize109 pub fn get_paper_size(&self) -> PaperSize { 110 unsafe { 111 from_glib_none(gtk_sys::gtk_page_setup_get_paper_size( 112 self.to_glib_none().0, 113 )) 114 } 115 } 116 get_paper_width(&self, unit: Unit) -> f64117 pub fn get_paper_width(&self, unit: Unit) -> f64 { 118 unsafe { gtk_sys::gtk_page_setup_get_paper_width(self.to_glib_none().0, unit.to_glib()) } 119 } 120 get_right_margin(&self, unit: Unit) -> f64121 pub fn get_right_margin(&self, unit: Unit) -> f64 { 122 unsafe { gtk_sys::gtk_page_setup_get_right_margin(self.to_glib_none().0, unit.to_glib()) } 123 } 124 get_top_margin(&self, unit: Unit) -> f64125 pub fn get_top_margin(&self, unit: Unit) -> f64 { 126 unsafe { gtk_sys::gtk_page_setup_get_top_margin(self.to_glib_none().0, unit.to_glib()) } 127 } 128 load_file<P: AsRef<std::path::Path>>(&self, file_name: P) -> Result<(), glib::Error>129 pub fn load_file<P: AsRef<std::path::Path>>(&self, file_name: P) -> Result<(), glib::Error> { 130 unsafe { 131 let mut error = ptr::null_mut(); 132 let _ = gtk_sys::gtk_page_setup_load_file( 133 self.to_glib_none().0, 134 file_name.as_ref().to_glib_none().0, 135 &mut error, 136 ); 137 if error.is_null() { 138 Ok(()) 139 } else { 140 Err(from_glib_full(error)) 141 } 142 } 143 } 144 load_key_file( &self, key_file: &glib::KeyFile, group_name: Option<&str>, ) -> Result<(), glib::Error>145 pub fn load_key_file( 146 &self, 147 key_file: &glib::KeyFile, 148 group_name: Option<&str>, 149 ) -> Result<(), glib::Error> { 150 unsafe { 151 let mut error = ptr::null_mut(); 152 let _ = gtk_sys::gtk_page_setup_load_key_file( 153 self.to_glib_none().0, 154 key_file.to_glib_none().0, 155 group_name.to_glib_none().0, 156 &mut error, 157 ); 158 if error.is_null() { 159 Ok(()) 160 } else { 161 Err(from_glib_full(error)) 162 } 163 } 164 } 165 set_bottom_margin(&self, margin: f64, unit: Unit)166 pub fn set_bottom_margin(&self, margin: f64, unit: Unit) { 167 unsafe { 168 gtk_sys::gtk_page_setup_set_bottom_margin( 169 self.to_glib_none().0, 170 margin, 171 unit.to_glib(), 172 ); 173 } 174 } 175 set_left_margin(&self, margin: f64, unit: Unit)176 pub fn set_left_margin(&self, margin: f64, unit: Unit) { 177 unsafe { 178 gtk_sys::gtk_page_setup_set_left_margin(self.to_glib_none().0, margin, unit.to_glib()); 179 } 180 } 181 set_orientation(&self, orientation: PageOrientation)182 pub fn set_orientation(&self, orientation: PageOrientation) { 183 unsafe { 184 gtk_sys::gtk_page_setup_set_orientation(self.to_glib_none().0, orientation.to_glib()); 185 } 186 } 187 set_paper_size(&self, size: &PaperSize)188 pub fn set_paper_size(&self, size: &PaperSize) { 189 unsafe { 190 gtk_sys::gtk_page_setup_set_paper_size( 191 self.to_glib_none().0, 192 mut_override(size.to_glib_none().0), 193 ); 194 } 195 } 196 set_paper_size_and_default_margins(&self, size: &PaperSize)197 pub fn set_paper_size_and_default_margins(&self, size: &PaperSize) { 198 unsafe { 199 gtk_sys::gtk_page_setup_set_paper_size_and_default_margins( 200 self.to_glib_none().0, 201 mut_override(size.to_glib_none().0), 202 ); 203 } 204 } 205 set_right_margin(&self, margin: f64, unit: Unit)206 pub fn set_right_margin(&self, margin: f64, unit: Unit) { 207 unsafe { 208 gtk_sys::gtk_page_setup_set_right_margin(self.to_glib_none().0, margin, unit.to_glib()); 209 } 210 } 211 set_top_margin(&self, margin: f64, unit: Unit)212 pub fn set_top_margin(&self, margin: f64, unit: Unit) { 213 unsafe { 214 gtk_sys::gtk_page_setup_set_top_margin(self.to_glib_none().0, margin, unit.to_glib()); 215 } 216 } 217 to_file<P: AsRef<std::path::Path>>(&self, file_name: P) -> Result<(), glib::Error>218 pub fn to_file<P: AsRef<std::path::Path>>(&self, file_name: P) -> Result<(), glib::Error> { 219 unsafe { 220 let mut error = ptr::null_mut(); 221 let _ = gtk_sys::gtk_page_setup_to_file( 222 self.to_glib_none().0, 223 file_name.as_ref().to_glib_none().0, 224 &mut error, 225 ); 226 if error.is_null() { 227 Ok(()) 228 } else { 229 Err(from_glib_full(error)) 230 } 231 } 232 } 233 234 #[cfg(any(feature = "v3_22", feature = "dox"))] to_gvariant(&self) -> Option<glib::Variant>235 pub fn to_gvariant(&self) -> Option<glib::Variant> { 236 unsafe { from_glib_none(gtk_sys::gtk_page_setup_to_gvariant(self.to_glib_none().0)) } 237 } 238 to_key_file(&self, key_file: &glib::KeyFile, group_name: Option<&str>)239 pub fn to_key_file(&self, key_file: &glib::KeyFile, group_name: Option<&str>) { 240 unsafe { 241 gtk_sys::gtk_page_setup_to_key_file( 242 self.to_glib_none().0, 243 key_file.to_glib_none().0, 244 group_name.to_glib_none().0, 245 ); 246 } 247 } 248 } 249 250 impl Default for PageSetup { default() -> Self251 fn default() -> Self { 252 Self::new() 253 } 254 } 255 256 impl fmt::Display for PageSetup { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result257 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 258 write!(f, "PageSetup") 259 } 260 } 261