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::Actionable; 6 use crate::Adjustment; 7 use crate::Align; 8 use crate::Bin; 9 use crate::Buildable; 10 use crate::Button; 11 use crate::Container; 12 use crate::IconSize; 13 use crate::Orientable; 14 use crate::Orientation; 15 use crate::PositionType; 16 use crate::ReliefStyle; 17 use crate::ResizeMode; 18 use crate::Widget; 19 use glib::object::Cast; 20 use glib::object::IsA; 21 use glib::object::ObjectExt; 22 use glib::signal::connect_raw; 23 use glib::signal::SignalHandlerId; 24 use glib::translate::*; 25 use glib::StaticType; 26 use glib::ToValue; 27 use std::boxed::Box as Box_; 28 use std::fmt; 29 use std::mem::transmute; 30 31 glib::wrapper! { 32 #[doc(alias = "GtkScaleButton")] 33 pub struct ScaleButton(Object<ffi::GtkScaleButton, ffi::GtkScaleButtonClass>) @extends Button, Bin, Container, Widget, @implements Buildable, Actionable, Orientable; 34 35 match fn { 36 type_ => || ffi::gtk_scale_button_get_type(), 37 } 38 } 39 40 impl ScaleButton { 41 #[doc(alias = "gtk_scale_button_new")] new(size: IconSize, min: f64, max: f64, step: f64, icons: &[&str]) -> ScaleButton42 pub fn new(size: IconSize, min: f64, max: f64, step: f64, icons: &[&str]) -> ScaleButton { 43 assert_initialized_main_thread!(); 44 unsafe { 45 Widget::from_glib_none(ffi::gtk_scale_button_new( 46 size.into_glib(), 47 min, 48 max, 49 step, 50 icons.to_glib_none().0, 51 )) 52 .unsafe_cast() 53 } 54 } 55 56 // rustdoc-stripper-ignore-next 57 /// Creates a new builder-pattern struct instance to construct [`ScaleButton`] objects. 58 /// 59 /// This method returns an instance of [`ScaleButtonBuilder`] which can be used to create [`ScaleButton`] objects. builder() -> ScaleButtonBuilder60 pub fn builder() -> ScaleButtonBuilder { 61 ScaleButtonBuilder::default() 62 } 63 } 64 65 #[derive(Clone, Default)] 66 // rustdoc-stripper-ignore-next 67 /// A [builder-pattern] type to construct [`ScaleButton`] objects. 68 /// 69 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 70 pub struct ScaleButtonBuilder { 71 adjustment: Option<Adjustment>, 72 icons: Option<Vec<String>>, 73 size: Option<IconSize>, 74 value: Option<f64>, 75 always_show_image: Option<bool>, 76 image: Option<Widget>, 77 image_position: Option<PositionType>, 78 label: Option<String>, 79 relief: Option<ReliefStyle>, 80 use_underline: Option<bool>, 81 border_width: Option<u32>, 82 child: Option<Widget>, 83 resize_mode: Option<ResizeMode>, 84 app_paintable: Option<bool>, 85 can_default: Option<bool>, 86 can_focus: Option<bool>, 87 events: Option<gdk::EventMask>, 88 expand: Option<bool>, 89 #[cfg(any(feature = "v3_20", feature = "dox"))] 90 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 91 focus_on_click: Option<bool>, 92 halign: Option<Align>, 93 has_default: Option<bool>, 94 has_focus: Option<bool>, 95 has_tooltip: Option<bool>, 96 height_request: Option<i32>, 97 hexpand: Option<bool>, 98 hexpand_set: Option<bool>, 99 is_focus: Option<bool>, 100 margin: Option<i32>, 101 margin_bottom: Option<i32>, 102 margin_end: Option<i32>, 103 margin_start: Option<i32>, 104 margin_top: Option<i32>, 105 name: Option<String>, 106 no_show_all: Option<bool>, 107 opacity: Option<f64>, 108 parent: Option<Container>, 109 receives_default: Option<bool>, 110 sensitive: Option<bool>, 111 tooltip_markup: Option<String>, 112 tooltip_text: Option<String>, 113 valign: Option<Align>, 114 vexpand: Option<bool>, 115 vexpand_set: Option<bool>, 116 visible: Option<bool>, 117 width_request: Option<i32>, 118 action_name: Option<String>, 119 action_target: Option<glib::Variant>, 120 orientation: Option<Orientation>, 121 } 122 123 impl ScaleButtonBuilder { 124 // rustdoc-stripper-ignore-next 125 /// Create a new [`ScaleButtonBuilder`]. new() -> Self126 pub fn new() -> Self { 127 Self::default() 128 } 129 130 // rustdoc-stripper-ignore-next 131 /// Build the [`ScaleButton`]. build(self) -> ScaleButton132 pub fn build(self) -> ScaleButton { 133 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 134 if let Some(ref adjustment) = self.adjustment { 135 properties.push(("adjustment", adjustment)); 136 } 137 if let Some(ref icons) = self.icons { 138 properties.push(("icons", icons)); 139 } 140 if let Some(ref size) = self.size { 141 properties.push(("size", size)); 142 } 143 if let Some(ref value) = self.value { 144 properties.push(("value", value)); 145 } 146 if let Some(ref always_show_image) = self.always_show_image { 147 properties.push(("always-show-image", always_show_image)); 148 } 149 if let Some(ref image) = self.image { 150 properties.push(("image", image)); 151 } 152 if let Some(ref image_position) = self.image_position { 153 properties.push(("image-position", image_position)); 154 } 155 if let Some(ref label) = self.label { 156 properties.push(("label", label)); 157 } 158 if let Some(ref relief) = self.relief { 159 properties.push(("relief", relief)); 160 } 161 if let Some(ref use_underline) = self.use_underline { 162 properties.push(("use-underline", use_underline)); 163 } 164 if let Some(ref border_width) = self.border_width { 165 properties.push(("border-width", border_width)); 166 } 167 if let Some(ref child) = self.child { 168 properties.push(("child", child)); 169 } 170 if let Some(ref resize_mode) = self.resize_mode { 171 properties.push(("resize-mode", resize_mode)); 172 } 173 if let Some(ref app_paintable) = self.app_paintable { 174 properties.push(("app-paintable", app_paintable)); 175 } 176 if let Some(ref can_default) = self.can_default { 177 properties.push(("can-default", can_default)); 178 } 179 if let Some(ref can_focus) = self.can_focus { 180 properties.push(("can-focus", can_focus)); 181 } 182 if let Some(ref events) = self.events { 183 properties.push(("events", events)); 184 } 185 if let Some(ref expand) = self.expand { 186 properties.push(("expand", expand)); 187 } 188 #[cfg(any(feature = "v3_20", feature = "dox"))] 189 if let Some(ref focus_on_click) = self.focus_on_click { 190 properties.push(("focus-on-click", focus_on_click)); 191 } 192 if let Some(ref halign) = self.halign { 193 properties.push(("halign", halign)); 194 } 195 if let Some(ref has_default) = self.has_default { 196 properties.push(("has-default", has_default)); 197 } 198 if let Some(ref has_focus) = self.has_focus { 199 properties.push(("has-focus", has_focus)); 200 } 201 if let Some(ref has_tooltip) = self.has_tooltip { 202 properties.push(("has-tooltip", has_tooltip)); 203 } 204 if let Some(ref height_request) = self.height_request { 205 properties.push(("height-request", height_request)); 206 } 207 if let Some(ref hexpand) = self.hexpand { 208 properties.push(("hexpand", hexpand)); 209 } 210 if let Some(ref hexpand_set) = self.hexpand_set { 211 properties.push(("hexpand-set", hexpand_set)); 212 } 213 if let Some(ref is_focus) = self.is_focus { 214 properties.push(("is-focus", is_focus)); 215 } 216 if let Some(ref margin) = self.margin { 217 properties.push(("margin", margin)); 218 } 219 if let Some(ref margin_bottom) = self.margin_bottom { 220 properties.push(("margin-bottom", margin_bottom)); 221 } 222 if let Some(ref margin_end) = self.margin_end { 223 properties.push(("margin-end", margin_end)); 224 } 225 if let Some(ref margin_start) = self.margin_start { 226 properties.push(("margin-start", margin_start)); 227 } 228 if let Some(ref margin_top) = self.margin_top { 229 properties.push(("margin-top", margin_top)); 230 } 231 if let Some(ref name) = self.name { 232 properties.push(("name", name)); 233 } 234 if let Some(ref no_show_all) = self.no_show_all { 235 properties.push(("no-show-all", no_show_all)); 236 } 237 if let Some(ref opacity) = self.opacity { 238 properties.push(("opacity", opacity)); 239 } 240 if let Some(ref parent) = self.parent { 241 properties.push(("parent", parent)); 242 } 243 if let Some(ref receives_default) = self.receives_default { 244 properties.push(("receives-default", receives_default)); 245 } 246 if let Some(ref sensitive) = self.sensitive { 247 properties.push(("sensitive", sensitive)); 248 } 249 if let Some(ref tooltip_markup) = self.tooltip_markup { 250 properties.push(("tooltip-markup", tooltip_markup)); 251 } 252 if let Some(ref tooltip_text) = self.tooltip_text { 253 properties.push(("tooltip-text", tooltip_text)); 254 } 255 if let Some(ref valign) = self.valign { 256 properties.push(("valign", valign)); 257 } 258 if let Some(ref vexpand) = self.vexpand { 259 properties.push(("vexpand", vexpand)); 260 } 261 if let Some(ref vexpand_set) = self.vexpand_set { 262 properties.push(("vexpand-set", vexpand_set)); 263 } 264 if let Some(ref visible) = self.visible { 265 properties.push(("visible", visible)); 266 } 267 if let Some(ref width_request) = self.width_request { 268 properties.push(("width-request", width_request)); 269 } 270 if let Some(ref action_name) = self.action_name { 271 properties.push(("action-name", action_name)); 272 } 273 if let Some(ref action_target) = self.action_target { 274 properties.push(("action-target", action_target)); 275 } 276 if let Some(ref orientation) = self.orientation { 277 properties.push(("orientation", orientation)); 278 } 279 glib::Object::new::<ScaleButton>(&properties) 280 .expect("Failed to create an instance of ScaleButton") 281 } 282 adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self283 pub fn adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self { 284 self.adjustment = Some(adjustment.clone().upcast()); 285 self 286 } 287 icons(mut self, icons: Vec<String>) -> Self288 pub fn icons(mut self, icons: Vec<String>) -> Self { 289 self.icons = Some(icons); 290 self 291 } 292 size(mut self, size: IconSize) -> Self293 pub fn size(mut self, size: IconSize) -> Self { 294 self.size = Some(size); 295 self 296 } 297 value(mut self, value: f64) -> Self298 pub fn value(mut self, value: f64) -> Self { 299 self.value = Some(value); 300 self 301 } 302 always_show_image(mut self, always_show_image: bool) -> Self303 pub fn always_show_image(mut self, always_show_image: bool) -> Self { 304 self.always_show_image = Some(always_show_image); 305 self 306 } 307 image<P: IsA<Widget>>(mut self, image: &P) -> Self308 pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self { 309 self.image = Some(image.clone().upcast()); 310 self 311 } 312 image_position(mut self, image_position: PositionType) -> Self313 pub fn image_position(mut self, image_position: PositionType) -> Self { 314 self.image_position = Some(image_position); 315 self 316 } 317 label(mut self, label: &str) -> Self318 pub fn label(mut self, label: &str) -> Self { 319 self.label = Some(label.to_string()); 320 self 321 } 322 relief(mut self, relief: ReliefStyle) -> Self323 pub fn relief(mut self, relief: ReliefStyle) -> Self { 324 self.relief = Some(relief); 325 self 326 } 327 use_underline(mut self, use_underline: bool) -> Self328 pub fn use_underline(mut self, use_underline: bool) -> Self { 329 self.use_underline = Some(use_underline); 330 self 331 } 332 border_width(mut self, border_width: u32) -> Self333 pub fn border_width(mut self, border_width: u32) -> Self { 334 self.border_width = Some(border_width); 335 self 336 } 337 child<P: IsA<Widget>>(mut self, child: &P) -> Self338 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 339 self.child = Some(child.clone().upcast()); 340 self 341 } 342 resize_mode(mut self, resize_mode: ResizeMode) -> Self343 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 344 self.resize_mode = Some(resize_mode); 345 self 346 } 347 app_paintable(mut self, app_paintable: bool) -> Self348 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 349 self.app_paintable = Some(app_paintable); 350 self 351 } 352 can_default(mut self, can_default: bool) -> Self353 pub fn can_default(mut self, can_default: bool) -> Self { 354 self.can_default = Some(can_default); 355 self 356 } 357 can_focus(mut self, can_focus: bool) -> Self358 pub fn can_focus(mut self, can_focus: bool) -> Self { 359 self.can_focus = Some(can_focus); 360 self 361 } 362 events(mut self, events: gdk::EventMask) -> Self363 pub fn events(mut self, events: gdk::EventMask) -> Self { 364 self.events = Some(events); 365 self 366 } 367 expand(mut self, expand: bool) -> Self368 pub fn expand(mut self, expand: bool) -> Self { 369 self.expand = Some(expand); 370 self 371 } 372 373 #[cfg(any(feature = "v3_20", feature = "dox"))] 374 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self375 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 376 self.focus_on_click = Some(focus_on_click); 377 self 378 } 379 halign(mut self, halign: Align) -> Self380 pub fn halign(mut self, halign: Align) -> Self { 381 self.halign = Some(halign); 382 self 383 } 384 has_default(mut self, has_default: bool) -> Self385 pub fn has_default(mut self, has_default: bool) -> Self { 386 self.has_default = Some(has_default); 387 self 388 } 389 has_focus(mut self, has_focus: bool) -> Self390 pub fn has_focus(mut self, has_focus: bool) -> Self { 391 self.has_focus = Some(has_focus); 392 self 393 } 394 has_tooltip(mut self, has_tooltip: bool) -> Self395 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 396 self.has_tooltip = Some(has_tooltip); 397 self 398 } 399 height_request(mut self, height_request: i32) -> Self400 pub fn height_request(mut self, height_request: i32) -> Self { 401 self.height_request = Some(height_request); 402 self 403 } 404 hexpand(mut self, hexpand: bool) -> Self405 pub fn hexpand(mut self, hexpand: bool) -> Self { 406 self.hexpand = Some(hexpand); 407 self 408 } 409 hexpand_set(mut self, hexpand_set: bool) -> Self410 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 411 self.hexpand_set = Some(hexpand_set); 412 self 413 } 414 is_focus(mut self, is_focus: bool) -> Self415 pub fn is_focus(mut self, is_focus: bool) -> Self { 416 self.is_focus = Some(is_focus); 417 self 418 } 419 margin(mut self, margin: i32) -> Self420 pub fn margin(mut self, margin: i32) -> Self { 421 self.margin = Some(margin); 422 self 423 } 424 margin_bottom(mut self, margin_bottom: i32) -> Self425 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 426 self.margin_bottom = Some(margin_bottom); 427 self 428 } 429 margin_end(mut self, margin_end: i32) -> Self430 pub fn margin_end(mut self, margin_end: i32) -> Self { 431 self.margin_end = Some(margin_end); 432 self 433 } 434 margin_start(mut self, margin_start: i32) -> Self435 pub fn margin_start(mut self, margin_start: i32) -> Self { 436 self.margin_start = Some(margin_start); 437 self 438 } 439 margin_top(mut self, margin_top: i32) -> Self440 pub fn margin_top(mut self, margin_top: i32) -> Self { 441 self.margin_top = Some(margin_top); 442 self 443 } 444 name(mut self, name: &str) -> Self445 pub fn name(mut self, name: &str) -> Self { 446 self.name = Some(name.to_string()); 447 self 448 } 449 no_show_all(mut self, no_show_all: bool) -> Self450 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 451 self.no_show_all = Some(no_show_all); 452 self 453 } 454 opacity(mut self, opacity: f64) -> Self455 pub fn opacity(mut self, opacity: f64) -> Self { 456 self.opacity = Some(opacity); 457 self 458 } 459 parent<P: IsA<Container>>(mut self, parent: &P) -> Self460 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 461 self.parent = Some(parent.clone().upcast()); 462 self 463 } 464 receives_default(mut self, receives_default: bool) -> Self465 pub fn receives_default(mut self, receives_default: bool) -> Self { 466 self.receives_default = Some(receives_default); 467 self 468 } 469 sensitive(mut self, sensitive: bool) -> Self470 pub fn sensitive(mut self, sensitive: bool) -> Self { 471 self.sensitive = Some(sensitive); 472 self 473 } 474 tooltip_markup(mut self, tooltip_markup: &str) -> Self475 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 476 self.tooltip_markup = Some(tooltip_markup.to_string()); 477 self 478 } 479 tooltip_text(mut self, tooltip_text: &str) -> Self480 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 481 self.tooltip_text = Some(tooltip_text.to_string()); 482 self 483 } 484 valign(mut self, valign: Align) -> Self485 pub fn valign(mut self, valign: Align) -> Self { 486 self.valign = Some(valign); 487 self 488 } 489 vexpand(mut self, vexpand: bool) -> Self490 pub fn vexpand(mut self, vexpand: bool) -> Self { 491 self.vexpand = Some(vexpand); 492 self 493 } 494 vexpand_set(mut self, vexpand_set: bool) -> Self495 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 496 self.vexpand_set = Some(vexpand_set); 497 self 498 } 499 visible(mut self, visible: bool) -> Self500 pub fn visible(mut self, visible: bool) -> Self { 501 self.visible = Some(visible); 502 self 503 } 504 width_request(mut self, width_request: i32) -> Self505 pub fn width_request(mut self, width_request: i32) -> Self { 506 self.width_request = Some(width_request); 507 self 508 } 509 action_name(mut self, action_name: &str) -> Self510 pub fn action_name(mut self, action_name: &str) -> Self { 511 self.action_name = Some(action_name.to_string()); 512 self 513 } 514 action_target(mut self, action_target: &glib::Variant) -> Self515 pub fn action_target(mut self, action_target: &glib::Variant) -> Self { 516 self.action_target = Some(action_target.clone()); 517 self 518 } 519 orientation(mut self, orientation: Orientation) -> Self520 pub fn orientation(mut self, orientation: Orientation) -> Self { 521 self.orientation = Some(orientation); 522 self 523 } 524 } 525 526 pub const NONE_SCALE_BUTTON: Option<&ScaleButton> = None; 527 528 pub trait ScaleButtonExt: 'static { 529 #[doc(alias = "gtk_scale_button_get_adjustment")] 530 #[doc(alias = "get_adjustment")] adjustment(&self) -> Adjustment531 fn adjustment(&self) -> Adjustment; 532 533 #[doc(alias = "gtk_scale_button_get_minus_button")] 534 #[doc(alias = "get_minus_button")] minus_button(&self) -> Option<Button>535 fn minus_button(&self) -> Option<Button>; 536 537 #[doc(alias = "gtk_scale_button_get_plus_button")] 538 #[doc(alias = "get_plus_button")] plus_button(&self) -> Option<Button>539 fn plus_button(&self) -> Option<Button>; 540 541 #[doc(alias = "gtk_scale_button_get_popup")] 542 #[doc(alias = "get_popup")] popup(&self) -> Option<Widget>543 fn popup(&self) -> Option<Widget>; 544 545 #[doc(alias = "gtk_scale_button_get_value")] 546 #[doc(alias = "get_value")] value(&self) -> f64547 fn value(&self) -> f64; 548 549 #[doc(alias = "gtk_scale_button_set_adjustment")] set_adjustment<P: IsA<Adjustment>>(&self, adjustment: &P)550 fn set_adjustment<P: IsA<Adjustment>>(&self, adjustment: &P); 551 552 #[doc(alias = "gtk_scale_button_set_icons")] set_icons(&self, icons: &[&str])553 fn set_icons(&self, icons: &[&str]); 554 555 #[doc(alias = "gtk_scale_button_set_value")] set_value(&self, value: f64)556 fn set_value(&self, value: f64); 557 icons(&self) -> Vec<glib::GString>558 fn icons(&self) -> Vec<glib::GString>; 559 size(&self) -> IconSize560 fn size(&self) -> IconSize; 561 set_size(&self, size: IconSize)562 fn set_size(&self, size: IconSize); 563 564 #[doc(alias = "popdown")] connect_popdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId565 fn connect_popdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 566 emit_popdown(&self)567 fn emit_popdown(&self); 568 569 #[doc(alias = "popup")] connect_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId570 fn connect_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 571 emit_popup(&self)572 fn emit_popup(&self); 573 574 #[doc(alias = "value-changed")] connect_value_changed<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId575 fn connect_value_changed<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId; 576 577 #[doc(alias = "adjustment")] connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId578 fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 579 580 #[doc(alias = "icons")] connect_icons_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId581 fn connect_icons_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 582 583 #[doc(alias = "size")] connect_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId584 fn connect_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 585 586 #[doc(alias = "value")] connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId587 fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 588 } 589 590 impl<O: IsA<ScaleButton>> ScaleButtonExt for O { adjustment(&self) -> Adjustment591 fn adjustment(&self) -> Adjustment { 592 unsafe { 593 from_glib_none(ffi::gtk_scale_button_get_adjustment( 594 self.as_ref().to_glib_none().0, 595 )) 596 } 597 } 598 minus_button(&self) -> Option<Button>599 fn minus_button(&self) -> Option<Button> { 600 unsafe { 601 from_glib_none(ffi::gtk_scale_button_get_minus_button( 602 self.as_ref().to_glib_none().0, 603 )) 604 } 605 } 606 plus_button(&self) -> Option<Button>607 fn plus_button(&self) -> Option<Button> { 608 unsafe { 609 from_glib_none(ffi::gtk_scale_button_get_plus_button( 610 self.as_ref().to_glib_none().0, 611 )) 612 } 613 } 614 popup(&self) -> Option<Widget>615 fn popup(&self) -> Option<Widget> { 616 unsafe { 617 from_glib_none(ffi::gtk_scale_button_get_popup( 618 self.as_ref().to_glib_none().0, 619 )) 620 } 621 } 622 value(&self) -> f64623 fn value(&self) -> f64 { 624 unsafe { ffi::gtk_scale_button_get_value(self.as_ref().to_glib_none().0) } 625 } 626 set_adjustment<P: IsA<Adjustment>>(&self, adjustment: &P)627 fn set_adjustment<P: IsA<Adjustment>>(&self, adjustment: &P) { 628 unsafe { 629 ffi::gtk_scale_button_set_adjustment( 630 self.as_ref().to_glib_none().0, 631 adjustment.as_ref().to_glib_none().0, 632 ); 633 } 634 } 635 set_icons(&self, icons: &[&str])636 fn set_icons(&self, icons: &[&str]) { 637 unsafe { 638 ffi::gtk_scale_button_set_icons(self.as_ref().to_glib_none().0, icons.to_glib_none().0); 639 } 640 } 641 set_value(&self, value: f64)642 fn set_value(&self, value: f64) { 643 unsafe { 644 ffi::gtk_scale_button_set_value(self.as_ref().to_glib_none().0, value); 645 } 646 } 647 icons(&self) -> Vec<glib::GString>648 fn icons(&self) -> Vec<glib::GString> { 649 unsafe { 650 let mut value = 651 glib::Value::from_type(<Vec<glib::GString> as StaticType>::static_type()); 652 glib::gobject_ffi::g_object_get_property( 653 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 654 b"icons\0".as_ptr() as *const _, 655 value.to_glib_none_mut().0, 656 ); 657 value 658 .get() 659 .expect("Return Value for property `icons` getter") 660 } 661 } 662 size(&self) -> IconSize663 fn size(&self) -> IconSize { 664 unsafe { 665 let mut value = glib::Value::from_type(<IconSize as StaticType>::static_type()); 666 glib::gobject_ffi::g_object_get_property( 667 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 668 b"size\0".as_ptr() as *const _, 669 value.to_glib_none_mut().0, 670 ); 671 value 672 .get() 673 .expect("Return Value for property `size` getter") 674 } 675 } 676 set_size(&self, size: IconSize)677 fn set_size(&self, size: IconSize) { 678 unsafe { 679 glib::gobject_ffi::g_object_set_property( 680 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 681 b"size\0".as_ptr() as *const _, 682 size.to_value().to_glib_none().0, 683 ); 684 } 685 } 686 connect_popdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId687 fn connect_popdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 688 unsafe extern "C" fn popdown_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>( 689 this: *mut ffi::GtkScaleButton, 690 f: glib::ffi::gpointer, 691 ) { 692 let f: &F = &*(f as *const F); 693 f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref()) 694 } 695 unsafe { 696 let f: Box_<F> = Box_::new(f); 697 connect_raw( 698 self.as_ptr() as *mut _, 699 b"popdown\0".as_ptr() as *const _, 700 Some(transmute::<_, unsafe extern "C" fn()>( 701 popdown_trampoline::<Self, F> as *const (), 702 )), 703 Box_::into_raw(f), 704 ) 705 } 706 } 707 emit_popdown(&self)708 fn emit_popdown(&self) { 709 let _ = unsafe { 710 glib::Object::from_glib_borrow(self.as_ptr() as *mut glib::gobject_ffi::GObject) 711 .emit_by_name("popdown", &[]) 712 .unwrap() 713 }; 714 } 715 connect_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId716 fn connect_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 717 unsafe extern "C" fn popup_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>( 718 this: *mut ffi::GtkScaleButton, 719 f: glib::ffi::gpointer, 720 ) { 721 let f: &F = &*(f as *const F); 722 f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref()) 723 } 724 unsafe { 725 let f: Box_<F> = Box_::new(f); 726 connect_raw( 727 self.as_ptr() as *mut _, 728 b"popup\0".as_ptr() as *const _, 729 Some(transmute::<_, unsafe extern "C" fn()>( 730 popup_trampoline::<Self, F> as *const (), 731 )), 732 Box_::into_raw(f), 733 ) 734 } 735 } 736 emit_popup(&self)737 fn emit_popup(&self) { 738 let _ = unsafe { 739 glib::Object::from_glib_borrow(self.as_ptr() as *mut glib::gobject_ffi::GObject) 740 .emit_by_name("popup", &[]) 741 .unwrap() 742 }; 743 } 744 connect_value_changed<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId745 fn connect_value_changed<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId { 746 unsafe extern "C" fn value_changed_trampoline< 747 P: IsA<ScaleButton>, 748 F: Fn(&P, f64) + 'static, 749 >( 750 this: *mut ffi::GtkScaleButton, 751 value: libc::c_double, 752 f: glib::ffi::gpointer, 753 ) { 754 let f: &F = &*(f as *const F); 755 f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref(), value) 756 } 757 unsafe { 758 let f: Box_<F> = Box_::new(f); 759 connect_raw( 760 self.as_ptr() as *mut _, 761 b"value-changed\0".as_ptr() as *const _, 762 Some(transmute::<_, unsafe extern "C" fn()>( 763 value_changed_trampoline::<Self, F> as *const (), 764 )), 765 Box_::into_raw(f), 766 ) 767 } 768 } 769 connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId770 fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 771 unsafe extern "C" fn notify_adjustment_trampoline< 772 P: IsA<ScaleButton>, 773 F: Fn(&P) + 'static, 774 >( 775 this: *mut ffi::GtkScaleButton, 776 _param_spec: glib::ffi::gpointer, 777 f: glib::ffi::gpointer, 778 ) { 779 let f: &F = &*(f as *const F); 780 f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref()) 781 } 782 unsafe { 783 let f: Box_<F> = Box_::new(f); 784 connect_raw( 785 self.as_ptr() as *mut _, 786 b"notify::adjustment\0".as_ptr() as *const _, 787 Some(transmute::<_, unsafe extern "C" fn()>( 788 notify_adjustment_trampoline::<Self, F> as *const (), 789 )), 790 Box_::into_raw(f), 791 ) 792 } 793 } 794 connect_icons_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId795 fn connect_icons_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 796 unsafe extern "C" fn notify_icons_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>( 797 this: *mut ffi::GtkScaleButton, 798 _param_spec: glib::ffi::gpointer, 799 f: glib::ffi::gpointer, 800 ) { 801 let f: &F = &*(f as *const F); 802 f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref()) 803 } 804 unsafe { 805 let f: Box_<F> = Box_::new(f); 806 connect_raw( 807 self.as_ptr() as *mut _, 808 b"notify::icons\0".as_ptr() as *const _, 809 Some(transmute::<_, unsafe extern "C" fn()>( 810 notify_icons_trampoline::<Self, F> as *const (), 811 )), 812 Box_::into_raw(f), 813 ) 814 } 815 } 816 connect_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId817 fn connect_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 818 unsafe extern "C" fn notify_size_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>( 819 this: *mut ffi::GtkScaleButton, 820 _param_spec: glib::ffi::gpointer, 821 f: glib::ffi::gpointer, 822 ) { 823 let f: &F = &*(f as *const F); 824 f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref()) 825 } 826 unsafe { 827 let f: Box_<F> = Box_::new(f); 828 connect_raw( 829 self.as_ptr() as *mut _, 830 b"notify::size\0".as_ptr() as *const _, 831 Some(transmute::<_, unsafe extern "C" fn()>( 832 notify_size_trampoline::<Self, F> as *const (), 833 )), 834 Box_::into_raw(f), 835 ) 836 } 837 } 838 connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId839 fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 840 unsafe extern "C" fn notify_value_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>( 841 this: *mut ffi::GtkScaleButton, 842 _param_spec: glib::ffi::gpointer, 843 f: glib::ffi::gpointer, 844 ) { 845 let f: &F = &*(f as *const F); 846 f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref()) 847 } 848 unsafe { 849 let f: Box_<F> = Box_::new(f); 850 connect_raw( 851 self.as_ptr() as *mut _, 852 b"notify::value\0".as_ptr() as *const _, 853 Some(transmute::<_, unsafe extern "C" fn()>( 854 notify_value_trampoline::<Self, F> as *const (), 855 )), 856 Box_::into_raw(f), 857 ) 858 } 859 } 860 } 861 862 impl fmt::Display for ScaleButton { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result863 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 864 f.write_str("ScaleButton") 865 } 866 } 867