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::Align; 7 use crate::Bin; 8 use crate::Buildable; 9 use crate::Button; 10 use crate::Container; 11 use crate::PositionType; 12 use crate::ReliefStyle; 13 use crate::ResizeMode; 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::transmute; 25 26 glib::wrapper! { 27 #[doc(alias = "GtkToggleButton")] 28 pub struct ToggleButton(Object<ffi::GtkToggleButton, ffi::GtkToggleButtonClass>) @extends Button, Bin, Container, Widget, @implements Buildable, Actionable; 29 30 match fn { 31 type_ => || ffi::gtk_toggle_button_get_type(), 32 } 33 } 34 35 impl ToggleButton { 36 #[doc(alias = "gtk_toggle_button_new")] new() -> ToggleButton37 pub fn new() -> ToggleButton { 38 assert_initialized_main_thread!(); 39 unsafe { Widget::from_glib_none(ffi::gtk_toggle_button_new()).unsafe_cast() } 40 } 41 42 #[doc(alias = "gtk_toggle_button_new_with_label")] 43 #[doc(alias = "new_with_label")] with_label(label: &str) -> ToggleButton44 pub fn with_label(label: &str) -> ToggleButton { 45 assert_initialized_main_thread!(); 46 unsafe { 47 Widget::from_glib_none(ffi::gtk_toggle_button_new_with_label( 48 label.to_glib_none().0, 49 )) 50 .unsafe_cast() 51 } 52 } 53 54 #[doc(alias = "gtk_toggle_button_new_with_mnemonic")] 55 #[doc(alias = "new_with_mnemonic")] with_mnemonic(label: &str) -> ToggleButton56 pub fn with_mnemonic(label: &str) -> ToggleButton { 57 assert_initialized_main_thread!(); 58 unsafe { 59 Widget::from_glib_none(ffi::gtk_toggle_button_new_with_mnemonic( 60 label.to_glib_none().0, 61 )) 62 .unsafe_cast() 63 } 64 } 65 66 // rustdoc-stripper-ignore-next 67 /// Creates a new builder-pattern struct instance to construct [`ToggleButton`] objects. 68 /// 69 /// This method returns an instance of [`ToggleButtonBuilder`] which can be used to create [`ToggleButton`] objects. builder() -> ToggleButtonBuilder70 pub fn builder() -> ToggleButtonBuilder { 71 ToggleButtonBuilder::default() 72 } 73 } 74 75 impl Default for ToggleButton { default() -> Self76 fn default() -> Self { 77 Self::new() 78 } 79 } 80 81 #[derive(Clone, Default)] 82 // rustdoc-stripper-ignore-next 83 /// A [builder-pattern] type to construct [`ToggleButton`] objects. 84 /// 85 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 86 pub struct ToggleButtonBuilder { 87 active: Option<bool>, 88 draw_indicator: Option<bool>, 89 inconsistent: Option<bool>, 90 always_show_image: Option<bool>, 91 image: Option<Widget>, 92 image_position: Option<PositionType>, 93 label: Option<String>, 94 relief: Option<ReliefStyle>, 95 use_underline: Option<bool>, 96 border_width: Option<u32>, 97 child: Option<Widget>, 98 resize_mode: Option<ResizeMode>, 99 app_paintable: Option<bool>, 100 can_default: Option<bool>, 101 can_focus: Option<bool>, 102 events: Option<gdk::EventMask>, 103 expand: Option<bool>, 104 #[cfg(any(feature = "v3_20", feature = "dox"))] 105 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 106 focus_on_click: Option<bool>, 107 halign: Option<Align>, 108 has_default: Option<bool>, 109 has_focus: Option<bool>, 110 has_tooltip: Option<bool>, 111 height_request: Option<i32>, 112 hexpand: Option<bool>, 113 hexpand_set: Option<bool>, 114 is_focus: Option<bool>, 115 margin: Option<i32>, 116 margin_bottom: Option<i32>, 117 margin_end: Option<i32>, 118 margin_start: Option<i32>, 119 margin_top: Option<i32>, 120 name: Option<String>, 121 no_show_all: Option<bool>, 122 opacity: Option<f64>, 123 parent: Option<Container>, 124 receives_default: Option<bool>, 125 sensitive: Option<bool>, 126 tooltip_markup: Option<String>, 127 tooltip_text: Option<String>, 128 valign: Option<Align>, 129 vexpand: Option<bool>, 130 vexpand_set: Option<bool>, 131 visible: Option<bool>, 132 width_request: Option<i32>, 133 action_name: Option<String>, 134 action_target: Option<glib::Variant>, 135 } 136 137 impl ToggleButtonBuilder { 138 // rustdoc-stripper-ignore-next 139 /// Create a new [`ToggleButtonBuilder`]. new() -> Self140 pub fn new() -> Self { 141 Self::default() 142 } 143 144 // rustdoc-stripper-ignore-next 145 /// Build the [`ToggleButton`]. build(self) -> ToggleButton146 pub fn build(self) -> ToggleButton { 147 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 148 if let Some(ref active) = self.active { 149 properties.push(("active", active)); 150 } 151 if let Some(ref draw_indicator) = self.draw_indicator { 152 properties.push(("draw-indicator", draw_indicator)); 153 } 154 if let Some(ref inconsistent) = self.inconsistent { 155 properties.push(("inconsistent", inconsistent)); 156 } 157 if let Some(ref always_show_image) = self.always_show_image { 158 properties.push(("always-show-image", always_show_image)); 159 } 160 if let Some(ref image) = self.image { 161 properties.push(("image", image)); 162 } 163 if let Some(ref image_position) = self.image_position { 164 properties.push(("image-position", image_position)); 165 } 166 if let Some(ref label) = self.label { 167 properties.push(("label", label)); 168 } 169 if let Some(ref relief) = self.relief { 170 properties.push(("relief", relief)); 171 } 172 if let Some(ref use_underline) = self.use_underline { 173 properties.push(("use-underline", use_underline)); 174 } 175 if let Some(ref border_width) = self.border_width { 176 properties.push(("border-width", border_width)); 177 } 178 if let Some(ref child) = self.child { 179 properties.push(("child", child)); 180 } 181 if let Some(ref resize_mode) = self.resize_mode { 182 properties.push(("resize-mode", resize_mode)); 183 } 184 if let Some(ref app_paintable) = self.app_paintable { 185 properties.push(("app-paintable", app_paintable)); 186 } 187 if let Some(ref can_default) = self.can_default { 188 properties.push(("can-default", can_default)); 189 } 190 if let Some(ref can_focus) = self.can_focus { 191 properties.push(("can-focus", can_focus)); 192 } 193 if let Some(ref events) = self.events { 194 properties.push(("events", events)); 195 } 196 if let Some(ref expand) = self.expand { 197 properties.push(("expand", expand)); 198 } 199 #[cfg(any(feature = "v3_20", feature = "dox"))] 200 if let Some(ref focus_on_click) = self.focus_on_click { 201 properties.push(("focus-on-click", focus_on_click)); 202 } 203 if let Some(ref halign) = self.halign { 204 properties.push(("halign", halign)); 205 } 206 if let Some(ref has_default) = self.has_default { 207 properties.push(("has-default", has_default)); 208 } 209 if let Some(ref has_focus) = self.has_focus { 210 properties.push(("has-focus", has_focus)); 211 } 212 if let Some(ref has_tooltip) = self.has_tooltip { 213 properties.push(("has-tooltip", has_tooltip)); 214 } 215 if let Some(ref height_request) = self.height_request { 216 properties.push(("height-request", height_request)); 217 } 218 if let Some(ref hexpand) = self.hexpand { 219 properties.push(("hexpand", hexpand)); 220 } 221 if let Some(ref hexpand_set) = self.hexpand_set { 222 properties.push(("hexpand-set", hexpand_set)); 223 } 224 if let Some(ref is_focus) = self.is_focus { 225 properties.push(("is-focus", is_focus)); 226 } 227 if let Some(ref margin) = self.margin { 228 properties.push(("margin", margin)); 229 } 230 if let Some(ref margin_bottom) = self.margin_bottom { 231 properties.push(("margin-bottom", margin_bottom)); 232 } 233 if let Some(ref margin_end) = self.margin_end { 234 properties.push(("margin-end", margin_end)); 235 } 236 if let Some(ref margin_start) = self.margin_start { 237 properties.push(("margin-start", margin_start)); 238 } 239 if let Some(ref margin_top) = self.margin_top { 240 properties.push(("margin-top", margin_top)); 241 } 242 if let Some(ref name) = self.name { 243 properties.push(("name", name)); 244 } 245 if let Some(ref no_show_all) = self.no_show_all { 246 properties.push(("no-show-all", no_show_all)); 247 } 248 if let Some(ref opacity) = self.opacity { 249 properties.push(("opacity", opacity)); 250 } 251 if let Some(ref parent) = self.parent { 252 properties.push(("parent", parent)); 253 } 254 if let Some(ref receives_default) = self.receives_default { 255 properties.push(("receives-default", receives_default)); 256 } 257 if let Some(ref sensitive) = self.sensitive { 258 properties.push(("sensitive", sensitive)); 259 } 260 if let Some(ref tooltip_markup) = self.tooltip_markup { 261 properties.push(("tooltip-markup", tooltip_markup)); 262 } 263 if let Some(ref tooltip_text) = self.tooltip_text { 264 properties.push(("tooltip-text", tooltip_text)); 265 } 266 if let Some(ref valign) = self.valign { 267 properties.push(("valign", valign)); 268 } 269 if let Some(ref vexpand) = self.vexpand { 270 properties.push(("vexpand", vexpand)); 271 } 272 if let Some(ref vexpand_set) = self.vexpand_set { 273 properties.push(("vexpand-set", vexpand_set)); 274 } 275 if let Some(ref visible) = self.visible { 276 properties.push(("visible", visible)); 277 } 278 if let Some(ref width_request) = self.width_request { 279 properties.push(("width-request", width_request)); 280 } 281 if let Some(ref action_name) = self.action_name { 282 properties.push(("action-name", action_name)); 283 } 284 if let Some(ref action_target) = self.action_target { 285 properties.push(("action-target", action_target)); 286 } 287 glib::Object::new::<ToggleButton>(&properties) 288 .expect("Failed to create an instance of ToggleButton") 289 } 290 active(mut self, active: bool) -> Self291 pub fn active(mut self, active: bool) -> Self { 292 self.active = Some(active); 293 self 294 } 295 draw_indicator(mut self, draw_indicator: bool) -> Self296 pub fn draw_indicator(mut self, draw_indicator: bool) -> Self { 297 self.draw_indicator = Some(draw_indicator); 298 self 299 } 300 inconsistent(mut self, inconsistent: bool) -> Self301 pub fn inconsistent(mut self, inconsistent: bool) -> Self { 302 self.inconsistent = Some(inconsistent); 303 self 304 } 305 always_show_image(mut self, always_show_image: bool) -> Self306 pub fn always_show_image(mut self, always_show_image: bool) -> Self { 307 self.always_show_image = Some(always_show_image); 308 self 309 } 310 image<P: IsA<Widget>>(mut self, image: &P) -> Self311 pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self { 312 self.image = Some(image.clone().upcast()); 313 self 314 } 315 image_position(mut self, image_position: PositionType) -> Self316 pub fn image_position(mut self, image_position: PositionType) -> Self { 317 self.image_position = Some(image_position); 318 self 319 } 320 label(mut self, label: &str) -> Self321 pub fn label(mut self, label: &str) -> Self { 322 self.label = Some(label.to_string()); 323 self 324 } 325 relief(mut self, relief: ReliefStyle) -> Self326 pub fn relief(mut self, relief: ReliefStyle) -> Self { 327 self.relief = Some(relief); 328 self 329 } 330 use_underline(mut self, use_underline: bool) -> Self331 pub fn use_underline(mut self, use_underline: bool) -> Self { 332 self.use_underline = Some(use_underline); 333 self 334 } 335 border_width(mut self, border_width: u32) -> Self336 pub fn border_width(mut self, border_width: u32) -> Self { 337 self.border_width = Some(border_width); 338 self 339 } 340 child<P: IsA<Widget>>(mut self, child: &P) -> Self341 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 342 self.child = Some(child.clone().upcast()); 343 self 344 } 345 resize_mode(mut self, resize_mode: ResizeMode) -> Self346 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 347 self.resize_mode = Some(resize_mode); 348 self 349 } 350 app_paintable(mut self, app_paintable: bool) -> Self351 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 352 self.app_paintable = Some(app_paintable); 353 self 354 } 355 can_default(mut self, can_default: bool) -> Self356 pub fn can_default(mut self, can_default: bool) -> Self { 357 self.can_default = Some(can_default); 358 self 359 } 360 can_focus(mut self, can_focus: bool) -> Self361 pub fn can_focus(mut self, can_focus: bool) -> Self { 362 self.can_focus = Some(can_focus); 363 self 364 } 365 events(mut self, events: gdk::EventMask) -> Self366 pub fn events(mut self, events: gdk::EventMask) -> Self { 367 self.events = Some(events); 368 self 369 } 370 expand(mut self, expand: bool) -> Self371 pub fn expand(mut self, expand: bool) -> Self { 372 self.expand = Some(expand); 373 self 374 } 375 376 #[cfg(any(feature = "v3_20", feature = "dox"))] 377 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self378 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 379 self.focus_on_click = Some(focus_on_click); 380 self 381 } 382 halign(mut self, halign: Align) -> Self383 pub fn halign(mut self, halign: Align) -> Self { 384 self.halign = Some(halign); 385 self 386 } 387 has_default(mut self, has_default: bool) -> Self388 pub fn has_default(mut self, has_default: bool) -> Self { 389 self.has_default = Some(has_default); 390 self 391 } 392 has_focus(mut self, has_focus: bool) -> Self393 pub fn has_focus(mut self, has_focus: bool) -> Self { 394 self.has_focus = Some(has_focus); 395 self 396 } 397 has_tooltip(mut self, has_tooltip: bool) -> Self398 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 399 self.has_tooltip = Some(has_tooltip); 400 self 401 } 402 height_request(mut self, height_request: i32) -> Self403 pub fn height_request(mut self, height_request: i32) -> Self { 404 self.height_request = Some(height_request); 405 self 406 } 407 hexpand(mut self, hexpand: bool) -> Self408 pub fn hexpand(mut self, hexpand: bool) -> Self { 409 self.hexpand = Some(hexpand); 410 self 411 } 412 hexpand_set(mut self, hexpand_set: bool) -> Self413 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 414 self.hexpand_set = Some(hexpand_set); 415 self 416 } 417 is_focus(mut self, is_focus: bool) -> Self418 pub fn is_focus(mut self, is_focus: bool) -> Self { 419 self.is_focus = Some(is_focus); 420 self 421 } 422 margin(mut self, margin: i32) -> Self423 pub fn margin(mut self, margin: i32) -> Self { 424 self.margin = Some(margin); 425 self 426 } 427 margin_bottom(mut self, margin_bottom: i32) -> Self428 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 429 self.margin_bottom = Some(margin_bottom); 430 self 431 } 432 margin_end(mut self, margin_end: i32) -> Self433 pub fn margin_end(mut self, margin_end: i32) -> Self { 434 self.margin_end = Some(margin_end); 435 self 436 } 437 margin_start(mut self, margin_start: i32) -> Self438 pub fn margin_start(mut self, margin_start: i32) -> Self { 439 self.margin_start = Some(margin_start); 440 self 441 } 442 margin_top(mut self, margin_top: i32) -> Self443 pub fn margin_top(mut self, margin_top: i32) -> Self { 444 self.margin_top = Some(margin_top); 445 self 446 } 447 name(mut self, name: &str) -> Self448 pub fn name(mut self, name: &str) -> Self { 449 self.name = Some(name.to_string()); 450 self 451 } 452 no_show_all(mut self, no_show_all: bool) -> Self453 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 454 self.no_show_all = Some(no_show_all); 455 self 456 } 457 opacity(mut self, opacity: f64) -> Self458 pub fn opacity(mut self, opacity: f64) -> Self { 459 self.opacity = Some(opacity); 460 self 461 } 462 parent<P: IsA<Container>>(mut self, parent: &P) -> Self463 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 464 self.parent = Some(parent.clone().upcast()); 465 self 466 } 467 receives_default(mut self, receives_default: bool) -> Self468 pub fn receives_default(mut self, receives_default: bool) -> Self { 469 self.receives_default = Some(receives_default); 470 self 471 } 472 sensitive(mut self, sensitive: bool) -> Self473 pub fn sensitive(mut self, sensitive: bool) -> Self { 474 self.sensitive = Some(sensitive); 475 self 476 } 477 tooltip_markup(mut self, tooltip_markup: &str) -> Self478 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 479 self.tooltip_markup = Some(tooltip_markup.to_string()); 480 self 481 } 482 tooltip_text(mut self, tooltip_text: &str) -> Self483 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 484 self.tooltip_text = Some(tooltip_text.to_string()); 485 self 486 } 487 valign(mut self, valign: Align) -> Self488 pub fn valign(mut self, valign: Align) -> Self { 489 self.valign = Some(valign); 490 self 491 } 492 vexpand(mut self, vexpand: bool) -> Self493 pub fn vexpand(mut self, vexpand: bool) -> Self { 494 self.vexpand = Some(vexpand); 495 self 496 } 497 vexpand_set(mut self, vexpand_set: bool) -> Self498 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 499 self.vexpand_set = Some(vexpand_set); 500 self 501 } 502 visible(mut self, visible: bool) -> Self503 pub fn visible(mut self, visible: bool) -> Self { 504 self.visible = Some(visible); 505 self 506 } 507 width_request(mut self, width_request: i32) -> Self508 pub fn width_request(mut self, width_request: i32) -> Self { 509 self.width_request = Some(width_request); 510 self 511 } 512 action_name(mut self, action_name: &str) -> Self513 pub fn action_name(mut self, action_name: &str) -> Self { 514 self.action_name = Some(action_name.to_string()); 515 self 516 } 517 action_target(mut self, action_target: &glib::Variant) -> Self518 pub fn action_target(mut self, action_target: &glib::Variant) -> Self { 519 self.action_target = Some(action_target.clone()); 520 self 521 } 522 } 523 524 pub const NONE_TOGGLE_BUTTON: Option<&ToggleButton> = None; 525 526 pub trait ToggleButtonExt: 'static { 527 #[doc(alias = "gtk_toggle_button_get_active")] 528 #[doc(alias = "get_active")] is_active(&self) -> bool529 fn is_active(&self) -> bool; 530 531 #[doc(alias = "gtk_toggle_button_get_inconsistent")] 532 #[doc(alias = "get_inconsistent")] is_inconsistent(&self) -> bool533 fn is_inconsistent(&self) -> bool; 534 535 #[doc(alias = "gtk_toggle_button_get_mode")] 536 #[doc(alias = "get_mode")] is_mode(&self) -> bool537 fn is_mode(&self) -> bool; 538 539 #[doc(alias = "gtk_toggle_button_set_active")] set_active(&self, is_active: bool)540 fn set_active(&self, is_active: bool); 541 542 #[doc(alias = "gtk_toggle_button_set_inconsistent")] set_inconsistent(&self, setting: bool)543 fn set_inconsistent(&self, setting: bool); 544 545 #[doc(alias = "gtk_toggle_button_set_mode")] set_mode(&self, draw_indicator: bool)546 fn set_mode(&self, draw_indicator: bool); 547 548 #[doc(alias = "gtk_toggle_button_toggled")] toggled(&self)549 fn toggled(&self); 550 551 #[doc(alias = "draw-indicator")] draws_indicator(&self) -> bool552 fn draws_indicator(&self) -> bool; 553 554 #[doc(alias = "draw-indicator")] set_draw_indicator(&self, draw_indicator: bool)555 fn set_draw_indicator(&self, draw_indicator: bool); 556 557 #[doc(alias = "toggled")] connect_toggled<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId558 fn connect_toggled<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 559 560 #[doc(alias = "active")] connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId561 fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 562 563 #[doc(alias = "draw-indicator")] connect_draw_indicator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId564 fn connect_draw_indicator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 565 566 #[doc(alias = "inconsistent")] connect_inconsistent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId567 fn connect_inconsistent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 568 } 569 570 impl<O: IsA<ToggleButton>> ToggleButtonExt for O { is_active(&self) -> bool571 fn is_active(&self) -> bool { 572 unsafe { 573 from_glib(ffi::gtk_toggle_button_get_active( 574 self.as_ref().to_glib_none().0, 575 )) 576 } 577 } 578 is_inconsistent(&self) -> bool579 fn is_inconsistent(&self) -> bool { 580 unsafe { 581 from_glib(ffi::gtk_toggle_button_get_inconsistent( 582 self.as_ref().to_glib_none().0, 583 )) 584 } 585 } 586 is_mode(&self) -> bool587 fn is_mode(&self) -> bool { 588 unsafe { 589 from_glib(ffi::gtk_toggle_button_get_mode( 590 self.as_ref().to_glib_none().0, 591 )) 592 } 593 } 594 set_active(&self, is_active: bool)595 fn set_active(&self, is_active: bool) { 596 unsafe { 597 ffi::gtk_toggle_button_set_active( 598 self.as_ref().to_glib_none().0, 599 is_active.into_glib(), 600 ); 601 } 602 } 603 set_inconsistent(&self, setting: bool)604 fn set_inconsistent(&self, setting: bool) { 605 unsafe { 606 ffi::gtk_toggle_button_set_inconsistent( 607 self.as_ref().to_glib_none().0, 608 setting.into_glib(), 609 ); 610 } 611 } 612 set_mode(&self, draw_indicator: bool)613 fn set_mode(&self, draw_indicator: bool) { 614 unsafe { 615 ffi::gtk_toggle_button_set_mode( 616 self.as_ref().to_glib_none().0, 617 draw_indicator.into_glib(), 618 ); 619 } 620 } 621 toggled(&self)622 fn toggled(&self) { 623 unsafe { 624 ffi::gtk_toggle_button_toggled(self.as_ref().to_glib_none().0); 625 } 626 } 627 draws_indicator(&self) -> bool628 fn draws_indicator(&self) -> bool { 629 unsafe { 630 let mut value = glib::Value::from_type(<bool as StaticType>::static_type()); 631 glib::gobject_ffi::g_object_get_property( 632 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 633 b"draw-indicator\0".as_ptr() as *const _, 634 value.to_glib_none_mut().0, 635 ); 636 value 637 .get() 638 .expect("Return Value for property `draw-indicator` getter") 639 } 640 } 641 set_draw_indicator(&self, draw_indicator: bool)642 fn set_draw_indicator(&self, draw_indicator: bool) { 643 unsafe { 644 glib::gobject_ffi::g_object_set_property( 645 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 646 b"draw-indicator\0".as_ptr() as *const _, 647 draw_indicator.to_value().to_glib_none().0, 648 ); 649 } 650 } 651 connect_toggled<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId652 fn connect_toggled<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 653 unsafe extern "C" fn toggled_trampoline<P: IsA<ToggleButton>, F: Fn(&P) + 'static>( 654 this: *mut ffi::GtkToggleButton, 655 f: glib::ffi::gpointer, 656 ) { 657 let f: &F = &*(f as *const F); 658 f(ToggleButton::from_glib_borrow(this).unsafe_cast_ref()) 659 } 660 unsafe { 661 let f: Box_<F> = Box_::new(f); 662 connect_raw( 663 self.as_ptr() as *mut _, 664 b"toggled\0".as_ptr() as *const _, 665 Some(transmute::<_, unsafe extern "C" fn()>( 666 toggled_trampoline::<Self, F> as *const (), 667 )), 668 Box_::into_raw(f), 669 ) 670 } 671 } 672 connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId673 fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 674 unsafe extern "C" fn notify_active_trampoline<P: IsA<ToggleButton>, F: Fn(&P) + 'static>( 675 this: *mut ffi::GtkToggleButton, 676 _param_spec: glib::ffi::gpointer, 677 f: glib::ffi::gpointer, 678 ) { 679 let f: &F = &*(f as *const F); 680 f(ToggleButton::from_glib_borrow(this).unsafe_cast_ref()) 681 } 682 unsafe { 683 let f: Box_<F> = Box_::new(f); 684 connect_raw( 685 self.as_ptr() as *mut _, 686 b"notify::active\0".as_ptr() as *const _, 687 Some(transmute::<_, unsafe extern "C" fn()>( 688 notify_active_trampoline::<Self, F> as *const (), 689 )), 690 Box_::into_raw(f), 691 ) 692 } 693 } 694 connect_draw_indicator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId695 fn connect_draw_indicator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 696 unsafe extern "C" fn notify_draw_indicator_trampoline< 697 P: IsA<ToggleButton>, 698 F: Fn(&P) + 'static, 699 >( 700 this: *mut ffi::GtkToggleButton, 701 _param_spec: glib::ffi::gpointer, 702 f: glib::ffi::gpointer, 703 ) { 704 let f: &F = &*(f as *const F); 705 f(ToggleButton::from_glib_borrow(this).unsafe_cast_ref()) 706 } 707 unsafe { 708 let f: Box_<F> = Box_::new(f); 709 connect_raw( 710 self.as_ptr() as *mut _, 711 b"notify::draw-indicator\0".as_ptr() as *const _, 712 Some(transmute::<_, unsafe extern "C" fn()>( 713 notify_draw_indicator_trampoline::<Self, F> as *const (), 714 )), 715 Box_::into_raw(f), 716 ) 717 } 718 } 719 connect_inconsistent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId720 fn connect_inconsistent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 721 unsafe extern "C" fn notify_inconsistent_trampoline< 722 P: IsA<ToggleButton>, 723 F: Fn(&P) + 'static, 724 >( 725 this: *mut ffi::GtkToggleButton, 726 _param_spec: glib::ffi::gpointer, 727 f: glib::ffi::gpointer, 728 ) { 729 let f: &F = &*(f as *const F); 730 f(ToggleButton::from_glib_borrow(this).unsafe_cast_ref()) 731 } 732 unsafe { 733 let f: Box_<F> = Box_::new(f); 734 connect_raw( 735 self.as_ptr() as *mut _, 736 b"notify::inconsistent\0".as_ptr() as *const _, 737 Some(transmute::<_, unsafe extern "C" fn()>( 738 notify_inconsistent_trampoline::<Self, F> as *const (), 739 )), 740 Box_::into_raw(f), 741 ) 742 } 743 } 744 } 745 746 impl fmt::Display for ToggleButton { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result747 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 748 f.write_str("ToggleButton") 749 } 750 } 751