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::Menu; 11 use crate::ResizeMode; 12 use crate::ToolButton; 13 use crate::ToolItem; 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 = "GtkMenuToolButton")] 28 pub struct MenuToolButton(Object<ffi::GtkMenuToolButton, ffi::GtkMenuToolButtonClass>) @extends ToolButton, ToolItem, Bin, Container, Widget, @implements Buildable, Actionable; 29 30 match fn { 31 type_ => || ffi::gtk_menu_tool_button_get_type(), 32 } 33 } 34 35 impl MenuToolButton { 36 #[doc(alias = "gtk_menu_tool_button_new")] new<P: IsA<Widget>>(icon_widget: Option<&P>, label: Option<&str>) -> MenuToolButton37 pub fn new<P: IsA<Widget>>(icon_widget: Option<&P>, label: Option<&str>) -> MenuToolButton { 38 assert_initialized_main_thread!(); 39 unsafe { 40 ToolItem::from_glib_none(ffi::gtk_menu_tool_button_new( 41 icon_widget.map(|p| p.as_ref()).to_glib_none().0, 42 label.to_glib_none().0, 43 )) 44 .unsafe_cast() 45 } 46 } 47 48 // rustdoc-stripper-ignore-next 49 /// Creates a new builder-pattern struct instance to construct [`MenuToolButton`] objects. 50 /// 51 /// This method returns an instance of [`MenuToolButtonBuilder`] which can be used to create [`MenuToolButton`] objects. builder() -> MenuToolButtonBuilder52 pub fn builder() -> MenuToolButtonBuilder { 53 MenuToolButtonBuilder::default() 54 } 55 } 56 57 #[derive(Clone, Default)] 58 // rustdoc-stripper-ignore-next 59 /// A [builder-pattern] type to construct [`MenuToolButton`] objects. 60 /// 61 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 62 pub struct MenuToolButtonBuilder { 63 menu: Option<Menu>, 64 icon_name: Option<String>, 65 icon_widget: Option<Widget>, 66 label: Option<String>, 67 label_widget: Option<Widget>, 68 use_underline: Option<bool>, 69 is_important: Option<bool>, 70 visible_horizontal: Option<bool>, 71 visible_vertical: Option<bool>, 72 border_width: Option<u32>, 73 child: Option<Widget>, 74 resize_mode: Option<ResizeMode>, 75 app_paintable: Option<bool>, 76 can_default: Option<bool>, 77 can_focus: Option<bool>, 78 events: Option<gdk::EventMask>, 79 expand: Option<bool>, 80 #[cfg(any(feature = "v3_20", feature = "dox"))] 81 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 82 focus_on_click: Option<bool>, 83 halign: Option<Align>, 84 has_default: Option<bool>, 85 has_focus: Option<bool>, 86 has_tooltip: Option<bool>, 87 height_request: Option<i32>, 88 hexpand: Option<bool>, 89 hexpand_set: Option<bool>, 90 is_focus: Option<bool>, 91 margin: Option<i32>, 92 margin_bottom: Option<i32>, 93 margin_end: Option<i32>, 94 margin_start: Option<i32>, 95 margin_top: Option<i32>, 96 name: Option<String>, 97 no_show_all: Option<bool>, 98 opacity: Option<f64>, 99 parent: Option<Container>, 100 receives_default: Option<bool>, 101 sensitive: Option<bool>, 102 tooltip_markup: Option<String>, 103 tooltip_text: Option<String>, 104 valign: Option<Align>, 105 vexpand: Option<bool>, 106 vexpand_set: Option<bool>, 107 visible: Option<bool>, 108 width_request: Option<i32>, 109 action_name: Option<String>, 110 action_target: Option<glib::Variant>, 111 } 112 113 impl MenuToolButtonBuilder { 114 // rustdoc-stripper-ignore-next 115 /// Create a new [`MenuToolButtonBuilder`]. new() -> Self116 pub fn new() -> Self { 117 Self::default() 118 } 119 120 // rustdoc-stripper-ignore-next 121 /// Build the [`MenuToolButton`]. build(self) -> MenuToolButton122 pub fn build(self) -> MenuToolButton { 123 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 124 if let Some(ref menu) = self.menu { 125 properties.push(("menu", menu)); 126 } 127 if let Some(ref icon_name) = self.icon_name { 128 properties.push(("icon-name", icon_name)); 129 } 130 if let Some(ref icon_widget) = self.icon_widget { 131 properties.push(("icon-widget", icon_widget)); 132 } 133 if let Some(ref label) = self.label { 134 properties.push(("label", label)); 135 } 136 if let Some(ref label_widget) = self.label_widget { 137 properties.push(("label-widget", label_widget)); 138 } 139 if let Some(ref use_underline) = self.use_underline { 140 properties.push(("use-underline", use_underline)); 141 } 142 if let Some(ref is_important) = self.is_important { 143 properties.push(("is-important", is_important)); 144 } 145 if let Some(ref visible_horizontal) = self.visible_horizontal { 146 properties.push(("visible-horizontal", visible_horizontal)); 147 } 148 if let Some(ref visible_vertical) = self.visible_vertical { 149 properties.push(("visible-vertical", visible_vertical)); 150 } 151 if let Some(ref border_width) = self.border_width { 152 properties.push(("border-width", border_width)); 153 } 154 if let Some(ref child) = self.child { 155 properties.push(("child", child)); 156 } 157 if let Some(ref resize_mode) = self.resize_mode { 158 properties.push(("resize-mode", resize_mode)); 159 } 160 if let Some(ref app_paintable) = self.app_paintable { 161 properties.push(("app-paintable", app_paintable)); 162 } 163 if let Some(ref can_default) = self.can_default { 164 properties.push(("can-default", can_default)); 165 } 166 if let Some(ref can_focus) = self.can_focus { 167 properties.push(("can-focus", can_focus)); 168 } 169 if let Some(ref events) = self.events { 170 properties.push(("events", events)); 171 } 172 if let Some(ref expand) = self.expand { 173 properties.push(("expand", expand)); 174 } 175 #[cfg(any(feature = "v3_20", feature = "dox"))] 176 if let Some(ref focus_on_click) = self.focus_on_click { 177 properties.push(("focus-on-click", focus_on_click)); 178 } 179 if let Some(ref halign) = self.halign { 180 properties.push(("halign", halign)); 181 } 182 if let Some(ref has_default) = self.has_default { 183 properties.push(("has-default", has_default)); 184 } 185 if let Some(ref has_focus) = self.has_focus { 186 properties.push(("has-focus", has_focus)); 187 } 188 if let Some(ref has_tooltip) = self.has_tooltip { 189 properties.push(("has-tooltip", has_tooltip)); 190 } 191 if let Some(ref height_request) = self.height_request { 192 properties.push(("height-request", height_request)); 193 } 194 if let Some(ref hexpand) = self.hexpand { 195 properties.push(("hexpand", hexpand)); 196 } 197 if let Some(ref hexpand_set) = self.hexpand_set { 198 properties.push(("hexpand-set", hexpand_set)); 199 } 200 if let Some(ref is_focus) = self.is_focus { 201 properties.push(("is-focus", is_focus)); 202 } 203 if let Some(ref margin) = self.margin { 204 properties.push(("margin", margin)); 205 } 206 if let Some(ref margin_bottom) = self.margin_bottom { 207 properties.push(("margin-bottom", margin_bottom)); 208 } 209 if let Some(ref margin_end) = self.margin_end { 210 properties.push(("margin-end", margin_end)); 211 } 212 if let Some(ref margin_start) = self.margin_start { 213 properties.push(("margin-start", margin_start)); 214 } 215 if let Some(ref margin_top) = self.margin_top { 216 properties.push(("margin-top", margin_top)); 217 } 218 if let Some(ref name) = self.name { 219 properties.push(("name", name)); 220 } 221 if let Some(ref no_show_all) = self.no_show_all { 222 properties.push(("no-show-all", no_show_all)); 223 } 224 if let Some(ref opacity) = self.opacity { 225 properties.push(("opacity", opacity)); 226 } 227 if let Some(ref parent) = self.parent { 228 properties.push(("parent", parent)); 229 } 230 if let Some(ref receives_default) = self.receives_default { 231 properties.push(("receives-default", receives_default)); 232 } 233 if let Some(ref sensitive) = self.sensitive { 234 properties.push(("sensitive", sensitive)); 235 } 236 if let Some(ref tooltip_markup) = self.tooltip_markup { 237 properties.push(("tooltip-markup", tooltip_markup)); 238 } 239 if let Some(ref tooltip_text) = self.tooltip_text { 240 properties.push(("tooltip-text", tooltip_text)); 241 } 242 if let Some(ref valign) = self.valign { 243 properties.push(("valign", valign)); 244 } 245 if let Some(ref vexpand) = self.vexpand { 246 properties.push(("vexpand", vexpand)); 247 } 248 if let Some(ref vexpand_set) = self.vexpand_set { 249 properties.push(("vexpand-set", vexpand_set)); 250 } 251 if let Some(ref visible) = self.visible { 252 properties.push(("visible", visible)); 253 } 254 if let Some(ref width_request) = self.width_request { 255 properties.push(("width-request", width_request)); 256 } 257 if let Some(ref action_name) = self.action_name { 258 properties.push(("action-name", action_name)); 259 } 260 if let Some(ref action_target) = self.action_target { 261 properties.push(("action-target", action_target)); 262 } 263 glib::Object::new::<MenuToolButton>(&properties) 264 .expect("Failed to create an instance of MenuToolButton") 265 } 266 menu<P: IsA<Menu>>(mut self, menu: &P) -> Self267 pub fn menu<P: IsA<Menu>>(mut self, menu: &P) -> Self { 268 self.menu = Some(menu.clone().upcast()); 269 self 270 } 271 icon_name(mut self, icon_name: &str) -> Self272 pub fn icon_name(mut self, icon_name: &str) -> Self { 273 self.icon_name = Some(icon_name.to_string()); 274 self 275 } 276 icon_widget<P: IsA<Widget>>(mut self, icon_widget: &P) -> Self277 pub fn icon_widget<P: IsA<Widget>>(mut self, icon_widget: &P) -> Self { 278 self.icon_widget = Some(icon_widget.clone().upcast()); 279 self 280 } 281 label(mut self, label: &str) -> Self282 pub fn label(mut self, label: &str) -> Self { 283 self.label = Some(label.to_string()); 284 self 285 } 286 label_widget<P: IsA<Widget>>(mut self, label_widget: &P) -> Self287 pub fn label_widget<P: IsA<Widget>>(mut self, label_widget: &P) -> Self { 288 self.label_widget = Some(label_widget.clone().upcast()); 289 self 290 } 291 use_underline(mut self, use_underline: bool) -> Self292 pub fn use_underline(mut self, use_underline: bool) -> Self { 293 self.use_underline = Some(use_underline); 294 self 295 } 296 is_important(mut self, is_important: bool) -> Self297 pub fn is_important(mut self, is_important: bool) -> Self { 298 self.is_important = Some(is_important); 299 self 300 } 301 visible_horizontal(mut self, visible_horizontal: bool) -> Self302 pub fn visible_horizontal(mut self, visible_horizontal: bool) -> Self { 303 self.visible_horizontal = Some(visible_horizontal); 304 self 305 } 306 visible_vertical(mut self, visible_vertical: bool) -> Self307 pub fn visible_vertical(mut self, visible_vertical: bool) -> Self { 308 self.visible_vertical = Some(visible_vertical); 309 self 310 } 311 border_width(mut self, border_width: u32) -> Self312 pub fn border_width(mut self, border_width: u32) -> Self { 313 self.border_width = Some(border_width); 314 self 315 } 316 child<P: IsA<Widget>>(mut self, child: &P) -> Self317 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 318 self.child = Some(child.clone().upcast()); 319 self 320 } 321 resize_mode(mut self, resize_mode: ResizeMode) -> Self322 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 323 self.resize_mode = Some(resize_mode); 324 self 325 } 326 app_paintable(mut self, app_paintable: bool) -> Self327 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 328 self.app_paintable = Some(app_paintable); 329 self 330 } 331 can_default(mut self, can_default: bool) -> Self332 pub fn can_default(mut self, can_default: bool) -> Self { 333 self.can_default = Some(can_default); 334 self 335 } 336 can_focus(mut self, can_focus: bool) -> Self337 pub fn can_focus(mut self, can_focus: bool) -> Self { 338 self.can_focus = Some(can_focus); 339 self 340 } 341 events(mut self, events: gdk::EventMask) -> Self342 pub fn events(mut self, events: gdk::EventMask) -> Self { 343 self.events = Some(events); 344 self 345 } 346 expand(mut self, expand: bool) -> Self347 pub fn expand(mut self, expand: bool) -> Self { 348 self.expand = Some(expand); 349 self 350 } 351 352 #[cfg(any(feature = "v3_20", feature = "dox"))] 353 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self354 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 355 self.focus_on_click = Some(focus_on_click); 356 self 357 } 358 halign(mut self, halign: Align) -> Self359 pub fn halign(mut self, halign: Align) -> Self { 360 self.halign = Some(halign); 361 self 362 } 363 has_default(mut self, has_default: bool) -> Self364 pub fn has_default(mut self, has_default: bool) -> Self { 365 self.has_default = Some(has_default); 366 self 367 } 368 has_focus(mut self, has_focus: bool) -> Self369 pub fn has_focus(mut self, has_focus: bool) -> Self { 370 self.has_focus = Some(has_focus); 371 self 372 } 373 has_tooltip(mut self, has_tooltip: bool) -> Self374 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 375 self.has_tooltip = Some(has_tooltip); 376 self 377 } 378 height_request(mut self, height_request: i32) -> Self379 pub fn height_request(mut self, height_request: i32) -> Self { 380 self.height_request = Some(height_request); 381 self 382 } 383 hexpand(mut self, hexpand: bool) -> Self384 pub fn hexpand(mut self, hexpand: bool) -> Self { 385 self.hexpand = Some(hexpand); 386 self 387 } 388 hexpand_set(mut self, hexpand_set: bool) -> Self389 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 390 self.hexpand_set = Some(hexpand_set); 391 self 392 } 393 is_focus(mut self, is_focus: bool) -> Self394 pub fn is_focus(mut self, is_focus: bool) -> Self { 395 self.is_focus = Some(is_focus); 396 self 397 } 398 margin(mut self, margin: i32) -> Self399 pub fn margin(mut self, margin: i32) -> Self { 400 self.margin = Some(margin); 401 self 402 } 403 margin_bottom(mut self, margin_bottom: i32) -> Self404 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 405 self.margin_bottom = Some(margin_bottom); 406 self 407 } 408 margin_end(mut self, margin_end: i32) -> Self409 pub fn margin_end(mut self, margin_end: i32) -> Self { 410 self.margin_end = Some(margin_end); 411 self 412 } 413 margin_start(mut self, margin_start: i32) -> Self414 pub fn margin_start(mut self, margin_start: i32) -> Self { 415 self.margin_start = Some(margin_start); 416 self 417 } 418 margin_top(mut self, margin_top: i32) -> Self419 pub fn margin_top(mut self, margin_top: i32) -> Self { 420 self.margin_top = Some(margin_top); 421 self 422 } 423 name(mut self, name: &str) -> Self424 pub fn name(mut self, name: &str) -> Self { 425 self.name = Some(name.to_string()); 426 self 427 } 428 no_show_all(mut self, no_show_all: bool) -> Self429 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 430 self.no_show_all = Some(no_show_all); 431 self 432 } 433 opacity(mut self, opacity: f64) -> Self434 pub fn opacity(mut self, opacity: f64) -> Self { 435 self.opacity = Some(opacity); 436 self 437 } 438 parent<P: IsA<Container>>(mut self, parent: &P) -> Self439 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 440 self.parent = Some(parent.clone().upcast()); 441 self 442 } 443 receives_default(mut self, receives_default: bool) -> Self444 pub fn receives_default(mut self, receives_default: bool) -> Self { 445 self.receives_default = Some(receives_default); 446 self 447 } 448 sensitive(mut self, sensitive: bool) -> Self449 pub fn sensitive(mut self, sensitive: bool) -> Self { 450 self.sensitive = Some(sensitive); 451 self 452 } 453 tooltip_markup(mut self, tooltip_markup: &str) -> Self454 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 455 self.tooltip_markup = Some(tooltip_markup.to_string()); 456 self 457 } 458 tooltip_text(mut self, tooltip_text: &str) -> Self459 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 460 self.tooltip_text = Some(tooltip_text.to_string()); 461 self 462 } 463 valign(mut self, valign: Align) -> Self464 pub fn valign(mut self, valign: Align) -> Self { 465 self.valign = Some(valign); 466 self 467 } 468 vexpand(mut self, vexpand: bool) -> Self469 pub fn vexpand(mut self, vexpand: bool) -> Self { 470 self.vexpand = Some(vexpand); 471 self 472 } 473 vexpand_set(mut self, vexpand_set: bool) -> Self474 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 475 self.vexpand_set = Some(vexpand_set); 476 self 477 } 478 visible(mut self, visible: bool) -> Self479 pub fn visible(mut self, visible: bool) -> Self { 480 self.visible = Some(visible); 481 self 482 } 483 width_request(mut self, width_request: i32) -> Self484 pub fn width_request(mut self, width_request: i32) -> Self { 485 self.width_request = Some(width_request); 486 self 487 } 488 action_name(mut self, action_name: &str) -> Self489 pub fn action_name(mut self, action_name: &str) -> Self { 490 self.action_name = Some(action_name.to_string()); 491 self 492 } 493 action_target(mut self, action_target: &glib::Variant) -> Self494 pub fn action_target(mut self, action_target: &glib::Variant) -> Self { 495 self.action_target = Some(action_target.clone()); 496 self 497 } 498 } 499 500 pub const NONE_MENU_TOOL_BUTTON: Option<&MenuToolButton> = None; 501 502 pub trait MenuToolButtonExt: 'static { 503 #[doc(alias = "gtk_menu_tool_button_get_menu")] 504 #[doc(alias = "get_menu")] menu(&self) -> Option<Widget>505 fn menu(&self) -> Option<Widget>; 506 507 #[doc(alias = "gtk_menu_tool_button_set_arrow_tooltip_markup")] set_arrow_tooltip_markup(&self, markup: &str)508 fn set_arrow_tooltip_markup(&self, markup: &str); 509 510 #[doc(alias = "gtk_menu_tool_button_set_arrow_tooltip_text")] set_arrow_tooltip_text(&self, text: &str)511 fn set_arrow_tooltip_text(&self, text: &str); 512 513 #[doc(alias = "gtk_menu_tool_button_set_menu")] set_menu<P: IsA<Widget>>(&self, menu: &P)514 fn set_menu<P: IsA<Widget>>(&self, menu: &P); 515 516 #[doc(alias = "show-menu")] connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId517 fn connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 518 519 #[doc(alias = "menu")] connect_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId520 fn connect_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 521 } 522 523 impl<O: IsA<MenuToolButton>> MenuToolButtonExt for O { menu(&self) -> Option<Widget>524 fn menu(&self) -> Option<Widget> { 525 unsafe { 526 from_glib_none(ffi::gtk_menu_tool_button_get_menu( 527 self.as_ref().to_glib_none().0, 528 )) 529 } 530 } 531 set_arrow_tooltip_markup(&self, markup: &str)532 fn set_arrow_tooltip_markup(&self, markup: &str) { 533 unsafe { 534 ffi::gtk_menu_tool_button_set_arrow_tooltip_markup( 535 self.as_ref().to_glib_none().0, 536 markup.to_glib_none().0, 537 ); 538 } 539 } 540 set_arrow_tooltip_text(&self, text: &str)541 fn set_arrow_tooltip_text(&self, text: &str) { 542 unsafe { 543 ffi::gtk_menu_tool_button_set_arrow_tooltip_text( 544 self.as_ref().to_glib_none().0, 545 text.to_glib_none().0, 546 ); 547 } 548 } 549 set_menu<P: IsA<Widget>>(&self, menu: &P)550 fn set_menu<P: IsA<Widget>>(&self, menu: &P) { 551 unsafe { 552 ffi::gtk_menu_tool_button_set_menu( 553 self.as_ref().to_glib_none().0, 554 menu.as_ref().to_glib_none().0, 555 ); 556 } 557 } 558 connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId559 fn connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 560 unsafe extern "C" fn show_menu_trampoline<P: IsA<MenuToolButton>, F: Fn(&P) + 'static>( 561 this: *mut ffi::GtkMenuToolButton, 562 f: glib::ffi::gpointer, 563 ) { 564 let f: &F = &*(f as *const F); 565 f(MenuToolButton::from_glib_borrow(this).unsafe_cast_ref()) 566 } 567 unsafe { 568 let f: Box_<F> = Box_::new(f); 569 connect_raw( 570 self.as_ptr() as *mut _, 571 b"show-menu\0".as_ptr() as *const _, 572 Some(transmute::<_, unsafe extern "C" fn()>( 573 show_menu_trampoline::<Self, F> as *const (), 574 )), 575 Box_::into_raw(f), 576 ) 577 } 578 } 579 connect_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId580 fn connect_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 581 unsafe extern "C" fn notify_menu_trampoline<P: IsA<MenuToolButton>, F: Fn(&P) + 'static>( 582 this: *mut ffi::GtkMenuToolButton, 583 _param_spec: glib::ffi::gpointer, 584 f: glib::ffi::gpointer, 585 ) { 586 let f: &F = &*(f as *const F); 587 f(MenuToolButton::from_glib_borrow(this).unsafe_cast_ref()) 588 } 589 unsafe { 590 let f: Box_<F> = Box_::new(f); 591 connect_raw( 592 self.as_ptr() as *mut _, 593 b"notify::menu\0".as_ptr() as *const _, 594 Some(transmute::<_, unsafe extern "C" fn()>( 595 notify_menu_trampoline::<Self, F> as *const (), 596 )), 597 Box_::into_raw(f), 598 ) 599 } 600 } 601 } 602 603 impl fmt::Display for MenuToolButton { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result604 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 605 f.write_str("MenuToolButton") 606 } 607 } 608