gtk/auto/menu_button.rs
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
5use crate::{
6 Actionable, Align, ArrowType, Bin, Buildable, Button, Container, Menu, Popover, PositionType,
7 ReliefStyle, ResizeMode, ToggleButton, Widget, ffi,
8};
9use glib::{
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 /// The [`MenuButton`][crate::MenuButton] widget is used to display a popup when clicked on.
18 /// This popup can be provided either as a [`Menu`][crate::Menu], a [`Popover`][crate::Popover] or an
19 /// abstract [`gio::MenuModel`][crate::gio::MenuModel].
20 ///
21 /// The [`MenuButton`][crate::MenuButton] widget can hold any valid child widget. That is, it
22 /// can hold almost any other standard [`Widget`][crate::Widget]. The most commonly used
23 /// child is [`Image`][crate::Image]. If no widget is explicitely added to the [`MenuButton`][crate::MenuButton],
24 /// a [`Image`][crate::Image] is automatically created, using an arrow image oriented
25 /// according to [`direction`][struct@crate::MenuButton#direction] or the generic “open-menu-symbolic”
26 /// icon if the direction is not set.
27 ///
28 /// The positioning of the popup is determined by the [`direction`][struct@crate::MenuButton#direction]
29 /// property of the menu button.
30 ///
31 /// For menus, the [`halign`][struct@crate::Widget#halign] and [`valign`][struct@crate::Widget#valign] properties of the
32 /// menu are also taken into account. For example, when the direction is
33 /// [`ArrowType::Down`][crate::ArrowType::Down] and the horizontal alignment is [`Align::Start`][crate::Align::Start], the
34 /// menu will be positioned below the button, with the starting edge
35 /// (depending on the text direction) of the menu aligned with the starting
36 /// edge of the button. If there is not enough space below the button, the
37 /// menu is popped up above the button instead. If the alignment would move
38 /// part of the menu offscreen, it is “pushed in”.
39 ///
40 /// ## Direction = Down
41 ///
42 /// - halign = start
43 ///
44 /// 
45 ///
46 /// - halign = center
47 ///
48 /// 
49 ///
50 /// - halign = end
51 ///
52 /// 
53 ///
54 /// ## Direction = Up
55 ///
56 /// - halign = start
57 ///
58 /// 
59 ///
60 /// - halign = center
61 ///
62 /// 
63 ///
64 /// - halign = end
65 ///
66 /// 
67 ///
68 /// ## Direction = Left
69 ///
70 /// - valign = start
71 ///
72 /// 
73 ///
74 /// - valign = center
75 ///
76 /// 
77 ///
78 /// - valign = end
79 ///
80 /// 
81 ///
82 /// ## Direction = Right
83 ///
84 /// - valign = start
85 ///
86 /// 
87 ///
88 /// - valign = center
89 ///
90 /// 
91 ///
92 /// - valign = end
93 ///
94 /// 
95 ///
96 /// # CSS nodes
97 ///
98 /// GtkMenuButton has a single CSS node with name button. To differentiate
99 /// it from a plain [`Button`][crate::Button], it gets the .popup style class.
100 ///
101 /// ## Properties
102 ///
103 ///
104 /// #### `align-widget`
105 /// The [`Widget`][crate::Widget] to use to align the menu with.
106 ///
107 /// Readable | Writable
108 ///
109 ///
110 /// #### `direction`
111 /// The [`ArrowType`][crate::ArrowType] representing the direction in which the
112 /// menu or popover will be popped out.
113 ///
114 /// Readable | Writable
115 ///
116 ///
117 /// #### `menu-model`
118 /// The [`gio::MenuModel`][crate::gio::MenuModel] from which the popup will be created.
119 /// Depending on the [`use-popover`][struct@crate::MenuButton#use-popover] property, that may
120 /// be a menu or a popover.
121 ///
122 /// See [`MenuButtonExt::set_menu_model()`][crate::prelude::MenuButtonExt::set_menu_model()] for the interaction with the
123 /// [`popup`][struct@crate::MenuButton#popup] property.
124 ///
125 /// Readable | Writable
126 ///
127 ///
128 /// #### `popover`
129 /// The [`Popover`][crate::Popover] that will be popped up when the button is clicked.
130 ///
131 /// Readable | Writable
132 ///
133 ///
134 /// #### `popup`
135 /// The [`Menu`][crate::Menu] that will be popped up when the button is clicked.
136 ///
137 /// Readable | Writable
138 ///
139 ///
140 /// #### `use-popover`
141 /// Whether to construct a [`Popover`][crate::Popover] from the menu model,
142 /// or a [`Menu`][crate::Menu].
143 ///
144 /// Readable | Writable
145 /// <details><summary><h4>ToggleButton</h4></summary>
146 ///
147 ///
148 /// #### `active`
149 /// Readable | Writable
150 ///
151 ///
152 /// #### `draw-indicator`
153 /// Readable | Writable
154 ///
155 ///
156 /// #### `inconsistent`
157 /// Readable | Writable
158 /// </details>
159 /// <details><summary><h4>Button</h4></summary>
160 ///
161 ///
162 /// #### `always-show-image`
163 /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
164 /// setting and always show the image, if available.
165 ///
166 /// Use this property if the button would be useless or hard to use
167 /// without the image.
168 ///
169 /// Readable | Writable | Construct
170 ///
171 ///
172 /// #### `image`
173 /// The child widget to appear next to the button text.
174 ///
175 /// Readable | Writable
176 ///
177 ///
178 /// #### `image-position`
179 /// The position of the image relative to the text inside the button.
180 ///
181 /// Readable | Writable
182 ///
183 ///
184 /// #### `label`
185 /// Readable | Writable | Construct
186 ///
187 ///
188 /// #### `relief`
189 /// Readable | Writable
190 ///
191 ///
192 /// #### `use-stock`
193 /// Readable | Writable | Construct
194 ///
195 ///
196 /// #### `use-underline`
197 /// Readable | Writable | Construct
198 ///
199 ///
200 /// #### `xalign`
201 /// If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
202 /// can be used to control its horizontal alignment. 0.0 is left aligned,
203 /// 1.0 is right aligned.
204 ///
205 /// Readable | Writable
206 ///
207 ///
208 /// #### `yalign`
209 /// If the child of the button is a [`Misc`][crate::Misc] or `GtkAlignment`, this property
210 /// can be used to control its vertical alignment. 0.0 is top aligned,
211 /// 1.0 is bottom aligned.
212 ///
213 /// Readable | Writable
214 /// </details>
215 /// <details><summary><h4>Container</h4></summary>
216 ///
217 ///
218 /// #### `border-width`
219 /// Readable | Writable
220 ///
221 ///
222 /// #### `child`
223 /// Writable
224 ///
225 ///
226 /// #### `resize-mode`
227 /// Readable | Writable
228 /// </details>
229 /// <details><summary><h4>Widget</h4></summary>
230 ///
231 ///
232 /// #### `app-paintable`
233 /// Readable | Writable
234 ///
235 ///
236 /// #### `can-default`
237 /// Readable | Writable
238 ///
239 ///
240 /// #### `can-focus`
241 /// Readable | Writable
242 ///
243 ///
244 /// #### `composite-child`
245 /// Readable
246 ///
247 ///
248 /// #### `double-buffered`
249 /// Whether the widget is double buffered.
250 ///
251 /// Readable | Writable
252 ///
253 ///
254 /// #### `events`
255 /// Readable | Writable
256 ///
257 ///
258 /// #### `expand`
259 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
260 ///
261 /// Readable | Writable
262 ///
263 ///
264 /// #### `focus-on-click`
265 /// Whether the widget should grab focus when it is clicked with the mouse.
266 ///
267 /// This property is only relevant for widgets that can take focus.
268 ///
269 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
270 /// GtkComboBox) implemented this property individually.
271 ///
272 /// Readable | Writable
273 ///
274 ///
275 /// #### `halign`
276 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
277 ///
278 /// Readable | Writable
279 ///
280 ///
281 /// #### `has-default`
282 /// Readable | Writable
283 ///
284 ///
285 /// #### `has-focus`
286 /// Readable | Writable
287 ///
288 ///
289 /// #### `has-tooltip`
290 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
291 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
292 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
293 /// whether it will provide a tooltip or not.
294 ///
295 /// Note that setting this property to [`true`] for the first time will change
296 /// the event masks of the GdkWindows of this widget to include leave-notify
297 /// and motion-notify events. This cannot and will not be undone when the
298 /// property is set to [`false`] again.
299 ///
300 /// Readable | Writable
301 ///
302 ///
303 /// #### `height-request`
304 /// Readable | Writable
305 ///
306 ///
307 /// #### `hexpand`
308 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
309 ///
310 /// Readable | Writable
311 ///
312 ///
313 /// #### `hexpand-set`
314 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
315 ///
316 /// Readable | Writable
317 ///
318 ///
319 /// #### `is-focus`
320 /// Readable | Writable
321 ///
322 ///
323 /// #### `margin`
324 /// Sets all four sides' margin at once. If read, returns max
325 /// margin on any side.
326 ///
327 /// Readable | Writable
328 ///
329 ///
330 /// #### `margin-bottom`
331 /// Margin on bottom side of widget.
332 ///
333 /// This property adds margin outside of the widget's normal size
334 /// request, the margin will be added in addition to the size from
335 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
336 ///
337 /// Readable | Writable
338 ///
339 ///
340 /// #### `margin-end`
341 /// Margin on end of widget, horizontally. This property supports
342 /// left-to-right and right-to-left text directions.
343 ///
344 /// This property adds margin outside of the widget's normal size
345 /// request, the margin will be added in addition to the size from
346 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
347 ///
348 /// Readable | Writable
349 ///
350 ///
351 /// #### `margin-left`
352 /// Margin on left side of widget.
353 ///
354 /// This property adds margin outside of the widget's normal size
355 /// request, the margin will be added in addition to the size from
356 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
357 ///
358 /// Readable | Writable
359 ///
360 ///
361 /// #### `margin-right`
362 /// Margin on right side of widget.
363 ///
364 /// This property adds margin outside of the widget's normal size
365 /// request, the margin will be added in addition to the size from
366 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
367 ///
368 /// Readable | Writable
369 ///
370 ///
371 /// #### `margin-start`
372 /// Margin on start of widget, horizontally. This property supports
373 /// left-to-right and right-to-left text directions.
374 ///
375 /// This property adds margin outside of the widget's normal size
376 /// request, the margin will be added in addition to the size from
377 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
378 ///
379 /// Readable | Writable
380 ///
381 ///
382 /// #### `margin-top`
383 /// Margin on top side of widget.
384 ///
385 /// This property adds margin outside of the widget's normal size
386 /// request, the margin will be added in addition to the size from
387 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
388 ///
389 /// Readable | Writable
390 ///
391 ///
392 /// #### `name`
393 /// Readable | Writable
394 ///
395 ///
396 /// #### `no-show-all`
397 /// Readable | Writable
398 ///
399 ///
400 /// #### `opacity`
401 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
402 /// more details about window opacity.
403 ///
404 /// Before 3.8 this was only available in GtkWindow
405 ///
406 /// Readable | Writable
407 ///
408 ///
409 /// #### `parent`
410 /// Readable | Writable
411 ///
412 ///
413 /// #### `receives-default`
414 /// Readable | Writable
415 ///
416 ///
417 /// #### `scale-factor`
418 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
419 /// more details about widget scaling.
420 ///
421 /// Readable
422 ///
423 ///
424 /// #### `sensitive`
425 /// Readable | Writable
426 ///
427 ///
428 /// #### `style`
429 /// The style of the widget, which contains information about how it will look (colors, etc).
430 ///
431 /// Readable | Writable
432 ///
433 ///
434 /// #### `tooltip-markup`
435 /// Sets the text of tooltip to be the given string, which is marked up
436 /// with the [Pango text markup language][PangoMarkupFormat].
437 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
438 ///
439 /// This is a convenience property which will take care of getting the
440 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
441 /// will automatically be set to [`true`] and there will be taken care of
442 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
443 ///
444 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
445 /// are set, the last one wins.
446 ///
447 /// Readable | Writable
448 ///
449 ///
450 /// #### `tooltip-text`
451 /// Sets the text of tooltip to be the given string.
452 ///
453 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
454 ///
455 /// This is a convenience property which will take care of getting the
456 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
457 /// will automatically be set to [`true`] and there will be taken care of
458 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
459 ///
460 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
461 /// are set, the last one wins.
462 ///
463 /// Readable | Writable
464 ///
465 ///
466 /// #### `valign`
467 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
468 ///
469 /// Readable | Writable
470 ///
471 ///
472 /// #### `vexpand`
473 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
474 ///
475 /// Readable | Writable
476 ///
477 ///
478 /// #### `vexpand-set`
479 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
480 ///
481 /// Readable | Writable
482 ///
483 ///
484 /// #### `visible`
485 /// Readable | Writable
486 ///
487 ///
488 /// #### `width-request`
489 /// Readable | Writable
490 ///
491 ///
492 /// #### `window`
493 /// The widget's window if it is realized, [`None`] otherwise.
494 ///
495 /// Readable
496 /// </details>
497 /// <details><summary><h4>Actionable</h4></summary>
498 ///
499 ///
500 /// #### `action-name`
501 /// Readable | Writable
502 ///
503 ///
504 /// #### `action-target`
505 /// Readable | Writable
506 /// </details>
507 /// <details><summary><h4>Activatable</h4></summary>
508 ///
509 ///
510 /// #### `related-action`
511 /// call `gtk_activatable_do_set_related_action()` when it changes.
512 ///
513 /// Readable | Writable
514 ///
515 ///
516 /// #### `use-action-appearance`
517 /// widget when it changes.
518 ///
519 /// Readable | Writable
520 /// </details>
521 ///
522 /// # Implements
523 ///
524 /// [`MenuButtonExt`][trait@crate::prelude::MenuButtonExt], [`ToggleButtonExt`][trait@crate::prelude::ToggleButtonExt], [`ButtonExt`][trait@crate::prelude::ButtonExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
525 #[doc(alias = "GtkMenuButton")]
526 pub struct MenuButton(Object<ffi::GtkMenuButton, ffi::GtkMenuButtonClass>) @extends ToggleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable;
527
528 match fn {
529 type_ => || ffi::gtk_menu_button_get_type(),
530 }
531}
532
533impl MenuButton {
534 pub const NONE: Option<&'static MenuButton> = None;
535
536 /// Creates a new [`MenuButton`][crate::MenuButton] widget with downwards-pointing
537 /// arrow as the only child. You can replace the child widget
538 /// with another [`Widget`][crate::Widget] should you wish to.
539 ///
540 /// # Returns
541 ///
542 /// The newly created [`MenuButton`][crate::MenuButton] widget
543 #[doc(alias = "gtk_menu_button_new")]
544 pub fn new() -> MenuButton {
545 assert_initialized_main_thread!();
546 unsafe { Widget::from_glib_none(ffi::gtk_menu_button_new()).unsafe_cast() }
547 }
548
549 // rustdoc-stripper-ignore-next
550 /// Creates a new builder-pattern struct instance to construct [`MenuButton`] objects.
551 ///
552 /// This method returns an instance of [`MenuButtonBuilder`](crate::builders::MenuButtonBuilder) which can be used to create [`MenuButton`] objects.
553 pub fn builder() -> MenuButtonBuilder {
554 MenuButtonBuilder::new()
555 }
556}
557
558impl Default for MenuButton {
559 fn default() -> Self {
560 Self::new()
561 }
562}
563
564// rustdoc-stripper-ignore-next
565/// A [builder-pattern] type to construct [`MenuButton`] objects.
566///
567/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
568#[must_use = "The builder must be built to be used"]
569pub struct MenuButtonBuilder {
570 builder: glib::object::ObjectBuilder<'static, MenuButton>,
571}
572
573impl MenuButtonBuilder {
574 fn new() -> Self {
575 Self {
576 builder: glib::object::Object::builder(),
577 }
578 }
579
580 /// The [`Widget`][crate::Widget] to use to align the menu with.
581 pub fn align_widget(self, align_widget: &impl IsA<Container>) -> Self {
582 Self {
583 builder: self
584 .builder
585 .property("align-widget", align_widget.clone().upcast()),
586 }
587 }
588
589 /// The [`ArrowType`][crate::ArrowType] representing the direction in which the
590 /// menu or popover will be popped out.
591 pub fn direction(self, direction: ArrowType) -> Self {
592 Self {
593 builder: self.builder.property("direction", direction),
594 }
595 }
596
597 /// The [`gio::MenuModel`][crate::gio::MenuModel] from which the popup will be created.
598 /// Depending on the [`use-popover`][struct@crate::MenuButton#use-popover] property, that may
599 /// be a menu or a popover.
600 ///
601 /// See [`MenuButtonExt::set_menu_model()`][crate::prelude::MenuButtonExt::set_menu_model()] for the interaction with the
602 /// [`popup`][struct@crate::MenuButton#popup] property.
603 pub fn menu_model(self, menu_model: &impl IsA<gio::MenuModel>) -> Self {
604 Self {
605 builder: self
606 .builder
607 .property("menu-model", menu_model.clone().upcast()),
608 }
609 }
610
611 /// The [`Popover`][crate::Popover] that will be popped up when the button is clicked.
612 pub fn popover(self, popover: &impl IsA<Popover>) -> Self {
613 Self {
614 builder: self.builder.property("popover", popover.clone().upcast()),
615 }
616 }
617
618 /// The [`Menu`][crate::Menu] that will be popped up when the button is clicked.
619 pub fn popup(self, popup: &impl IsA<Menu>) -> Self {
620 Self {
621 builder: self.builder.property("popup", popup.clone().upcast()),
622 }
623 }
624
625 /// Whether to construct a [`Popover`][crate::Popover] from the menu model,
626 /// or a [`Menu`][crate::Menu].
627 pub fn use_popover(self, use_popover: bool) -> Self {
628 Self {
629 builder: self.builder.property("use-popover", use_popover),
630 }
631 }
632
633 pub fn active(self, active: bool) -> Self {
634 Self {
635 builder: self.builder.property("active", active),
636 }
637 }
638
639 pub fn draw_indicator(self, draw_indicator: bool) -> Self {
640 Self {
641 builder: self.builder.property("draw-indicator", draw_indicator),
642 }
643 }
644
645 pub fn inconsistent(self, inconsistent: bool) -> Self {
646 Self {
647 builder: self.builder.property("inconsistent", inconsistent),
648 }
649 }
650
651 /// If [`true`], the button will ignore the [`gtk-button-images`][struct@crate::Settings#gtk-button-images]
652 /// setting and always show the image, if available.
653 ///
654 /// Use this property if the button would be useless or hard to use
655 /// without the image.
656 pub fn always_show_image(self, always_show_image: bool) -> Self {
657 Self {
658 builder: self
659 .builder
660 .property("always-show-image", always_show_image),
661 }
662 }
663
664 /// The child widget to appear next to the button text.
665 pub fn image(self, image: &impl IsA<Widget>) -> Self {
666 Self {
667 builder: self.builder.property("image", image.clone().upcast()),
668 }
669 }
670
671 /// The position of the image relative to the text inside the button.
672 pub fn image_position(self, image_position: PositionType) -> Self {
673 Self {
674 builder: self.builder.property("image-position", image_position),
675 }
676 }
677
678 pub fn label(self, label: impl Into<glib::GString>) -> Self {
679 Self {
680 builder: self.builder.property("label", label.into()),
681 }
682 }
683
684 pub fn relief(self, relief: ReliefStyle) -> Self {
685 Self {
686 builder: self.builder.property("relief", relief),
687 }
688 }
689
690 pub fn use_underline(self, use_underline: bool) -> Self {
691 Self {
692 builder: self.builder.property("use-underline", use_underline),
693 }
694 }
695
696 pub fn border_width(self, border_width: u32) -> Self {
697 Self {
698 builder: self.builder.property("border-width", border_width),
699 }
700 }
701
702 pub fn child(self, child: &impl IsA<Widget>) -> Self {
703 Self {
704 builder: self.builder.property("child", child.clone().upcast()),
705 }
706 }
707
708 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
709 Self {
710 builder: self.builder.property("resize-mode", resize_mode),
711 }
712 }
713
714 pub fn app_paintable(self, app_paintable: bool) -> Self {
715 Self {
716 builder: self.builder.property("app-paintable", app_paintable),
717 }
718 }
719
720 pub fn can_default(self, can_default: bool) -> Self {
721 Self {
722 builder: self.builder.property("can-default", can_default),
723 }
724 }
725
726 pub fn can_focus(self, can_focus: bool) -> Self {
727 Self {
728 builder: self.builder.property("can-focus", can_focus),
729 }
730 }
731
732 pub fn events(self, events: gdk::EventMask) -> Self {
733 Self {
734 builder: self.builder.property("events", events),
735 }
736 }
737
738 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
739 pub fn expand(self, expand: bool) -> Self {
740 Self {
741 builder: self.builder.property("expand", expand),
742 }
743 }
744
745 /// Whether the widget should grab focus when it is clicked with the mouse.
746 ///
747 /// This property is only relevant for widgets that can take focus.
748 ///
749 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
750 /// GtkComboBox) implemented this property individually.
751 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
752 Self {
753 builder: self.builder.property("focus-on-click", focus_on_click),
754 }
755 }
756
757 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
758 pub fn halign(self, halign: Align) -> Self {
759 Self {
760 builder: self.builder.property("halign", halign),
761 }
762 }
763
764 pub fn has_default(self, has_default: bool) -> Self {
765 Self {
766 builder: self.builder.property("has-default", has_default),
767 }
768 }
769
770 pub fn has_focus(self, has_focus: bool) -> Self {
771 Self {
772 builder: self.builder.property("has-focus", has_focus),
773 }
774 }
775
776 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
777 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
778 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
779 /// whether it will provide a tooltip or not.
780 ///
781 /// Note that setting this property to [`true`] for the first time will change
782 /// the event masks of the GdkWindows of this widget to include leave-notify
783 /// and motion-notify events. This cannot and will not be undone when the
784 /// property is set to [`false`] again.
785 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
786 Self {
787 builder: self.builder.property("has-tooltip", has_tooltip),
788 }
789 }
790
791 pub fn height_request(self, height_request: i32) -> Self {
792 Self {
793 builder: self.builder.property("height-request", height_request),
794 }
795 }
796
797 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
798 pub fn hexpand(self, hexpand: bool) -> Self {
799 Self {
800 builder: self.builder.property("hexpand", hexpand),
801 }
802 }
803
804 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
805 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
806 Self {
807 builder: self.builder.property("hexpand-set", hexpand_set),
808 }
809 }
810
811 pub fn is_focus(self, is_focus: bool) -> Self {
812 Self {
813 builder: self.builder.property("is-focus", is_focus),
814 }
815 }
816
817 /// Sets all four sides' margin at once. If read, returns max
818 /// margin on any side.
819 pub fn margin(self, margin: i32) -> Self {
820 Self {
821 builder: self.builder.property("margin", margin),
822 }
823 }
824
825 /// Margin on bottom side of widget.
826 ///
827 /// This property adds margin outside of the widget's normal size
828 /// request, the margin will be added in addition to the size from
829 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
830 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
831 Self {
832 builder: self.builder.property("margin-bottom", margin_bottom),
833 }
834 }
835
836 /// Margin on end of widget, horizontally. This property supports
837 /// left-to-right and right-to-left text directions.
838 ///
839 /// This property adds margin outside of the widget's normal size
840 /// request, the margin will be added in addition to the size from
841 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
842 pub fn margin_end(self, margin_end: i32) -> Self {
843 Self {
844 builder: self.builder.property("margin-end", margin_end),
845 }
846 }
847
848 /// Margin on start of widget, horizontally. This property supports
849 /// left-to-right and right-to-left text directions.
850 ///
851 /// This property adds margin outside of the widget's normal size
852 /// request, the margin will be added in addition to the size from
853 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
854 pub fn margin_start(self, margin_start: i32) -> Self {
855 Self {
856 builder: self.builder.property("margin-start", margin_start),
857 }
858 }
859
860 /// Margin on top side of widget.
861 ///
862 /// This property adds margin outside of the widget's normal size
863 /// request, the margin will be added in addition to the size from
864 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
865 pub fn margin_top(self, margin_top: i32) -> Self {
866 Self {
867 builder: self.builder.property("margin-top", margin_top),
868 }
869 }
870
871 pub fn name(self, name: impl Into<glib::GString>) -> Self {
872 Self {
873 builder: self.builder.property("name", name.into()),
874 }
875 }
876
877 pub fn no_show_all(self, no_show_all: bool) -> Self {
878 Self {
879 builder: self.builder.property("no-show-all", no_show_all),
880 }
881 }
882
883 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
884 /// more details about window opacity.
885 ///
886 /// Before 3.8 this was only available in GtkWindow
887 pub fn opacity(self, opacity: f64) -> Self {
888 Self {
889 builder: self.builder.property("opacity", opacity),
890 }
891 }
892
893 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
894 Self {
895 builder: self.builder.property("parent", parent.clone().upcast()),
896 }
897 }
898
899 pub fn receives_default(self, receives_default: bool) -> Self {
900 Self {
901 builder: self.builder.property("receives-default", receives_default),
902 }
903 }
904
905 pub fn sensitive(self, sensitive: bool) -> Self {
906 Self {
907 builder: self.builder.property("sensitive", sensitive),
908 }
909 }
910
911 /// Sets the text of tooltip to be the given string, which is marked up
912 /// with the [Pango text markup language][PangoMarkupFormat].
913 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
914 ///
915 /// This is a convenience property which will take care of getting the
916 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
917 /// will automatically be set to [`true`] and there will be taken care of
918 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
919 ///
920 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
921 /// are set, the last one wins.
922 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
923 Self {
924 builder: self
925 .builder
926 .property("tooltip-markup", tooltip_markup.into()),
927 }
928 }
929
930 /// Sets the text of tooltip to be the given string.
931 ///
932 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
933 ///
934 /// This is a convenience property which will take care of getting the
935 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
936 /// will automatically be set to [`true`] and there will be taken care of
937 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
938 ///
939 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
940 /// are set, the last one wins.
941 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
942 Self {
943 builder: self.builder.property("tooltip-text", tooltip_text.into()),
944 }
945 }
946
947 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
948 pub fn valign(self, valign: Align) -> Self {
949 Self {
950 builder: self.builder.property("valign", valign),
951 }
952 }
953
954 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
955 pub fn vexpand(self, vexpand: bool) -> Self {
956 Self {
957 builder: self.builder.property("vexpand", vexpand),
958 }
959 }
960
961 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
962 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
963 Self {
964 builder: self.builder.property("vexpand-set", vexpand_set),
965 }
966 }
967
968 pub fn visible(self, visible: bool) -> Self {
969 Self {
970 builder: self.builder.property("visible", visible),
971 }
972 }
973
974 pub fn width_request(self, width_request: i32) -> Self {
975 Self {
976 builder: self.builder.property("width-request", width_request),
977 }
978 }
979
980 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
981 Self {
982 builder: self.builder.property("action-name", action_name.into()),
983 }
984 }
985
986 pub fn action_target(self, action_target: &glib::Variant) -> Self {
987 Self {
988 builder: self
989 .builder
990 .property("action-target", action_target.clone()),
991 }
992 }
993
994 // rustdoc-stripper-ignore-next
995 /// Build the [`MenuButton`].
996 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
997 pub fn build(self) -> MenuButton {
998 assert_initialized_main_thread!();
999 self.builder.build()
1000 }
1001}
1002
1003/// Trait containing all [`struct@MenuButton`] methods.
1004///
1005/// # Implementors
1006///
1007/// [`MenuButton`][struct@crate::MenuButton]
1008pub trait MenuButtonExt: IsA<MenuButton> + 'static {
1009 /// Returns the parent [`Widget`][crate::Widget] to use to line up with menu.
1010 ///
1011 /// # Returns
1012 ///
1013 /// a [`Widget`][crate::Widget] value or [`None`]
1014 #[doc(alias = "gtk_menu_button_get_align_widget")]
1015 #[doc(alias = "get_align_widget")]
1016 #[doc(alias = "align-widget")]
1017 fn align_widget(&self) -> Option<Widget> {
1018 unsafe {
1019 from_glib_none(ffi::gtk_menu_button_get_align_widget(
1020 self.as_ref().to_glib_none().0,
1021 ))
1022 }
1023 }
1024
1025 /// Returns the direction the popup will be pointing at when popped up.
1026 ///
1027 /// # Returns
1028 ///
1029 /// a [`ArrowType`][crate::ArrowType] value
1030 #[doc(alias = "gtk_menu_button_get_direction")]
1031 #[doc(alias = "get_direction")]
1032 fn direction(&self) -> ArrowType {
1033 unsafe {
1034 from_glib(ffi::gtk_menu_button_get_direction(
1035 self.as_ref().to_glib_none().0,
1036 ))
1037 }
1038 }
1039
1040 /// Returns the [`gio::MenuModel`][crate::gio::MenuModel] used to generate the popup.
1041 ///
1042 /// # Returns
1043 ///
1044 /// a [`gio::MenuModel`][crate::gio::MenuModel] or [`None`]
1045 #[doc(alias = "gtk_menu_button_get_menu_model")]
1046 #[doc(alias = "get_menu_model")]
1047 #[doc(alias = "menu-model")]
1048 fn menu_model(&self) -> Option<gio::MenuModel> {
1049 unsafe {
1050 from_glib_none(ffi::gtk_menu_button_get_menu_model(
1051 self.as_ref().to_glib_none().0,
1052 ))
1053 }
1054 }
1055
1056 /// Returns the [`Popover`][crate::Popover] that pops out of the button.
1057 /// If the button is not using a [`Popover`][crate::Popover], this function
1058 /// returns [`None`].
1059 ///
1060 /// # Returns
1061 ///
1062 /// a [`Popover`][crate::Popover] or [`None`]
1063 #[doc(alias = "gtk_menu_button_get_popover")]
1064 #[doc(alias = "get_popover")]
1065 fn popover(&self) -> Option<Popover> {
1066 unsafe {
1067 from_glib_none(ffi::gtk_menu_button_get_popover(
1068 self.as_ref().to_glib_none().0,
1069 ))
1070 }
1071 }
1072
1073 /// Returns the [`Menu`][crate::Menu] that pops out of the button.
1074 /// If the button does not use a [`Menu`][crate::Menu], this function
1075 /// returns [`None`].
1076 ///
1077 /// # Returns
1078 ///
1079 /// a [`Menu`][crate::Menu] or [`None`]
1080 #[doc(alias = "gtk_menu_button_get_popup")]
1081 #[doc(alias = "get_popup")]
1082 fn popup(&self) -> Option<Menu> {
1083 unsafe {
1084 from_glib_none(ffi::gtk_menu_button_get_popup(
1085 self.as_ref().to_glib_none().0,
1086 ))
1087 }
1088 }
1089
1090 /// Returns whether a [`Popover`][crate::Popover] or a [`Menu`][crate::Menu] will be constructed
1091 /// from the menu model.
1092 ///
1093 /// # Returns
1094 ///
1095 /// [`true`] if using a [`Popover`][crate::Popover]
1096 #[doc(alias = "gtk_menu_button_get_use_popover")]
1097 #[doc(alias = "get_use_popover")]
1098 #[doc(alias = "use-popover")]
1099 fn uses_popover(&self) -> bool {
1100 unsafe {
1101 from_glib(ffi::gtk_menu_button_get_use_popover(
1102 self.as_ref().to_glib_none().0,
1103 ))
1104 }
1105 }
1106
1107 /// Sets the [`Widget`][crate::Widget] to use to line the menu with when popped up.
1108 /// Note that the `align_widget` must contain the [`MenuButton`][crate::MenuButton] itself.
1109 ///
1110 /// Setting it to [`None`] means that the menu will be aligned with the
1111 /// button itself.
1112 ///
1113 /// Note that this property is only used with menus currently,
1114 /// and not for popovers.
1115 /// ## `align_widget`
1116 /// a [`Widget`][crate::Widget]
1117 #[doc(alias = "gtk_menu_button_set_align_widget")]
1118 #[doc(alias = "align-widget")]
1119 fn set_align_widget(&self, align_widget: Option<&impl IsA<Widget>>) {
1120 unsafe {
1121 ffi::gtk_menu_button_set_align_widget(
1122 self.as_ref().to_glib_none().0,
1123 align_widget.map(|p| p.as_ref()).to_glib_none().0,
1124 );
1125 }
1126 }
1127
1128 /// Sets the direction in which the popup will be popped up, as
1129 /// well as changing the arrow’s direction. The child will not
1130 /// be changed to an arrow if it was customized.
1131 ///
1132 /// If the does not fit in the available space in the given direction,
1133 /// GTK+ will its best to keep it inside the screen and fully visible.
1134 ///
1135 /// If you pass [`ArrowType::None`][crate::ArrowType::None] for a `direction`, the popup will behave
1136 /// as if you passed [`ArrowType::Down`][crate::ArrowType::Down] (although you won’t see any arrows).
1137 /// ## `direction`
1138 /// a [`ArrowType`][crate::ArrowType]
1139 #[doc(alias = "gtk_menu_button_set_direction")]
1140 #[doc(alias = "direction")]
1141 fn set_direction(&self, direction: ArrowType) {
1142 unsafe {
1143 ffi::gtk_menu_button_set_direction(
1144 self.as_ref().to_glib_none().0,
1145 direction.into_glib(),
1146 );
1147 }
1148 }
1149
1150 /// Sets the [`gio::MenuModel`][crate::gio::MenuModel] from which the popup will be constructed,
1151 /// or [`None`] to dissociate any existing menu model and disable the button.
1152 ///
1153 /// Depending on the value of [`use-popover`][struct@crate::MenuButton#use-popover], either a
1154 /// [`Menu`][crate::Menu] will be created with [`Menu::from_model()`][crate::Menu::from_model()], or a
1155 /// [`Popover`][crate::Popover] with [`Popover::from_model()`][crate::Popover::from_model()]. In either case,
1156 /// actions will be connected as documented for these functions.
1157 ///
1158 /// If [`popup`][struct@crate::MenuButton#popup] or [`popover`][struct@crate::MenuButton#popover] are already set, those
1159 /// widgets are dissociated from the `self`, and those properties are set
1160 /// to [`None`].
1161 /// ## `menu_model`
1162 /// a [`gio::MenuModel`][crate::gio::MenuModel], or [`None`] to unset and disable the
1163 /// button
1164 #[doc(alias = "gtk_menu_button_set_menu_model")]
1165 #[doc(alias = "menu-model")]
1166 fn set_menu_model(&self, menu_model: Option<&impl IsA<gio::MenuModel>>) {
1167 unsafe {
1168 ffi::gtk_menu_button_set_menu_model(
1169 self.as_ref().to_glib_none().0,
1170 menu_model.map(|p| p.as_ref()).to_glib_none().0,
1171 );
1172 }
1173 }
1174
1175 /// Sets the [`Popover`][crate::Popover] that will be popped up when the `self` is clicked,
1176 /// or [`None`] to dissociate any existing popover and disable the button.
1177 ///
1178 /// If [`menu-model`][struct@crate::MenuButton#menu-model] or [`popup`][struct@crate::MenuButton#popup] are set, those objects
1179 /// are dissociated from the `self`, and those properties are set to [`None`].
1180 /// ## `popover`
1181 /// a [`Popover`][crate::Popover], or [`None`] to unset and disable the button
1182 #[doc(alias = "gtk_menu_button_set_popover")]
1183 #[doc(alias = "popover")]
1184 fn set_popover(&self, popover: Option<&impl IsA<Widget>>) {
1185 unsafe {
1186 ffi::gtk_menu_button_set_popover(
1187 self.as_ref().to_glib_none().0,
1188 popover.map(|p| p.as_ref()).to_glib_none().0,
1189 );
1190 }
1191 }
1192
1193 /// Sets the [`Menu`][crate::Menu] that will be popped up when the `self` is clicked, or
1194 /// [`None`] to dissociate any existing menu and disable the button.
1195 ///
1196 /// If [`menu-model`][struct@crate::MenuButton#menu-model] or [`popover`][struct@crate::MenuButton#popover] are set, those objects
1197 /// are dissociated from the `self`, and those properties are set to [`None`].
1198 /// ## `menu`
1199 /// a [`Menu`][crate::Menu], or [`None`] to unset and disable the button
1200 #[doc(alias = "gtk_menu_button_set_popup")]
1201 #[doc(alias = "popup")]
1202 fn set_popup(&self, menu: Option<&impl IsA<Widget>>) {
1203 unsafe {
1204 ffi::gtk_menu_button_set_popup(
1205 self.as_ref().to_glib_none().0,
1206 menu.map(|p| p.as_ref()).to_glib_none().0,
1207 );
1208 }
1209 }
1210
1211 /// Sets whether to construct a [`Popover`][crate::Popover] instead of [`Menu`][crate::Menu]
1212 /// when [`set_menu_model()`][Self::set_menu_model()] is called. Note that
1213 /// this property is only consulted when a new menu model is set.
1214 /// ## `use_popover`
1215 /// [`true`] to construct a popover from the menu model
1216 #[doc(alias = "gtk_menu_button_set_use_popover")]
1217 #[doc(alias = "use-popover")]
1218 fn set_use_popover(&self, use_popover: bool) {
1219 unsafe {
1220 ffi::gtk_menu_button_set_use_popover(
1221 self.as_ref().to_glib_none().0,
1222 use_popover.into_glib(),
1223 );
1224 }
1225 }
1226
1227 #[doc(alias = "align-widget")]
1228 fn connect_align_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1229 unsafe extern "C" fn notify_align_widget_trampoline<
1230 P: IsA<MenuButton>,
1231 F: Fn(&P) + 'static,
1232 >(
1233 this: *mut ffi::GtkMenuButton,
1234 _param_spec: glib::ffi::gpointer,
1235 f: glib::ffi::gpointer,
1236 ) {
1237 unsafe {
1238 let f: &F = &*(f as *const F);
1239 f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1240 }
1241 }
1242 unsafe {
1243 let f: Box_<F> = Box_::new(f);
1244 connect_raw(
1245 self.as_ptr() as *mut _,
1246 c"notify::align-widget".as_ptr(),
1247 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1248 notify_align_widget_trampoline::<Self, F> as *const (),
1249 )),
1250 Box_::into_raw(f),
1251 )
1252 }
1253 }
1254
1255 #[doc(alias = "direction")]
1256 fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1257 unsafe extern "C" fn notify_direction_trampoline<
1258 P: IsA<MenuButton>,
1259 F: Fn(&P) + 'static,
1260 >(
1261 this: *mut ffi::GtkMenuButton,
1262 _param_spec: glib::ffi::gpointer,
1263 f: glib::ffi::gpointer,
1264 ) {
1265 unsafe {
1266 let f: &F = &*(f as *const F);
1267 f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1268 }
1269 }
1270 unsafe {
1271 let f: Box_<F> = Box_::new(f);
1272 connect_raw(
1273 self.as_ptr() as *mut _,
1274 c"notify::direction".as_ptr(),
1275 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1276 notify_direction_trampoline::<Self, F> as *const (),
1277 )),
1278 Box_::into_raw(f),
1279 )
1280 }
1281 }
1282
1283 #[doc(alias = "menu-model")]
1284 fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1285 unsafe extern "C" fn notify_menu_model_trampoline<
1286 P: IsA<MenuButton>,
1287 F: Fn(&P) + 'static,
1288 >(
1289 this: *mut ffi::GtkMenuButton,
1290 _param_spec: glib::ffi::gpointer,
1291 f: glib::ffi::gpointer,
1292 ) {
1293 unsafe {
1294 let f: &F = &*(f as *const F);
1295 f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1296 }
1297 }
1298 unsafe {
1299 let f: Box_<F> = Box_::new(f);
1300 connect_raw(
1301 self.as_ptr() as *mut _,
1302 c"notify::menu-model".as_ptr(),
1303 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1304 notify_menu_model_trampoline::<Self, F> as *const (),
1305 )),
1306 Box_::into_raw(f),
1307 )
1308 }
1309 }
1310
1311 #[doc(alias = "popover")]
1312 fn connect_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1313 unsafe extern "C" fn notify_popover_trampoline<P: IsA<MenuButton>, F: Fn(&P) + 'static>(
1314 this: *mut ffi::GtkMenuButton,
1315 _param_spec: glib::ffi::gpointer,
1316 f: glib::ffi::gpointer,
1317 ) {
1318 unsafe {
1319 let f: &F = &*(f as *const F);
1320 f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1321 }
1322 }
1323 unsafe {
1324 let f: Box_<F> = Box_::new(f);
1325 connect_raw(
1326 self.as_ptr() as *mut _,
1327 c"notify::popover".as_ptr(),
1328 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1329 notify_popover_trampoline::<Self, F> as *const (),
1330 )),
1331 Box_::into_raw(f),
1332 )
1333 }
1334 }
1335
1336 #[doc(alias = "popup")]
1337 fn connect_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1338 unsafe extern "C" fn notify_popup_trampoline<P: IsA<MenuButton>, F: Fn(&P) + 'static>(
1339 this: *mut ffi::GtkMenuButton,
1340 _param_spec: glib::ffi::gpointer,
1341 f: glib::ffi::gpointer,
1342 ) {
1343 unsafe {
1344 let f: &F = &*(f as *const F);
1345 f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1346 }
1347 }
1348 unsafe {
1349 let f: Box_<F> = Box_::new(f);
1350 connect_raw(
1351 self.as_ptr() as *mut _,
1352 c"notify::popup".as_ptr(),
1353 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1354 notify_popup_trampoline::<Self, F> as *const (),
1355 )),
1356 Box_::into_raw(f),
1357 )
1358 }
1359 }
1360
1361 #[doc(alias = "use-popover")]
1362 fn connect_use_popover_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1363 unsafe extern "C" fn notify_use_popover_trampoline<
1364 P: IsA<MenuButton>,
1365 F: Fn(&P) + 'static,
1366 >(
1367 this: *mut ffi::GtkMenuButton,
1368 _param_spec: glib::ffi::gpointer,
1369 f: glib::ffi::gpointer,
1370 ) {
1371 unsafe {
1372 let f: &F = &*(f as *const F);
1373 f(MenuButton::from_glib_borrow(this).unsafe_cast_ref())
1374 }
1375 }
1376 unsafe {
1377 let f: Box_<F> = Box_::new(f);
1378 connect_raw(
1379 self.as_ptr() as *mut _,
1380 c"notify::use-popover".as_ptr(),
1381 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1382 notify_use_popover_trampoline::<Self, F> as *const (),
1383 )),
1384 Box_::into_raw(f),
1385 )
1386 }
1387 }
1388}
1389
1390impl<O: IsA<MenuButton>> MenuButtonExt for O {}