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::Adjustment; 6 use crate::Align; 7 use crate::Buildable; 8 use crate::Container; 9 use crate::Orientable; 10 use crate::Orientation; 11 use crate::PositionType; 12 use crate::Range; 13 use crate::SensitivityType; 14 use crate::Widget; 15 use glib::object::Cast; 16 use glib::object::IsA; 17 use glib::signal::connect_raw; 18 use glib::signal::SignalHandlerId; 19 use glib::translate::*; 20 use glib::StaticType; 21 use glib::ToValue; 22 use std::boxed::Box as Box_; 23 use std::fmt; 24 use std::mem; 25 use std::mem::transmute; 26 27 glib::wrapper! { 28 #[doc(alias = "GtkScale")] 29 pub struct Scale(Object<ffi::GtkScale, ffi::GtkScaleClass>) @extends Range, Widget, @implements Buildable, Orientable; 30 31 match fn { 32 type_ => || ffi::gtk_scale_get_type(), 33 } 34 } 35 36 impl Scale { 37 #[doc(alias = "gtk_scale_new")] new<P: IsA<Adjustment>>(orientation: Orientation, adjustment: Option<&P>) -> Scale38 pub fn new<P: IsA<Adjustment>>(orientation: Orientation, adjustment: Option<&P>) -> Scale { 39 assert_initialized_main_thread!(); 40 unsafe { 41 Widget::from_glib_none(ffi::gtk_scale_new( 42 orientation.into_glib(), 43 adjustment.map(|p| p.as_ref()).to_glib_none().0, 44 )) 45 .unsafe_cast() 46 } 47 } 48 49 #[doc(alias = "gtk_scale_new_with_range")] 50 #[doc(alias = "new_with_range")] with_range(orientation: Orientation, min: f64, max: f64, step: f64) -> Scale51 pub fn with_range(orientation: Orientation, min: f64, max: f64, step: f64) -> Scale { 52 assert_initialized_main_thread!(); 53 unsafe { 54 Widget::from_glib_none(ffi::gtk_scale_new_with_range( 55 orientation.into_glib(), 56 min, 57 max, 58 step, 59 )) 60 .unsafe_cast() 61 } 62 } 63 64 // rustdoc-stripper-ignore-next 65 /// Creates a new builder-pattern struct instance to construct [`Scale`] objects. 66 /// 67 /// This method returns an instance of [`ScaleBuilder`] which can be used to create [`Scale`] objects. builder() -> ScaleBuilder68 pub fn builder() -> ScaleBuilder { 69 ScaleBuilder::default() 70 } 71 } 72 73 #[derive(Clone, Default)] 74 // rustdoc-stripper-ignore-next 75 /// A [builder-pattern] type to construct [`Scale`] objects. 76 /// 77 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 78 pub struct ScaleBuilder { 79 digits: Option<i32>, 80 draw_value: Option<bool>, 81 has_origin: Option<bool>, 82 value_pos: Option<PositionType>, 83 adjustment: Option<Adjustment>, 84 fill_level: Option<f64>, 85 inverted: Option<bool>, 86 lower_stepper_sensitivity: Option<SensitivityType>, 87 restrict_to_fill_level: Option<bool>, 88 round_digits: Option<i32>, 89 show_fill_level: Option<bool>, 90 upper_stepper_sensitivity: Option<SensitivityType>, 91 app_paintable: Option<bool>, 92 can_default: Option<bool>, 93 can_focus: Option<bool>, 94 events: Option<gdk::EventMask>, 95 expand: Option<bool>, 96 #[cfg(any(feature = "v3_20", feature = "dox"))] 97 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 98 focus_on_click: Option<bool>, 99 halign: Option<Align>, 100 has_default: Option<bool>, 101 has_focus: Option<bool>, 102 has_tooltip: Option<bool>, 103 height_request: Option<i32>, 104 hexpand: Option<bool>, 105 hexpand_set: Option<bool>, 106 is_focus: Option<bool>, 107 margin: Option<i32>, 108 margin_bottom: Option<i32>, 109 margin_end: Option<i32>, 110 margin_start: Option<i32>, 111 margin_top: Option<i32>, 112 name: Option<String>, 113 no_show_all: Option<bool>, 114 opacity: Option<f64>, 115 parent: Option<Container>, 116 receives_default: Option<bool>, 117 sensitive: Option<bool>, 118 tooltip_markup: Option<String>, 119 tooltip_text: Option<String>, 120 valign: Option<Align>, 121 vexpand: Option<bool>, 122 vexpand_set: Option<bool>, 123 visible: Option<bool>, 124 width_request: Option<i32>, 125 orientation: Option<Orientation>, 126 } 127 128 impl ScaleBuilder { 129 // rustdoc-stripper-ignore-next 130 /// Create a new [`ScaleBuilder`]. new() -> Self131 pub fn new() -> Self { 132 Self::default() 133 } 134 135 // rustdoc-stripper-ignore-next 136 /// Build the [`Scale`]. build(self) -> Scale137 pub fn build(self) -> Scale { 138 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 139 if let Some(ref digits) = self.digits { 140 properties.push(("digits", digits)); 141 } 142 if let Some(ref draw_value) = self.draw_value { 143 properties.push(("draw-value", draw_value)); 144 } 145 if let Some(ref has_origin) = self.has_origin { 146 properties.push(("has-origin", has_origin)); 147 } 148 if let Some(ref value_pos) = self.value_pos { 149 properties.push(("value-pos", value_pos)); 150 } 151 if let Some(ref adjustment) = self.adjustment { 152 properties.push(("adjustment", adjustment)); 153 } 154 if let Some(ref fill_level) = self.fill_level { 155 properties.push(("fill-level", fill_level)); 156 } 157 if let Some(ref inverted) = self.inverted { 158 properties.push(("inverted", inverted)); 159 } 160 if let Some(ref lower_stepper_sensitivity) = self.lower_stepper_sensitivity { 161 properties.push(("lower-stepper-sensitivity", lower_stepper_sensitivity)); 162 } 163 if let Some(ref restrict_to_fill_level) = self.restrict_to_fill_level { 164 properties.push(("restrict-to-fill-level", restrict_to_fill_level)); 165 } 166 if let Some(ref round_digits) = self.round_digits { 167 properties.push(("round-digits", round_digits)); 168 } 169 if let Some(ref show_fill_level) = self.show_fill_level { 170 properties.push(("show-fill-level", show_fill_level)); 171 } 172 if let Some(ref upper_stepper_sensitivity) = self.upper_stepper_sensitivity { 173 properties.push(("upper-stepper-sensitivity", upper_stepper_sensitivity)); 174 } 175 if let Some(ref app_paintable) = self.app_paintable { 176 properties.push(("app-paintable", app_paintable)); 177 } 178 if let Some(ref can_default) = self.can_default { 179 properties.push(("can-default", can_default)); 180 } 181 if let Some(ref can_focus) = self.can_focus { 182 properties.push(("can-focus", can_focus)); 183 } 184 if let Some(ref events) = self.events { 185 properties.push(("events", events)); 186 } 187 if let Some(ref expand) = self.expand { 188 properties.push(("expand", expand)); 189 } 190 #[cfg(any(feature = "v3_20", feature = "dox"))] 191 if let Some(ref focus_on_click) = self.focus_on_click { 192 properties.push(("focus-on-click", focus_on_click)); 193 } 194 if let Some(ref halign) = self.halign { 195 properties.push(("halign", halign)); 196 } 197 if let Some(ref has_default) = self.has_default { 198 properties.push(("has-default", has_default)); 199 } 200 if let Some(ref has_focus) = self.has_focus { 201 properties.push(("has-focus", has_focus)); 202 } 203 if let Some(ref has_tooltip) = self.has_tooltip { 204 properties.push(("has-tooltip", has_tooltip)); 205 } 206 if let Some(ref height_request) = self.height_request { 207 properties.push(("height-request", height_request)); 208 } 209 if let Some(ref hexpand) = self.hexpand { 210 properties.push(("hexpand", hexpand)); 211 } 212 if let Some(ref hexpand_set) = self.hexpand_set { 213 properties.push(("hexpand-set", hexpand_set)); 214 } 215 if let Some(ref is_focus) = self.is_focus { 216 properties.push(("is-focus", is_focus)); 217 } 218 if let Some(ref margin) = self.margin { 219 properties.push(("margin", margin)); 220 } 221 if let Some(ref margin_bottom) = self.margin_bottom { 222 properties.push(("margin-bottom", margin_bottom)); 223 } 224 if let Some(ref margin_end) = self.margin_end { 225 properties.push(("margin-end", margin_end)); 226 } 227 if let Some(ref margin_start) = self.margin_start { 228 properties.push(("margin-start", margin_start)); 229 } 230 if let Some(ref margin_top) = self.margin_top { 231 properties.push(("margin-top", margin_top)); 232 } 233 if let Some(ref name) = self.name { 234 properties.push(("name", name)); 235 } 236 if let Some(ref no_show_all) = self.no_show_all { 237 properties.push(("no-show-all", no_show_all)); 238 } 239 if let Some(ref opacity) = self.opacity { 240 properties.push(("opacity", opacity)); 241 } 242 if let Some(ref parent) = self.parent { 243 properties.push(("parent", parent)); 244 } 245 if let Some(ref receives_default) = self.receives_default { 246 properties.push(("receives-default", receives_default)); 247 } 248 if let Some(ref sensitive) = self.sensitive { 249 properties.push(("sensitive", sensitive)); 250 } 251 if let Some(ref tooltip_markup) = self.tooltip_markup { 252 properties.push(("tooltip-markup", tooltip_markup)); 253 } 254 if let Some(ref tooltip_text) = self.tooltip_text { 255 properties.push(("tooltip-text", tooltip_text)); 256 } 257 if let Some(ref valign) = self.valign { 258 properties.push(("valign", valign)); 259 } 260 if let Some(ref vexpand) = self.vexpand { 261 properties.push(("vexpand", vexpand)); 262 } 263 if let Some(ref vexpand_set) = self.vexpand_set { 264 properties.push(("vexpand-set", vexpand_set)); 265 } 266 if let Some(ref visible) = self.visible { 267 properties.push(("visible", visible)); 268 } 269 if let Some(ref width_request) = self.width_request { 270 properties.push(("width-request", width_request)); 271 } 272 if let Some(ref orientation) = self.orientation { 273 properties.push(("orientation", orientation)); 274 } 275 glib::Object::new::<Scale>(&properties).expect("Failed to create an instance of Scale") 276 } 277 digits(mut self, digits: i32) -> Self278 pub fn digits(mut self, digits: i32) -> Self { 279 self.digits = Some(digits); 280 self 281 } 282 draw_value(mut self, draw_value: bool) -> Self283 pub fn draw_value(mut self, draw_value: bool) -> Self { 284 self.draw_value = Some(draw_value); 285 self 286 } 287 has_origin(mut self, has_origin: bool) -> Self288 pub fn has_origin(mut self, has_origin: bool) -> Self { 289 self.has_origin = Some(has_origin); 290 self 291 } 292 value_pos(mut self, value_pos: PositionType) -> Self293 pub fn value_pos(mut self, value_pos: PositionType) -> Self { 294 self.value_pos = Some(value_pos); 295 self 296 } 297 adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self298 pub fn adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self { 299 self.adjustment = Some(adjustment.clone().upcast()); 300 self 301 } 302 fill_level(mut self, fill_level: f64) -> Self303 pub fn fill_level(mut self, fill_level: f64) -> Self { 304 self.fill_level = Some(fill_level); 305 self 306 } 307 inverted(mut self, inverted: bool) -> Self308 pub fn inverted(mut self, inverted: bool) -> Self { 309 self.inverted = Some(inverted); 310 self 311 } 312 lower_stepper_sensitivity(mut self, lower_stepper_sensitivity: SensitivityType) -> Self313 pub fn lower_stepper_sensitivity(mut self, lower_stepper_sensitivity: SensitivityType) -> Self { 314 self.lower_stepper_sensitivity = Some(lower_stepper_sensitivity); 315 self 316 } 317 restrict_to_fill_level(mut self, restrict_to_fill_level: bool) -> Self318 pub fn restrict_to_fill_level(mut self, restrict_to_fill_level: bool) -> Self { 319 self.restrict_to_fill_level = Some(restrict_to_fill_level); 320 self 321 } 322 round_digits(mut self, round_digits: i32) -> Self323 pub fn round_digits(mut self, round_digits: i32) -> Self { 324 self.round_digits = Some(round_digits); 325 self 326 } 327 show_fill_level(mut self, show_fill_level: bool) -> Self328 pub fn show_fill_level(mut self, show_fill_level: bool) -> Self { 329 self.show_fill_level = Some(show_fill_level); 330 self 331 } 332 upper_stepper_sensitivity(mut self, upper_stepper_sensitivity: SensitivityType) -> Self333 pub fn upper_stepper_sensitivity(mut self, upper_stepper_sensitivity: SensitivityType) -> Self { 334 self.upper_stepper_sensitivity = Some(upper_stepper_sensitivity); 335 self 336 } 337 app_paintable(mut self, app_paintable: bool) -> Self338 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 339 self.app_paintable = Some(app_paintable); 340 self 341 } 342 can_default(mut self, can_default: bool) -> Self343 pub fn can_default(mut self, can_default: bool) -> Self { 344 self.can_default = Some(can_default); 345 self 346 } 347 can_focus(mut self, can_focus: bool) -> Self348 pub fn can_focus(mut self, can_focus: bool) -> Self { 349 self.can_focus = Some(can_focus); 350 self 351 } 352 events(mut self, events: gdk::EventMask) -> Self353 pub fn events(mut self, events: gdk::EventMask) -> Self { 354 self.events = Some(events); 355 self 356 } 357 expand(mut self, expand: bool) -> Self358 pub fn expand(mut self, expand: bool) -> Self { 359 self.expand = Some(expand); 360 self 361 } 362 363 #[cfg(any(feature = "v3_20", feature = "dox"))] 364 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self365 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 366 self.focus_on_click = Some(focus_on_click); 367 self 368 } 369 halign(mut self, halign: Align) -> Self370 pub fn halign(mut self, halign: Align) -> Self { 371 self.halign = Some(halign); 372 self 373 } 374 has_default(mut self, has_default: bool) -> Self375 pub fn has_default(mut self, has_default: bool) -> Self { 376 self.has_default = Some(has_default); 377 self 378 } 379 has_focus(mut self, has_focus: bool) -> Self380 pub fn has_focus(mut self, has_focus: bool) -> Self { 381 self.has_focus = Some(has_focus); 382 self 383 } 384 has_tooltip(mut self, has_tooltip: bool) -> Self385 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 386 self.has_tooltip = Some(has_tooltip); 387 self 388 } 389 height_request(mut self, height_request: i32) -> Self390 pub fn height_request(mut self, height_request: i32) -> Self { 391 self.height_request = Some(height_request); 392 self 393 } 394 hexpand(mut self, hexpand: bool) -> Self395 pub fn hexpand(mut self, hexpand: bool) -> Self { 396 self.hexpand = Some(hexpand); 397 self 398 } 399 hexpand_set(mut self, hexpand_set: bool) -> Self400 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 401 self.hexpand_set = Some(hexpand_set); 402 self 403 } 404 is_focus(mut self, is_focus: bool) -> Self405 pub fn is_focus(mut self, is_focus: bool) -> Self { 406 self.is_focus = Some(is_focus); 407 self 408 } 409 margin(mut self, margin: i32) -> Self410 pub fn margin(mut self, margin: i32) -> Self { 411 self.margin = Some(margin); 412 self 413 } 414 margin_bottom(mut self, margin_bottom: i32) -> Self415 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 416 self.margin_bottom = Some(margin_bottom); 417 self 418 } 419 margin_end(mut self, margin_end: i32) -> Self420 pub fn margin_end(mut self, margin_end: i32) -> Self { 421 self.margin_end = Some(margin_end); 422 self 423 } 424 margin_start(mut self, margin_start: i32) -> Self425 pub fn margin_start(mut self, margin_start: i32) -> Self { 426 self.margin_start = Some(margin_start); 427 self 428 } 429 margin_top(mut self, margin_top: i32) -> Self430 pub fn margin_top(mut self, margin_top: i32) -> Self { 431 self.margin_top = Some(margin_top); 432 self 433 } 434 name(mut self, name: &str) -> Self435 pub fn name(mut self, name: &str) -> Self { 436 self.name = Some(name.to_string()); 437 self 438 } 439 no_show_all(mut self, no_show_all: bool) -> Self440 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 441 self.no_show_all = Some(no_show_all); 442 self 443 } 444 opacity(mut self, opacity: f64) -> Self445 pub fn opacity(mut self, opacity: f64) -> Self { 446 self.opacity = Some(opacity); 447 self 448 } 449 parent<P: IsA<Container>>(mut self, parent: &P) -> Self450 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 451 self.parent = Some(parent.clone().upcast()); 452 self 453 } 454 receives_default(mut self, receives_default: bool) -> Self455 pub fn receives_default(mut self, receives_default: bool) -> Self { 456 self.receives_default = Some(receives_default); 457 self 458 } 459 sensitive(mut self, sensitive: bool) -> Self460 pub fn sensitive(mut self, sensitive: bool) -> Self { 461 self.sensitive = Some(sensitive); 462 self 463 } 464 tooltip_markup(mut self, tooltip_markup: &str) -> Self465 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 466 self.tooltip_markup = Some(tooltip_markup.to_string()); 467 self 468 } 469 tooltip_text(mut self, tooltip_text: &str) -> Self470 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 471 self.tooltip_text = Some(tooltip_text.to_string()); 472 self 473 } 474 valign(mut self, valign: Align) -> Self475 pub fn valign(mut self, valign: Align) -> Self { 476 self.valign = Some(valign); 477 self 478 } 479 vexpand(mut self, vexpand: bool) -> Self480 pub fn vexpand(mut self, vexpand: bool) -> Self { 481 self.vexpand = Some(vexpand); 482 self 483 } 484 vexpand_set(mut self, vexpand_set: bool) -> Self485 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 486 self.vexpand_set = Some(vexpand_set); 487 self 488 } 489 visible(mut self, visible: bool) -> Self490 pub fn visible(mut self, visible: bool) -> Self { 491 self.visible = Some(visible); 492 self 493 } 494 width_request(mut self, width_request: i32) -> Self495 pub fn width_request(mut self, width_request: i32) -> Self { 496 self.width_request = Some(width_request); 497 self 498 } 499 orientation(mut self, orientation: Orientation) -> Self500 pub fn orientation(mut self, orientation: Orientation) -> Self { 501 self.orientation = Some(orientation); 502 self 503 } 504 } 505 506 pub const NONE_SCALE: Option<&Scale> = None; 507 508 pub trait ScaleExt: 'static { 509 #[doc(alias = "gtk_scale_add_mark")] add_mark(&self, value: f64, position: PositionType, markup: Option<&str>)510 fn add_mark(&self, value: f64, position: PositionType, markup: Option<&str>); 511 512 #[doc(alias = "gtk_scale_clear_marks")] clear_marks(&self)513 fn clear_marks(&self); 514 515 #[doc(alias = "gtk_scale_get_digits")] 516 #[doc(alias = "get_digits")] digits(&self) -> i32517 fn digits(&self) -> i32; 518 519 #[doc(alias = "gtk_scale_get_draw_value")] 520 #[doc(alias = "get_draw_value")] draws_value(&self) -> bool521 fn draws_value(&self) -> bool; 522 523 #[doc(alias = "gtk_scale_get_has_origin")] 524 #[doc(alias = "get_has_origin")] has_origin(&self) -> bool525 fn has_origin(&self) -> bool; 526 527 #[doc(alias = "gtk_scale_get_layout")] 528 #[doc(alias = "get_layout")] layout(&self) -> Option<pango::Layout>529 fn layout(&self) -> Option<pango::Layout>; 530 531 #[doc(alias = "gtk_scale_get_layout_offsets")] 532 #[doc(alias = "get_layout_offsets")] layout_offsets(&self) -> (i32, i32)533 fn layout_offsets(&self) -> (i32, i32); 534 535 #[doc(alias = "gtk_scale_get_value_pos")] 536 #[doc(alias = "get_value_pos")] value_pos(&self) -> PositionType537 fn value_pos(&self) -> PositionType; 538 539 #[doc(alias = "gtk_scale_set_digits")] set_digits(&self, digits: i32)540 fn set_digits(&self, digits: i32); 541 542 #[doc(alias = "gtk_scale_set_draw_value")] set_draw_value(&self, draw_value: bool)543 fn set_draw_value(&self, draw_value: bool); 544 545 #[doc(alias = "gtk_scale_set_has_origin")] set_has_origin(&self, has_origin: bool)546 fn set_has_origin(&self, has_origin: bool); 547 548 #[doc(alias = "gtk_scale_set_value_pos")] set_value_pos(&self, pos: PositionType)549 fn set_value_pos(&self, pos: PositionType); 550 551 #[doc(alias = "format-value")] connect_format_value<F: Fn(&Self, f64) -> String + 'static>(&self, f: F) -> SignalHandlerId552 fn connect_format_value<F: Fn(&Self, f64) -> String + 'static>(&self, f: F) -> SignalHandlerId; 553 554 #[doc(alias = "digits")] connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId555 fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 556 557 #[doc(alias = "draw-value")] connect_draw_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId558 fn connect_draw_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 559 560 #[doc(alias = "has-origin")] connect_has_origin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId561 fn connect_has_origin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 562 563 #[doc(alias = "value-pos")] connect_value_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId564 fn connect_value_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 565 } 566 567 impl<O: IsA<Scale>> ScaleExt for O { add_mark(&self, value: f64, position: PositionType, markup: Option<&str>)568 fn add_mark(&self, value: f64, position: PositionType, markup: Option<&str>) { 569 unsafe { 570 ffi::gtk_scale_add_mark( 571 self.as_ref().to_glib_none().0, 572 value, 573 position.into_glib(), 574 markup.to_glib_none().0, 575 ); 576 } 577 } 578 clear_marks(&self)579 fn clear_marks(&self) { 580 unsafe { 581 ffi::gtk_scale_clear_marks(self.as_ref().to_glib_none().0); 582 } 583 } 584 digits(&self) -> i32585 fn digits(&self) -> i32 { 586 unsafe { ffi::gtk_scale_get_digits(self.as_ref().to_glib_none().0) } 587 } 588 draws_value(&self) -> bool589 fn draws_value(&self) -> bool { 590 unsafe { 591 from_glib(ffi::gtk_scale_get_draw_value( 592 self.as_ref().to_glib_none().0, 593 )) 594 } 595 } 596 has_origin(&self) -> bool597 fn has_origin(&self) -> bool { 598 unsafe { 599 from_glib(ffi::gtk_scale_get_has_origin( 600 self.as_ref().to_glib_none().0, 601 )) 602 } 603 } 604 layout(&self) -> Option<pango::Layout>605 fn layout(&self) -> Option<pango::Layout> { 606 unsafe { from_glib_none(ffi::gtk_scale_get_layout(self.as_ref().to_glib_none().0)) } 607 } 608 layout_offsets(&self) -> (i32, i32)609 fn layout_offsets(&self) -> (i32, i32) { 610 unsafe { 611 let mut x = mem::MaybeUninit::uninit(); 612 let mut y = mem::MaybeUninit::uninit(); 613 ffi::gtk_scale_get_layout_offsets( 614 self.as_ref().to_glib_none().0, 615 x.as_mut_ptr(), 616 y.as_mut_ptr(), 617 ); 618 let x = x.assume_init(); 619 let y = y.assume_init(); 620 (x, y) 621 } 622 } 623 value_pos(&self) -> PositionType624 fn value_pos(&self) -> PositionType { 625 unsafe { from_glib(ffi::gtk_scale_get_value_pos(self.as_ref().to_glib_none().0)) } 626 } 627 set_digits(&self, digits: i32)628 fn set_digits(&self, digits: i32) { 629 unsafe { 630 ffi::gtk_scale_set_digits(self.as_ref().to_glib_none().0, digits); 631 } 632 } 633 set_draw_value(&self, draw_value: bool)634 fn set_draw_value(&self, draw_value: bool) { 635 unsafe { 636 ffi::gtk_scale_set_draw_value(self.as_ref().to_glib_none().0, draw_value.into_glib()); 637 } 638 } 639 set_has_origin(&self, has_origin: bool)640 fn set_has_origin(&self, has_origin: bool) { 641 unsafe { 642 ffi::gtk_scale_set_has_origin(self.as_ref().to_glib_none().0, has_origin.into_glib()); 643 } 644 } 645 set_value_pos(&self, pos: PositionType)646 fn set_value_pos(&self, pos: PositionType) { 647 unsafe { 648 ffi::gtk_scale_set_value_pos(self.as_ref().to_glib_none().0, pos.into_glib()); 649 } 650 } 651 connect_format_value<F: Fn(&Self, f64) -> String + 'static>(&self, f: F) -> SignalHandlerId652 fn connect_format_value<F: Fn(&Self, f64) -> String + 'static>(&self, f: F) -> SignalHandlerId { 653 unsafe extern "C" fn format_value_trampoline< 654 P: IsA<Scale>, 655 F: Fn(&P, f64) -> String + 'static, 656 >( 657 this: *mut ffi::GtkScale, 658 value: libc::c_double, 659 f: glib::ffi::gpointer, 660 ) -> *mut libc::c_char { 661 let f: &F = &*(f as *const F); 662 f(Scale::from_glib_borrow(this).unsafe_cast_ref(), value).to_glib_full() 663 } 664 unsafe { 665 let f: Box_<F> = Box_::new(f); 666 connect_raw( 667 self.as_ptr() as *mut _, 668 b"format-value\0".as_ptr() as *const _, 669 Some(transmute::<_, unsafe extern "C" fn()>( 670 format_value_trampoline::<Self, F> as *const (), 671 )), 672 Box_::into_raw(f), 673 ) 674 } 675 } 676 connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId677 fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 678 unsafe extern "C" fn notify_digits_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>( 679 this: *mut ffi::GtkScale, 680 _param_spec: glib::ffi::gpointer, 681 f: glib::ffi::gpointer, 682 ) { 683 let f: &F = &*(f as *const F); 684 f(Scale::from_glib_borrow(this).unsafe_cast_ref()) 685 } 686 unsafe { 687 let f: Box_<F> = Box_::new(f); 688 connect_raw( 689 self.as_ptr() as *mut _, 690 b"notify::digits\0".as_ptr() as *const _, 691 Some(transmute::<_, unsafe extern "C" fn()>( 692 notify_digits_trampoline::<Self, F> as *const (), 693 )), 694 Box_::into_raw(f), 695 ) 696 } 697 } 698 connect_draw_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId699 fn connect_draw_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 700 unsafe extern "C" fn notify_draw_value_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>( 701 this: *mut ffi::GtkScale, 702 _param_spec: glib::ffi::gpointer, 703 f: glib::ffi::gpointer, 704 ) { 705 let f: &F = &*(f as *const F); 706 f(Scale::from_glib_borrow(this).unsafe_cast_ref()) 707 } 708 unsafe { 709 let f: Box_<F> = Box_::new(f); 710 connect_raw( 711 self.as_ptr() as *mut _, 712 b"notify::draw-value\0".as_ptr() as *const _, 713 Some(transmute::<_, unsafe extern "C" fn()>( 714 notify_draw_value_trampoline::<Self, F> as *const (), 715 )), 716 Box_::into_raw(f), 717 ) 718 } 719 } 720 connect_has_origin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId721 fn connect_has_origin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 722 unsafe extern "C" fn notify_has_origin_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>( 723 this: *mut ffi::GtkScale, 724 _param_spec: glib::ffi::gpointer, 725 f: glib::ffi::gpointer, 726 ) { 727 let f: &F = &*(f as *const F); 728 f(Scale::from_glib_borrow(this).unsafe_cast_ref()) 729 } 730 unsafe { 731 let f: Box_<F> = Box_::new(f); 732 connect_raw( 733 self.as_ptr() as *mut _, 734 b"notify::has-origin\0".as_ptr() as *const _, 735 Some(transmute::<_, unsafe extern "C" fn()>( 736 notify_has_origin_trampoline::<Self, F> as *const (), 737 )), 738 Box_::into_raw(f), 739 ) 740 } 741 } 742 connect_value_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId743 fn connect_value_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 744 unsafe extern "C" fn notify_value_pos_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>( 745 this: *mut ffi::GtkScale, 746 _param_spec: glib::ffi::gpointer, 747 f: glib::ffi::gpointer, 748 ) { 749 let f: &F = &*(f as *const F); 750 f(Scale::from_glib_borrow(this).unsafe_cast_ref()) 751 } 752 unsafe { 753 let f: Box_<F> = Box_::new(f); 754 connect_raw( 755 self.as_ptr() as *mut _, 756 b"notify::value-pos\0".as_ptr() as *const _, 757 Some(transmute::<_, unsafe extern "C" fn()>( 758 notify_value_pos_trampoline::<Self, F> as *const (), 759 )), 760 Box_::into_raw(f), 761 ) 762 } 763 } 764 } 765 766 impl fmt::Display for Scale { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result767 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 768 f.write_str("Scale") 769 } 770 } 771