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::ArrowType;
8 use crate::Bin;
9 use crate::Buildable;
10 use crate::Button;
11 use crate::Container;
12 use crate::Menu;
13 use crate::Popover;
14 use crate::PositionType;
15 use crate::ReliefStyle;
16 use crate::ResizeMode;
17 use crate::ToggleButton;
18 use crate::Widget;
19 use glib::object::Cast;
20 use glib::object::IsA;
21 use glib::signal::connect_raw;
22 use glib::signal::SignalHandlerId;
23 use glib::translate::*;
24 use glib::StaticType;
25 use glib::ToValue;
26 use std::boxed::Box as Box_;
27 use std::fmt;
28 use std::mem::transmute;
29 
30 glib::wrapper! {
31     #[doc(alias = "GtkMenuButton")]
32     pub struct MenuButton(Object<ffi::GtkMenuButton, ffi::GtkMenuButtonClass>) @extends ToggleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable;
33 
34     match fn {
35         type_ => || ffi::gtk_menu_button_get_type(),
36     }
37 }
38 
39 impl MenuButton {
40     #[doc(alias = "gtk_menu_button_new")]
new() -> MenuButton41     pub fn new() -> MenuButton {
42         assert_initialized_main_thread!();
43         unsafe { Widget::from_glib_none(ffi::gtk_menu_button_new()).unsafe_cast() }
44     }
45 
46     // rustdoc-stripper-ignore-next
47     /// Creates a new builder-pattern struct instance to construct [`MenuButton`] objects.
48     ///
49     /// This method returns an instance of [`MenuButtonBuilder`] which can be used to create [`MenuButton`] objects.
builder() -> MenuButtonBuilder50     pub fn builder() -> MenuButtonBuilder {
51         MenuButtonBuilder::default()
52     }
53 }
54 
55 impl Default for MenuButton {
default() -> Self56     fn default() -> Self {
57         Self::new()
58     }
59 }
60 
61 #[derive(Clone, Default)]
62 // rustdoc-stripper-ignore-next
63 /// A [builder-pattern] type to construct [`MenuButton`] objects.
64 ///
65 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
66 pub struct MenuButtonBuilder {
67     align_widget: Option<Container>,
68     direction: Option<ArrowType>,
69     menu_model: Option<gio::MenuModel>,
70     popover: Option<Popover>,
71     popup: Option<Menu>,
72     use_popover: Option<bool>,
73     active: Option<bool>,
74     draw_indicator: Option<bool>,
75     inconsistent: Option<bool>,
76     always_show_image: Option<bool>,
77     image: Option<Widget>,
78     image_position: Option<PositionType>,
79     label: Option<String>,
80     relief: Option<ReliefStyle>,
81     use_underline: Option<bool>,
82     border_width: Option<u32>,
83     child: Option<Widget>,
84     resize_mode: Option<ResizeMode>,
85     app_paintable: Option<bool>,
86     can_default: Option<bool>,
87     can_focus: Option<bool>,
88     events: Option<gdk::EventMask>,
89     expand: Option<bool>,
90     #[cfg(any(feature = "v3_20", feature = "dox"))]
91     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
92     focus_on_click: Option<bool>,
93     halign: Option<Align>,
94     has_default: Option<bool>,
95     has_focus: Option<bool>,
96     has_tooltip: Option<bool>,
97     height_request: Option<i32>,
98     hexpand: Option<bool>,
99     hexpand_set: Option<bool>,
100     is_focus: Option<bool>,
101     margin: Option<i32>,
102     margin_bottom: Option<i32>,
103     margin_end: Option<i32>,
104     margin_start: Option<i32>,
105     margin_top: Option<i32>,
106     name: Option<String>,
107     no_show_all: Option<bool>,
108     opacity: Option<f64>,
109     parent: Option<Container>,
110     receives_default: Option<bool>,
111     sensitive: Option<bool>,
112     tooltip_markup: Option<String>,
113     tooltip_text: Option<String>,
114     valign: Option<Align>,
115     vexpand: Option<bool>,
116     vexpand_set: Option<bool>,
117     visible: Option<bool>,
118     width_request: Option<i32>,
119     action_name: Option<String>,
120     action_target: Option<glib::Variant>,
121 }
122 
123 impl MenuButtonBuilder {
124     // rustdoc-stripper-ignore-next
125     /// Create a new [`MenuButtonBuilder`].
new() -> Self126     pub fn new() -> Self {
127         Self::default()
128     }
129 
130     // rustdoc-stripper-ignore-next
131     /// Build the [`MenuButton`].
build(self) -> MenuButton132     pub fn build(self) -> MenuButton {
133         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
134         if let Some(ref align_widget) = self.align_widget {
135             properties.push(("align-widget", align_widget));
136         }
137         if let Some(ref direction) = self.direction {
138             properties.push(("direction", direction));
139         }
140         if let Some(ref menu_model) = self.menu_model {
141             properties.push(("menu-model", menu_model));
142         }
143         if let Some(ref popover) = self.popover {
144             properties.push(("popover", popover));
145         }
146         if let Some(ref popup) = self.popup {
147             properties.push(("popup", popup));
148         }
149         if let Some(ref use_popover) = self.use_popover {
150             properties.push(("use-popover", use_popover));
151         }
152         if let Some(ref active) = self.active {
153             properties.push(("active", active));
154         }
155         if let Some(ref draw_indicator) = self.draw_indicator {
156             properties.push(("draw-indicator", draw_indicator));
157         }
158         if let Some(ref inconsistent) = self.inconsistent {
159             properties.push(("inconsistent", inconsistent));
160         }
161         if let Some(ref always_show_image) = self.always_show_image {
162             properties.push(("always-show-image", always_show_image));
163         }
164         if let Some(ref image) = self.image {
165             properties.push(("image", image));
166         }
167         if let Some(ref image_position) = self.image_position {
168             properties.push(("image-position", image_position));
169         }
170         if let Some(ref label) = self.label {
171             properties.push(("label", label));
172         }
173         if let Some(ref relief) = self.relief {
174             properties.push(("relief", relief));
175         }
176         if let Some(ref use_underline) = self.use_underline {
177             properties.push(("use-underline", use_underline));
178         }
179         if let Some(ref border_width) = self.border_width {
180             properties.push(("border-width", border_width));
181         }
182         if let Some(ref child) = self.child {
183             properties.push(("child", child));
184         }
185         if let Some(ref resize_mode) = self.resize_mode {
186             properties.push(("resize-mode", resize_mode));
187         }
188         if let Some(ref app_paintable) = self.app_paintable {
189             properties.push(("app-paintable", app_paintable));
190         }
191         if let Some(ref can_default) = self.can_default {
192             properties.push(("can-default", can_default));
193         }
194         if let Some(ref can_focus) = self.can_focus {
195             properties.push(("can-focus", can_focus));
196         }
197         if let Some(ref events) = self.events {
198             properties.push(("events", events));
199         }
200         if let Some(ref expand) = self.expand {
201             properties.push(("expand", expand));
202         }
203         #[cfg(any(feature = "v3_20", feature = "dox"))]
204         if let Some(ref focus_on_click) = self.focus_on_click {
205             properties.push(("focus-on-click", focus_on_click));
206         }
207         if let Some(ref halign) = self.halign {
208             properties.push(("halign", halign));
209         }
210         if let Some(ref has_default) = self.has_default {
211             properties.push(("has-default", has_default));
212         }
213         if let Some(ref has_focus) = self.has_focus {
214             properties.push(("has-focus", has_focus));
215         }
216         if let Some(ref has_tooltip) = self.has_tooltip {
217             properties.push(("has-tooltip", has_tooltip));
218         }
219         if let Some(ref height_request) = self.height_request {
220             properties.push(("height-request", height_request));
221         }
222         if let Some(ref hexpand) = self.hexpand {
223             properties.push(("hexpand", hexpand));
224         }
225         if let Some(ref hexpand_set) = self.hexpand_set {
226             properties.push(("hexpand-set", hexpand_set));
227         }
228         if let Some(ref is_focus) = self.is_focus {
229             properties.push(("is-focus", is_focus));
230         }
231         if let Some(ref margin) = self.margin {
232             properties.push(("margin", margin));
233         }
234         if let Some(ref margin_bottom) = self.margin_bottom {
235             properties.push(("margin-bottom", margin_bottom));
236         }
237         if let Some(ref margin_end) = self.margin_end {
238             properties.push(("margin-end", margin_end));
239         }
240         if let Some(ref margin_start) = self.margin_start {
241             properties.push(("margin-start", margin_start));
242         }
243         if let Some(ref margin_top) = self.margin_top {
244             properties.push(("margin-top", margin_top));
245         }
246         if let Some(ref name) = self.name {
247             properties.push(("name", name));
248         }
249         if let Some(ref no_show_all) = self.no_show_all {
250             properties.push(("no-show-all", no_show_all));
251         }
252         if let Some(ref opacity) = self.opacity {
253             properties.push(("opacity", opacity));
254         }
255         if let Some(ref parent) = self.parent {
256             properties.push(("parent", parent));
257         }
258         if let Some(ref receives_default) = self.receives_default {
259             properties.push(("receives-default", receives_default));
260         }
261         if let Some(ref sensitive) = self.sensitive {
262             properties.push(("sensitive", sensitive));
263         }
264         if let Some(ref tooltip_markup) = self.tooltip_markup {
265             properties.push(("tooltip-markup", tooltip_markup));
266         }
267         if let Some(ref tooltip_text) = self.tooltip_text {
268             properties.push(("tooltip-text", tooltip_text));
269         }
270         if let Some(ref valign) = self.valign {
271             properties.push(("valign", valign));
272         }
273         if let Some(ref vexpand) = self.vexpand {
274             properties.push(("vexpand", vexpand));
275         }
276         if let Some(ref vexpand_set) = self.vexpand_set {
277             properties.push(("vexpand-set", vexpand_set));
278         }
279         if let Some(ref visible) = self.visible {
280             properties.push(("visible", visible));
281         }
282         if let Some(ref width_request) = self.width_request {
283             properties.push(("width-request", width_request));
284         }
285         if let Some(ref action_name) = self.action_name {
286             properties.push(("action-name", action_name));
287         }
288         if let Some(ref action_target) = self.action_target {
289             properties.push(("action-target", action_target));
290         }
291         glib::Object::new::<MenuButton>(&properties)
292             .expect("Failed to create an instance of MenuButton")
293     }
294 
align_widget<P: IsA<Container>>(mut self, align_widget: &P) -> Self295     pub fn align_widget<P: IsA<Container>>(mut self, align_widget: &P) -> Self {
296         self.align_widget = Some(align_widget.clone().upcast());
297         self
298     }
299 
direction(mut self, direction: ArrowType) -> Self300     pub fn direction(mut self, direction: ArrowType) -> Self {
301         self.direction = Some(direction);
302         self
303     }
304 
menu_model<P: IsA<gio::MenuModel>>(mut self, menu_model: &P) -> Self305     pub fn menu_model<P: IsA<gio::MenuModel>>(mut self, menu_model: &P) -> Self {
306         self.menu_model = Some(menu_model.clone().upcast());
307         self
308     }
309 
popover<P: IsA<Popover>>(mut self, popover: &P) -> Self310     pub fn popover<P: IsA<Popover>>(mut self, popover: &P) -> Self {
311         self.popover = Some(popover.clone().upcast());
312         self
313     }
314 
popup<P: IsA<Menu>>(mut self, popup: &P) -> Self315     pub fn popup<P: IsA<Menu>>(mut self, popup: &P) -> Self {
316         self.popup = Some(popup.clone().upcast());
317         self
318     }
319 
use_popover(mut self, use_popover: bool) -> Self320     pub fn use_popover(mut self, use_popover: bool) -> Self {
321         self.use_popover = Some(use_popover);
322         self
323     }
324 
active(mut self, active: bool) -> Self325     pub fn active(mut self, active: bool) -> Self {
326         self.active = Some(active);
327         self
328     }
329 
draw_indicator(mut self, draw_indicator: bool) -> Self330     pub fn draw_indicator(mut self, draw_indicator: bool) -> Self {
331         self.draw_indicator = Some(draw_indicator);
332         self
333     }
334 
inconsistent(mut self, inconsistent: bool) -> Self335     pub fn inconsistent(mut self, inconsistent: bool) -> Self {
336         self.inconsistent = Some(inconsistent);
337         self
338     }
339 
always_show_image(mut self, always_show_image: bool) -> Self340     pub fn always_show_image(mut self, always_show_image: bool) -> Self {
341         self.always_show_image = Some(always_show_image);
342         self
343     }
344 
image<P: IsA<Widget>>(mut self, image: &P) -> Self345     pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self {
346         self.image = Some(image.clone().upcast());
347         self
348     }
349 
image_position(mut self, image_position: PositionType) -> Self350     pub fn image_position(mut self, image_position: PositionType) -> Self {
351         self.image_position = Some(image_position);
352         self
353     }
354 
label(mut self, label: &str) -> Self355     pub fn label(mut self, label: &str) -> Self {
356         self.label = Some(label.to_string());
357         self
358     }
359 
relief(mut self, relief: ReliefStyle) -> Self360     pub fn relief(mut self, relief: ReliefStyle) -> Self {
361         self.relief = Some(relief);
362         self
363     }
364 
use_underline(mut self, use_underline: bool) -> Self365     pub fn use_underline(mut self, use_underline: bool) -> Self {
366         self.use_underline = Some(use_underline);
367         self
368     }
369 
border_width(mut self, border_width: u32) -> Self370     pub fn border_width(mut self, border_width: u32) -> Self {
371         self.border_width = Some(border_width);
372         self
373     }
374 
child<P: IsA<Widget>>(mut self, child: &P) -> Self375     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
376         self.child = Some(child.clone().upcast());
377         self
378     }
379 
resize_mode(mut self, resize_mode: ResizeMode) -> Self380     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
381         self.resize_mode = Some(resize_mode);
382         self
383     }
384 
app_paintable(mut self, app_paintable: bool) -> Self385     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
386         self.app_paintable = Some(app_paintable);
387         self
388     }
389 
can_default(mut self, can_default: bool) -> Self390     pub fn can_default(mut self, can_default: bool) -> Self {
391         self.can_default = Some(can_default);
392         self
393     }
394 
can_focus(mut self, can_focus: bool) -> Self395     pub fn can_focus(mut self, can_focus: bool) -> Self {
396         self.can_focus = Some(can_focus);
397         self
398     }
399 
events(mut self, events: gdk::EventMask) -> Self400     pub fn events(mut self, events: gdk::EventMask) -> Self {
401         self.events = Some(events);
402         self
403     }
404 
expand(mut self, expand: bool) -> Self405     pub fn expand(mut self, expand: bool) -> Self {
406         self.expand = Some(expand);
407         self
408     }
409 
410     #[cfg(any(feature = "v3_20", feature = "dox"))]
411     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
focus_on_click(mut self, focus_on_click: bool) -> Self412     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
413         self.focus_on_click = Some(focus_on_click);
414         self
415     }
416 
halign(mut self, halign: Align) -> Self417     pub fn halign(mut self, halign: Align) -> Self {
418         self.halign = Some(halign);
419         self
420     }
421 
has_default(mut self, has_default: bool) -> Self422     pub fn has_default(mut self, has_default: bool) -> Self {
423         self.has_default = Some(has_default);
424         self
425     }
426 
has_focus(mut self, has_focus: bool) -> Self427     pub fn has_focus(mut self, has_focus: bool) -> Self {
428         self.has_focus = Some(has_focus);
429         self
430     }
431 
has_tooltip(mut self, has_tooltip: bool) -> Self432     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
433         self.has_tooltip = Some(has_tooltip);
434         self
435     }
436 
height_request(mut self, height_request: i32) -> Self437     pub fn height_request(mut self, height_request: i32) -> Self {
438         self.height_request = Some(height_request);
439         self
440     }
441 
hexpand(mut self, hexpand: bool) -> Self442     pub fn hexpand(mut self, hexpand: bool) -> Self {
443         self.hexpand = Some(hexpand);
444         self
445     }
446 
hexpand_set(mut self, hexpand_set: bool) -> Self447     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
448         self.hexpand_set = Some(hexpand_set);
449         self
450     }
451 
is_focus(mut self, is_focus: bool) -> Self452     pub fn is_focus(mut self, is_focus: bool) -> Self {
453         self.is_focus = Some(is_focus);
454         self
455     }
456 
margin(mut self, margin: i32) -> Self457     pub fn margin(mut self, margin: i32) -> Self {
458         self.margin = Some(margin);
459         self
460     }
461 
margin_bottom(mut self, margin_bottom: i32) -> Self462     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
463         self.margin_bottom = Some(margin_bottom);
464         self
465     }
466 
margin_end(mut self, margin_end: i32) -> Self467     pub fn margin_end(mut self, margin_end: i32) -> Self {
468         self.margin_end = Some(margin_end);
469         self
470     }
471 
margin_start(mut self, margin_start: i32) -> Self472     pub fn margin_start(mut self, margin_start: i32) -> Self {
473         self.margin_start = Some(margin_start);
474         self
475     }
476 
margin_top(mut self, margin_top: i32) -> Self477     pub fn margin_top(mut self, margin_top: i32) -> Self {
478         self.margin_top = Some(margin_top);
479         self
480     }
481 
name(mut self, name: &str) -> Self482     pub fn name(mut self, name: &str) -> Self {
483         self.name = Some(name.to_string());
484         self
485     }
486 
no_show_all(mut self, no_show_all: bool) -> Self487     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
488         self.no_show_all = Some(no_show_all);
489         self
490     }
491 
opacity(mut self, opacity: f64) -> Self492     pub fn opacity(mut self, opacity: f64) -> Self {
493         self.opacity = Some(opacity);
494         self
495     }
496 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self497     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
498         self.parent = Some(parent.clone().upcast());
499         self
500     }
501 
receives_default(mut self, receives_default: bool) -> Self502     pub fn receives_default(mut self, receives_default: bool) -> Self {
503         self.receives_default = Some(receives_default);
504         self
505     }
506 
sensitive(mut self, sensitive: bool) -> Self507     pub fn sensitive(mut self, sensitive: bool) -> Self {
508         self.sensitive = Some(sensitive);
509         self
510     }
511 
tooltip_markup(mut self, tooltip_markup: &str) -> Self512     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
513         self.tooltip_markup = Some(tooltip_markup.to_string());
514         self
515     }
516 
tooltip_text(mut self, tooltip_text: &str) -> Self517     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
518         self.tooltip_text = Some(tooltip_text.to_string());
519         self
520     }
521 
valign(mut self, valign: Align) -> Self522     pub fn valign(mut self, valign: Align) -> Self {
523         self.valign = Some(valign);
524         self
525     }
526 
vexpand(mut self, vexpand: bool) -> Self527     pub fn vexpand(mut self, vexpand: bool) -> Self {
528         self.vexpand = Some(vexpand);
529         self
530     }
531 
vexpand_set(mut self, vexpand_set: bool) -> Self532     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
533         self.vexpand_set = Some(vexpand_set);
534         self
535     }
536 
visible(mut self, visible: bool) -> Self537     pub fn visible(mut self, visible: bool) -> Self {
538         self.visible = Some(visible);
539         self
540     }
541 
width_request(mut self, width_request: i32) -> Self542     pub fn width_request(mut self, width_request: i32) -> Self {
543         self.width_request = Some(width_request);
544         self
545     }
546 
action_name(mut self, action_name: &str) -> Self547     pub fn action_name(mut self, action_name: &str) -> Self {
548         self.action_name = Some(action_name.to_string());
549         self
550     }
551 
action_target(mut self, action_target: &glib::Variant) -> Self552     pub fn action_target(mut self, action_target: &glib::Variant) -> Self {
553         self.action_target = Some(action_target.clone());
554         self
555     }
556 }
557 
558 pub const NONE_MENU_BUTTON: Option<&MenuButton> = None;
559 
560 pub trait MenuButtonExt: 'static {
561     #[doc(alias = "gtk_menu_button_get_align_widget")]
562     #[doc(alias = "get_align_widget")]
align_widget(&self) -> Option<Widget>563     fn align_widget(&self) -> Option<Widget>;
564 
565     #[doc(alias = "gtk_menu_button_get_direction")]
566     #[doc(alias = "get_direction")]
direction(&self) -> ArrowType567     fn direction(&self) -> ArrowType;
568 
569     #[doc(alias = "gtk_menu_button_get_menu_model")]
570     #[doc(alias = "get_menu_model")]
menu_model(&self) -> Option<gio::MenuModel>571     fn menu_model(&self) -> Option<gio::MenuModel>;
572 
573     #[doc(alias = "gtk_menu_button_get_popover")]
574     #[doc(alias = "get_popover")]
popover(&self) -> Option<Popover>575     fn popover(&self) -> Option<Popover>;
576 
577     #[doc(alias = "gtk_menu_button_get_popup")]
578     #[doc(alias = "get_popup")]
popup(&self) -> Option<Menu>579     fn popup(&self) -> Option<Menu>;
580 
581     #[doc(alias = "gtk_menu_button_get_use_popover")]
582     #[doc(alias = "get_use_popover")]
uses_popover(&self) -> bool583     fn uses_popover(&self) -> bool;
584 
585     #[doc(alias = "gtk_menu_button_set_align_widget")]
set_align_widget<P: IsA<Widget>>(&self, align_widget: Option<&P>)586     fn set_align_widget<P: IsA<Widget>>(&self, align_widget: Option<&P>);
587 
588     #[doc(alias = "gtk_menu_button_set_direction")]
set_direction(&self, direction: ArrowType)589     fn set_direction(&self, direction: ArrowType);
590 
591     #[doc(alias = "gtk_menu_button_set_menu_model")]
set_menu_model<P: IsA<gio::MenuModel>>(&self, menu_model: Option<&P>)592     fn set_menu_model<P: IsA<gio::MenuModel>>(&self, menu_model: Option<&P>);
593 
594     #[doc(alias = "gtk_menu_button_set_popover")]
set_popover<P: IsA<Widget>>(&self, popover: Option<&P>)595     fn set_popover<P: IsA<Widget>>(&self, popover: Option<&P>);
596 
597     #[doc(alias = "gtk_menu_button_set_popup")]
set_popup<P: IsA<Widget>>(&self, menu: Option<&P>)598     fn set_popup<P: IsA<Widget>>(&self, menu: Option<&P>);
599 
600     #[doc(alias = "gtk_menu_button_set_use_popover")]
set_use_popover(&self, use_popover: bool)601     fn set_use_popover(&self, use_popover: bool);
602 
603     #[doc(alias = "align-widget")]
connect_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId604     fn connect_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
605 
606     #[doc(alias = "direction")]
connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId607     fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
608 
609     #[doc(alias = "menu-model")]
connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId610     fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
611 
612     #[doc(alias = "popover")]
connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId613     fn connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
614 
615     #[doc(alias = "popup")]
connect_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId616     fn connect_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
617 
618     #[doc(alias = "use-popover")]
connect_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId619     fn connect_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
620 }
621 
622 impl<O: IsA<MenuButton>> MenuButtonExt for O {
align_widget(&self) -> Option<Widget>623     fn align_widget(&self) -> Option<Widget> {
624         unsafe {
625             from_glib_none(ffi::gtk_menu_button_get_align_widget(
626                 self.as_ref().to_glib_none().0,
627             ))
628         }
629     }
630 
direction(&self) -> ArrowType631     fn direction(&self) -> ArrowType {
632         unsafe {
633             from_glib(ffi::gtk_menu_button_get_direction(
634                 self.as_ref().to_glib_none().0,
635             ))
636         }
637     }
638 
menu_model(&self) -> Option<gio::MenuModel>639     fn menu_model(&self) -> Option<gio::MenuModel> {
640         unsafe {
641             from_glib_none(ffi::gtk_menu_button_get_menu_model(
642                 self.as_ref().to_glib_none().0,
643             ))
644         }
645     }
646 
popover(&self) -> Option<Popover>647     fn popover(&self) -> Option<Popover> {
648         unsafe {
649             from_glib_none(ffi::gtk_menu_button_get_popover(
650                 self.as_ref().to_glib_none().0,
651             ))
652         }
653     }
654 
popup(&self) -> Option<Menu>655     fn popup(&self) -> Option<Menu> {
656         unsafe {
657             from_glib_none(ffi::gtk_menu_button_get_popup(
658                 self.as_ref().to_glib_none().0,
659             ))
660         }
661     }
662 
uses_popover(&self) -> bool663     fn uses_popover(&self) -> bool {
664         unsafe {
665             from_glib(ffi::gtk_menu_button_get_use_popover(
666                 self.as_ref().to_glib_none().0,
667             ))
668         }
669     }
670 
set_align_widget<P: IsA<Widget>>(&self, align_widget: Option<&P>)671     fn set_align_widget<P: IsA<Widget>>(&self, align_widget: Option<&P>) {
672         unsafe {
673             ffi::gtk_menu_button_set_align_widget(
674                 self.as_ref().to_glib_none().0,
675                 align_widget.map(|p| p.as_ref()).to_glib_none().0,
676             );
677         }
678     }
679 
set_direction(&self, direction: ArrowType)680     fn set_direction(&self, direction: ArrowType) {
681         unsafe {
682             ffi::gtk_menu_button_set_direction(
683                 self.as_ref().to_glib_none().0,
684                 direction.into_glib(),
685             );
686         }
687     }
688 
set_menu_model<P: IsA<gio::MenuModel>>(&self, menu_model: Option<&P>)689     fn set_menu_model<P: IsA<gio::MenuModel>>(&self, menu_model: Option<&P>) {
690         unsafe {
691             ffi::gtk_menu_button_set_menu_model(
692                 self.as_ref().to_glib_none().0,
693                 menu_model.map(|p| p.as_ref()).to_glib_none().0,
694             );
695         }
696     }
697 
set_popover<P: IsA<Widget>>(&self, popover: Option<&P>)698     fn set_popover<P: IsA<Widget>>(&self, popover: Option<&P>) {
699         unsafe {
700             ffi::gtk_menu_button_set_popover(
701                 self.as_ref().to_glib_none().0,
702                 popover.map(|p| p.as_ref()).to_glib_none().0,
703             );
704         }
705     }
706 
set_popup<P: IsA<Widget>>(&self, menu: Option<&P>)707     fn set_popup<P: IsA<Widget>>(&self, menu: Option<&P>) {
708         unsafe {
709             ffi::gtk_menu_button_set_popup(
710                 self.as_ref().to_glib_none().0,
711                 menu.map(|p| p.as_ref()).to_glib_none().0,
712             );
713         }
714     }
715 
set_use_popover(&self, use_popover: bool)716     fn set_use_popover(&self, use_popover: bool) {
717         unsafe {
718             ffi::gtk_menu_button_set_use_popover(
719                 self.as_ref().to_glib_none().0,
720                 use_popover.into_glib(),
721             );
722         }
723     }
724 
connect_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId725     fn connect_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
726         unsafe extern "C" fn notify_align_widget_trampoline<
727             P: IsA<MenuButton>,
728             F: Fn(&P) + 'static,
729         >(
730             this: *mut ffi::GtkMenuButton,
731             _param_spec: glib::ffi::gpointer,
732             f: glib::ffi::gpointer,
733         ) {
734             let f: &F = &*(f as *const F);
735             f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
736         }
737         unsafe {
738             let f: Box_<F> = Box_::new(f);
739             connect_raw(
740                 self.as_ptr() as *mut _,
741                 b"notify::align-widget\0".as_ptr() as *const _,
742                 Some(transmute::<_, unsafe extern "C" fn()>(
743                     notify_align_widget_trampoline::<Self, F> as *const (),
744                 )),
745                 Box_::into_raw(f),
746             )
747         }
748     }
749 
connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId750     fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
751         unsafe extern "C" fn notify_direction_trampoline<
752             P: IsA<MenuButton>,
753             F: Fn(&P) + 'static,
754         >(
755             this: *mut ffi::GtkMenuButton,
756             _param_spec: glib::ffi::gpointer,
757             f: glib::ffi::gpointer,
758         ) {
759             let f: &F = &*(f as *const F);
760             f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
761         }
762         unsafe {
763             let f: Box_<F> = Box_::new(f);
764             connect_raw(
765                 self.as_ptr() as *mut _,
766                 b"notify::direction\0".as_ptr() as *const _,
767                 Some(transmute::<_, unsafe extern "C" fn()>(
768                     notify_direction_trampoline::<Self, F> as *const (),
769                 )),
770                 Box_::into_raw(f),
771             )
772         }
773     }
774 
connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId775     fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
776         unsafe extern "C" fn notify_menu_model_trampoline<
777             P: IsA<MenuButton>,
778             F: Fn(&P) + 'static,
779         >(
780             this: *mut ffi::GtkMenuButton,
781             _param_spec: glib::ffi::gpointer,
782             f: glib::ffi::gpointer,
783         ) {
784             let f: &F = &*(f as *const F);
785             f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
786         }
787         unsafe {
788             let f: Box_<F> = Box_::new(f);
789             connect_raw(
790                 self.as_ptr() as *mut _,
791                 b"notify::menu-model\0".as_ptr() as *const _,
792                 Some(transmute::<_, unsafe extern "C" fn()>(
793                     notify_menu_model_trampoline::<Self, F> as *const (),
794                 )),
795                 Box_::into_raw(f),
796             )
797         }
798     }
799 
connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId800     fn connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
801         unsafe extern "C" fn notify_popover_trampoline<P: IsA<MenuButton>, F: Fn(&P) + 'static>(
802             this: *mut ffi::GtkMenuButton,
803             _param_spec: glib::ffi::gpointer,
804             f: glib::ffi::gpointer,
805         ) {
806             let f: &F = &*(f as *const F);
807             f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
808         }
809         unsafe {
810             let f: Box_<F> = Box_::new(f);
811             connect_raw(
812                 self.as_ptr() as *mut _,
813                 b"notify::popover\0".as_ptr() as *const _,
814                 Some(transmute::<_, unsafe extern "C" fn()>(
815                     notify_popover_trampoline::<Self, F> as *const (),
816                 )),
817                 Box_::into_raw(f),
818             )
819         }
820     }
821 
connect_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId822     fn connect_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
823         unsafe extern "C" fn notify_popup_trampoline<P: IsA<MenuButton>, F: Fn(&P) + 'static>(
824             this: *mut ffi::GtkMenuButton,
825             _param_spec: glib::ffi::gpointer,
826             f: glib::ffi::gpointer,
827         ) {
828             let f: &F = &*(f as *const F);
829             f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
830         }
831         unsafe {
832             let f: Box_<F> = Box_::new(f);
833             connect_raw(
834                 self.as_ptr() as *mut _,
835                 b"notify::popup\0".as_ptr() as *const _,
836                 Some(transmute::<_, unsafe extern "C" fn()>(
837                     notify_popup_trampoline::<Self, F> as *const (),
838                 )),
839                 Box_::into_raw(f),
840             )
841         }
842     }
843 
connect_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId844     fn connect_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
845         unsafe extern "C" fn notify_use_popover_trampoline<
846             P: IsA<MenuButton>,
847             F: Fn(&P) + 'static,
848         >(
849             this: *mut ffi::GtkMenuButton,
850             _param_spec: glib::ffi::gpointer,
851             f: glib::ffi::gpointer,
852         ) {
853             let f: &F = &*(f as *const F);
854             f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
855         }
856         unsafe {
857             let f: Box_<F> = Box_::new(f);
858             connect_raw(
859                 self.as_ptr() as *mut _,
860                 b"notify::use-popover\0".as_ptr() as *const _,
861                 Some(transmute::<_, unsafe extern "C" fn()>(
862                     notify_use_popover_trampoline::<Self, F> as *const (),
863                 )),
864                 Box_::into_raw(f),
865             )
866         }
867     }
868 }
869 
870 impl fmt::Display for MenuButton {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result871     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
872         f.write_str("MenuButton")
873     }
874 }
875