gtk/auto/menu_tool_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, Bin, Buildable, Container, Menu, ResizeMode, ToolButton, ToolItem, Widget,
7 ffi,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 ///
19 /// ]|
20 ///
21 /// ## Properties
22 ///
23 ///
24 /// #### `menu`
25 /// Readable | Writable
26 /// <details><summary><h4>ToolButton</h4></summary>
27 ///
28 ///
29 /// #### `icon-name`
30 /// The name of the themed icon displayed on the item.
31 /// This property only has an effect if not overridden by
32 /// [`label-widget`][struct@crate::ToolButton#label-widget], [`icon-widget`][struct@crate::ToolButton#icon-widget] or
33 /// [`stock-id`][struct@crate::ToolButton#stock-id] properties.
34 ///
35 /// Readable | Writable
36 ///
37 ///
38 /// #### `icon-widget`
39 /// Readable | Writable
40 ///
41 ///
42 /// #### `label`
43 /// Readable | Writable
44 ///
45 ///
46 /// #### `label-widget`
47 /// Readable | Writable
48 ///
49 ///
50 /// #### `stock-id`
51 /// Readable | Writable
52 ///
53 ///
54 /// #### `use-underline`
55 /// Readable | Writable
56 /// </details>
57 /// <details><summary><h4>ToolItem</h4></summary>
58 ///
59 ///
60 /// #### `is-important`
61 /// Readable | Writable
62 ///
63 ///
64 /// #### `visible-horizontal`
65 /// Readable | Writable
66 ///
67 ///
68 /// #### `visible-vertical`
69 /// Readable | Writable
70 /// </details>
71 /// <details><summary><h4>Container</h4></summary>
72 ///
73 ///
74 /// #### `border-width`
75 /// Readable | Writable
76 ///
77 ///
78 /// #### `child`
79 /// Writable
80 ///
81 ///
82 /// #### `resize-mode`
83 /// Readable | Writable
84 /// </details>
85 /// <details><summary><h4>Widget</h4></summary>
86 ///
87 ///
88 /// #### `app-paintable`
89 /// Readable | Writable
90 ///
91 ///
92 /// #### `can-default`
93 /// Readable | Writable
94 ///
95 ///
96 /// #### `can-focus`
97 /// Readable | Writable
98 ///
99 ///
100 /// #### `composite-child`
101 /// Readable
102 ///
103 ///
104 /// #### `double-buffered`
105 /// Whether the widget is double buffered.
106 ///
107 /// Readable | Writable
108 ///
109 ///
110 /// #### `events`
111 /// Readable | Writable
112 ///
113 ///
114 /// #### `expand`
115 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
116 ///
117 /// Readable | Writable
118 ///
119 ///
120 /// #### `focus-on-click`
121 /// Whether the widget should grab focus when it is clicked with the mouse.
122 ///
123 /// This property is only relevant for widgets that can take focus.
124 ///
125 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
126 /// GtkComboBox) implemented this property individually.
127 ///
128 /// Readable | Writable
129 ///
130 ///
131 /// #### `halign`
132 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
133 ///
134 /// Readable | Writable
135 ///
136 ///
137 /// #### `has-default`
138 /// Readable | Writable
139 ///
140 ///
141 /// #### `has-focus`
142 /// Readable | Writable
143 ///
144 ///
145 /// #### `has-tooltip`
146 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
147 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
148 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
149 /// whether it will provide a tooltip or not.
150 ///
151 /// Note that setting this property to [`true`] for the first time will change
152 /// the event masks of the GdkWindows of this widget to include leave-notify
153 /// and motion-notify events. This cannot and will not be undone when the
154 /// property is set to [`false`] again.
155 ///
156 /// Readable | Writable
157 ///
158 ///
159 /// #### `height-request`
160 /// Readable | Writable
161 ///
162 ///
163 /// #### `hexpand`
164 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
165 ///
166 /// Readable | Writable
167 ///
168 ///
169 /// #### `hexpand-set`
170 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
171 ///
172 /// Readable | Writable
173 ///
174 ///
175 /// #### `is-focus`
176 /// Readable | Writable
177 ///
178 ///
179 /// #### `margin`
180 /// Sets all four sides' margin at once. If read, returns max
181 /// margin on any side.
182 ///
183 /// Readable | Writable
184 ///
185 ///
186 /// #### `margin-bottom`
187 /// Margin on bottom side of widget.
188 ///
189 /// This property adds margin outside of the widget's normal size
190 /// request, the margin will be added in addition to the size from
191 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
192 ///
193 /// Readable | Writable
194 ///
195 ///
196 /// #### `margin-end`
197 /// Margin on end of widget, horizontally. This property supports
198 /// left-to-right and right-to-left text directions.
199 ///
200 /// This property adds margin outside of the widget's normal size
201 /// request, the margin will be added in addition to the size from
202 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
203 ///
204 /// Readable | Writable
205 ///
206 ///
207 /// #### `margin-left`
208 /// Margin on left side of widget.
209 ///
210 /// This property adds margin outside of the widget's normal size
211 /// request, the margin will be added in addition to the size from
212 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
213 ///
214 /// Readable | Writable
215 ///
216 ///
217 /// #### `margin-right`
218 /// Margin on right side of widget.
219 ///
220 /// This property adds margin outside of the widget's normal size
221 /// request, the margin will be added in addition to the size from
222 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
223 ///
224 /// Readable | Writable
225 ///
226 ///
227 /// #### `margin-start`
228 /// Margin on start of widget, horizontally. This property supports
229 /// left-to-right and right-to-left text directions.
230 ///
231 /// This property adds margin outside of the widget's normal size
232 /// request, the margin will be added in addition to the size from
233 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
234 ///
235 /// Readable | Writable
236 ///
237 ///
238 /// #### `margin-top`
239 /// Margin on top side of widget.
240 ///
241 /// This property adds margin outside of the widget's normal size
242 /// request, the margin will be added in addition to the size from
243 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
244 ///
245 /// Readable | Writable
246 ///
247 ///
248 /// #### `name`
249 /// Readable | Writable
250 ///
251 ///
252 /// #### `no-show-all`
253 /// Readable | Writable
254 ///
255 ///
256 /// #### `opacity`
257 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
258 /// more details about window opacity.
259 ///
260 /// Before 3.8 this was only available in GtkWindow
261 ///
262 /// Readable | Writable
263 ///
264 ///
265 /// #### `parent`
266 /// Readable | Writable
267 ///
268 ///
269 /// #### `receives-default`
270 /// Readable | Writable
271 ///
272 ///
273 /// #### `scale-factor`
274 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
275 /// more details about widget scaling.
276 ///
277 /// Readable
278 ///
279 ///
280 /// #### `sensitive`
281 /// Readable | Writable
282 ///
283 ///
284 /// #### `style`
285 /// The style of the widget, which contains information about how it will look (colors, etc).
286 ///
287 /// Readable | Writable
288 ///
289 ///
290 /// #### `tooltip-markup`
291 /// Sets the text of tooltip to be the given string, which is marked up
292 /// with the [Pango text markup language][PangoMarkupFormat].
293 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
294 ///
295 /// This is a convenience property which will take care of getting the
296 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
297 /// will automatically be set to [`true`] and there will be taken care of
298 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
299 ///
300 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
301 /// are set, the last one wins.
302 ///
303 /// Readable | Writable
304 ///
305 ///
306 /// #### `tooltip-text`
307 /// Sets the text of tooltip to be the given string.
308 ///
309 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
310 ///
311 /// This is a convenience property which will take care of getting the
312 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
313 /// will automatically be set to [`true`] and there will be taken care of
314 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
315 ///
316 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
317 /// are set, the last one wins.
318 ///
319 /// Readable | Writable
320 ///
321 ///
322 /// #### `valign`
323 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
324 ///
325 /// Readable | Writable
326 ///
327 ///
328 /// #### `vexpand`
329 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
330 ///
331 /// Readable | Writable
332 ///
333 ///
334 /// #### `vexpand-set`
335 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
336 ///
337 /// Readable | Writable
338 ///
339 ///
340 /// #### `visible`
341 /// Readable | Writable
342 ///
343 ///
344 /// #### `width-request`
345 /// Readable | Writable
346 ///
347 ///
348 /// #### `window`
349 /// The widget's window if it is realized, [`None`] otherwise.
350 ///
351 /// Readable
352 /// </details>
353 /// <details><summary><h4>Activatable</h4></summary>
354 ///
355 ///
356 /// #### `related-action`
357 /// call `gtk_activatable_do_set_related_action()` when it changes.
358 ///
359 /// Readable | Writable
360 ///
361 ///
362 /// #### `use-action-appearance`
363 /// widget when it changes.
364 ///
365 /// Readable | Writable
366 /// </details>
367 /// <details><summary><h4>Actionable</h4></summary>
368 ///
369 ///
370 /// #### `action-name`
371 /// Readable | Writable
372 ///
373 ///
374 /// #### `action-target`
375 /// Readable | Writable
376 /// </details>
377 ///
378 /// ## Signals
379 ///
380 ///
381 /// #### `show-menu`
382 /// The ::show-menu signal is emitted before the menu is shown.
383 ///
384 /// It can be used to populate the menu on demand, using
385 /// [`MenuToolButtonExt::set_menu()`][crate::prelude::MenuToolButtonExt::set_menu()].
386 ///
387 /// Note that even if you populate the menu dynamically in this way,
388 /// you must set an empty menu on the [`MenuToolButton`][crate::MenuToolButton] beforehand,
389 /// since the arrow is made insensitive if the menu is not set.
390 ///
391 ///
392 /// <details><summary><h4>ToolButton</h4></summary>
393 ///
394 ///
395 /// #### `clicked`
396 /// This signal is emitted when the tool button is clicked with the mouse
397 /// or activated with the keyboard.
398 ///
399 /// Action
400 /// </details>
401 /// <details><summary><h4>ToolItem</h4></summary>
402 ///
403 ///
404 /// #### `create-menu-proxy`
405 /// This signal is emitted when the toolbar needs information from `tool_item`
406 /// about whether the item should appear in the toolbar overflow menu. In
407 /// response the tool item should either
408 ///
409 /// - call [`ToolItemExt::set_proxy_menu_item()`][crate::prelude::ToolItemExt::set_proxy_menu_item()] with a [`None`]
410 /// pointer and return [`true`] to indicate that the item should not appear
411 /// in the overflow menu
412 ///
413 /// - call [`ToolItemExt::set_proxy_menu_item()`][crate::prelude::ToolItemExt::set_proxy_menu_item()] with a new menu
414 /// item and return [`true`], or
415 ///
416 /// - return [`false`] to indicate that the signal was not handled by the item.
417 /// This means that the item will not appear in the overflow menu unless
418 /// a later handler installs a menu item.
419 ///
420 /// The toolbar may cache the result of this signal. When the tool item changes
421 /// how it will respond to this signal it must call [`ToolItemExt::rebuild_menu()`][crate::prelude::ToolItemExt::rebuild_menu()]
422 /// to invalidate the cache and ensure that the toolbar rebuilds its overflow
423 /// menu.
424 ///
425 ///
426 ///
427 ///
428 /// #### `toolbar-reconfigured`
429 /// This signal is emitted when some property of the toolbar that the
430 /// item is a child of changes. For custom subclasses of [`ToolItem`][crate::ToolItem],
431 /// the default handler of this signal use the functions
432 /// - [`ToolShellExt::orientation()`][crate::prelude::ToolShellExt::orientation()]
433 /// - [`ToolShellExt::style()`][crate::prelude::ToolShellExt::style()]
434 /// - [`ToolShellExt::icon_size()`][crate::prelude::ToolShellExt::icon_size()]
435 /// - [`ToolShellExt::relief_style()`][crate::prelude::ToolShellExt::relief_style()]
436 /// to find out what the toolbar should look like and change
437 /// themselves accordingly.
438 ///
439 ///
440 /// </details>
441 /// <details><summary><h4>Container</h4></summary>
442 ///
443 ///
444 /// #### `add`
445 ///
446 ///
447 ///
448 /// #### `check-resize`
449 ///
450 ///
451 ///
452 /// #### `remove`
453 ///
454 ///
455 ///
456 /// #### `set-focus-child`
457 ///
458 /// </details>
459 /// <details><summary><h4>Widget</h4></summary>
460 ///
461 ///
462 /// #### `accel-closures-changed`
463 ///
464 ///
465 ///
466 /// #### `button-press-event`
467 /// The ::button-press-event signal will be emitted when a button
468 /// (typically from a mouse) is pressed.
469 ///
470 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
471 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
472 ///
473 /// This signal will be sent to the grab widget if there is one.
474 ///
475 ///
476 ///
477 ///
478 /// #### `button-release-event`
479 /// The ::button-release-event signal will be emitted when a button
480 /// (typically from a mouse) is released.
481 ///
482 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
483 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
484 ///
485 /// This signal will be sent to the grab widget if there is one.
486 ///
487 ///
488 ///
489 ///
490 /// #### `can-activate-accel`
491 /// Determines whether an accelerator that activates the signal
492 /// identified by `signal_id` can currently be activated.
493 /// This signal is present to allow applications and derived
494 /// widgets to override the default [`Widget`][crate::Widget] handling
495 /// for determining whether an accelerator can be activated.
496 ///
497 ///
498 ///
499 ///
500 /// #### `child-notify`
501 /// The ::child-notify signal is emitted for each
502 /// [child property][child-properties] that has
503 /// changed on an object. The signal's detail holds the property name.
504 ///
505 /// Detailed
506 ///
507 ///
508 /// #### `composited-changed`
509 /// The ::composited-changed signal is emitted when the composited
510 /// status of `widgets` screen changes.
511 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
512 ///
513 /// Action
514 ///
515 ///
516 /// #### `configure-event`
517 /// The ::configure-event signal will be emitted when the size, position or
518 /// stacking of the `widget`'s window has changed.
519 ///
520 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
521 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
522 /// automatically for all new windows.
523 ///
524 ///
525 ///
526 ///
527 /// #### `damage-event`
528 /// Emitted when a redirected window belonging to `widget` gets drawn into.
529 /// The region/area members of the event shows what area of the redirected
530 /// drawable was drawn into.
531 ///
532 ///
533 ///
534 ///
535 /// #### `delete-event`
536 /// The ::delete-event signal is emitted if a user requests that
537 /// a toplevel window is closed. The default handler for this signal
538 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
539 /// this signal will cause the window to be hidden instead, so that
540 /// it can later be shown again without reconstructing it.
541 ///
542 ///
543 ///
544 ///
545 /// #### `destroy`
546 /// Signals that all holders of a reference to the widget should release
547 /// the reference that they hold. May result in finalization of the widget
548 /// if all references are released.
549 ///
550 /// This signal is not suitable for saving widget state.
551 ///
552 ///
553 ///
554 ///
555 /// #### `destroy-event`
556 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
557 /// You rarely get this signal, because most widgets disconnect themselves
558 /// from their window before they destroy it, so no widget owns the
559 /// window at destroy time.
560 ///
561 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
562 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
563 /// automatically for all new windows.
564 ///
565 ///
566 ///
567 ///
568 /// #### `direction-changed`
569 /// The ::direction-changed signal is emitted when the text direction
570 /// of a widget changes.
571 ///
572 ///
573 ///
574 ///
575 /// #### `drag-begin`
576 /// The ::drag-begin signal is emitted on the drag source when a drag is
577 /// started. A typical reason to connect to this signal is to set up a
578 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
579 ///
580 /// Note that some widgets set up a drag icon in the default handler of
581 /// this signal, so you may have to use `g_signal_connect_after()` to
582 /// override what the default handler did.
583 ///
584 ///
585 ///
586 ///
587 /// #### `drag-data-delete`
588 /// The ::drag-data-delete signal is emitted on the drag source when a drag
589 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
590 /// handler is responsible for deleting the data that has been dropped. What
591 /// "delete" means depends on the context of the drag operation.
592 ///
593 ///
594 ///
595 ///
596 /// #### `drag-data-get`
597 /// The ::drag-data-get signal is emitted on the drag source when the drop
598 /// site requests the data which is dragged. It is the responsibility of
599 /// the signal handler to fill `data` with the data in the format which
600 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
601 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
602 ///
603 ///
604 ///
605 ///
606 /// #### `drag-data-received`
607 /// format == 8))
608 /// {
609 /// GdkDragAction action;
610 ///
611 /// // handle data here
612 ///
613 /// action = gdk_drag_context_get_selected_action (context);
614 /// if (action == GDK_ACTION_ASK)
615 /// {
616 /// GtkWidget *dialog;
617 /// gint response;
618 ///
619 /// dialog = gtk_message_dialog_new (NULL,
620 /// GTK_DIALOG_MODAL |
621 /// GTK_DIALOG_DESTROY_WITH_PARENT,
622 /// GTK_MESSAGE_INFO,
623 /// GTK_BUTTONS_YES_NO,
624 /// "Move the data ?\n");
625 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
626 /// gtk_widget_destroy (dialog);
627 ///
628 /// if (response == GTK_RESPONSE_YES)
629 /// action = GDK_ACTION_MOVE;
630 /// else
631 /// action = GDK_ACTION_COPY;
632 /// }
633 ///
634 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
635 /// }
636 /// else
637 /// gtk_drag_finish (context, FALSE, FALSE, time);
638 /// }
639 /// ]|
640 ///
641 ///
642 ///
643 ///
644 /// #### `drag-drop`
645 /// The ::drag-drop signal is emitted on the drop site when the user drops
646 /// the data onto the widget. The signal handler must determine whether
647 /// the cursor position is in a drop zone or not. If it is not in a drop
648 /// zone, it returns [`false`] and no further processing is necessary.
649 /// Otherwise, the handler returns [`true`]. In this case, the handler must
650 /// ensure that `gtk_drag_finish()` is called to let the source know that
651 /// the drop is done. The call to `gtk_drag_finish()` can be done either
652 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
653 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
654 /// or more of the supported targets.
655 ///
656 ///
657 ///
658 ///
659 /// #### `drag-end`
660 /// The ::drag-end signal is emitted on the drag source when a drag is
661 /// finished. A typical reason to connect to this signal is to undo
662 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
663 ///
664 ///
665 ///
666 ///
667 /// #### `drag-failed`
668 /// The ::drag-failed signal is emitted on the drag source when a drag has
669 /// failed. The signal handler may hook custom code to handle a failed DnD
670 /// operation based on the type of error, it returns [`true`] is the failure has
671 /// been already handled (not showing the default "drag operation failed"
672 /// animation), otherwise it returns [`false`].
673 ///
674 ///
675 ///
676 ///
677 /// #### `drag-leave`
678 /// The ::drag-leave signal is emitted on the drop site when the cursor
679 /// leaves the widget. A typical reason to connect to this signal is to
680 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
681 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
682 ///
683 ///
684 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
685 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
686 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
687 ///
688 ///
689 ///
690 ///
691 /// #### `drag-motion`
692 /// suggested_action,
693 /// time);
694 /// }
695 /// else
696 /// {
697 /// // accept the drop
698 /// }
699 /// }
700 /// ]|
701 ///
702 ///
703 ///
704 ///
705 /// #### `draw`
706 /// This signal is emitted when a widget is supposed to render itself.
707 /// The `widget`'s top left corner must be painted at the origin of
708 /// the passed in context and be sized to the values returned by
709 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
710 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
711 ///
712 /// Signal handlers connected to this signal can modify the cairo
713 /// context passed as `cr` in any way they like and don't need to
714 /// restore it. The signal emission takes care of calling `cairo_save()`
715 /// before and `cairo_restore()` after invoking the handler.
716 ///
717 /// The signal handler will get a `cr` with a clip region already set to the
718 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
719 /// widgets that want to avoid redrawing themselves completely can get the full
720 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
721 /// get a finer-grained representation of the dirty region with
722 /// `cairo_copy_clip_rectangle_list()`.
723 ///
724 ///
725 ///
726 ///
727 /// #### `enter-notify-event`
728 /// The ::enter-notify-event will be emitted when the pointer enters
729 /// the `widget`'s window.
730 ///
731 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
732 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
733 ///
734 /// This signal will be sent to the grab widget if there is one.
735 ///
736 ///
737 ///
738 ///
739 /// #### `event`
740 /// The GTK+ main loop will emit three signals for each GDK event delivered
741 /// to a widget: one generic ::event signal, another, more specific,
742 /// signal that matches the type of event delivered (e.g.
743 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
744 /// [`event-after`][struct@crate::Widget#event-after] signal.
745 ///
746 ///
747 ///
748 ///
749 /// #### `event-after`
750 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
751 /// the second more specific signal, ::event-after will be emitted
752 /// regardless of the previous two signals handlers return values.
753 ///
754 ///
755 ///
756 ///
757 /// #### `focus`
758 ///
759 ///
760 ///
761 /// #### `focus-in-event`
762 /// The ::focus-in-event signal will be emitted when the keyboard focus
763 /// enters the `widget`'s window.
764 ///
765 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
766 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
767 ///
768 ///
769 ///
770 ///
771 /// #### `focus-out-event`
772 /// The ::focus-out-event signal will be emitted when the keyboard focus
773 /// leaves the `widget`'s window.
774 ///
775 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
776 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
777 ///
778 ///
779 ///
780 ///
781 /// #### `grab-broken-event`
782 /// Emitted when a pointer or keyboard grab on a window belonging
783 /// to `widget` gets broken.
784 ///
785 /// On X11, this happens when the grab window becomes unviewable
786 /// (i.e. it or one of its ancestors is unmapped), or if the same
787 /// application grabs the pointer or keyboard again.
788 ///
789 ///
790 ///
791 ///
792 /// #### `grab-focus`
793 /// Action
794 ///
795 ///
796 /// #### `grab-notify`
797 /// The ::grab-notify signal is emitted when a widget becomes
798 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
799 /// another widget, or when it becomes unshadowed due to a grab
800 /// being removed.
801 ///
802 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
803 /// grab widget in the grab stack of its window group is not
804 /// its ancestor.
805 ///
806 ///
807 ///
808 ///
809 /// #### `hide`
810 /// The ::hide signal is emitted when `widget` is hidden, for example with
811 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
812 ///
813 ///
814 ///
815 ///
816 /// #### `hierarchy-changed`
817 /// The ::hierarchy-changed signal is emitted when the
818 /// anchored state of a widget changes. A widget is
819 /// “anchored” when its toplevel
820 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
821 /// a widget changes from un-anchored to anchored or vice-versa.
822 ///
823 ///
824 ///
825 ///
826 /// #### `key-press-event`
827 /// The ::key-press-event signal is emitted when a key is pressed. The signal
828 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
829 ///
830 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
831 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
832 ///
833 /// This signal will be sent to the grab widget if there is one.
834 ///
835 ///
836 ///
837 ///
838 /// #### `key-release-event`
839 /// The ::key-release-event signal is emitted when a key is released.
840 ///
841 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
842 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
843 ///
844 /// This signal will be sent to the grab widget if there is one.
845 ///
846 ///
847 ///
848 ///
849 /// #### `keynav-failed`
850 /// Gets emitted if keyboard navigation fails.
851 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
852 ///
853 ///
854 ///
855 ///
856 /// #### `leave-notify-event`
857 /// The ::leave-notify-event will be emitted when the pointer leaves
858 /// the `widget`'s window.
859 ///
860 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
861 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
862 ///
863 /// This signal will be sent to the grab widget if there is one.
864 ///
865 ///
866 ///
867 ///
868 /// #### `map`
869 /// The ::map signal is emitted when `widget` is going to be mapped, that is
870 /// when the widget is visible (which is controlled with
871 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
872 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
873 /// be emitted.
874 ///
875 /// The ::map signal can be used to determine whether a widget will be drawn,
876 /// for instance it can resume an animation that was stopped during the
877 /// emission of [`unmap`][struct@crate::Widget#unmap].
878 ///
879 ///
880 ///
881 ///
882 /// #### `map-event`
883 /// The ::map-event signal will be emitted when the `widget`'s window is
884 /// mapped. A window is mapped when it becomes visible on the screen.
885 ///
886 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
887 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
888 /// automatically for all new windows.
889 ///
890 ///
891 ///
892 ///
893 /// #### `mnemonic-activate`
894 /// The default handler for this signal activates `widget` if `group_cycling`
895 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
896 ///
897 ///
898 ///
899 ///
900 /// #### `motion-notify-event`
901 /// The ::motion-notify-event signal is emitted when the pointer moves
902 /// over the widget's [`gdk::Window`][crate::gdk::Window].
903 ///
904 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
905 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
906 ///
907 /// This signal will be sent to the grab widget if there is one.
908 ///
909 ///
910 ///
911 ///
912 /// #### `move-focus`
913 /// Action
914 ///
915 ///
916 /// #### `parent-set`
917 /// The ::parent-set signal is emitted when a new parent
918 /// has been set on a widget.
919 ///
920 ///
921 ///
922 ///
923 /// #### `popup-menu`
924 /// This signal gets emitted whenever a widget should pop up a context
925 /// menu. This usually happens through the standard key binding mechanism;
926 /// by pressing a certain key while a widget is focused, the user can cause
927 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
928 /// a menu with clipboard commands. See the
929 /// [Popup Menu Migration Checklist][checklist-popup-menu]
930 /// for an example of how to use this signal.
931 ///
932 /// Action
933 ///
934 ///
935 /// #### `property-notify-event`
936 /// The ::property-notify-event signal will be emitted when a property on
937 /// the `widget`'s window has been changed or deleted.
938 ///
939 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
940 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
941 ///
942 ///
943 ///
944 ///
945 /// #### `proximity-in-event`
946 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
947 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
948 ///
949 /// This signal will be sent to the grab widget if there is one.
950 ///
951 ///
952 ///
953 ///
954 /// #### `proximity-out-event`
955 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
956 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
957 ///
958 /// This signal will be sent to the grab widget if there is one.
959 ///
960 ///
961 ///
962 ///
963 /// #### `query-tooltip`
964 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
965 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
966 /// focus in keyboard mode.
967 ///
968 /// Using the given coordinates, the signal handler should determine
969 /// whether a tooltip should be shown for `widget`. If this is the case
970 /// [`true`] should be returned, [`false`] otherwise. Note that if
971 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
972 /// should not be used.
973 ///
974 /// The signal handler is free to manipulate `tooltip` with the therefore
975 /// destined function calls.
976 ///
977 ///
978 ///
979 ///
980 /// #### `realize`
981 /// The ::realize signal is emitted when `widget` is associated with a
982 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
983 /// widget has been mapped (that is, it is going to be drawn).
984 ///
985 ///
986 ///
987 ///
988 /// #### `screen-changed`
989 /// The ::screen-changed signal gets emitted when the
990 /// screen of a widget has changed.
991 ///
992 ///
993 ///
994 ///
995 /// #### `scroll-event`
996 /// The ::scroll-event signal is emitted when a button in the 4 to 7
997 /// range is pressed. Wheel mice are usually configured to generate
998 /// button press events for buttons 4 and 5 when the wheel is turned.
999 ///
1000 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1001 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1002 ///
1003 /// This signal will be sent to the grab widget if there is one.
1004 ///
1005 ///
1006 ///
1007 ///
1008 /// #### `selection-clear-event`
1009 /// The ::selection-clear-event signal will be emitted when the
1010 /// the `widget`'s window has lost ownership of a selection.
1011 ///
1012 ///
1013 ///
1014 ///
1015 /// #### `selection-get`
1016 ///
1017 ///
1018 ///
1019 /// #### `selection-notify-event`
1020 ///
1021 ///
1022 ///
1023 /// #### `selection-received`
1024 ///
1025 ///
1026 ///
1027 /// #### `selection-request-event`
1028 /// The ::selection-request-event signal will be emitted when
1029 /// another client requests ownership of the selection owned by
1030 /// the `widget`'s window.
1031 ///
1032 ///
1033 ///
1034 ///
1035 /// #### `show`
1036 /// The ::show signal is emitted when `widget` is shown, for example with
1037 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1038 ///
1039 ///
1040 ///
1041 ///
1042 /// #### `show-help`
1043 /// Action
1044 ///
1045 ///
1046 /// #### `size-allocate`
1047 ///
1048 ///
1049 ///
1050 /// #### `state-changed`
1051 /// The ::state-changed signal is emitted when the widget state changes.
1052 /// See `gtk_widget_get_state()`.
1053 ///
1054 ///
1055 ///
1056 ///
1057 /// #### `state-flags-changed`
1058 /// The ::state-flags-changed signal is emitted when the widget state
1059 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1060 ///
1061 ///
1062 ///
1063 ///
1064 /// #### `style-set`
1065 /// The ::style-set signal is emitted when a new style has been set
1066 /// on a widget. Note that style-modifying functions like
1067 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1068 ///
1069 /// Note that this signal is emitted for changes to the deprecated
1070 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1071 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1072 ///
1073 ///
1074 ///
1075 ///
1076 /// #### `style-updated`
1077 /// The ::style-updated signal is a convenience signal that is emitted when the
1078 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1079 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1080 ///
1081 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1082 /// cause this signal to be emitted.
1083 ///
1084 ///
1085 ///
1086 ///
1087 /// #### `touch-event`
1088 ///
1089 ///
1090 ///
1091 /// #### `unmap`
1092 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1093 /// means that either it or any of its parents up to the toplevel widget have
1094 /// been set as hidden.
1095 ///
1096 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1097 /// used to, for example, stop an animation on the widget.
1098 ///
1099 ///
1100 ///
1101 ///
1102 /// #### `unmap-event`
1103 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1104 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1105 ///
1106 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1107 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1108 /// automatically for all new windows.
1109 ///
1110 ///
1111 ///
1112 ///
1113 /// #### `unrealize`
1114 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1115 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1116 /// called or the widget has been unmapped (that is, it is going to be
1117 /// hidden).
1118 ///
1119 ///
1120 ///
1121 ///
1122 /// #### `visibility-notify-event`
1123 /// The ::visibility-notify-event will be emitted when the `widget`'s
1124 /// window is obscured or unobscured.
1125 ///
1126 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1127 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1128 ///
1129 ///
1130 ///
1131 ///
1132 /// #### `window-state-event`
1133 /// The ::window-state-event will be emitted when the state of the
1134 /// toplevel window associated to the `widget` changes.
1135 ///
1136 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1137 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1138 /// this mask automatically for all new windows.
1139 ///
1140 ///
1141 /// </details>
1142 ///
1143 /// # Implements
1144 ///
1145 /// [`MenuToolButtonExt`][trait@crate::prelude::MenuToolButtonExt], [`ToolButtonExt`][trait@crate::prelude::ToolButtonExt], [`ToolItemExt`][trait@crate::prelude::ToolItemExt], [`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]
1146 #[doc(alias = "GtkMenuToolButton")]
1147 pub struct MenuToolButton(Object<ffi::GtkMenuToolButton, ffi::GtkMenuToolButtonClass>) @extends ToolButton, ToolItem, Bin, Container, Widget, @implements Buildable, Actionable;
1148
1149 match fn {
1150 type_ => || ffi::gtk_menu_tool_button_get_type(),
1151 }
1152}
1153
1154impl MenuToolButton {
1155 pub const NONE: Option<&'static MenuToolButton> = None;
1156
1157 /// Creates a new [`MenuToolButton`][crate::MenuToolButton] using `icon_widget` as icon and
1158 /// `label` as label.
1159 /// ## `icon_widget`
1160 /// a widget that will be used as icon widget, or [`None`]
1161 /// ## `label`
1162 /// a string that will be used as label, or [`None`]
1163 ///
1164 /// # Returns
1165 ///
1166 /// the new [`MenuToolButton`][crate::MenuToolButton]
1167 #[doc(alias = "gtk_menu_tool_button_new")]
1168 pub fn new(icon_widget: Option<&impl IsA<Widget>>, label: Option<&str>) -> MenuToolButton {
1169 assert_initialized_main_thread!();
1170 unsafe {
1171 ToolItem::from_glib_none(ffi::gtk_menu_tool_button_new(
1172 icon_widget.map(|p| p.as_ref()).to_glib_none().0,
1173 label.to_glib_none().0,
1174 ))
1175 .unsafe_cast()
1176 }
1177 }
1178
1179 // rustdoc-stripper-ignore-next
1180 /// Creates a new builder-pattern struct instance to construct [`MenuToolButton`] objects.
1181 ///
1182 /// This method returns an instance of [`MenuToolButtonBuilder`](crate::builders::MenuToolButtonBuilder) which can be used to create [`MenuToolButton`] objects.
1183 pub fn builder() -> MenuToolButtonBuilder {
1184 MenuToolButtonBuilder::new()
1185 }
1186}
1187
1188impl Default for MenuToolButton {
1189 fn default() -> Self {
1190 glib::object::Object::new::<Self>()
1191 }
1192}
1193
1194// rustdoc-stripper-ignore-next
1195/// A [builder-pattern] type to construct [`MenuToolButton`] objects.
1196///
1197/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1198#[must_use = "The builder must be built to be used"]
1199pub struct MenuToolButtonBuilder {
1200 builder: glib::object::ObjectBuilder<'static, MenuToolButton>,
1201}
1202
1203impl MenuToolButtonBuilder {
1204 fn new() -> Self {
1205 Self {
1206 builder: glib::object::Object::builder(),
1207 }
1208 }
1209
1210 pub fn menu(self, menu: &impl IsA<Menu>) -> Self {
1211 Self {
1212 builder: self.builder.property("menu", menu.clone().upcast()),
1213 }
1214 }
1215
1216 /// The name of the themed icon displayed on the item.
1217 /// This property only has an effect if not overridden by
1218 /// [`label-widget`][struct@crate::ToolButton#label-widget], [`icon-widget`][struct@crate::ToolButton#icon-widget] or
1219 /// [`stock-id`][struct@crate::ToolButton#stock-id] properties.
1220 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1221 Self {
1222 builder: self.builder.property("icon-name", icon_name.into()),
1223 }
1224 }
1225
1226 pub fn icon_widget(self, icon_widget: &impl IsA<Widget>) -> Self {
1227 Self {
1228 builder: self
1229 .builder
1230 .property("icon-widget", icon_widget.clone().upcast()),
1231 }
1232 }
1233
1234 pub fn label(self, label: impl Into<glib::GString>) -> Self {
1235 Self {
1236 builder: self.builder.property("label", label.into()),
1237 }
1238 }
1239
1240 pub fn label_widget(self, label_widget: &impl IsA<Widget>) -> Self {
1241 Self {
1242 builder: self
1243 .builder
1244 .property("label-widget", label_widget.clone().upcast()),
1245 }
1246 }
1247
1248 pub fn use_underline(self, use_underline: bool) -> Self {
1249 Self {
1250 builder: self.builder.property("use-underline", use_underline),
1251 }
1252 }
1253
1254 pub fn is_important(self, is_important: bool) -> Self {
1255 Self {
1256 builder: self.builder.property("is-important", is_important),
1257 }
1258 }
1259
1260 pub fn visible_horizontal(self, visible_horizontal: bool) -> Self {
1261 Self {
1262 builder: self
1263 .builder
1264 .property("visible-horizontal", visible_horizontal),
1265 }
1266 }
1267
1268 pub fn visible_vertical(self, visible_vertical: bool) -> Self {
1269 Self {
1270 builder: self.builder.property("visible-vertical", visible_vertical),
1271 }
1272 }
1273
1274 pub fn border_width(self, border_width: u32) -> Self {
1275 Self {
1276 builder: self.builder.property("border-width", border_width),
1277 }
1278 }
1279
1280 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1281 Self {
1282 builder: self.builder.property("child", child.clone().upcast()),
1283 }
1284 }
1285
1286 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1287 Self {
1288 builder: self.builder.property("resize-mode", resize_mode),
1289 }
1290 }
1291
1292 pub fn app_paintable(self, app_paintable: bool) -> Self {
1293 Self {
1294 builder: self.builder.property("app-paintable", app_paintable),
1295 }
1296 }
1297
1298 pub fn can_default(self, can_default: bool) -> Self {
1299 Self {
1300 builder: self.builder.property("can-default", can_default),
1301 }
1302 }
1303
1304 pub fn can_focus(self, can_focus: bool) -> Self {
1305 Self {
1306 builder: self.builder.property("can-focus", can_focus),
1307 }
1308 }
1309
1310 pub fn events(self, events: gdk::EventMask) -> Self {
1311 Self {
1312 builder: self.builder.property("events", events),
1313 }
1314 }
1315
1316 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1317 pub fn expand(self, expand: bool) -> Self {
1318 Self {
1319 builder: self.builder.property("expand", expand),
1320 }
1321 }
1322
1323 /// Whether the widget should grab focus when it is clicked with the mouse.
1324 ///
1325 /// This property is only relevant for widgets that can take focus.
1326 ///
1327 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1328 /// GtkComboBox) implemented this property individually.
1329 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1330 Self {
1331 builder: self.builder.property("focus-on-click", focus_on_click),
1332 }
1333 }
1334
1335 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1336 pub fn halign(self, halign: Align) -> Self {
1337 Self {
1338 builder: self.builder.property("halign", halign),
1339 }
1340 }
1341
1342 pub fn has_default(self, has_default: bool) -> Self {
1343 Self {
1344 builder: self.builder.property("has-default", has_default),
1345 }
1346 }
1347
1348 pub fn has_focus(self, has_focus: bool) -> Self {
1349 Self {
1350 builder: self.builder.property("has-focus", has_focus),
1351 }
1352 }
1353
1354 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1355 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1356 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1357 /// whether it will provide a tooltip or not.
1358 ///
1359 /// Note that setting this property to [`true`] for the first time will change
1360 /// the event masks of the GdkWindows of this widget to include leave-notify
1361 /// and motion-notify events. This cannot and will not be undone when the
1362 /// property is set to [`false`] again.
1363 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1364 Self {
1365 builder: self.builder.property("has-tooltip", has_tooltip),
1366 }
1367 }
1368
1369 pub fn height_request(self, height_request: i32) -> Self {
1370 Self {
1371 builder: self.builder.property("height-request", height_request),
1372 }
1373 }
1374
1375 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1376 pub fn hexpand(self, hexpand: bool) -> Self {
1377 Self {
1378 builder: self.builder.property("hexpand", hexpand),
1379 }
1380 }
1381
1382 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1383 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1384 Self {
1385 builder: self.builder.property("hexpand-set", hexpand_set),
1386 }
1387 }
1388
1389 pub fn is_focus(self, is_focus: bool) -> Self {
1390 Self {
1391 builder: self.builder.property("is-focus", is_focus),
1392 }
1393 }
1394
1395 /// Sets all four sides' margin at once. If read, returns max
1396 /// margin on any side.
1397 pub fn margin(self, margin: i32) -> Self {
1398 Self {
1399 builder: self.builder.property("margin", margin),
1400 }
1401 }
1402
1403 /// Margin on bottom side of widget.
1404 ///
1405 /// This property adds margin outside of the widget's normal size
1406 /// request, the margin will be added in addition to the size from
1407 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1408 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1409 Self {
1410 builder: self.builder.property("margin-bottom", margin_bottom),
1411 }
1412 }
1413
1414 /// Margin on end of widget, horizontally. This property supports
1415 /// left-to-right and right-to-left text directions.
1416 ///
1417 /// This property adds margin outside of the widget's normal size
1418 /// request, the margin will be added in addition to the size from
1419 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1420 pub fn margin_end(self, margin_end: i32) -> Self {
1421 Self {
1422 builder: self.builder.property("margin-end", margin_end),
1423 }
1424 }
1425
1426 /// Margin on start of widget, horizontally. This property supports
1427 /// left-to-right and right-to-left text directions.
1428 ///
1429 /// This property adds margin outside of the widget's normal size
1430 /// request, the margin will be added in addition to the size from
1431 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1432 pub fn margin_start(self, margin_start: i32) -> Self {
1433 Self {
1434 builder: self.builder.property("margin-start", margin_start),
1435 }
1436 }
1437
1438 /// Margin on top side of widget.
1439 ///
1440 /// This property adds margin outside of the widget's normal size
1441 /// request, the margin will be added in addition to the size from
1442 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1443 pub fn margin_top(self, margin_top: i32) -> Self {
1444 Self {
1445 builder: self.builder.property("margin-top", margin_top),
1446 }
1447 }
1448
1449 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1450 Self {
1451 builder: self.builder.property("name", name.into()),
1452 }
1453 }
1454
1455 pub fn no_show_all(self, no_show_all: bool) -> Self {
1456 Self {
1457 builder: self.builder.property("no-show-all", no_show_all),
1458 }
1459 }
1460
1461 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1462 /// more details about window opacity.
1463 ///
1464 /// Before 3.8 this was only available in GtkWindow
1465 pub fn opacity(self, opacity: f64) -> Self {
1466 Self {
1467 builder: self.builder.property("opacity", opacity),
1468 }
1469 }
1470
1471 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1472 Self {
1473 builder: self.builder.property("parent", parent.clone().upcast()),
1474 }
1475 }
1476
1477 pub fn receives_default(self, receives_default: bool) -> Self {
1478 Self {
1479 builder: self.builder.property("receives-default", receives_default),
1480 }
1481 }
1482
1483 pub fn sensitive(self, sensitive: bool) -> Self {
1484 Self {
1485 builder: self.builder.property("sensitive", sensitive),
1486 }
1487 }
1488
1489 /// Sets the text of tooltip to be the given string, which is marked up
1490 /// with the [Pango text markup language][PangoMarkupFormat].
1491 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1492 ///
1493 /// This is a convenience property which will take care of getting the
1494 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1495 /// will automatically be set to [`true`] and there will be taken care of
1496 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1497 ///
1498 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1499 /// are set, the last one wins.
1500 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1501 Self {
1502 builder: self
1503 .builder
1504 .property("tooltip-markup", tooltip_markup.into()),
1505 }
1506 }
1507
1508 /// Sets the text of tooltip to be the given string.
1509 ///
1510 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1511 ///
1512 /// This is a convenience property which will take care of getting the
1513 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1514 /// will automatically be set to [`true`] and there will be taken care of
1515 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1516 ///
1517 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1518 /// are set, the last one wins.
1519 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1520 Self {
1521 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1522 }
1523 }
1524
1525 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1526 pub fn valign(self, valign: Align) -> Self {
1527 Self {
1528 builder: self.builder.property("valign", valign),
1529 }
1530 }
1531
1532 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1533 pub fn vexpand(self, vexpand: bool) -> Self {
1534 Self {
1535 builder: self.builder.property("vexpand", vexpand),
1536 }
1537 }
1538
1539 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1540 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1541 Self {
1542 builder: self.builder.property("vexpand-set", vexpand_set),
1543 }
1544 }
1545
1546 pub fn visible(self, visible: bool) -> Self {
1547 Self {
1548 builder: self.builder.property("visible", visible),
1549 }
1550 }
1551
1552 pub fn width_request(self, width_request: i32) -> Self {
1553 Self {
1554 builder: self.builder.property("width-request", width_request),
1555 }
1556 }
1557
1558 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1559 Self {
1560 builder: self.builder.property("action-name", action_name.into()),
1561 }
1562 }
1563
1564 pub fn action_target(self, action_target: &glib::Variant) -> Self {
1565 Self {
1566 builder: self
1567 .builder
1568 .property("action-target", action_target.clone()),
1569 }
1570 }
1571
1572 // rustdoc-stripper-ignore-next
1573 /// Build the [`MenuToolButton`].
1574 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1575 pub fn build(self) -> MenuToolButton {
1576 assert_initialized_main_thread!();
1577 self.builder.build()
1578 }
1579}
1580
1581/// Trait containing all [`struct@MenuToolButton`] methods.
1582///
1583/// # Implementors
1584///
1585/// [`MenuToolButton`][struct@crate::MenuToolButton]
1586pub trait MenuToolButtonExt: IsA<MenuToolButton> + 'static {
1587 /// Gets the [`Menu`][crate::Menu] associated with [`MenuToolButton`][crate::MenuToolButton].
1588 ///
1589 /// # Returns
1590 ///
1591 /// the [`Menu`][crate::Menu] associated
1592 /// with [`MenuToolButton`][crate::MenuToolButton]
1593 #[doc(alias = "gtk_menu_tool_button_get_menu")]
1594 #[doc(alias = "get_menu")]
1595 fn menu(&self) -> Option<Widget> {
1596 unsafe {
1597 from_glib_none(ffi::gtk_menu_tool_button_get_menu(
1598 self.as_ref().to_glib_none().0,
1599 ))
1600 }
1601 }
1602
1603 /// Sets the tooltip markup text to be used as tooltip for the arrow button
1604 /// which pops up the menu. See [`ToolItemExt::set_tooltip_text()`][crate::prelude::ToolItemExt::set_tooltip_text()] for setting
1605 /// a tooltip on the whole [`MenuToolButton`][crate::MenuToolButton].
1606 /// ## `markup`
1607 /// markup text to be used as tooltip text for button’s arrow button
1608 #[doc(alias = "gtk_menu_tool_button_set_arrow_tooltip_markup")]
1609 fn set_arrow_tooltip_markup(&self, markup: &str) {
1610 unsafe {
1611 ffi::gtk_menu_tool_button_set_arrow_tooltip_markup(
1612 self.as_ref().to_glib_none().0,
1613 markup.to_glib_none().0,
1614 );
1615 }
1616 }
1617
1618 /// Sets the tooltip text to be used as tooltip for the arrow button which
1619 /// pops up the menu. See [`ToolItemExt::set_tooltip_text()`][crate::prelude::ToolItemExt::set_tooltip_text()] for setting a tooltip
1620 /// on the whole [`MenuToolButton`][crate::MenuToolButton].
1621 /// ## `text`
1622 /// text to be used as tooltip text for button’s arrow button
1623 #[doc(alias = "gtk_menu_tool_button_set_arrow_tooltip_text")]
1624 fn set_arrow_tooltip_text(&self, text: &str) {
1625 unsafe {
1626 ffi::gtk_menu_tool_button_set_arrow_tooltip_text(
1627 self.as_ref().to_glib_none().0,
1628 text.to_glib_none().0,
1629 );
1630 }
1631 }
1632
1633 /// Sets the [`Menu`][crate::Menu] that is popped up when the user clicks on the arrow.
1634 /// If `menu` is NULL, the arrow button becomes insensitive.
1635 /// ## `menu`
1636 /// the [`Menu`][crate::Menu] associated with [`MenuToolButton`][crate::MenuToolButton]
1637 #[doc(alias = "gtk_menu_tool_button_set_menu")]
1638 #[doc(alias = "menu")]
1639 fn set_menu(&self, menu: &impl IsA<Widget>) {
1640 unsafe {
1641 ffi::gtk_menu_tool_button_set_menu(
1642 self.as_ref().to_glib_none().0,
1643 menu.as_ref().to_glib_none().0,
1644 );
1645 }
1646 }
1647
1648 /// The ::show-menu signal is emitted before the menu is shown.
1649 ///
1650 /// It can be used to populate the menu on demand, using
1651 /// [`set_menu()`][Self::set_menu()].
1652 ///
1653 /// Note that even if you populate the menu dynamically in this way,
1654 /// you must set an empty menu on the [`MenuToolButton`][crate::MenuToolButton] beforehand,
1655 /// since the arrow is made insensitive if the menu is not set.
1656 #[doc(alias = "show-menu")]
1657 fn connect_show_menu<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1658 unsafe extern "C" fn show_menu_trampoline<P: IsA<MenuToolButton>, F: Fn(&P) + 'static>(
1659 this: *mut ffi::GtkMenuToolButton,
1660 f: glib::ffi::gpointer,
1661 ) {
1662 unsafe {
1663 let f: &F = &*(f as *const F);
1664 f(MenuToolButton::from_glib_borrow(this).unsafe_cast_ref())
1665 }
1666 }
1667 unsafe {
1668 let f: Box_<F> = Box_::new(f);
1669 connect_raw(
1670 self.as_ptr() as *mut _,
1671 c"show-menu".as_ptr(),
1672 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1673 show_menu_trampoline::<Self, F> as *const (),
1674 )),
1675 Box_::into_raw(f),
1676 )
1677 }
1678 }
1679
1680 #[doc(alias = "menu")]
1681 fn connect_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1682 unsafe extern "C" fn notify_menu_trampoline<P: IsA<MenuToolButton>, F: Fn(&P) + 'static>(
1683 this: *mut ffi::GtkMenuToolButton,
1684 _param_spec: glib::ffi::gpointer,
1685 f: glib::ffi::gpointer,
1686 ) {
1687 unsafe {
1688 let f: &F = &*(f as *const F);
1689 f(MenuToolButton::from_glib_borrow(this).unsafe_cast_ref())
1690 }
1691 }
1692 unsafe {
1693 let f: Box_<F> = Box_::new(f);
1694 connect_raw(
1695 self.as_ptr() as *mut _,
1696 c"notify::menu".as_ptr(),
1697 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1698 notify_menu_trampoline::<Self, F> as *const (),
1699 )),
1700 Box_::into_raw(f),
1701 )
1702 }
1703 }
1704}
1705
1706impl<O: IsA<MenuToolButton>> MenuToolButtonExt for O {}