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::Container; 10 use crate::ResizeMode; 11 use crate::ToolItem; 12 use crate::Widget; 13 use glib::object::Cast; 14 use glib::object::IsA; 15 use glib::object::ObjectExt; 16 use glib::signal::connect_raw; 17 use glib::signal::SignalHandlerId; 18 use glib::translate::*; 19 use glib::StaticType; 20 use glib::ToValue; 21 use std::boxed::Box as Box_; 22 use std::fmt; 23 use std::mem::transmute; 24 25 glib::wrapper! { 26 #[doc(alias = "GtkToolButton")] 27 pub struct ToolButton(Object<ffi::GtkToolButton, ffi::GtkToolButtonClass>) @extends ToolItem, Bin, Container, Widget, @implements Buildable, Actionable; 28 29 match fn { 30 type_ => || ffi::gtk_tool_button_get_type(), 31 } 32 } 33 34 impl ToolButton { 35 #[doc(alias = "gtk_tool_button_new")] new<P: IsA<Widget>>(icon_widget: Option<&P>, label: Option<&str>) -> ToolButton36 pub fn new<P: IsA<Widget>>(icon_widget: Option<&P>, label: Option<&str>) -> ToolButton { 37 assert_initialized_main_thread!(); 38 unsafe { 39 ToolItem::from_glib_none(ffi::gtk_tool_button_new( 40 icon_widget.map(|p| p.as_ref()).to_glib_none().0, 41 label.to_glib_none().0, 42 )) 43 .unsafe_cast() 44 } 45 } 46 47 // rustdoc-stripper-ignore-next 48 /// Creates a new builder-pattern struct instance to construct [`ToolButton`] objects. 49 /// 50 /// This method returns an instance of [`ToolButtonBuilder`] which can be used to create [`ToolButton`] objects. builder() -> ToolButtonBuilder51 pub fn builder() -> ToolButtonBuilder { 52 ToolButtonBuilder::default() 53 } 54 } 55 56 #[derive(Clone, Default)] 57 // rustdoc-stripper-ignore-next 58 /// A [builder-pattern] type to construct [`ToolButton`] objects. 59 /// 60 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 61 pub struct ToolButtonBuilder { 62 icon_name: Option<String>, 63 icon_widget: Option<Widget>, 64 label: Option<String>, 65 label_widget: Option<Widget>, 66 use_underline: Option<bool>, 67 is_important: Option<bool>, 68 visible_horizontal: Option<bool>, 69 visible_vertical: Option<bool>, 70 border_width: Option<u32>, 71 child: Option<Widget>, 72 resize_mode: Option<ResizeMode>, 73 app_paintable: Option<bool>, 74 can_default: Option<bool>, 75 can_focus: Option<bool>, 76 events: Option<gdk::EventMask>, 77 expand: Option<bool>, 78 #[cfg(any(feature = "v3_20", feature = "dox"))] 79 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 80 focus_on_click: Option<bool>, 81 halign: Option<Align>, 82 has_default: Option<bool>, 83 has_focus: Option<bool>, 84 has_tooltip: Option<bool>, 85 height_request: Option<i32>, 86 hexpand: Option<bool>, 87 hexpand_set: Option<bool>, 88 is_focus: Option<bool>, 89 margin: Option<i32>, 90 margin_bottom: Option<i32>, 91 margin_end: Option<i32>, 92 margin_start: Option<i32>, 93 margin_top: Option<i32>, 94 name: Option<String>, 95 no_show_all: Option<bool>, 96 opacity: Option<f64>, 97 parent: Option<Container>, 98 receives_default: Option<bool>, 99 sensitive: Option<bool>, 100 tooltip_markup: Option<String>, 101 tooltip_text: Option<String>, 102 valign: Option<Align>, 103 vexpand: Option<bool>, 104 vexpand_set: Option<bool>, 105 visible: Option<bool>, 106 width_request: Option<i32>, 107 action_name: Option<String>, 108 action_target: Option<glib::Variant>, 109 } 110 111 impl ToolButtonBuilder { 112 // rustdoc-stripper-ignore-next 113 /// Create a new [`ToolButtonBuilder`]. new() -> Self114 pub fn new() -> Self { 115 Self::default() 116 } 117 118 // rustdoc-stripper-ignore-next 119 /// Build the [`ToolButton`]. build(self) -> ToolButton120 pub fn build(self) -> ToolButton { 121 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 122 if let Some(ref icon_name) = self.icon_name { 123 properties.push(("icon-name", icon_name)); 124 } 125 if let Some(ref icon_widget) = self.icon_widget { 126 properties.push(("icon-widget", icon_widget)); 127 } 128 if let Some(ref label) = self.label { 129 properties.push(("label", label)); 130 } 131 if let Some(ref label_widget) = self.label_widget { 132 properties.push(("label-widget", label_widget)); 133 } 134 if let Some(ref use_underline) = self.use_underline { 135 properties.push(("use-underline", use_underline)); 136 } 137 if let Some(ref is_important) = self.is_important { 138 properties.push(("is-important", is_important)); 139 } 140 if let Some(ref visible_horizontal) = self.visible_horizontal { 141 properties.push(("visible-horizontal", visible_horizontal)); 142 } 143 if let Some(ref visible_vertical) = self.visible_vertical { 144 properties.push(("visible-vertical", visible_vertical)); 145 } 146 if let Some(ref border_width) = self.border_width { 147 properties.push(("border-width", border_width)); 148 } 149 if let Some(ref child) = self.child { 150 properties.push(("child", child)); 151 } 152 if let Some(ref resize_mode) = self.resize_mode { 153 properties.push(("resize-mode", resize_mode)); 154 } 155 if let Some(ref app_paintable) = self.app_paintable { 156 properties.push(("app-paintable", app_paintable)); 157 } 158 if let Some(ref can_default) = self.can_default { 159 properties.push(("can-default", can_default)); 160 } 161 if let Some(ref can_focus) = self.can_focus { 162 properties.push(("can-focus", can_focus)); 163 } 164 if let Some(ref events) = self.events { 165 properties.push(("events", events)); 166 } 167 if let Some(ref expand) = self.expand { 168 properties.push(("expand", expand)); 169 } 170 #[cfg(any(feature = "v3_20", feature = "dox"))] 171 if let Some(ref focus_on_click) = self.focus_on_click { 172 properties.push(("focus-on-click", focus_on_click)); 173 } 174 if let Some(ref halign) = self.halign { 175 properties.push(("halign", halign)); 176 } 177 if let Some(ref has_default) = self.has_default { 178 properties.push(("has-default", has_default)); 179 } 180 if let Some(ref has_focus) = self.has_focus { 181 properties.push(("has-focus", has_focus)); 182 } 183 if let Some(ref has_tooltip) = self.has_tooltip { 184 properties.push(("has-tooltip", has_tooltip)); 185 } 186 if let Some(ref height_request) = self.height_request { 187 properties.push(("height-request", height_request)); 188 } 189 if let Some(ref hexpand) = self.hexpand { 190 properties.push(("hexpand", hexpand)); 191 } 192 if let Some(ref hexpand_set) = self.hexpand_set { 193 properties.push(("hexpand-set", hexpand_set)); 194 } 195 if let Some(ref is_focus) = self.is_focus { 196 properties.push(("is-focus", is_focus)); 197 } 198 if let Some(ref margin) = self.margin { 199 properties.push(("margin", margin)); 200 } 201 if let Some(ref margin_bottom) = self.margin_bottom { 202 properties.push(("margin-bottom", margin_bottom)); 203 } 204 if let Some(ref margin_end) = self.margin_end { 205 properties.push(("margin-end", margin_end)); 206 } 207 if let Some(ref margin_start) = self.margin_start { 208 properties.push(("margin-start", margin_start)); 209 } 210 if let Some(ref margin_top) = self.margin_top { 211 properties.push(("margin-top", margin_top)); 212 } 213 if let Some(ref name) = self.name { 214 properties.push(("name", name)); 215 } 216 if let Some(ref no_show_all) = self.no_show_all { 217 properties.push(("no-show-all", no_show_all)); 218 } 219 if let Some(ref opacity) = self.opacity { 220 properties.push(("opacity", opacity)); 221 } 222 if let Some(ref parent) = self.parent { 223 properties.push(("parent", parent)); 224 } 225 if let Some(ref receives_default) = self.receives_default { 226 properties.push(("receives-default", receives_default)); 227 } 228 if let Some(ref sensitive) = self.sensitive { 229 properties.push(("sensitive", sensitive)); 230 } 231 if let Some(ref tooltip_markup) = self.tooltip_markup { 232 properties.push(("tooltip-markup", tooltip_markup)); 233 } 234 if let Some(ref tooltip_text) = self.tooltip_text { 235 properties.push(("tooltip-text", tooltip_text)); 236 } 237 if let Some(ref valign) = self.valign { 238 properties.push(("valign", valign)); 239 } 240 if let Some(ref vexpand) = self.vexpand { 241 properties.push(("vexpand", vexpand)); 242 } 243 if let Some(ref vexpand_set) = self.vexpand_set { 244 properties.push(("vexpand-set", vexpand_set)); 245 } 246 if let Some(ref visible) = self.visible { 247 properties.push(("visible", visible)); 248 } 249 if let Some(ref width_request) = self.width_request { 250 properties.push(("width-request", width_request)); 251 } 252 if let Some(ref action_name) = self.action_name { 253 properties.push(("action-name", action_name)); 254 } 255 if let Some(ref action_target) = self.action_target { 256 properties.push(("action-target", action_target)); 257 } 258 glib::Object::new::<ToolButton>(&properties) 259 .expect("Failed to create an instance of ToolButton") 260 } 261 icon_name(mut self, icon_name: &str) -> Self262 pub fn icon_name(mut self, icon_name: &str) -> Self { 263 self.icon_name = Some(icon_name.to_string()); 264 self 265 } 266 icon_widget<P: IsA<Widget>>(mut self, icon_widget: &P) -> Self267 pub fn icon_widget<P: IsA<Widget>>(mut self, icon_widget: &P) -> Self { 268 self.icon_widget = Some(icon_widget.clone().upcast()); 269 self 270 } 271 label(mut self, label: &str) -> Self272 pub fn label(mut self, label: &str) -> Self { 273 self.label = Some(label.to_string()); 274 self 275 } 276 label_widget<P: IsA<Widget>>(mut self, label_widget: &P) -> Self277 pub fn label_widget<P: IsA<Widget>>(mut self, label_widget: &P) -> Self { 278 self.label_widget = Some(label_widget.clone().upcast()); 279 self 280 } 281 use_underline(mut self, use_underline: bool) -> Self282 pub fn use_underline(mut self, use_underline: bool) -> Self { 283 self.use_underline = Some(use_underline); 284 self 285 } 286 is_important(mut self, is_important: bool) -> Self287 pub fn is_important(mut self, is_important: bool) -> Self { 288 self.is_important = Some(is_important); 289 self 290 } 291 visible_horizontal(mut self, visible_horizontal: bool) -> Self292 pub fn visible_horizontal(mut self, visible_horizontal: bool) -> Self { 293 self.visible_horizontal = Some(visible_horizontal); 294 self 295 } 296 visible_vertical(mut self, visible_vertical: bool) -> Self297 pub fn visible_vertical(mut self, visible_vertical: bool) -> Self { 298 self.visible_vertical = Some(visible_vertical); 299 self 300 } 301 border_width(mut self, border_width: u32) -> Self302 pub fn border_width(mut self, border_width: u32) -> Self { 303 self.border_width = Some(border_width); 304 self 305 } 306 child<P: IsA<Widget>>(mut self, child: &P) -> Self307 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 308 self.child = Some(child.clone().upcast()); 309 self 310 } 311 resize_mode(mut self, resize_mode: ResizeMode) -> Self312 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 313 self.resize_mode = Some(resize_mode); 314 self 315 } 316 app_paintable(mut self, app_paintable: bool) -> Self317 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 318 self.app_paintable = Some(app_paintable); 319 self 320 } 321 can_default(mut self, can_default: bool) -> Self322 pub fn can_default(mut self, can_default: bool) -> Self { 323 self.can_default = Some(can_default); 324 self 325 } 326 can_focus(mut self, can_focus: bool) -> Self327 pub fn can_focus(mut self, can_focus: bool) -> Self { 328 self.can_focus = Some(can_focus); 329 self 330 } 331 events(mut self, events: gdk::EventMask) -> Self332 pub fn events(mut self, events: gdk::EventMask) -> Self { 333 self.events = Some(events); 334 self 335 } 336 expand(mut self, expand: bool) -> Self337 pub fn expand(mut self, expand: bool) -> Self { 338 self.expand = Some(expand); 339 self 340 } 341 342 #[cfg(any(feature = "v3_20", feature = "dox"))] 343 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self344 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 345 self.focus_on_click = Some(focus_on_click); 346 self 347 } 348 halign(mut self, halign: Align) -> Self349 pub fn halign(mut self, halign: Align) -> Self { 350 self.halign = Some(halign); 351 self 352 } 353 has_default(mut self, has_default: bool) -> Self354 pub fn has_default(mut self, has_default: bool) -> Self { 355 self.has_default = Some(has_default); 356 self 357 } 358 has_focus(mut self, has_focus: bool) -> Self359 pub fn has_focus(mut self, has_focus: bool) -> Self { 360 self.has_focus = Some(has_focus); 361 self 362 } 363 has_tooltip(mut self, has_tooltip: bool) -> Self364 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 365 self.has_tooltip = Some(has_tooltip); 366 self 367 } 368 height_request(mut self, height_request: i32) -> Self369 pub fn height_request(mut self, height_request: i32) -> Self { 370 self.height_request = Some(height_request); 371 self 372 } 373 hexpand(mut self, hexpand: bool) -> Self374 pub fn hexpand(mut self, hexpand: bool) -> Self { 375 self.hexpand = Some(hexpand); 376 self 377 } 378 hexpand_set(mut self, hexpand_set: bool) -> Self379 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 380 self.hexpand_set = Some(hexpand_set); 381 self 382 } 383 is_focus(mut self, is_focus: bool) -> Self384 pub fn is_focus(mut self, is_focus: bool) -> Self { 385 self.is_focus = Some(is_focus); 386 self 387 } 388 margin(mut self, margin: i32) -> Self389 pub fn margin(mut self, margin: i32) -> Self { 390 self.margin = Some(margin); 391 self 392 } 393 margin_bottom(mut self, margin_bottom: i32) -> Self394 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 395 self.margin_bottom = Some(margin_bottom); 396 self 397 } 398 margin_end(mut self, margin_end: i32) -> Self399 pub fn margin_end(mut self, margin_end: i32) -> Self { 400 self.margin_end = Some(margin_end); 401 self 402 } 403 margin_start(mut self, margin_start: i32) -> Self404 pub fn margin_start(mut self, margin_start: i32) -> Self { 405 self.margin_start = Some(margin_start); 406 self 407 } 408 margin_top(mut self, margin_top: i32) -> Self409 pub fn margin_top(mut self, margin_top: i32) -> Self { 410 self.margin_top = Some(margin_top); 411 self 412 } 413 name(mut self, name: &str) -> Self414 pub fn name(mut self, name: &str) -> Self { 415 self.name = Some(name.to_string()); 416 self 417 } 418 no_show_all(mut self, no_show_all: bool) -> Self419 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 420 self.no_show_all = Some(no_show_all); 421 self 422 } 423 opacity(mut self, opacity: f64) -> Self424 pub fn opacity(mut self, opacity: f64) -> Self { 425 self.opacity = Some(opacity); 426 self 427 } 428 parent<P: IsA<Container>>(mut self, parent: &P) -> Self429 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 430 self.parent = Some(parent.clone().upcast()); 431 self 432 } 433 receives_default(mut self, receives_default: bool) -> Self434 pub fn receives_default(mut self, receives_default: bool) -> Self { 435 self.receives_default = Some(receives_default); 436 self 437 } 438 sensitive(mut self, sensitive: bool) -> Self439 pub fn sensitive(mut self, sensitive: bool) -> Self { 440 self.sensitive = Some(sensitive); 441 self 442 } 443 tooltip_markup(mut self, tooltip_markup: &str) -> Self444 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 445 self.tooltip_markup = Some(tooltip_markup.to_string()); 446 self 447 } 448 tooltip_text(mut self, tooltip_text: &str) -> Self449 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 450 self.tooltip_text = Some(tooltip_text.to_string()); 451 self 452 } 453 valign(mut self, valign: Align) -> Self454 pub fn valign(mut self, valign: Align) -> Self { 455 self.valign = Some(valign); 456 self 457 } 458 vexpand(mut self, vexpand: bool) -> Self459 pub fn vexpand(mut self, vexpand: bool) -> Self { 460 self.vexpand = Some(vexpand); 461 self 462 } 463 vexpand_set(mut self, vexpand_set: bool) -> Self464 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 465 self.vexpand_set = Some(vexpand_set); 466 self 467 } 468 visible(mut self, visible: bool) -> Self469 pub fn visible(mut self, visible: bool) -> Self { 470 self.visible = Some(visible); 471 self 472 } 473 width_request(mut self, width_request: i32) -> Self474 pub fn width_request(mut self, width_request: i32) -> Self { 475 self.width_request = Some(width_request); 476 self 477 } 478 action_name(mut self, action_name: &str) -> Self479 pub fn action_name(mut self, action_name: &str) -> Self { 480 self.action_name = Some(action_name.to_string()); 481 self 482 } 483 action_target(mut self, action_target: &glib::Variant) -> Self484 pub fn action_target(mut self, action_target: &glib::Variant) -> Self { 485 self.action_target = Some(action_target.clone()); 486 self 487 } 488 } 489 490 pub const NONE_TOOL_BUTTON: Option<&ToolButton> = None; 491 492 pub trait ToolButtonExt: 'static { 493 #[doc(alias = "gtk_tool_button_get_icon_name")] 494 #[doc(alias = "get_icon_name")] icon_name(&self) -> Option<glib::GString>495 fn icon_name(&self) -> Option<glib::GString>; 496 497 #[doc(alias = "gtk_tool_button_get_icon_widget")] 498 #[doc(alias = "get_icon_widget")] icon_widget(&self) -> Option<Widget>499 fn icon_widget(&self) -> Option<Widget>; 500 501 #[doc(alias = "gtk_tool_button_get_label")] 502 #[doc(alias = "get_label")] label(&self) -> Option<glib::GString>503 fn label(&self) -> Option<glib::GString>; 504 505 #[doc(alias = "gtk_tool_button_get_label_widget")] 506 #[doc(alias = "get_label_widget")] label_widget(&self) -> Option<Widget>507 fn label_widget(&self) -> Option<Widget>; 508 509 #[doc(alias = "gtk_tool_button_get_use_underline")] 510 #[doc(alias = "get_use_underline")] uses_underline(&self) -> bool511 fn uses_underline(&self) -> bool; 512 513 #[doc(alias = "gtk_tool_button_set_icon_name")] set_icon_name(&self, icon_name: Option<&str>)514 fn set_icon_name(&self, icon_name: Option<&str>); 515 516 #[doc(alias = "gtk_tool_button_set_icon_widget")] set_icon_widget<P: IsA<Widget>>(&self, icon_widget: Option<&P>)517 fn set_icon_widget<P: IsA<Widget>>(&self, icon_widget: Option<&P>); 518 519 #[doc(alias = "gtk_tool_button_set_label")] set_label(&self, label: Option<&str>)520 fn set_label(&self, label: Option<&str>); 521 522 #[doc(alias = "gtk_tool_button_set_label_widget")] set_label_widget<P: IsA<Widget>>(&self, label_widget: Option<&P>)523 fn set_label_widget<P: IsA<Widget>>(&self, label_widget: Option<&P>); 524 525 #[doc(alias = "gtk_tool_button_set_use_underline")] set_use_underline(&self, use_underline: bool)526 fn set_use_underline(&self, use_underline: bool); 527 528 #[doc(alias = "clicked")] connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId529 fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 530 emit_clicked(&self)531 fn emit_clicked(&self); 532 533 #[doc(alias = "icon-name")] connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId534 fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 535 536 #[doc(alias = "icon-widget")] connect_icon_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId537 fn connect_icon_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 538 539 #[doc(alias = "label")] connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId540 fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 541 542 #[doc(alias = "label-widget")] connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId543 fn connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 544 545 #[doc(alias = "use-underline")] connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId546 fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 547 } 548 549 impl<O: IsA<ToolButton>> ToolButtonExt for O { icon_name(&self) -> Option<glib::GString>550 fn icon_name(&self) -> Option<glib::GString> { 551 unsafe { 552 from_glib_none(ffi::gtk_tool_button_get_icon_name( 553 self.as_ref().to_glib_none().0, 554 )) 555 } 556 } 557 icon_widget(&self) -> Option<Widget>558 fn icon_widget(&self) -> Option<Widget> { 559 unsafe { 560 from_glib_none(ffi::gtk_tool_button_get_icon_widget( 561 self.as_ref().to_glib_none().0, 562 )) 563 } 564 } 565 label(&self) -> Option<glib::GString>566 fn label(&self) -> Option<glib::GString> { 567 unsafe { 568 from_glib_none(ffi::gtk_tool_button_get_label( 569 self.as_ref().to_glib_none().0, 570 )) 571 } 572 } 573 label_widget(&self) -> Option<Widget>574 fn label_widget(&self) -> Option<Widget> { 575 unsafe { 576 from_glib_none(ffi::gtk_tool_button_get_label_widget( 577 self.as_ref().to_glib_none().0, 578 )) 579 } 580 } 581 uses_underline(&self) -> bool582 fn uses_underline(&self) -> bool { 583 unsafe { 584 from_glib(ffi::gtk_tool_button_get_use_underline( 585 self.as_ref().to_glib_none().0, 586 )) 587 } 588 } 589 set_icon_name(&self, icon_name: Option<&str>)590 fn set_icon_name(&self, icon_name: Option<&str>) { 591 unsafe { 592 ffi::gtk_tool_button_set_icon_name( 593 self.as_ref().to_glib_none().0, 594 icon_name.to_glib_none().0, 595 ); 596 } 597 } 598 set_icon_widget<P: IsA<Widget>>(&self, icon_widget: Option<&P>)599 fn set_icon_widget<P: IsA<Widget>>(&self, icon_widget: Option<&P>) { 600 unsafe { 601 ffi::gtk_tool_button_set_icon_widget( 602 self.as_ref().to_glib_none().0, 603 icon_widget.map(|p| p.as_ref()).to_glib_none().0, 604 ); 605 } 606 } 607 set_label(&self, label: Option<&str>)608 fn set_label(&self, label: Option<&str>) { 609 unsafe { 610 ffi::gtk_tool_button_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0); 611 } 612 } 613 set_label_widget<P: IsA<Widget>>(&self, label_widget: Option<&P>)614 fn set_label_widget<P: IsA<Widget>>(&self, label_widget: Option<&P>) { 615 unsafe { 616 ffi::gtk_tool_button_set_label_widget( 617 self.as_ref().to_glib_none().0, 618 label_widget.map(|p| p.as_ref()).to_glib_none().0, 619 ); 620 } 621 } 622 set_use_underline(&self, use_underline: bool)623 fn set_use_underline(&self, use_underline: bool) { 624 unsafe { 625 ffi::gtk_tool_button_set_use_underline( 626 self.as_ref().to_glib_none().0, 627 use_underline.into_glib(), 628 ); 629 } 630 } 631 connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId632 fn connect_clicked<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 633 unsafe extern "C" fn clicked_trampoline<P: IsA<ToolButton>, F: Fn(&P) + 'static>( 634 this: *mut ffi::GtkToolButton, 635 f: glib::ffi::gpointer, 636 ) { 637 let f: &F = &*(f as *const F); 638 f(ToolButton::from_glib_borrow(this).unsafe_cast_ref()) 639 } 640 unsafe { 641 let f: Box_<F> = Box_::new(f); 642 connect_raw( 643 self.as_ptr() as *mut _, 644 b"clicked\0".as_ptr() as *const _, 645 Some(transmute::<_, unsafe extern "C" fn()>( 646 clicked_trampoline::<Self, F> as *const (), 647 )), 648 Box_::into_raw(f), 649 ) 650 } 651 } 652 emit_clicked(&self)653 fn emit_clicked(&self) { 654 let _ = unsafe { 655 glib::Object::from_glib_borrow(self.as_ptr() as *mut glib::gobject_ffi::GObject) 656 .emit_by_name("clicked", &[]) 657 .unwrap() 658 }; 659 } 660 connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId661 fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 662 unsafe extern "C" fn notify_icon_name_trampoline< 663 P: IsA<ToolButton>, 664 F: Fn(&P) + 'static, 665 >( 666 this: *mut ffi::GtkToolButton, 667 _param_spec: glib::ffi::gpointer, 668 f: glib::ffi::gpointer, 669 ) { 670 let f: &F = &*(f as *const F); 671 f(ToolButton::from_glib_borrow(this).unsafe_cast_ref()) 672 } 673 unsafe { 674 let f: Box_<F> = Box_::new(f); 675 connect_raw( 676 self.as_ptr() as *mut _, 677 b"notify::icon-name\0".as_ptr() as *const _, 678 Some(transmute::<_, unsafe extern "C" fn()>( 679 notify_icon_name_trampoline::<Self, F> as *const (), 680 )), 681 Box_::into_raw(f), 682 ) 683 } 684 } 685 connect_icon_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId686 fn connect_icon_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 687 unsafe extern "C" fn notify_icon_widget_trampoline< 688 P: IsA<ToolButton>, 689 F: Fn(&P) + 'static, 690 >( 691 this: *mut ffi::GtkToolButton, 692 _param_spec: glib::ffi::gpointer, 693 f: glib::ffi::gpointer, 694 ) { 695 let f: &F = &*(f as *const F); 696 f(ToolButton::from_glib_borrow(this).unsafe_cast_ref()) 697 } 698 unsafe { 699 let f: Box_<F> = Box_::new(f); 700 connect_raw( 701 self.as_ptr() as *mut _, 702 b"notify::icon-widget\0".as_ptr() as *const _, 703 Some(transmute::<_, unsafe extern "C" fn()>( 704 notify_icon_widget_trampoline::<Self, F> as *const (), 705 )), 706 Box_::into_raw(f), 707 ) 708 } 709 } 710 connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId711 fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 712 unsafe extern "C" fn notify_label_trampoline<P: IsA<ToolButton>, F: Fn(&P) + 'static>( 713 this: *mut ffi::GtkToolButton, 714 _param_spec: glib::ffi::gpointer, 715 f: glib::ffi::gpointer, 716 ) { 717 let f: &F = &*(f as *const F); 718 f(ToolButton::from_glib_borrow(this).unsafe_cast_ref()) 719 } 720 unsafe { 721 let f: Box_<F> = Box_::new(f); 722 connect_raw( 723 self.as_ptr() as *mut _, 724 b"notify::label\0".as_ptr() as *const _, 725 Some(transmute::<_, unsafe extern "C" fn()>( 726 notify_label_trampoline::<Self, F> as *const (), 727 )), 728 Box_::into_raw(f), 729 ) 730 } 731 } 732 connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId733 fn connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 734 unsafe extern "C" fn notify_label_widget_trampoline< 735 P: IsA<ToolButton>, 736 F: Fn(&P) + 'static, 737 >( 738 this: *mut ffi::GtkToolButton, 739 _param_spec: glib::ffi::gpointer, 740 f: glib::ffi::gpointer, 741 ) { 742 let f: &F = &*(f as *const F); 743 f(ToolButton::from_glib_borrow(this).unsafe_cast_ref()) 744 } 745 unsafe { 746 let f: Box_<F> = Box_::new(f); 747 connect_raw( 748 self.as_ptr() as *mut _, 749 b"notify::label-widget\0".as_ptr() as *const _, 750 Some(transmute::<_, unsafe extern "C" fn()>( 751 notify_label_widget_trampoline::<Self, F> as *const (), 752 )), 753 Box_::into_raw(f), 754 ) 755 } 756 } 757 connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId758 fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 759 unsafe extern "C" fn notify_use_underline_trampoline< 760 P: IsA<ToolButton>, 761 F: Fn(&P) + 'static, 762 >( 763 this: *mut ffi::GtkToolButton, 764 _param_spec: glib::ffi::gpointer, 765 f: glib::ffi::gpointer, 766 ) { 767 let f: &F = &*(f as *const F); 768 f(ToolButton::from_glib_borrow(this).unsafe_cast_ref()) 769 } 770 unsafe { 771 let f: Box_<F> = Box_::new(f); 772 connect_raw( 773 self.as_ptr() as *mut _, 774 b"notify::use-underline\0".as_ptr() as *const _, 775 Some(transmute::<_, unsafe extern "C" fn()>( 776 notify_use_underline_trampoline::<Self, F> as *const (), 777 )), 778 Box_::into_raw(f), 779 ) 780 } 781 } 782 } 783 784 impl fmt::Display for ToolButton { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result785 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 786 f.write_str("ToolButton") 787 } 788 } 789