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 gdk; 6 use gio; 7 use glib; 8 use glib::object::Cast; 9 use glib::object::IsA; 10 use glib::signal::connect_raw; 11 use glib::signal::SignalHandlerId; 12 use glib::translate::*; 13 use glib::StaticType; 14 use glib::ToValue; 15 use glib_sys; 16 use gtk_sys; 17 use std::boxed::Box as Box_; 18 use std::fmt; 19 use std::mem::transmute; 20 use Actionable; 21 use Align; 22 use ArrowType; 23 use Bin; 24 use Buildable; 25 use Button; 26 use Container; 27 use Menu; 28 use Popover; 29 use PositionType; 30 use ReliefStyle; 31 use ResizeMode; 32 use ToggleButton; 33 use Widget; 34 35 glib_wrapper! { 36 pub struct MenuButton(Object<gtk_sys::GtkMenuButton, gtk_sys::GtkMenuButtonClass, MenuButtonClass>) @extends ToggleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable; 37 38 match fn { 39 get_type => || gtk_sys::gtk_menu_button_get_type(), 40 } 41 } 42 43 impl MenuButton { new() -> MenuButton44 pub fn new() -> MenuButton { 45 assert_initialized_main_thread!(); 46 unsafe { Widget::from_glib_none(gtk_sys::gtk_menu_button_new()).unsafe_cast() } 47 } 48 } 49 50 impl Default for MenuButton { default() -> Self51 fn default() -> Self { 52 Self::new() 53 } 54 } 55 56 #[derive(Clone, Default)] 57 pub struct MenuButtonBuilder { 58 align_widget: Option<Container>, 59 direction: Option<ArrowType>, 60 menu_model: Option<gio::MenuModel>, 61 popover: Option<Popover>, 62 popup: Option<Menu>, 63 use_popover: Option<bool>, 64 active: Option<bool>, 65 draw_indicator: Option<bool>, 66 inconsistent: Option<bool>, 67 always_show_image: Option<bool>, 68 image: Option<Widget>, 69 image_position: Option<PositionType>, 70 label: Option<String>, 71 relief: Option<ReliefStyle>, 72 use_underline: Option<bool>, 73 border_width: Option<u32>, 74 child: Option<Widget>, 75 resize_mode: Option<ResizeMode>, 76 app_paintable: Option<bool>, 77 can_default: Option<bool>, 78 can_focus: Option<bool>, 79 events: Option<gdk::EventMask>, 80 expand: Option<bool>, 81 #[cfg(any(feature = "v3_20", feature = "dox"))] 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 MenuButtonBuilder { new() -> Self114 pub fn new() -> Self { 115 Self::default() 116 } 117 build(self) -> MenuButton118 pub fn build(self) -> MenuButton { 119 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 120 if let Some(ref align_widget) = self.align_widget { 121 properties.push(("align-widget", align_widget)); 122 } 123 if let Some(ref direction) = self.direction { 124 properties.push(("direction", direction)); 125 } 126 if let Some(ref menu_model) = self.menu_model { 127 properties.push(("menu-model", menu_model)); 128 } 129 if let Some(ref popover) = self.popover { 130 properties.push(("popover", popover)); 131 } 132 if let Some(ref popup) = self.popup { 133 properties.push(("popup", popup)); 134 } 135 if let Some(ref use_popover) = self.use_popover { 136 properties.push(("use-popover", use_popover)); 137 } 138 if let Some(ref active) = self.active { 139 properties.push(("active", active)); 140 } 141 if let Some(ref draw_indicator) = self.draw_indicator { 142 properties.push(("draw-indicator", draw_indicator)); 143 } 144 if let Some(ref inconsistent) = self.inconsistent { 145 properties.push(("inconsistent", inconsistent)); 146 } 147 if let Some(ref always_show_image) = self.always_show_image { 148 properties.push(("always-show-image", always_show_image)); 149 } 150 if let Some(ref image) = self.image { 151 properties.push(("image", image)); 152 } 153 if let Some(ref image_position) = self.image_position { 154 properties.push(("image-position", image_position)); 155 } 156 if let Some(ref label) = self.label { 157 properties.push(("label", label)); 158 } 159 if let Some(ref relief) = self.relief { 160 properties.push(("relief", relief)); 161 } 162 if let Some(ref use_underline) = self.use_underline { 163 properties.push(("use-underline", use_underline)); 164 } 165 if let Some(ref border_width) = self.border_width { 166 properties.push(("border-width", border_width)); 167 } 168 if let Some(ref child) = self.child { 169 properties.push(("child", child)); 170 } 171 if let Some(ref resize_mode) = self.resize_mode { 172 properties.push(("resize-mode", resize_mode)); 173 } 174 if let Some(ref app_paintable) = self.app_paintable { 175 properties.push(("app-paintable", app_paintable)); 176 } 177 if let Some(ref can_default) = self.can_default { 178 properties.push(("can-default", can_default)); 179 } 180 if let Some(ref can_focus) = self.can_focus { 181 properties.push(("can-focus", can_focus)); 182 } 183 if let Some(ref events) = self.events { 184 properties.push(("events", events)); 185 } 186 if let Some(ref expand) = self.expand { 187 properties.push(("expand", expand)); 188 } 189 #[cfg(any(feature = "v3_20", feature = "dox"))] 190 { 191 if let Some(ref focus_on_click) = self.focus_on_click { 192 properties.push(("focus-on-click", focus_on_click)); 193 } 194 } 195 if let Some(ref halign) = self.halign { 196 properties.push(("halign", halign)); 197 } 198 if let Some(ref has_default) = self.has_default { 199 properties.push(("has-default", has_default)); 200 } 201 if let Some(ref has_focus) = self.has_focus { 202 properties.push(("has-focus", has_focus)); 203 } 204 if let Some(ref has_tooltip) = self.has_tooltip { 205 properties.push(("has-tooltip", has_tooltip)); 206 } 207 if let Some(ref height_request) = self.height_request { 208 properties.push(("height-request", height_request)); 209 } 210 if let Some(ref hexpand) = self.hexpand { 211 properties.push(("hexpand", hexpand)); 212 } 213 if let Some(ref hexpand_set) = self.hexpand_set { 214 properties.push(("hexpand-set", hexpand_set)); 215 } 216 if let Some(ref is_focus) = self.is_focus { 217 properties.push(("is-focus", is_focus)); 218 } 219 if let Some(ref margin) = self.margin { 220 properties.push(("margin", margin)); 221 } 222 if let Some(ref margin_bottom) = self.margin_bottom { 223 properties.push(("margin-bottom", margin_bottom)); 224 } 225 if let Some(ref margin_end) = self.margin_end { 226 properties.push(("margin-end", margin_end)); 227 } 228 if let Some(ref margin_start) = self.margin_start { 229 properties.push(("margin-start", margin_start)); 230 } 231 if let Some(ref margin_top) = self.margin_top { 232 properties.push(("margin-top", margin_top)); 233 } 234 if let Some(ref name) = self.name { 235 properties.push(("name", name)); 236 } 237 if let Some(ref no_show_all) = self.no_show_all { 238 properties.push(("no-show-all", no_show_all)); 239 } 240 if let Some(ref opacity) = self.opacity { 241 properties.push(("opacity", opacity)); 242 } 243 if let Some(ref parent) = self.parent { 244 properties.push(("parent", parent)); 245 } 246 if let Some(ref receives_default) = self.receives_default { 247 properties.push(("receives-default", receives_default)); 248 } 249 if let Some(ref sensitive) = self.sensitive { 250 properties.push(("sensitive", sensitive)); 251 } 252 if let Some(ref tooltip_markup) = self.tooltip_markup { 253 properties.push(("tooltip-markup", tooltip_markup)); 254 } 255 if let Some(ref tooltip_text) = self.tooltip_text { 256 properties.push(("tooltip-text", tooltip_text)); 257 } 258 if let Some(ref valign) = self.valign { 259 properties.push(("valign", valign)); 260 } 261 if let Some(ref vexpand) = self.vexpand { 262 properties.push(("vexpand", vexpand)); 263 } 264 if let Some(ref vexpand_set) = self.vexpand_set { 265 properties.push(("vexpand-set", vexpand_set)); 266 } 267 if let Some(ref visible) = self.visible { 268 properties.push(("visible", visible)); 269 } 270 if let Some(ref width_request) = self.width_request { 271 properties.push(("width-request", width_request)); 272 } 273 if let Some(ref action_name) = self.action_name { 274 properties.push(("action-name", action_name)); 275 } 276 if let Some(ref action_target) = self.action_target { 277 properties.push(("action-target", action_target)); 278 } 279 glib::Object::new(MenuButton::static_type(), &properties) 280 .expect("object new") 281 .downcast() 282 .expect("downcast") 283 } 284 align_widget<P: IsA<Container>>(mut self, align_widget: &P) -> Self285 pub fn align_widget<P: IsA<Container>>(mut self, align_widget: &P) -> Self { 286 self.align_widget = Some(align_widget.clone().upcast()); 287 self 288 } 289 direction(mut self, direction: ArrowType) -> Self290 pub fn direction(mut self, direction: ArrowType) -> Self { 291 self.direction = Some(direction); 292 self 293 } 294 menu_model<P: IsA<gio::MenuModel>>(mut self, menu_model: &P) -> Self295 pub fn menu_model<P: IsA<gio::MenuModel>>(mut self, menu_model: &P) -> Self { 296 self.menu_model = Some(menu_model.clone().upcast()); 297 self 298 } 299 popover<P: IsA<Popover>>(mut self, popover: &P) -> Self300 pub fn popover<P: IsA<Popover>>(mut self, popover: &P) -> Self { 301 self.popover = Some(popover.clone().upcast()); 302 self 303 } 304 popup<P: IsA<Menu>>(mut self, popup: &P) -> Self305 pub fn popup<P: IsA<Menu>>(mut self, popup: &P) -> Self { 306 self.popup = Some(popup.clone().upcast()); 307 self 308 } 309 use_popover(mut self, use_popover: bool) -> Self310 pub fn use_popover(mut self, use_popover: bool) -> Self { 311 self.use_popover = Some(use_popover); 312 self 313 } 314 active(mut self, active: bool) -> Self315 pub fn active(mut self, active: bool) -> Self { 316 self.active = Some(active); 317 self 318 } 319 draw_indicator(mut self, draw_indicator: bool) -> Self320 pub fn draw_indicator(mut self, draw_indicator: bool) -> Self { 321 self.draw_indicator = Some(draw_indicator); 322 self 323 } 324 inconsistent(mut self, inconsistent: bool) -> Self325 pub fn inconsistent(mut self, inconsistent: bool) -> Self { 326 self.inconsistent = Some(inconsistent); 327 self 328 } 329 always_show_image(mut self, always_show_image: bool) -> Self330 pub fn always_show_image(mut self, always_show_image: bool) -> Self { 331 self.always_show_image = Some(always_show_image); 332 self 333 } 334 image<P: IsA<Widget>>(mut self, image: &P) -> Self335 pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self { 336 self.image = Some(image.clone().upcast()); 337 self 338 } 339 image_position(mut self, image_position: PositionType) -> Self340 pub fn image_position(mut self, image_position: PositionType) -> Self { 341 self.image_position = Some(image_position); 342 self 343 } 344 label(mut self, label: &str) -> Self345 pub fn label(mut self, label: &str) -> Self { 346 self.label = Some(label.to_string()); 347 self 348 } 349 relief(mut self, relief: ReliefStyle) -> Self350 pub fn relief(mut self, relief: ReliefStyle) -> Self { 351 self.relief = Some(relief); 352 self 353 } 354 use_underline(mut self, use_underline: bool) -> Self355 pub fn use_underline(mut self, use_underline: bool) -> Self { 356 self.use_underline = Some(use_underline); 357 self 358 } 359 border_width(mut self, border_width: u32) -> Self360 pub fn border_width(mut self, border_width: u32) -> Self { 361 self.border_width = Some(border_width); 362 self 363 } 364 child<P: IsA<Widget>>(mut self, child: &P) -> Self365 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 366 self.child = Some(child.clone().upcast()); 367 self 368 } 369 resize_mode(mut self, resize_mode: ResizeMode) -> Self370 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 371 self.resize_mode = Some(resize_mode); 372 self 373 } 374 app_paintable(mut self, app_paintable: bool) -> Self375 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 376 self.app_paintable = Some(app_paintable); 377 self 378 } 379 can_default(mut self, can_default: bool) -> Self380 pub fn can_default(mut self, can_default: bool) -> Self { 381 self.can_default = Some(can_default); 382 self 383 } 384 can_focus(mut self, can_focus: bool) -> Self385 pub fn can_focus(mut self, can_focus: bool) -> Self { 386 self.can_focus = Some(can_focus); 387 self 388 } 389 events(mut self, events: gdk::EventMask) -> Self390 pub fn events(mut self, events: gdk::EventMask) -> Self { 391 self.events = Some(events); 392 self 393 } 394 expand(mut self, expand: bool) -> Self395 pub fn expand(mut self, expand: bool) -> Self { 396 self.expand = Some(expand); 397 self 398 } 399 400 #[cfg(any(feature = "v3_20", feature = "dox"))] focus_on_click(mut self, focus_on_click: bool) -> Self401 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 402 self.focus_on_click = Some(focus_on_click); 403 self 404 } 405 halign(mut self, halign: Align) -> Self406 pub fn halign(mut self, halign: Align) -> Self { 407 self.halign = Some(halign); 408 self 409 } 410 has_default(mut self, has_default: bool) -> Self411 pub fn has_default(mut self, has_default: bool) -> Self { 412 self.has_default = Some(has_default); 413 self 414 } 415 has_focus(mut self, has_focus: bool) -> Self416 pub fn has_focus(mut self, has_focus: bool) -> Self { 417 self.has_focus = Some(has_focus); 418 self 419 } 420 has_tooltip(mut self, has_tooltip: bool) -> Self421 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 422 self.has_tooltip = Some(has_tooltip); 423 self 424 } 425 height_request(mut self, height_request: i32) -> Self426 pub fn height_request(mut self, height_request: i32) -> Self { 427 self.height_request = Some(height_request); 428 self 429 } 430 hexpand(mut self, hexpand: bool) -> Self431 pub fn hexpand(mut self, hexpand: bool) -> Self { 432 self.hexpand = Some(hexpand); 433 self 434 } 435 hexpand_set(mut self, hexpand_set: bool) -> Self436 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 437 self.hexpand_set = Some(hexpand_set); 438 self 439 } 440 is_focus(mut self, is_focus: bool) -> Self441 pub fn is_focus(mut self, is_focus: bool) -> Self { 442 self.is_focus = Some(is_focus); 443 self 444 } 445 margin(mut self, margin: i32) -> Self446 pub fn margin(mut self, margin: i32) -> Self { 447 self.margin = Some(margin); 448 self 449 } 450 margin_bottom(mut self, margin_bottom: i32) -> Self451 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 452 self.margin_bottom = Some(margin_bottom); 453 self 454 } 455 margin_end(mut self, margin_end: i32) -> Self456 pub fn margin_end(mut self, margin_end: i32) -> Self { 457 self.margin_end = Some(margin_end); 458 self 459 } 460 margin_start(mut self, margin_start: i32) -> Self461 pub fn margin_start(mut self, margin_start: i32) -> Self { 462 self.margin_start = Some(margin_start); 463 self 464 } 465 margin_top(mut self, margin_top: i32) -> Self466 pub fn margin_top(mut self, margin_top: i32) -> Self { 467 self.margin_top = Some(margin_top); 468 self 469 } 470 name(mut self, name: &str) -> Self471 pub fn name(mut self, name: &str) -> Self { 472 self.name = Some(name.to_string()); 473 self 474 } 475 no_show_all(mut self, no_show_all: bool) -> Self476 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 477 self.no_show_all = Some(no_show_all); 478 self 479 } 480 opacity(mut self, opacity: f64) -> Self481 pub fn opacity(mut self, opacity: f64) -> Self { 482 self.opacity = Some(opacity); 483 self 484 } 485 parent<P: IsA<Container>>(mut self, parent: &P) -> Self486 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 487 self.parent = Some(parent.clone().upcast()); 488 self 489 } 490 receives_default(mut self, receives_default: bool) -> Self491 pub fn receives_default(mut self, receives_default: bool) -> Self { 492 self.receives_default = Some(receives_default); 493 self 494 } 495 sensitive(mut self, sensitive: bool) -> Self496 pub fn sensitive(mut self, sensitive: bool) -> Self { 497 self.sensitive = Some(sensitive); 498 self 499 } 500 tooltip_markup(mut self, tooltip_markup: &str) -> Self501 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 502 self.tooltip_markup = Some(tooltip_markup.to_string()); 503 self 504 } 505 tooltip_text(mut self, tooltip_text: &str) -> Self506 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 507 self.tooltip_text = Some(tooltip_text.to_string()); 508 self 509 } 510 valign(mut self, valign: Align) -> Self511 pub fn valign(mut self, valign: Align) -> Self { 512 self.valign = Some(valign); 513 self 514 } 515 vexpand(mut self, vexpand: bool) -> Self516 pub fn vexpand(mut self, vexpand: bool) -> Self { 517 self.vexpand = Some(vexpand); 518 self 519 } 520 vexpand_set(mut self, vexpand_set: bool) -> Self521 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 522 self.vexpand_set = Some(vexpand_set); 523 self 524 } 525 visible(mut self, visible: bool) -> Self526 pub fn visible(mut self, visible: bool) -> Self { 527 self.visible = Some(visible); 528 self 529 } 530 width_request(mut self, width_request: i32) -> Self531 pub fn width_request(mut self, width_request: i32) -> Self { 532 self.width_request = Some(width_request); 533 self 534 } 535 action_name(mut self, action_name: &str) -> Self536 pub fn action_name(mut self, action_name: &str) -> Self { 537 self.action_name = Some(action_name.to_string()); 538 self 539 } 540 action_target(mut self, action_target: &glib::Variant) -> Self541 pub fn action_target(mut self, action_target: &glib::Variant) -> Self { 542 self.action_target = Some(action_target.clone()); 543 self 544 } 545 } 546 547 pub const NONE_MENU_BUTTON: Option<&MenuButton> = None; 548 549 pub trait MenuButtonExt: 'static { get_align_widget(&self) -> Option<Widget>550 fn get_align_widget(&self) -> Option<Widget>; 551 get_direction(&self) -> ArrowType552 fn get_direction(&self) -> ArrowType; 553 get_menu_model(&self) -> Option<gio::MenuModel>554 fn get_menu_model(&self) -> Option<gio::MenuModel>; 555 get_popover(&self) -> Option<Popover>556 fn get_popover(&self) -> Option<Popover>; 557 get_popup(&self) -> Option<Menu>558 fn get_popup(&self) -> Option<Menu>; 559 get_use_popover(&self) -> bool560 fn get_use_popover(&self) -> bool; 561 set_align_widget<P: IsA<Widget>>(&self, align_widget: Option<&P>)562 fn set_align_widget<P: IsA<Widget>>(&self, align_widget: Option<&P>); 563 set_direction(&self, direction: ArrowType)564 fn set_direction(&self, direction: ArrowType); 565 set_menu_model<P: IsA<gio::MenuModel>>(&self, menu_model: Option<&P>)566 fn set_menu_model<P: IsA<gio::MenuModel>>(&self, menu_model: Option<&P>); 567 set_popover<P: IsA<Widget>>(&self, popover: Option<&P>)568 fn set_popover<P: IsA<Widget>>(&self, popover: Option<&P>); 569 set_popup<P: IsA<Widget>>(&self, menu: Option<&P>)570 fn set_popup<P: IsA<Widget>>(&self, menu: Option<&P>); 571 set_use_popover(&self, use_popover: bool)572 fn set_use_popover(&self, use_popover: bool); 573 connect_property_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId574 fn connect_property_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) 575 -> SignalHandlerId; 576 connect_property_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId577 fn connect_property_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 578 connect_property_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId579 fn connect_property_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 580 connect_property_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId581 fn connect_property_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 582 connect_property_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId583 fn connect_property_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 584 connect_property_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId585 fn connect_property_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 586 } 587 588 impl<O: IsA<MenuButton>> MenuButtonExt for O { get_align_widget(&self) -> Option<Widget>589 fn get_align_widget(&self) -> Option<Widget> { 590 unsafe { 591 from_glib_none(gtk_sys::gtk_menu_button_get_align_widget( 592 self.as_ref().to_glib_none().0, 593 )) 594 } 595 } 596 get_direction(&self) -> ArrowType597 fn get_direction(&self) -> ArrowType { 598 unsafe { 599 from_glib(gtk_sys::gtk_menu_button_get_direction( 600 self.as_ref().to_glib_none().0, 601 )) 602 } 603 } 604 get_menu_model(&self) -> Option<gio::MenuModel>605 fn get_menu_model(&self) -> Option<gio::MenuModel> { 606 unsafe { 607 from_glib_none(gtk_sys::gtk_menu_button_get_menu_model( 608 self.as_ref().to_glib_none().0, 609 )) 610 } 611 } 612 get_popover(&self) -> Option<Popover>613 fn get_popover(&self) -> Option<Popover> { 614 unsafe { 615 from_glib_none(gtk_sys::gtk_menu_button_get_popover( 616 self.as_ref().to_glib_none().0, 617 )) 618 } 619 } 620 get_popup(&self) -> Option<Menu>621 fn get_popup(&self) -> Option<Menu> { 622 unsafe { 623 from_glib_none(gtk_sys::gtk_menu_button_get_popup( 624 self.as_ref().to_glib_none().0, 625 )) 626 } 627 } 628 get_use_popover(&self) -> bool629 fn get_use_popover(&self) -> bool { 630 unsafe { 631 from_glib(gtk_sys::gtk_menu_button_get_use_popover( 632 self.as_ref().to_glib_none().0, 633 )) 634 } 635 } 636 set_align_widget<P: IsA<Widget>>(&self, align_widget: Option<&P>)637 fn set_align_widget<P: IsA<Widget>>(&self, align_widget: Option<&P>) { 638 unsafe { 639 gtk_sys::gtk_menu_button_set_align_widget( 640 self.as_ref().to_glib_none().0, 641 align_widget.map(|p| p.as_ref()).to_glib_none().0, 642 ); 643 } 644 } 645 set_direction(&self, direction: ArrowType)646 fn set_direction(&self, direction: ArrowType) { 647 unsafe { 648 gtk_sys::gtk_menu_button_set_direction( 649 self.as_ref().to_glib_none().0, 650 direction.to_glib(), 651 ); 652 } 653 } 654 set_menu_model<P: IsA<gio::MenuModel>>(&self, menu_model: Option<&P>)655 fn set_menu_model<P: IsA<gio::MenuModel>>(&self, menu_model: Option<&P>) { 656 unsafe { 657 gtk_sys::gtk_menu_button_set_menu_model( 658 self.as_ref().to_glib_none().0, 659 menu_model.map(|p| p.as_ref()).to_glib_none().0, 660 ); 661 } 662 } 663 set_popover<P: IsA<Widget>>(&self, popover: Option<&P>)664 fn set_popover<P: IsA<Widget>>(&self, popover: Option<&P>) { 665 unsafe { 666 gtk_sys::gtk_menu_button_set_popover( 667 self.as_ref().to_glib_none().0, 668 popover.map(|p| p.as_ref()).to_glib_none().0, 669 ); 670 } 671 } 672 set_popup<P: IsA<Widget>>(&self, menu: Option<&P>)673 fn set_popup<P: IsA<Widget>>(&self, menu: Option<&P>) { 674 unsafe { 675 gtk_sys::gtk_menu_button_set_popup( 676 self.as_ref().to_glib_none().0, 677 menu.map(|p| p.as_ref()).to_glib_none().0, 678 ); 679 } 680 } 681 set_use_popover(&self, use_popover: bool)682 fn set_use_popover(&self, use_popover: bool) { 683 unsafe { 684 gtk_sys::gtk_menu_button_set_use_popover( 685 self.as_ref().to_glib_none().0, 686 use_popover.to_glib(), 687 ); 688 } 689 } 690 connect_property_align_widget_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId691 fn connect_property_align_widget_notify<F: Fn(&Self) + 'static>( 692 &self, 693 f: F, 694 ) -> SignalHandlerId { 695 unsafe extern "C" fn notify_align_widget_trampoline<P, F: Fn(&P) + 'static>( 696 this: *mut gtk_sys::GtkMenuButton, 697 _param_spec: glib_sys::gpointer, 698 f: glib_sys::gpointer, 699 ) where 700 P: IsA<MenuButton>, 701 { 702 let f: &F = &*(f as *const F); 703 f(&MenuButton::from_glib_borrow(this).unsafe_cast()) 704 } 705 unsafe { 706 let f: Box_<F> = Box_::new(f); 707 connect_raw( 708 self.as_ptr() as *mut _, 709 b"notify::align-widget\0".as_ptr() as *const _, 710 Some(transmute( 711 notify_align_widget_trampoline::<Self, F> as usize, 712 )), 713 Box_::into_raw(f), 714 ) 715 } 716 } 717 connect_property_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId718 fn connect_property_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 719 unsafe extern "C" fn notify_direction_trampoline<P, F: Fn(&P) + 'static>( 720 this: *mut gtk_sys::GtkMenuButton, 721 _param_spec: glib_sys::gpointer, 722 f: glib_sys::gpointer, 723 ) where 724 P: IsA<MenuButton>, 725 { 726 let f: &F = &*(f as *const F); 727 f(&MenuButton::from_glib_borrow(this).unsafe_cast()) 728 } 729 unsafe { 730 let f: Box_<F> = Box_::new(f); 731 connect_raw( 732 self.as_ptr() as *mut _, 733 b"notify::direction\0".as_ptr() as *const _, 734 Some(transmute(notify_direction_trampoline::<Self, F> as usize)), 735 Box_::into_raw(f), 736 ) 737 } 738 } 739 connect_property_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId740 fn connect_property_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 741 unsafe extern "C" fn notify_menu_model_trampoline<P, F: Fn(&P) + 'static>( 742 this: *mut gtk_sys::GtkMenuButton, 743 _param_spec: glib_sys::gpointer, 744 f: glib_sys::gpointer, 745 ) where 746 P: IsA<MenuButton>, 747 { 748 let f: &F = &*(f as *const F); 749 f(&MenuButton::from_glib_borrow(this).unsafe_cast()) 750 } 751 unsafe { 752 let f: Box_<F> = Box_::new(f); 753 connect_raw( 754 self.as_ptr() as *mut _, 755 b"notify::menu-model\0".as_ptr() as *const _, 756 Some(transmute(notify_menu_model_trampoline::<Self, F> as usize)), 757 Box_::into_raw(f), 758 ) 759 } 760 } 761 connect_property_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId762 fn connect_property_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 763 unsafe extern "C" fn notify_popover_trampoline<P, F: Fn(&P) + 'static>( 764 this: *mut gtk_sys::GtkMenuButton, 765 _param_spec: glib_sys::gpointer, 766 f: glib_sys::gpointer, 767 ) where 768 P: IsA<MenuButton>, 769 { 770 let f: &F = &*(f as *const F); 771 f(&MenuButton::from_glib_borrow(this).unsafe_cast()) 772 } 773 unsafe { 774 let f: Box_<F> = Box_::new(f); 775 connect_raw( 776 self.as_ptr() as *mut _, 777 b"notify::popover\0".as_ptr() as *const _, 778 Some(transmute(notify_popover_trampoline::<Self, F> as usize)), 779 Box_::into_raw(f), 780 ) 781 } 782 } 783 connect_property_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId784 fn connect_property_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 785 unsafe extern "C" fn notify_popup_trampoline<P, F: Fn(&P) + 'static>( 786 this: *mut gtk_sys::GtkMenuButton, 787 _param_spec: glib_sys::gpointer, 788 f: glib_sys::gpointer, 789 ) where 790 P: IsA<MenuButton>, 791 { 792 let f: &F = &*(f as *const F); 793 f(&MenuButton::from_glib_borrow(this).unsafe_cast()) 794 } 795 unsafe { 796 let f: Box_<F> = Box_::new(f); 797 connect_raw( 798 self.as_ptr() as *mut _, 799 b"notify::popup\0".as_ptr() as *const _, 800 Some(transmute(notify_popup_trampoline::<Self, F> as usize)), 801 Box_::into_raw(f), 802 ) 803 } 804 } 805 connect_property_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId806 fn connect_property_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 807 unsafe extern "C" fn notify_use_popover_trampoline<P, F: Fn(&P) + 'static>( 808 this: *mut gtk_sys::GtkMenuButton, 809 _param_spec: glib_sys::gpointer, 810 f: glib_sys::gpointer, 811 ) where 812 P: IsA<MenuButton>, 813 { 814 let f: &F = &*(f as *const F); 815 f(&MenuButton::from_glib_borrow(this).unsafe_cast()) 816 } 817 unsafe { 818 let f: Box_<F> = Box_::new(f); 819 connect_raw( 820 self.as_ptr() as *mut _, 821 b"notify::use-popover\0".as_ptr() as *const _, 822 Some(transmute(notify_use_popover_trampoline::<Self, F> as usize)), 823 Box_::into_raw(f), 824 ) 825 } 826 } 827 } 828 829 impl fmt::Display for MenuButton { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result830 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 831 write!(f, "MenuButton") 832 } 833 } 834