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 glib;
7 use glib::object::Cast;
8 use glib::object::IsA;
9 use glib::signal::connect_raw;
10 use glib::signal::SignalHandlerId;
11 use glib::translate::*;
12 use glib::StaticType;
13 use glib::ToValue;
14 use glib_sys;
15 use gtk_sys;
16 use std::boxed::Box as Box_;
17 use std::fmt;
18 use std::mem::transmute;
19 use Actionable;
20 use Align;
21 use Bin;
22 use Buildable;
23 use Container;
24 use Menu;
25 use ResizeMode;
26 use ToolButton;
27 use ToolItem;
28 use Widget;
29 
30 glib_wrapper! {
31     pub struct MenuToolButton(Object<gtk_sys::GtkMenuToolButton, gtk_sys::GtkMenuToolButtonClass, MenuToolButtonClass>) @extends ToolButton, ToolItem, Bin, Container, Widget, @implements Buildable, Actionable;
32 
33     match fn {
34         get_type => || gtk_sys::gtk_menu_tool_button_get_type(),
35     }
36 }
37 
38 impl MenuToolButton {
new<P: IsA<Widget>>(icon_widget: Option<&P>, label: Option<&str>) -> MenuToolButton39     pub fn new<P: IsA<Widget>>(icon_widget: Option<&P>, label: Option<&str>) -> MenuToolButton {
40         assert_initialized_main_thread!();
41         unsafe {
42             ToolItem::from_glib_none(gtk_sys::gtk_menu_tool_button_new(
43                 icon_widget.map(|p| p.as_ref()).to_glib_none().0,
44                 label.to_glib_none().0,
45             ))
46             .unsafe_cast()
47         }
48     }
49 }
50 
51 #[derive(Clone, Default)]
52 pub struct MenuToolButtonBuilder {
53     menu: Option<Menu>,
54     icon_name: Option<String>,
55     icon_widget: Option<Widget>,
56     label: Option<String>,
57     label_widget: Option<Widget>,
58     use_underline: Option<bool>,
59     is_important: Option<bool>,
60     visible_horizontal: Option<bool>,
61     visible_vertical: Option<bool>,
62     border_width: Option<u32>,
63     child: Option<Widget>,
64     resize_mode: Option<ResizeMode>,
65     app_paintable: Option<bool>,
66     can_default: Option<bool>,
67     can_focus: Option<bool>,
68     events: Option<gdk::EventMask>,
69     expand: Option<bool>,
70     #[cfg(any(feature = "v3_20", feature = "dox"))]
71     focus_on_click: Option<bool>,
72     halign: Option<Align>,
73     has_default: Option<bool>,
74     has_focus: Option<bool>,
75     has_tooltip: Option<bool>,
76     height_request: Option<i32>,
77     hexpand: Option<bool>,
78     hexpand_set: Option<bool>,
79     is_focus: Option<bool>,
80     margin: Option<i32>,
81     margin_bottom: Option<i32>,
82     margin_end: Option<i32>,
83     margin_start: Option<i32>,
84     margin_top: Option<i32>,
85     name: Option<String>,
86     no_show_all: Option<bool>,
87     opacity: Option<f64>,
88     parent: Option<Container>,
89     receives_default: Option<bool>,
90     sensitive: Option<bool>,
91     tooltip_markup: Option<String>,
92     tooltip_text: Option<String>,
93     valign: Option<Align>,
94     vexpand: Option<bool>,
95     vexpand_set: Option<bool>,
96     visible: Option<bool>,
97     width_request: Option<i32>,
98     action_name: Option<String>,
99     action_target: Option<glib::Variant>,
100 }
101 
102 impl MenuToolButtonBuilder {
new() -> Self103     pub fn new() -> Self {
104         Self::default()
105     }
106 
build(self) -> MenuToolButton107     pub fn build(self) -> MenuToolButton {
108         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
109         if let Some(ref menu) = self.menu {
110             properties.push(("menu", menu));
111         }
112         if let Some(ref icon_name) = self.icon_name {
113             properties.push(("icon-name", icon_name));
114         }
115         if let Some(ref icon_widget) = self.icon_widget {
116             properties.push(("icon-widget", icon_widget));
117         }
118         if let Some(ref label) = self.label {
119             properties.push(("label", label));
120         }
121         if let Some(ref label_widget) = self.label_widget {
122             properties.push(("label-widget", label_widget));
123         }
124         if let Some(ref use_underline) = self.use_underline {
125             properties.push(("use-underline", use_underline));
126         }
127         if let Some(ref is_important) = self.is_important {
128             properties.push(("is-important", is_important));
129         }
130         if let Some(ref visible_horizontal) = self.visible_horizontal {
131             properties.push(("visible-horizontal", visible_horizontal));
132         }
133         if let Some(ref visible_vertical) = self.visible_vertical {
134             properties.push(("visible-vertical", visible_vertical));
135         }
136         if let Some(ref border_width) = self.border_width {
137             properties.push(("border-width", border_width));
138         }
139         if let Some(ref child) = self.child {
140             properties.push(("child", child));
141         }
142         if let Some(ref resize_mode) = self.resize_mode {
143             properties.push(("resize-mode", resize_mode));
144         }
145         if let Some(ref app_paintable) = self.app_paintable {
146             properties.push(("app-paintable", app_paintable));
147         }
148         if let Some(ref can_default) = self.can_default {
149             properties.push(("can-default", can_default));
150         }
151         if let Some(ref can_focus) = self.can_focus {
152             properties.push(("can-focus", can_focus));
153         }
154         if let Some(ref events) = self.events {
155             properties.push(("events", events));
156         }
157         if let Some(ref expand) = self.expand {
158             properties.push(("expand", expand));
159         }
160         #[cfg(any(feature = "v3_20", feature = "dox"))]
161         {
162             if let Some(ref focus_on_click) = self.focus_on_click {
163                 properties.push(("focus-on-click", focus_on_click));
164             }
165         }
166         if let Some(ref halign) = self.halign {
167             properties.push(("halign", halign));
168         }
169         if let Some(ref has_default) = self.has_default {
170             properties.push(("has-default", has_default));
171         }
172         if let Some(ref has_focus) = self.has_focus {
173             properties.push(("has-focus", has_focus));
174         }
175         if let Some(ref has_tooltip) = self.has_tooltip {
176             properties.push(("has-tooltip", has_tooltip));
177         }
178         if let Some(ref height_request) = self.height_request {
179             properties.push(("height-request", height_request));
180         }
181         if let Some(ref hexpand) = self.hexpand {
182             properties.push(("hexpand", hexpand));
183         }
184         if let Some(ref hexpand_set) = self.hexpand_set {
185             properties.push(("hexpand-set", hexpand_set));
186         }
187         if let Some(ref is_focus) = self.is_focus {
188             properties.push(("is-focus", is_focus));
189         }
190         if let Some(ref margin) = self.margin {
191             properties.push(("margin", margin));
192         }
193         if let Some(ref margin_bottom) = self.margin_bottom {
194             properties.push(("margin-bottom", margin_bottom));
195         }
196         if let Some(ref margin_end) = self.margin_end {
197             properties.push(("margin-end", margin_end));
198         }
199         if let Some(ref margin_start) = self.margin_start {
200             properties.push(("margin-start", margin_start));
201         }
202         if let Some(ref margin_top) = self.margin_top {
203             properties.push(("margin-top", margin_top));
204         }
205         if let Some(ref name) = self.name {
206             properties.push(("name", name));
207         }
208         if let Some(ref no_show_all) = self.no_show_all {
209             properties.push(("no-show-all", no_show_all));
210         }
211         if let Some(ref opacity) = self.opacity {
212             properties.push(("opacity", opacity));
213         }
214         if let Some(ref parent) = self.parent {
215             properties.push(("parent", parent));
216         }
217         if let Some(ref receives_default) = self.receives_default {
218             properties.push(("receives-default", receives_default));
219         }
220         if let Some(ref sensitive) = self.sensitive {
221             properties.push(("sensitive", sensitive));
222         }
223         if let Some(ref tooltip_markup) = self.tooltip_markup {
224             properties.push(("tooltip-markup", tooltip_markup));
225         }
226         if let Some(ref tooltip_text) = self.tooltip_text {
227             properties.push(("tooltip-text", tooltip_text));
228         }
229         if let Some(ref valign) = self.valign {
230             properties.push(("valign", valign));
231         }
232         if let Some(ref vexpand) = self.vexpand {
233             properties.push(("vexpand", vexpand));
234         }
235         if let Some(ref vexpand_set) = self.vexpand_set {
236             properties.push(("vexpand-set", vexpand_set));
237         }
238         if let Some(ref visible) = self.visible {
239             properties.push(("visible", visible));
240         }
241         if let Some(ref width_request) = self.width_request {
242             properties.push(("width-request", width_request));
243         }
244         if let Some(ref action_name) = self.action_name {
245             properties.push(("action-name", action_name));
246         }
247         if let Some(ref action_target) = self.action_target {
248             properties.push(("action-target", action_target));
249         }
250         glib::Object::new(MenuToolButton::static_type(), &properties)
251             .expect("object new")
252             .downcast()
253             .expect("downcast")
254     }
255 
menu<P: IsA<Menu>>(mut self, menu: &P) -> Self256     pub fn menu<P: IsA<Menu>>(mut self, menu: &P) -> Self {
257         self.menu = Some(menu.clone().upcast());
258         self
259     }
260 
icon_name(mut self, icon_name: &str) -> Self261     pub fn icon_name(mut self, icon_name: &str) -> Self {
262         self.icon_name = Some(icon_name.to_string());
263         self
264     }
265 
icon_widget<P: IsA<Widget>>(mut self, icon_widget: &P) -> Self266     pub fn icon_widget<P: IsA<Widget>>(mut self, icon_widget: &P) -> Self {
267         self.icon_widget = Some(icon_widget.clone().upcast());
268         self
269     }
270 
label(mut self, label: &str) -> Self271     pub fn label(mut self, label: &str) -> Self {
272         self.label = Some(label.to_string());
273         self
274     }
275 
label_widget<P: IsA<Widget>>(mut self, label_widget: &P) -> Self276     pub fn label_widget<P: IsA<Widget>>(mut self, label_widget: &P) -> Self {
277         self.label_widget = Some(label_widget.clone().upcast());
278         self
279     }
280 
use_underline(mut self, use_underline: bool) -> Self281     pub fn use_underline(mut self, use_underline: bool) -> Self {
282         self.use_underline = Some(use_underline);
283         self
284     }
285 
is_important(mut self, is_important: bool) -> Self286     pub fn is_important(mut self, is_important: bool) -> Self {
287         self.is_important = Some(is_important);
288         self
289     }
290 
visible_horizontal(mut self, visible_horizontal: bool) -> Self291     pub fn visible_horizontal(mut self, visible_horizontal: bool) -> Self {
292         self.visible_horizontal = Some(visible_horizontal);
293         self
294     }
295 
visible_vertical(mut self, visible_vertical: bool) -> Self296     pub fn visible_vertical(mut self, visible_vertical: bool) -> Self {
297         self.visible_vertical = Some(visible_vertical);
298         self
299     }
300 
border_width(mut self, border_width: u32) -> Self301     pub fn border_width(mut self, border_width: u32) -> Self {
302         self.border_width = Some(border_width);
303         self
304     }
305 
child<P: IsA<Widget>>(mut self, child: &P) -> Self306     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
307         self.child = Some(child.clone().upcast());
308         self
309     }
310 
resize_mode(mut self, resize_mode: ResizeMode) -> Self311     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
312         self.resize_mode = Some(resize_mode);
313         self
314     }
315 
app_paintable(mut self, app_paintable: bool) -> Self316     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
317         self.app_paintable = Some(app_paintable);
318         self
319     }
320 
can_default(mut self, can_default: bool) -> Self321     pub fn can_default(mut self, can_default: bool) -> Self {
322         self.can_default = Some(can_default);
323         self
324     }
325 
can_focus(mut self, can_focus: bool) -> Self326     pub fn can_focus(mut self, can_focus: bool) -> Self {
327         self.can_focus = Some(can_focus);
328         self
329     }
330 
events(mut self, events: gdk::EventMask) -> Self331     pub fn events(mut self, events: gdk::EventMask) -> Self {
332         self.events = Some(events);
333         self
334     }
335 
expand(mut self, expand: bool) -> Self336     pub fn expand(mut self, expand: bool) -> Self {
337         self.expand = Some(expand);
338         self
339     }
340 
341     #[cfg(any(feature = "v3_20", feature = "dox"))]
focus_on_click(mut self, focus_on_click: bool) -> Self342     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
343         self.focus_on_click = Some(focus_on_click);
344         self
345     }
346 
halign(mut self, halign: Align) -> Self347     pub fn halign(mut self, halign: Align) -> Self {
348         self.halign = Some(halign);
349         self
350     }
351 
has_default(mut self, has_default: bool) -> Self352     pub fn has_default(mut self, has_default: bool) -> Self {
353         self.has_default = Some(has_default);
354         self
355     }
356 
has_focus(mut self, has_focus: bool) -> Self357     pub fn has_focus(mut self, has_focus: bool) -> Self {
358         self.has_focus = Some(has_focus);
359         self
360     }
361 
has_tooltip(mut self, has_tooltip: bool) -> Self362     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
363         self.has_tooltip = Some(has_tooltip);
364         self
365     }
366 
height_request(mut self, height_request: i32) -> Self367     pub fn height_request(mut self, height_request: i32) -> Self {
368         self.height_request = Some(height_request);
369         self
370     }
371 
hexpand(mut self, hexpand: bool) -> Self372     pub fn hexpand(mut self, hexpand: bool) -> Self {
373         self.hexpand = Some(hexpand);
374         self
375     }
376 
hexpand_set(mut self, hexpand_set: bool) -> Self377     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
378         self.hexpand_set = Some(hexpand_set);
379         self
380     }
381 
is_focus(mut self, is_focus: bool) -> Self382     pub fn is_focus(mut self, is_focus: bool) -> Self {
383         self.is_focus = Some(is_focus);
384         self
385     }
386 
margin(mut self, margin: i32) -> Self387     pub fn margin(mut self, margin: i32) -> Self {
388         self.margin = Some(margin);
389         self
390     }
391 
margin_bottom(mut self, margin_bottom: i32) -> Self392     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
393         self.margin_bottom = Some(margin_bottom);
394         self
395     }
396 
margin_end(mut self, margin_end: i32) -> Self397     pub fn margin_end(mut self, margin_end: i32) -> Self {
398         self.margin_end = Some(margin_end);
399         self
400     }
401 
margin_start(mut self, margin_start: i32) -> Self402     pub fn margin_start(mut self, margin_start: i32) -> Self {
403         self.margin_start = Some(margin_start);
404         self
405     }
406 
margin_top(mut self, margin_top: i32) -> Self407     pub fn margin_top(mut self, margin_top: i32) -> Self {
408         self.margin_top = Some(margin_top);
409         self
410     }
411 
name(mut self, name: &str) -> Self412     pub fn name(mut self, name: &str) -> Self {
413         self.name = Some(name.to_string());
414         self
415     }
416 
no_show_all(mut self, no_show_all: bool) -> Self417     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
418         self.no_show_all = Some(no_show_all);
419         self
420     }
421 
opacity(mut self, opacity: f64) -> Self422     pub fn opacity(mut self, opacity: f64) -> Self {
423         self.opacity = Some(opacity);
424         self
425     }
426 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self427     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
428         self.parent = Some(parent.clone().upcast());
429         self
430     }
431 
receives_default(mut self, receives_default: bool) -> Self432     pub fn receives_default(mut self, receives_default: bool) -> Self {
433         self.receives_default = Some(receives_default);
434         self
435     }
436 
sensitive(mut self, sensitive: bool) -> Self437     pub fn sensitive(mut self, sensitive: bool) -> Self {
438         self.sensitive = Some(sensitive);
439         self
440     }
441 
tooltip_markup(mut self, tooltip_markup: &str) -> Self442     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
443         self.tooltip_markup = Some(tooltip_markup.to_string());
444         self
445     }
446 
tooltip_text(mut self, tooltip_text: &str) -> Self447     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
448         self.tooltip_text = Some(tooltip_text.to_string());
449         self
450     }
451 
valign(mut self, valign: Align) -> Self452     pub fn valign(mut self, valign: Align) -> Self {
453         self.valign = Some(valign);
454         self
455     }
456 
vexpand(mut self, vexpand: bool) -> Self457     pub fn vexpand(mut self, vexpand: bool) -> Self {
458         self.vexpand = Some(vexpand);
459         self
460     }
461 
vexpand_set(mut self, vexpand_set: bool) -> Self462     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
463         self.vexpand_set = Some(vexpand_set);
464         self
465     }
466 
visible(mut self, visible: bool) -> Self467     pub fn visible(mut self, visible: bool) -> Self {
468         self.visible = Some(visible);
469         self
470     }
471 
width_request(mut self, width_request: i32) -> Self472     pub fn width_request(mut self, width_request: i32) -> Self {
473         self.width_request = Some(width_request);
474         self
475     }
476 
action_name(mut self, action_name: &str) -> Self477     pub fn action_name(mut self, action_name: &str) -> Self {
478         self.action_name = Some(action_name.to_string());
479         self
480     }
481 
action_target(mut self, action_target: &glib::Variant) -> Self482     pub fn action_target(mut self, action_target: &glib::Variant) -> Self {
483         self.action_target = Some(action_target.clone());
484         self
485     }
486 }
487 
488 pub const NONE_MENU_TOOL_BUTTON: Option<&MenuToolButton> = None;
489 
490 pub trait MenuToolButtonExt: 'static {
get_menu(&self) -> Option<Widget>491     fn get_menu(&self) -> Option<Widget>;
492 
set_arrow_tooltip_markup(&self, markup: &str)493     fn set_arrow_tooltip_markup(&self, markup: &str);
494 
set_arrow_tooltip_text(&self, text: &str)495     fn set_arrow_tooltip_text(&self, text: &str);
496 
set_menu<P: IsA<Widget>>(&self, menu: &P)497     fn set_menu<P: IsA<Widget>>(&self, menu: &P);
498 
connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId499     fn connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
500 
connect_property_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId501     fn connect_property_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
502 }
503 
504 impl<O: IsA<MenuToolButton>> MenuToolButtonExt for O {
get_menu(&self) -> Option<Widget>505     fn get_menu(&self) -> Option<Widget> {
506         unsafe {
507             from_glib_none(gtk_sys::gtk_menu_tool_button_get_menu(
508                 self.as_ref().to_glib_none().0,
509             ))
510         }
511     }
512 
set_arrow_tooltip_markup(&self, markup: &str)513     fn set_arrow_tooltip_markup(&self, markup: &str) {
514         unsafe {
515             gtk_sys::gtk_menu_tool_button_set_arrow_tooltip_markup(
516                 self.as_ref().to_glib_none().0,
517                 markup.to_glib_none().0,
518             );
519         }
520     }
521 
set_arrow_tooltip_text(&self, text: &str)522     fn set_arrow_tooltip_text(&self, text: &str) {
523         unsafe {
524             gtk_sys::gtk_menu_tool_button_set_arrow_tooltip_text(
525                 self.as_ref().to_glib_none().0,
526                 text.to_glib_none().0,
527             );
528         }
529     }
530 
set_menu<P: IsA<Widget>>(&self, menu: &P)531     fn set_menu<P: IsA<Widget>>(&self, menu: &P) {
532         unsafe {
533             gtk_sys::gtk_menu_tool_button_set_menu(
534                 self.as_ref().to_glib_none().0,
535                 menu.as_ref().to_glib_none().0,
536             );
537         }
538     }
539 
connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId540     fn connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
541         unsafe extern "C" fn show_menu_trampoline<P, F: Fn(&P) + 'static>(
542             this: *mut gtk_sys::GtkMenuToolButton,
543             f: glib_sys::gpointer,
544         ) where
545             P: IsA<MenuToolButton>,
546         {
547             let f: &F = &*(f as *const F);
548             f(&MenuToolButton::from_glib_borrow(this).unsafe_cast())
549         }
550         unsafe {
551             let f: Box_<F> = Box_::new(f);
552             connect_raw(
553                 self.as_ptr() as *mut _,
554                 b"show-menu\0".as_ptr() as *const _,
555                 Some(transmute(show_menu_trampoline::<Self, F> as usize)),
556                 Box_::into_raw(f),
557             )
558         }
559     }
560 
connect_property_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId561     fn connect_property_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
562         unsafe extern "C" fn notify_menu_trampoline<P, F: Fn(&P) + 'static>(
563             this: *mut gtk_sys::GtkMenuToolButton,
564             _param_spec: glib_sys::gpointer,
565             f: glib_sys::gpointer,
566         ) where
567             P: IsA<MenuToolButton>,
568         {
569             let f: &F = &*(f as *const F);
570             f(&MenuToolButton::from_glib_borrow(this).unsafe_cast())
571         }
572         unsafe {
573             let f: Box_<F> = Box_::new(f);
574             connect_raw(
575                 self.as_ptr() as *mut _,
576                 b"notify::menu\0".as_ptr() as *const _,
577                 Some(transmute(notify_menu_trampoline::<Self, F> as usize)),
578                 Box_::into_raw(f),
579             )
580         }
581     }
582 }
583 
584 impl fmt::Display for MenuToolButton {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result585     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
586         write!(f, "MenuToolButton")
587     }
588 }
589