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::object::Cast; 6 use glib::object::IsA; 7 use glib::signal::connect_raw; 8 use glib::signal::SignalHandlerId; 9 use glib::translate::*; 10 use glib::StaticType; 11 use glib::ToValue; 12 use std::boxed::Box as Box_; 13 use std::fmt; 14 use std::mem::transmute; 15 16 glib::wrapper! { 17 #[doc(alias = "GtkAdjustment")] 18 pub struct Adjustment(Object<ffi::GtkAdjustment, ffi::GtkAdjustmentClass>); 19 20 match fn { 21 type_ => || ffi::gtk_adjustment_get_type(), 22 } 23 } 24 25 impl Adjustment { 26 #[doc(alias = "gtk_adjustment_new")] new( value: f64, lower: f64, upper: f64, step_increment: f64, page_increment: f64, page_size: f64, ) -> Adjustment27 pub fn new( 28 value: f64, 29 lower: f64, 30 upper: f64, 31 step_increment: f64, 32 page_increment: f64, 33 page_size: f64, 34 ) -> Adjustment { 35 assert_initialized_main_thread!(); 36 unsafe { 37 from_glib_none(ffi::gtk_adjustment_new( 38 value, 39 lower, 40 upper, 41 step_increment, 42 page_increment, 43 page_size, 44 )) 45 } 46 } 47 48 // rustdoc-stripper-ignore-next 49 /// Creates a new builder-pattern struct instance to construct [`Adjustment`] objects. 50 /// 51 /// This method returns an instance of [`AdjustmentBuilder`] which can be used to create [`Adjustment`] objects. builder() -> AdjustmentBuilder52 pub fn builder() -> AdjustmentBuilder { 53 AdjustmentBuilder::default() 54 } 55 } 56 57 #[derive(Clone, Default)] 58 // rustdoc-stripper-ignore-next 59 /// A [builder-pattern] type to construct [`Adjustment`] objects. 60 /// 61 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 62 pub struct AdjustmentBuilder { 63 lower: Option<f64>, 64 page_increment: Option<f64>, 65 page_size: Option<f64>, 66 step_increment: Option<f64>, 67 upper: Option<f64>, 68 value: Option<f64>, 69 } 70 71 impl AdjustmentBuilder { 72 // rustdoc-stripper-ignore-next 73 /// Create a new [`AdjustmentBuilder`]. new() -> Self74 pub fn new() -> Self { 75 Self::default() 76 } 77 78 // rustdoc-stripper-ignore-next 79 /// Build the [`Adjustment`]. build(self) -> Adjustment80 pub fn build(self) -> Adjustment { 81 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 82 if let Some(ref lower) = self.lower { 83 properties.push(("lower", lower)); 84 } 85 if let Some(ref page_increment) = self.page_increment { 86 properties.push(("page-increment", page_increment)); 87 } 88 if let Some(ref page_size) = self.page_size { 89 properties.push(("page-size", page_size)); 90 } 91 if let Some(ref step_increment) = self.step_increment { 92 properties.push(("step-increment", step_increment)); 93 } 94 if let Some(ref upper) = self.upper { 95 properties.push(("upper", upper)); 96 } 97 if let Some(ref value) = self.value { 98 properties.push(("value", value)); 99 } 100 glib::Object::new::<Adjustment>(&properties) 101 .expect("Failed to create an instance of Adjustment") 102 } 103 lower(mut self, lower: f64) -> Self104 pub fn lower(mut self, lower: f64) -> Self { 105 self.lower = Some(lower); 106 self 107 } 108 page_increment(mut self, page_increment: f64) -> Self109 pub fn page_increment(mut self, page_increment: f64) -> Self { 110 self.page_increment = Some(page_increment); 111 self 112 } 113 page_size(mut self, page_size: f64) -> Self114 pub fn page_size(mut self, page_size: f64) -> Self { 115 self.page_size = Some(page_size); 116 self 117 } 118 step_increment(mut self, step_increment: f64) -> Self119 pub fn step_increment(mut self, step_increment: f64) -> Self { 120 self.step_increment = Some(step_increment); 121 self 122 } 123 upper(mut self, upper: f64) -> Self124 pub fn upper(mut self, upper: f64) -> Self { 125 self.upper = Some(upper); 126 self 127 } 128 value(mut self, value: f64) -> Self129 pub fn value(mut self, value: f64) -> Self { 130 self.value = Some(value); 131 self 132 } 133 } 134 135 pub const NONE_ADJUSTMENT: Option<&Adjustment> = None; 136 137 pub trait AdjustmentExt: 'static { 138 #[doc(alias = "gtk_adjustment_clamp_page")] clamp_page(&self, lower: f64, upper: f64)139 fn clamp_page(&self, lower: f64, upper: f64); 140 141 #[doc(alias = "gtk_adjustment_configure")] configure( &self, value: f64, lower: f64, upper: f64, step_increment: f64, page_increment: f64, page_size: f64, )142 fn configure( 143 &self, 144 value: f64, 145 lower: f64, 146 upper: f64, 147 step_increment: f64, 148 page_increment: f64, 149 page_size: f64, 150 ); 151 152 #[doc(alias = "gtk_adjustment_get_lower")] 153 #[doc(alias = "get_lower")] lower(&self) -> f64154 fn lower(&self) -> f64; 155 156 #[doc(alias = "gtk_adjustment_get_minimum_increment")] 157 #[doc(alias = "get_minimum_increment")] minimum_increment(&self) -> f64158 fn minimum_increment(&self) -> f64; 159 160 #[doc(alias = "gtk_adjustment_get_page_increment")] 161 #[doc(alias = "get_page_increment")] page_increment(&self) -> f64162 fn page_increment(&self) -> f64; 163 164 #[doc(alias = "gtk_adjustment_get_page_size")] 165 #[doc(alias = "get_page_size")] page_size(&self) -> f64166 fn page_size(&self) -> f64; 167 168 #[doc(alias = "gtk_adjustment_get_step_increment")] 169 #[doc(alias = "get_step_increment")] step_increment(&self) -> f64170 fn step_increment(&self) -> f64; 171 172 #[doc(alias = "gtk_adjustment_get_upper")] 173 #[doc(alias = "get_upper")] upper(&self) -> f64174 fn upper(&self) -> f64; 175 176 #[doc(alias = "gtk_adjustment_get_value")] 177 #[doc(alias = "get_value")] value(&self) -> f64178 fn value(&self) -> f64; 179 180 #[doc(alias = "gtk_adjustment_set_lower")] set_lower(&self, lower: f64)181 fn set_lower(&self, lower: f64); 182 183 #[doc(alias = "gtk_adjustment_set_page_increment")] set_page_increment(&self, page_increment: f64)184 fn set_page_increment(&self, page_increment: f64); 185 186 #[doc(alias = "gtk_adjustment_set_page_size")] set_page_size(&self, page_size: f64)187 fn set_page_size(&self, page_size: f64); 188 189 #[doc(alias = "gtk_adjustment_set_step_increment")] set_step_increment(&self, step_increment: f64)190 fn set_step_increment(&self, step_increment: f64); 191 192 #[doc(alias = "gtk_adjustment_set_upper")] set_upper(&self, upper: f64)193 fn set_upper(&self, upper: f64); 194 195 #[doc(alias = "gtk_adjustment_set_value")] set_value(&self, value: f64)196 fn set_value(&self, value: f64); 197 198 #[doc(alias = "changed")] connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId199 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 200 201 #[doc(alias = "value-changed")] connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId202 fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 203 204 #[doc(alias = "lower")] connect_lower_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId205 fn connect_lower_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 206 207 #[doc(alias = "page-increment")] connect_page_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId208 fn connect_page_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 209 210 #[doc(alias = "page-size")] connect_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId211 fn connect_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 212 213 #[doc(alias = "step-increment")] connect_step_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId214 fn connect_step_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 215 216 #[doc(alias = "upper")] connect_upper_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId217 fn connect_upper_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 218 219 #[doc(alias = "value")] connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId220 fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 221 } 222 223 impl<O: IsA<Adjustment>> AdjustmentExt for O { clamp_page(&self, lower: f64, upper: f64)224 fn clamp_page(&self, lower: f64, upper: f64) { 225 unsafe { 226 ffi::gtk_adjustment_clamp_page(self.as_ref().to_glib_none().0, lower, upper); 227 } 228 } 229 configure( &self, value: f64, lower: f64, upper: f64, step_increment: f64, page_increment: f64, page_size: f64, )230 fn configure( 231 &self, 232 value: f64, 233 lower: f64, 234 upper: f64, 235 step_increment: f64, 236 page_increment: f64, 237 page_size: f64, 238 ) { 239 unsafe { 240 ffi::gtk_adjustment_configure( 241 self.as_ref().to_glib_none().0, 242 value, 243 lower, 244 upper, 245 step_increment, 246 page_increment, 247 page_size, 248 ); 249 } 250 } 251 lower(&self) -> f64252 fn lower(&self) -> f64 { 253 unsafe { ffi::gtk_adjustment_get_lower(self.as_ref().to_glib_none().0) } 254 } 255 minimum_increment(&self) -> f64256 fn minimum_increment(&self) -> f64 { 257 unsafe { ffi::gtk_adjustment_get_minimum_increment(self.as_ref().to_glib_none().0) } 258 } 259 page_increment(&self) -> f64260 fn page_increment(&self) -> f64 { 261 unsafe { ffi::gtk_adjustment_get_page_increment(self.as_ref().to_glib_none().0) } 262 } 263 page_size(&self) -> f64264 fn page_size(&self) -> f64 { 265 unsafe { ffi::gtk_adjustment_get_page_size(self.as_ref().to_glib_none().0) } 266 } 267 step_increment(&self) -> f64268 fn step_increment(&self) -> f64 { 269 unsafe { ffi::gtk_adjustment_get_step_increment(self.as_ref().to_glib_none().0) } 270 } 271 upper(&self) -> f64272 fn upper(&self) -> f64 { 273 unsafe { ffi::gtk_adjustment_get_upper(self.as_ref().to_glib_none().0) } 274 } 275 value(&self) -> f64276 fn value(&self) -> f64 { 277 unsafe { ffi::gtk_adjustment_get_value(self.as_ref().to_glib_none().0) } 278 } 279 set_lower(&self, lower: f64)280 fn set_lower(&self, lower: f64) { 281 unsafe { 282 ffi::gtk_adjustment_set_lower(self.as_ref().to_glib_none().0, lower); 283 } 284 } 285 set_page_increment(&self, page_increment: f64)286 fn set_page_increment(&self, page_increment: f64) { 287 unsafe { 288 ffi::gtk_adjustment_set_page_increment(self.as_ref().to_glib_none().0, page_increment); 289 } 290 } 291 set_page_size(&self, page_size: f64)292 fn set_page_size(&self, page_size: f64) { 293 unsafe { 294 ffi::gtk_adjustment_set_page_size(self.as_ref().to_glib_none().0, page_size); 295 } 296 } 297 set_step_increment(&self, step_increment: f64)298 fn set_step_increment(&self, step_increment: f64) { 299 unsafe { 300 ffi::gtk_adjustment_set_step_increment(self.as_ref().to_glib_none().0, step_increment); 301 } 302 } 303 set_upper(&self, upper: f64)304 fn set_upper(&self, upper: f64) { 305 unsafe { 306 ffi::gtk_adjustment_set_upper(self.as_ref().to_glib_none().0, upper); 307 } 308 } 309 set_value(&self, value: f64)310 fn set_value(&self, value: f64) { 311 unsafe { 312 ffi::gtk_adjustment_set_value(self.as_ref().to_glib_none().0, value); 313 } 314 } 315 connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId316 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 317 unsafe extern "C" fn changed_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>( 318 this: *mut ffi::GtkAdjustment, 319 f: glib::ffi::gpointer, 320 ) { 321 let f: &F = &*(f as *const F); 322 f(Adjustment::from_glib_borrow(this).unsafe_cast_ref()) 323 } 324 unsafe { 325 let f: Box_<F> = Box_::new(f); 326 connect_raw( 327 self.as_ptr() as *mut _, 328 b"changed\0".as_ptr() as *const _, 329 Some(transmute::<_, unsafe extern "C" fn()>( 330 changed_trampoline::<Self, F> as *const (), 331 )), 332 Box_::into_raw(f), 333 ) 334 } 335 } 336 connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId337 fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 338 unsafe extern "C" fn value_changed_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>( 339 this: *mut ffi::GtkAdjustment, 340 f: glib::ffi::gpointer, 341 ) { 342 let f: &F = &*(f as *const F); 343 f(Adjustment::from_glib_borrow(this).unsafe_cast_ref()) 344 } 345 unsafe { 346 let f: Box_<F> = Box_::new(f); 347 connect_raw( 348 self.as_ptr() as *mut _, 349 b"value-changed\0".as_ptr() as *const _, 350 Some(transmute::<_, unsafe extern "C" fn()>( 351 value_changed_trampoline::<Self, F> as *const (), 352 )), 353 Box_::into_raw(f), 354 ) 355 } 356 } 357 connect_lower_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId358 fn connect_lower_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 359 unsafe extern "C" fn notify_lower_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>( 360 this: *mut ffi::GtkAdjustment, 361 _param_spec: glib::ffi::gpointer, 362 f: glib::ffi::gpointer, 363 ) { 364 let f: &F = &*(f as *const F); 365 f(Adjustment::from_glib_borrow(this).unsafe_cast_ref()) 366 } 367 unsafe { 368 let f: Box_<F> = Box_::new(f); 369 connect_raw( 370 self.as_ptr() as *mut _, 371 b"notify::lower\0".as_ptr() as *const _, 372 Some(transmute::<_, unsafe extern "C" fn()>( 373 notify_lower_trampoline::<Self, F> as *const (), 374 )), 375 Box_::into_raw(f), 376 ) 377 } 378 } 379 connect_page_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId380 fn connect_page_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 381 unsafe extern "C" fn notify_page_increment_trampoline< 382 P: IsA<Adjustment>, 383 F: Fn(&P) + 'static, 384 >( 385 this: *mut ffi::GtkAdjustment, 386 _param_spec: glib::ffi::gpointer, 387 f: glib::ffi::gpointer, 388 ) { 389 let f: &F = &*(f as *const F); 390 f(Adjustment::from_glib_borrow(this).unsafe_cast_ref()) 391 } 392 unsafe { 393 let f: Box_<F> = Box_::new(f); 394 connect_raw( 395 self.as_ptr() as *mut _, 396 b"notify::page-increment\0".as_ptr() as *const _, 397 Some(transmute::<_, unsafe extern "C" fn()>( 398 notify_page_increment_trampoline::<Self, F> as *const (), 399 )), 400 Box_::into_raw(f), 401 ) 402 } 403 } 404 connect_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId405 fn connect_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 406 unsafe extern "C" fn notify_page_size_trampoline< 407 P: IsA<Adjustment>, 408 F: Fn(&P) + 'static, 409 >( 410 this: *mut ffi::GtkAdjustment, 411 _param_spec: glib::ffi::gpointer, 412 f: glib::ffi::gpointer, 413 ) { 414 let f: &F = &*(f as *const F); 415 f(Adjustment::from_glib_borrow(this).unsafe_cast_ref()) 416 } 417 unsafe { 418 let f: Box_<F> = Box_::new(f); 419 connect_raw( 420 self.as_ptr() as *mut _, 421 b"notify::page-size\0".as_ptr() as *const _, 422 Some(transmute::<_, unsafe extern "C" fn()>( 423 notify_page_size_trampoline::<Self, F> as *const (), 424 )), 425 Box_::into_raw(f), 426 ) 427 } 428 } 429 connect_step_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId430 fn connect_step_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 431 unsafe extern "C" fn notify_step_increment_trampoline< 432 P: IsA<Adjustment>, 433 F: Fn(&P) + 'static, 434 >( 435 this: *mut ffi::GtkAdjustment, 436 _param_spec: glib::ffi::gpointer, 437 f: glib::ffi::gpointer, 438 ) { 439 let f: &F = &*(f as *const F); 440 f(Adjustment::from_glib_borrow(this).unsafe_cast_ref()) 441 } 442 unsafe { 443 let f: Box_<F> = Box_::new(f); 444 connect_raw( 445 self.as_ptr() as *mut _, 446 b"notify::step-increment\0".as_ptr() as *const _, 447 Some(transmute::<_, unsafe extern "C" fn()>( 448 notify_step_increment_trampoline::<Self, F> as *const (), 449 )), 450 Box_::into_raw(f), 451 ) 452 } 453 } 454 connect_upper_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId455 fn connect_upper_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 456 unsafe extern "C" fn notify_upper_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>( 457 this: *mut ffi::GtkAdjustment, 458 _param_spec: glib::ffi::gpointer, 459 f: glib::ffi::gpointer, 460 ) { 461 let f: &F = &*(f as *const F); 462 f(Adjustment::from_glib_borrow(this).unsafe_cast_ref()) 463 } 464 unsafe { 465 let f: Box_<F> = Box_::new(f); 466 connect_raw( 467 self.as_ptr() as *mut _, 468 b"notify::upper\0".as_ptr() as *const _, 469 Some(transmute::<_, unsafe extern "C" fn()>( 470 notify_upper_trampoline::<Self, F> as *const (), 471 )), 472 Box_::into_raw(f), 473 ) 474 } 475 } 476 connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId477 fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 478 unsafe extern "C" fn notify_value_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>( 479 this: *mut ffi::GtkAdjustment, 480 _param_spec: glib::ffi::gpointer, 481 f: glib::ffi::gpointer, 482 ) { 483 let f: &F = &*(f as *const F); 484 f(Adjustment::from_glib_borrow(this).unsafe_cast_ref()) 485 } 486 unsafe { 487 let f: Box_<F> = Box_::new(f); 488 connect_raw( 489 self.as_ptr() as *mut _, 490 b"notify::value\0".as_ptr() as *const _, 491 Some(transmute::<_, unsafe extern "C" fn()>( 492 notify_value_trampoline::<Self, F> as *const (), 493 )), 494 Box_::into_raw(f), 495 ) 496 } 497 } 498 } 499 500 impl fmt::Display for Adjustment { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result501 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 502 f.write_str("Adjustment") 503 } 504 } 505