gtk/auto/menu_item.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::{Actionable, Align, Bin, Buildable, Container, Menu, ResizeMode, Widget};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14 /// The [`MenuItem`][crate::MenuItem] widget and the derived widgets are the only valid
15 /// children for menus. Their function is to correctly handle highlighting,
16 /// alignment, events and submenus.
17 ///
18 /// As a GtkMenuItem derives from [`Bin`][crate::Bin] it can hold any valid child widget,
19 /// although only a few are really useful.
20 ///
21 /// By default, a GtkMenuItem sets a [`AccelLabel`][crate::AccelLabel] as its child.
22 /// GtkMenuItem has direct functions to set the label and its mnemonic.
23 /// For more advanced label settings, you can fetch the child widget from the GtkBin.
24 ///
25 /// An example for setting markup and accelerator on a MenuItem:
26 ///
27 ///
28 ///
29 /// **⚠️ The following code is in C ⚠️**
30 ///
31 /// ```C
32 /// GtkWidget *menu_item = gtk_menu_item_new_with_label ("Example Menu Item");
33 ///
34 /// GtkWidget *child = gtk_bin_get_child (GTK_BIN (menu_item));
35 /// gtk_label_set_markup (GTK_LABEL (child), "<i>new label</i> with <b>markup</b>");
36 /// gtk_accel_label_set_accel (GTK_ACCEL_LABEL (child), GDK_KEY_1, 0);
37 /// ```
38 ///
39 /// # GtkMenuItem as GtkBuildable
40 ///
41 /// The GtkMenuItem implementation of the [`Buildable`][crate::Buildable] interface supports
42 /// adding a submenu by specifying “submenu” as the “type” attribute of
43 /// a ``<child>`` element.
44 ///
45 /// An example of UI definition fragment with submenus:
46 ///
47 ///
48 ///
49 /// **⚠️ The following code is in xml ⚠️**
50 ///
51 /// ```xml
52 /// <object class="GtkMenuItem">
53 /// <child type="submenu">
54 /// <object class="GtkMenu"/>
55 /// </child>
56 /// </object>
57 /// ```
58 ///
59 /// # CSS nodes
60 ///
61 ///
62 ///
63 /// **⚠️ The following code is in plain ⚠️**
64 ///
65 /// ```plain
66 /// menuitem
67 /// ├── <child>
68 /// ╰── [arrow.right]
69 /// ```
70 ///
71 /// GtkMenuItem has a single CSS node with name menuitem. If the menuitem
72 /// has a submenu, it gets another CSS node with name arrow, which has
73 /// the .left or .right style class.
74 ///
75 /// ## Properties
76 ///
77 ///
78 /// #### `accel-path`
79 /// Sets the accelerator path of the menu item, through which runtime
80 /// changes of the menu item's accelerator caused by the user can be
81 /// identified and saved to persistant storage.
82 ///
83 /// Readable | Writeable
84 ///
85 ///
86 /// #### `label`
87 /// The text for the child label.
88 ///
89 /// Readable | Writeable
90 ///
91 ///
92 /// #### `right-justified`
93 /// Sets whether the menu item appears justified
94 /// at the right side of a menu bar.
95 ///
96 /// Readable | Writeable
97 ///
98 ///
99 /// #### `submenu`
100 /// The submenu attached to the menu item, or [`None`] if it has none.
101 ///
102 /// Readable | Writeable
103 ///
104 ///
105 /// #### `use-underline`
106 /// [`true`] if underlines in the text indicate mnemonics.
107 ///
108 /// Readable | Writeable
109 /// <details><summary><h4>Container</h4></summary>
110 ///
111 ///
112 /// #### `border-width`
113 /// Readable | Writeable
114 ///
115 ///
116 /// #### `child`
117 /// Writeable
118 ///
119 ///
120 /// #### `resize-mode`
121 /// Readable | Writeable
122 /// </details>
123 /// <details><summary><h4>Widget</h4></summary>
124 ///
125 ///
126 /// #### `app-paintable`
127 /// Readable | Writeable
128 ///
129 ///
130 /// #### `can-default`
131 /// Readable | Writeable
132 ///
133 ///
134 /// #### `can-focus`
135 /// Readable | Writeable
136 ///
137 ///
138 /// #### `composite-child`
139 /// Readable
140 ///
141 ///
142 /// #### `double-buffered`
143 /// Whether the widget is double buffered.
144 ///
145 /// Readable | Writeable
146 ///
147 ///
148 /// #### `events`
149 /// Readable | Writeable
150 ///
151 ///
152 /// #### `expand`
153 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
154 ///
155 /// Readable | Writeable
156 ///
157 ///
158 /// #### `focus-on-click`
159 /// Whether the widget should grab focus when it is clicked with the mouse.
160 ///
161 /// This property is only relevant for widgets that can take focus.
162 ///
163 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
164 /// GtkComboBox) implemented this property individually.
165 ///
166 /// Readable | Writeable
167 ///
168 ///
169 /// #### `halign`
170 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
171 ///
172 /// Readable | Writeable
173 ///
174 ///
175 /// #### `has-default`
176 /// Readable | Writeable
177 ///
178 ///
179 /// #### `has-focus`
180 /// Readable | Writeable
181 ///
182 ///
183 /// #### `has-tooltip`
184 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
185 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
186 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
187 /// whether it will provide a tooltip or not.
188 ///
189 /// Note that setting this property to [`true`] for the first time will change
190 /// the event masks of the GdkWindows of this widget to include leave-notify
191 /// and motion-notify events. This cannot and will not be undone when the
192 /// property is set to [`false`] again.
193 ///
194 /// Readable | Writeable
195 ///
196 ///
197 /// #### `height-request`
198 /// Readable | Writeable
199 ///
200 ///
201 /// #### `hexpand`
202 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
203 ///
204 /// Readable | Writeable
205 ///
206 ///
207 /// #### `hexpand-set`
208 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
209 ///
210 /// Readable | Writeable
211 ///
212 ///
213 /// #### `is-focus`
214 /// Readable | Writeable
215 ///
216 ///
217 /// #### `margin`
218 /// Sets all four sides' margin at once. If read, returns max
219 /// margin on any side.
220 ///
221 /// Readable | Writeable
222 ///
223 ///
224 /// #### `margin-bottom`
225 /// Margin on bottom side of widget.
226 ///
227 /// This property adds margin outside of the widget's normal size
228 /// request, the margin will be added in addition to the size from
229 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
230 ///
231 /// Readable | Writeable
232 ///
233 ///
234 /// #### `margin-end`
235 /// Margin on end of widget, horizontally. This property supports
236 /// left-to-right and right-to-left text directions.
237 ///
238 /// This property adds margin outside of the widget's normal size
239 /// request, the margin will be added in addition to the size from
240 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
241 ///
242 /// Readable | Writeable
243 ///
244 ///
245 /// #### `margin-left`
246 /// Margin on left side of widget.
247 ///
248 /// This property adds margin outside of the widget's normal size
249 /// request, the margin will be added in addition to the size from
250 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
251 ///
252 /// Readable | Writeable
253 ///
254 ///
255 /// #### `margin-right`
256 /// Margin on right side of widget.
257 ///
258 /// This property adds margin outside of the widget's normal size
259 /// request, the margin will be added in addition to the size from
260 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
261 ///
262 /// Readable | Writeable
263 ///
264 ///
265 /// #### `margin-start`
266 /// Margin on start of widget, horizontally. This property supports
267 /// left-to-right and right-to-left text directions.
268 ///
269 /// This property adds margin outside of the widget's normal size
270 /// request, the margin will be added in addition to the size from
271 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
272 ///
273 /// Readable | Writeable
274 ///
275 ///
276 /// #### `margin-top`
277 /// Margin on top side of widget.
278 ///
279 /// This property adds margin outside of the widget's normal size
280 /// request, the margin will be added in addition to the size from
281 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
282 ///
283 /// Readable | Writeable
284 ///
285 ///
286 /// #### `name`
287 /// Readable | Writeable
288 ///
289 ///
290 /// #### `no-show-all`
291 /// Readable | Writeable
292 ///
293 ///
294 /// #### `opacity`
295 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
296 /// more details about window opacity.
297 ///
298 /// Before 3.8 this was only available in GtkWindow
299 ///
300 /// Readable | Writeable
301 ///
302 ///
303 /// #### `parent`
304 /// Readable | Writeable
305 ///
306 ///
307 /// #### `receives-default`
308 /// Readable | Writeable
309 ///
310 ///
311 /// #### `scale-factor`
312 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
313 /// more details about widget scaling.
314 ///
315 /// Readable
316 ///
317 ///
318 /// #### `sensitive`
319 /// Readable | Writeable
320 ///
321 ///
322 /// #### `style`
323 /// The style of the widget, which contains information about how it will look (colors, etc).
324 ///
325 /// Readable | Writeable
326 ///
327 ///
328 /// #### `tooltip-markup`
329 /// Sets the text of tooltip to be the given string, which is marked up
330 /// with the [Pango text markup language][PangoMarkupFormat].
331 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
332 ///
333 /// This is a convenience property which will take care of getting the
334 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
335 /// will automatically be set to [`true`] and there will be taken care of
336 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
337 ///
338 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
339 /// are set, the last one wins.
340 ///
341 /// Readable | Writeable
342 ///
343 ///
344 /// #### `tooltip-text`
345 /// Sets the text of tooltip to be the given string.
346 ///
347 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
348 ///
349 /// This is a convenience property which will take care of getting the
350 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
351 /// will automatically be set to [`true`] and there will be taken care of
352 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
353 ///
354 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
355 /// are set, the last one wins.
356 ///
357 /// Readable | Writeable
358 ///
359 ///
360 /// #### `valign`
361 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
362 ///
363 /// Readable | Writeable
364 ///
365 ///
366 /// #### `vexpand`
367 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
368 ///
369 /// Readable | Writeable
370 ///
371 ///
372 /// #### `vexpand-set`
373 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
374 ///
375 /// Readable | Writeable
376 ///
377 ///
378 /// #### `visible`
379 /// Readable | Writeable
380 ///
381 ///
382 /// #### `width-request`
383 /// Readable | Writeable
384 ///
385 ///
386 /// #### `window`
387 /// The widget's window if it is realized, [`None`] otherwise.
388 ///
389 /// Readable
390 /// </details>
391 /// <details><summary><h4>Actionable</h4></summary>
392 ///
393 ///
394 /// #### `action-name`
395 /// Readable | Writeable
396 ///
397 ///
398 /// #### `action-target`
399 /// Readable | Writeable
400 /// </details>
401 /// <details><summary><h4>Activatable</h4></summary>
402 ///
403 ///
404 /// #### `related-action`
405 /// The action that this activatable will activate and receive
406 /// updates from for various states and possibly appearance.
407 ///
408 /// > `GtkActivatable` implementors need to handle the this property and
409 /// > call `gtk_activatable_do_set_related_action()` when it changes.
410 ///
411 /// Readable | Writeable
412 ///
413 ///
414 /// #### `use-action-appearance`
415 /// Whether this activatable should reset its layout
416 /// and appearance when setting the related action or when
417 /// the action changes appearance.
418 ///
419 /// See the `GtkAction` documentation directly to find which properties
420 /// should be ignored by the `GtkActivatable` when this property is [`false`].
421 ///
422 /// > `GtkActivatable` implementors need to handle this property
423 /// > and call `gtk_activatable_sync_action_properties()` on the activatable
424 /// > widget when it changes.
425 ///
426 /// Readable | Writeable
427 /// </details>
428 ///
429 /// ## Signals
430 ///
431 ///
432 /// #### `activate`
433 /// Emitted when the item is activated.
434 ///
435 /// Action
436 ///
437 ///
438 /// #### `activate-item`
439 /// Emitted when the item is activated, but also if the menu item has a
440 /// submenu. For normal applications, the relevant signal is
441 /// [`activate`][struct@crate::MenuItem#activate].
442 ///
443 ///
444 ///
445 ///
446 /// #### `deselect`
447 ///
448 ///
449 ///
450 /// #### `select`
451 ///
452 ///
453 ///
454 /// #### `toggle-size-allocate`
455 ///
456 ///
457 ///
458 /// #### `toggle-size-request`
459 ///
460 /// <details><summary><h4>Container</h4></summary>
461 ///
462 ///
463 /// #### `add`
464 ///
465 ///
466 ///
467 /// #### `check-resize`
468 ///
469 ///
470 ///
471 /// #### `remove`
472 ///
473 ///
474 ///
475 /// #### `set-focus-child`
476 ///
477 /// </details>
478 /// <details><summary><h4>Widget</h4></summary>
479 ///
480 ///
481 /// #### `accel-closures-changed`
482 ///
483 ///
484 ///
485 /// #### `button-press-event`
486 /// The ::button-press-event signal will be emitted when a button
487 /// (typically from a mouse) is pressed.
488 ///
489 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
490 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
491 ///
492 /// This signal will be sent to the grab widget if there is one.
493 ///
494 ///
495 ///
496 ///
497 /// #### `button-release-event`
498 /// The ::button-release-event signal will be emitted when a button
499 /// (typically from a mouse) is released.
500 ///
501 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
502 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
503 ///
504 /// This signal will be sent to the grab widget if there is one.
505 ///
506 ///
507 ///
508 ///
509 /// #### `can-activate-accel`
510 /// Determines whether an accelerator that activates the signal
511 /// identified by `signal_id` can currently be activated.
512 /// This signal is present to allow applications and derived
513 /// widgets to override the default [`Widget`][crate::Widget] handling
514 /// for determining whether an accelerator can be activated.
515 ///
516 ///
517 ///
518 ///
519 /// #### `child-notify`
520 /// The ::child-notify signal is emitted for each
521 /// [child property][child-properties] that has
522 /// changed on an object. The signal's detail holds the property name.
523 ///
524 /// Detailed
525 ///
526 ///
527 /// #### `composited-changed`
528 /// The ::composited-changed signal is emitted when the composited
529 /// status of `widgets` screen changes.
530 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
531 ///
532 /// Action
533 ///
534 ///
535 /// #### `configure-event`
536 /// The ::configure-event signal will be emitted when the size, position or
537 /// stacking of the `widget`'s window has changed.
538 ///
539 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
540 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
541 /// automatically for all new windows.
542 ///
543 ///
544 ///
545 ///
546 /// #### `damage-event`
547 /// Emitted when a redirected window belonging to `widget` gets drawn into.
548 /// The region/area members of the event shows what area of the redirected
549 /// drawable was drawn into.
550 ///
551 ///
552 ///
553 ///
554 /// #### `delete-event`
555 /// The ::delete-event signal is emitted if a user requests that
556 /// a toplevel window is closed. The default handler for this signal
557 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
558 /// this signal will cause the window to be hidden instead, so that
559 /// it can later be shown again without reconstructing it.
560 ///
561 ///
562 ///
563 ///
564 /// #### `destroy`
565 /// Signals that all holders of a reference to the widget should release
566 /// the reference that they hold. May result in finalization of the widget
567 /// if all references are released.
568 ///
569 /// This signal is not suitable for saving widget state.
570 ///
571 ///
572 ///
573 ///
574 /// #### `destroy-event`
575 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
576 /// You rarely get this signal, because most widgets disconnect themselves
577 /// from their window before they destroy it, so no widget owns the
578 /// window at destroy time.
579 ///
580 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
581 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
582 /// automatically for all new windows.
583 ///
584 ///
585 ///
586 ///
587 /// #### `direction-changed`
588 /// The ::direction-changed signal is emitted when the text direction
589 /// of a widget changes.
590 ///
591 ///
592 ///
593 ///
594 /// #### `drag-begin`
595 /// The ::drag-begin signal is emitted on the drag source when a drag is
596 /// started. A typical reason to connect to this signal is to set up a
597 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
598 ///
599 /// Note that some widgets set up a drag icon in the default handler of
600 /// this signal, so you may have to use `g_signal_connect_after()` to
601 /// override what the default handler did.
602 ///
603 ///
604 ///
605 ///
606 /// #### `drag-data-delete`
607 /// The ::drag-data-delete signal is emitted on the drag source when a drag
608 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
609 /// handler is responsible for deleting the data that has been dropped. What
610 /// "delete" means depends on the context of the drag operation.
611 ///
612 ///
613 ///
614 ///
615 /// #### `drag-data-get`
616 /// The ::drag-data-get signal is emitted on the drag source when the drop
617 /// site requests the data which is dragged. It is the responsibility of
618 /// the signal handler to fill `data` with the data in the format which
619 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
620 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
621 ///
622 ///
623 ///
624 ///
625 /// #### `drag-data-received`
626 /// The ::drag-data-received signal is emitted on the drop site when the
627 /// dragged data has been received. If the data was received in order to
628 /// determine whether the drop will be accepted, the handler is expected
629 /// to call `gdk_drag_status()` and not finish the drag.
630 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
631 /// (and this is the last target to be received), the handler for this
632 /// signal is expected to process the received data and then call
633 /// `gtk_drag_finish()`, setting the `success` parameter depending on
634 /// whether the data was processed successfully.
635 ///
636 /// Applications must create some means to determine why the signal was emitted
637 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
638 ///
639 /// The handler may inspect the selected action with
640 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
641 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
642 /// shown in the following example:
643 ///
644 ///
645 /// **⚠️ The following code is in C ⚠️**
646 ///
647 /// ```C
648 /// void
649 /// drag_data_received (GtkWidget *widget,
650 /// GdkDragContext *context,
651 /// gint x,
652 /// gint y,
653 /// GtkSelectionData *data,
654 /// guint info,
655 /// guint time)
656 /// {
657 /// if ((data->length >= 0) && (data->format == 8))
658 /// {
659 /// GdkDragAction action;
660 ///
661 /// // handle data here
662 ///
663 /// action = gdk_drag_context_get_selected_action (context);
664 /// if (action == GDK_ACTION_ASK)
665 /// {
666 /// GtkWidget *dialog;
667 /// gint response;
668 ///
669 /// dialog = gtk_message_dialog_new (NULL,
670 /// GTK_DIALOG_MODAL |
671 /// GTK_DIALOG_DESTROY_WITH_PARENT,
672 /// GTK_MESSAGE_INFO,
673 /// GTK_BUTTONS_YES_NO,
674 /// "Move the data ?\n");
675 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
676 /// gtk_widget_destroy (dialog);
677 ///
678 /// if (response == GTK_RESPONSE_YES)
679 /// action = GDK_ACTION_MOVE;
680 /// else
681 /// action = GDK_ACTION_COPY;
682 /// }
683 ///
684 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
685 /// }
686 /// else
687 /// gtk_drag_finish (context, FALSE, FALSE, time);
688 /// }
689 /// ```
690 ///
691 ///
692 ///
693 ///
694 /// #### `drag-drop`
695 /// The ::drag-drop signal is emitted on the drop site when the user drops
696 /// the data onto the widget. The signal handler must determine whether
697 /// the cursor position is in a drop zone or not. If it is not in a drop
698 /// zone, it returns [`false`] and no further processing is necessary.
699 /// Otherwise, the handler returns [`true`]. In this case, the handler must
700 /// ensure that `gtk_drag_finish()` is called to let the source know that
701 /// the drop is done. The call to `gtk_drag_finish()` can be done either
702 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
703 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
704 /// or more of the supported targets.
705 ///
706 ///
707 ///
708 ///
709 /// #### `drag-end`
710 /// The ::drag-end signal is emitted on the drag source when a drag is
711 /// finished. A typical reason to connect to this signal is to undo
712 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
713 ///
714 ///
715 ///
716 ///
717 /// #### `drag-failed`
718 /// The ::drag-failed signal is emitted on the drag source when a drag has
719 /// failed. The signal handler may hook custom code to handle a failed DnD
720 /// operation based on the type of error, it returns [`true`] is the failure has
721 /// been already handled (not showing the default "drag operation failed"
722 /// animation), otherwise it returns [`false`].
723 ///
724 ///
725 ///
726 ///
727 /// #### `drag-leave`
728 /// The ::drag-leave signal is emitted on the drop site when the cursor
729 /// leaves the widget. A typical reason to connect to this signal is to
730 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
731 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
732 ///
733 ///
734 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
735 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
736 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
737 ///
738 ///
739 ///
740 ///
741 /// #### `drag-motion`
742 /// The ::drag-motion signal is emitted on the drop site when the user
743 /// moves the cursor over the widget during a drag. The signal handler
744 /// must determine whether the cursor position is in a drop zone or not.
745 /// If it is not in a drop zone, it returns [`false`] and no further processing
746 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
747 /// handler is responsible for providing the necessary information for
748 /// displaying feedback to the user, by calling `gdk_drag_status()`.
749 ///
750 /// If the decision whether the drop will be accepted or rejected can't be
751 /// made based solely on the cursor position and the type of the data, the
752 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
753 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
754 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
755 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
756 /// when using the drag-motion signal that way.
757 ///
758 /// Also note that there is no drag-enter signal. The drag receiver has to
759 /// keep track of whether he has received any drag-motion signals since the
760 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
761 /// an "enter" signal. Upon an "enter", the handler will typically highlight
762 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
763 ///
764 ///
765 /// **⚠️ The following code is in C ⚠️**
766 ///
767 /// ```C
768 /// static void
769 /// drag_motion (GtkWidget *widget,
770 /// GdkDragContext *context,
771 /// gint x,
772 /// gint y,
773 /// guint time)
774 /// {
775 /// GdkAtom target;
776 ///
777 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
778 ///
779 /// if (!private_data->drag_highlight)
780 /// {
781 /// private_data->drag_highlight = 1;
782 /// gtk_drag_highlight (widget);
783 /// }
784 ///
785 /// target = gtk_drag_dest_find_target (widget, context, NULL);
786 /// if (target == GDK_NONE)
787 /// gdk_drag_status (context, 0, time);
788 /// else
789 /// {
790 /// private_data->pending_status
791 /// = gdk_drag_context_get_suggested_action (context);
792 /// gtk_drag_get_data (widget, context, target, time);
793 /// }
794 ///
795 /// return TRUE;
796 /// }
797 ///
798 /// static void
799 /// drag_data_received (GtkWidget *widget,
800 /// GdkDragContext *context,
801 /// gint x,
802 /// gint y,
803 /// GtkSelectionData *selection_data,
804 /// guint info,
805 /// guint time)
806 /// {
807 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
808 ///
809 /// if (private_data->suggested_action)
810 /// {
811 /// private_data->suggested_action = 0;
812 ///
813 /// // We are getting this data due to a request in drag_motion,
814 /// // rather than due to a request in drag_drop, so we are just
815 /// // supposed to call gdk_drag_status(), not actually paste in
816 /// // the data.
817 ///
818 /// str = gtk_selection_data_get_text (selection_data);
819 /// if (!data_is_acceptable (str))
820 /// gdk_drag_status (context, 0, time);
821 /// else
822 /// gdk_drag_status (context,
823 /// private_data->suggested_action,
824 /// time);
825 /// }
826 /// else
827 /// {
828 /// // accept the drop
829 /// }
830 /// }
831 /// ```
832 ///
833 ///
834 ///
835 ///
836 /// #### `draw`
837 /// This signal is emitted when a widget is supposed to render itself.
838 /// The `widget`'s top left corner must be painted at the origin of
839 /// the passed in context and be sized to the values returned by
840 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
841 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
842 ///
843 /// Signal handlers connected to this signal can modify the cairo
844 /// context passed as `cr` in any way they like and don't need to
845 /// restore it. The signal emission takes care of calling `cairo_save()`
846 /// before and `cairo_restore()` after invoking the handler.
847 ///
848 /// The signal handler will get a `cr` with a clip region already set to the
849 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
850 /// widgets that want to avoid redrawing themselves completely can get the full
851 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
852 /// get a finer-grained representation of the dirty region with
853 /// `cairo_copy_clip_rectangle_list()`.
854 ///
855 ///
856 ///
857 ///
858 /// #### `enter-notify-event`
859 /// The ::enter-notify-event will be emitted when the pointer enters
860 /// the `widget`'s window.
861 ///
862 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
863 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
864 ///
865 /// This signal will be sent to the grab widget if there is one.
866 ///
867 ///
868 ///
869 ///
870 /// #### `event`
871 /// The GTK+ main loop will emit three signals for each GDK event delivered
872 /// to a widget: one generic ::event signal, another, more specific,
873 /// signal that matches the type of event delivered (e.g.
874 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
875 /// [`event-after`][struct@crate::Widget#event-after] signal.
876 ///
877 ///
878 ///
879 ///
880 /// #### `event-after`
881 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
882 /// the second more specific signal, ::event-after will be emitted
883 /// regardless of the previous two signals handlers return values.
884 ///
885 ///
886 ///
887 ///
888 /// #### `focus`
889 ///
890 ///
891 ///
892 /// #### `focus-in-event`
893 /// The ::focus-in-event signal will be emitted when the keyboard focus
894 /// enters the `widget`'s window.
895 ///
896 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
897 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
898 ///
899 ///
900 ///
901 ///
902 /// #### `focus-out-event`
903 /// The ::focus-out-event signal will be emitted when the keyboard focus
904 /// leaves the `widget`'s window.
905 ///
906 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
907 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
908 ///
909 ///
910 ///
911 ///
912 /// #### `grab-broken-event`
913 /// Emitted when a pointer or keyboard grab on a window belonging
914 /// to `widget` gets broken.
915 ///
916 /// On X11, this happens when the grab window becomes unviewable
917 /// (i.e. it or one of its ancestors is unmapped), or if the same
918 /// application grabs the pointer or keyboard again.
919 ///
920 ///
921 ///
922 ///
923 /// #### `grab-focus`
924 /// Action
925 ///
926 ///
927 /// #### `grab-notify`
928 /// The ::grab-notify signal is emitted when a widget becomes
929 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
930 /// another widget, or when it becomes unshadowed due to a grab
931 /// being removed.
932 ///
933 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
934 /// grab widget in the grab stack of its window group is not
935 /// its ancestor.
936 ///
937 ///
938 ///
939 ///
940 /// #### `hide`
941 /// The ::hide signal is emitted when `widget` is hidden, for example with
942 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
943 ///
944 ///
945 ///
946 ///
947 /// #### `hierarchy-changed`
948 /// The ::hierarchy-changed signal is emitted when the
949 /// anchored state of a widget changes. A widget is
950 /// “anchored” when its toplevel
951 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
952 /// a widget changes from un-anchored to anchored or vice-versa.
953 ///
954 ///
955 ///
956 ///
957 /// #### `key-press-event`
958 /// The ::key-press-event signal is emitted when a key is pressed. The signal
959 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
960 ///
961 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
962 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
963 ///
964 /// This signal will be sent to the grab widget if there is one.
965 ///
966 ///
967 ///
968 ///
969 /// #### `key-release-event`
970 /// The ::key-release-event signal is emitted when a key is released.
971 ///
972 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
973 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
974 ///
975 /// This signal will be sent to the grab widget if there is one.
976 ///
977 ///
978 ///
979 ///
980 /// #### `keynav-failed`
981 /// Gets emitted if keyboard navigation fails.
982 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
983 ///
984 ///
985 ///
986 ///
987 /// #### `leave-notify-event`
988 /// The ::leave-notify-event will be emitted when the pointer leaves
989 /// the `widget`'s window.
990 ///
991 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
992 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
993 ///
994 /// This signal will be sent to the grab widget if there is one.
995 ///
996 ///
997 ///
998 ///
999 /// #### `map`
1000 /// The ::map signal is emitted when `widget` is going to be mapped, that is
1001 /// when the widget is visible (which is controlled with
1002 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1003 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1004 /// be emitted.
1005 ///
1006 /// The ::map signal can be used to determine whether a widget will be drawn,
1007 /// for instance it can resume an animation that was stopped during the
1008 /// emission of [`unmap`][struct@crate::Widget#unmap].
1009 ///
1010 ///
1011 ///
1012 ///
1013 /// #### `map-event`
1014 /// The ::map-event signal will be emitted when the `widget`'s window is
1015 /// mapped. A window is mapped when it becomes visible on the screen.
1016 ///
1017 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1018 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1019 /// automatically for all new windows.
1020 ///
1021 ///
1022 ///
1023 ///
1024 /// #### `mnemonic-activate`
1025 /// The default handler for this signal activates `widget` if `group_cycling`
1026 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1027 ///
1028 ///
1029 ///
1030 ///
1031 /// #### `motion-notify-event`
1032 /// The ::motion-notify-event signal is emitted when the pointer moves
1033 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1034 ///
1035 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1036 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1037 ///
1038 /// This signal will be sent to the grab widget if there is one.
1039 ///
1040 ///
1041 ///
1042 ///
1043 /// #### `move-focus`
1044 /// Action
1045 ///
1046 ///
1047 /// #### `parent-set`
1048 /// The ::parent-set signal is emitted when a new parent
1049 /// has been set on a widget.
1050 ///
1051 ///
1052 ///
1053 ///
1054 /// #### `popup-menu`
1055 /// This signal gets emitted whenever a widget should pop up a context
1056 /// menu. This usually happens through the standard key binding mechanism;
1057 /// by pressing a certain key while a widget is focused, the user can cause
1058 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1059 /// a menu with clipboard commands. See the
1060 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1061 /// for an example of how to use this signal.
1062 ///
1063 /// Action
1064 ///
1065 ///
1066 /// #### `property-notify-event`
1067 /// The ::property-notify-event signal will be emitted when a property on
1068 /// the `widget`'s window has been changed or deleted.
1069 ///
1070 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1071 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1072 ///
1073 ///
1074 ///
1075 ///
1076 /// #### `proximity-in-event`
1077 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1078 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1079 ///
1080 /// This signal will be sent to the grab widget if there is one.
1081 ///
1082 ///
1083 ///
1084 ///
1085 /// #### `proximity-out-event`
1086 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1087 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1088 ///
1089 /// This signal will be sent to the grab widget if there is one.
1090 ///
1091 ///
1092 ///
1093 ///
1094 /// #### `query-tooltip`
1095 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1096 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1097 /// focus in keyboard mode.
1098 ///
1099 /// Using the given coordinates, the signal handler should determine
1100 /// whether a tooltip should be shown for `widget`. If this is the case
1101 /// [`true`] should be returned, [`false`] otherwise. Note that if
1102 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1103 /// should not be used.
1104 ///
1105 /// The signal handler is free to manipulate `tooltip` with the therefore
1106 /// destined function calls.
1107 ///
1108 ///
1109 ///
1110 ///
1111 /// #### `realize`
1112 /// The ::realize signal is emitted when `widget` is associated with a
1113 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1114 /// widget has been mapped (that is, it is going to be drawn).
1115 ///
1116 ///
1117 ///
1118 ///
1119 /// #### `screen-changed`
1120 /// The ::screen-changed signal gets emitted when the
1121 /// screen of a widget has changed.
1122 ///
1123 ///
1124 ///
1125 ///
1126 /// #### `scroll-event`
1127 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1128 /// range is pressed. Wheel mice are usually configured to generate
1129 /// button press events for buttons 4 and 5 when the wheel is turned.
1130 ///
1131 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1132 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1133 ///
1134 /// This signal will be sent to the grab widget if there is one.
1135 ///
1136 ///
1137 ///
1138 ///
1139 /// #### `selection-clear-event`
1140 /// The ::selection-clear-event signal will be emitted when the
1141 /// the `widget`'s window has lost ownership of a selection.
1142 ///
1143 ///
1144 ///
1145 ///
1146 /// #### `selection-get`
1147 ///
1148 ///
1149 ///
1150 /// #### `selection-notify-event`
1151 ///
1152 ///
1153 ///
1154 /// #### `selection-received`
1155 ///
1156 ///
1157 ///
1158 /// #### `selection-request-event`
1159 /// The ::selection-request-event signal will be emitted when
1160 /// another client requests ownership of the selection owned by
1161 /// the `widget`'s window.
1162 ///
1163 ///
1164 ///
1165 ///
1166 /// #### `show`
1167 /// The ::show signal is emitted when `widget` is shown, for example with
1168 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1169 ///
1170 ///
1171 ///
1172 ///
1173 /// #### `show-help`
1174 /// Action
1175 ///
1176 ///
1177 /// #### `size-allocate`
1178 ///
1179 ///
1180 ///
1181 /// #### `state-changed`
1182 /// The ::state-changed signal is emitted when the widget state changes.
1183 /// See `gtk_widget_get_state()`.
1184 ///
1185 ///
1186 ///
1187 ///
1188 /// #### `state-flags-changed`
1189 /// The ::state-flags-changed signal is emitted when the widget state
1190 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1191 ///
1192 ///
1193 ///
1194 ///
1195 /// #### `style-set`
1196 /// The ::style-set signal is emitted when a new style has been set
1197 /// on a widget. Note that style-modifying functions like
1198 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1199 ///
1200 /// Note that this signal is emitted for changes to the deprecated
1201 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1202 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1203 ///
1204 ///
1205 ///
1206 ///
1207 /// #### `style-updated`
1208 /// The ::style-updated signal is a convenience signal that is emitted when the
1209 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1210 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1211 ///
1212 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1213 /// cause this signal to be emitted.
1214 ///
1215 ///
1216 ///
1217 ///
1218 /// #### `touch-event`
1219 ///
1220 ///
1221 ///
1222 /// #### `unmap`
1223 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1224 /// means that either it or any of its parents up to the toplevel widget have
1225 /// been set as hidden.
1226 ///
1227 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1228 /// used to, for example, stop an animation on the widget.
1229 ///
1230 ///
1231 ///
1232 ///
1233 /// #### `unmap-event`
1234 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1235 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1236 ///
1237 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1238 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1239 /// automatically for all new windows.
1240 ///
1241 ///
1242 ///
1243 ///
1244 /// #### `unrealize`
1245 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1246 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1247 /// called or the widget has been unmapped (that is, it is going to be
1248 /// hidden).
1249 ///
1250 ///
1251 ///
1252 ///
1253 /// #### `visibility-notify-event`
1254 /// The ::visibility-notify-event will be emitted when the `widget`'s
1255 /// window is obscured or unobscured.
1256 ///
1257 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1258 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1259 ///
1260 ///
1261 ///
1262 ///
1263 /// #### `window-state-event`
1264 /// The ::window-state-event will be emitted when the state of the
1265 /// toplevel window associated to the `widget` changes.
1266 ///
1267 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1268 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1269 /// this mask automatically for all new windows.
1270 ///
1271 ///
1272 /// </details>
1273 ///
1274 /// # Implements
1275 ///
1276 /// [`GtkMenuItemExt`][trait@crate::prelude::GtkMenuItemExt], [`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]
1277 #[doc(alias = "GtkMenuItem")]
1278 pub struct MenuItem(Object<ffi::GtkMenuItem, ffi::GtkMenuItemClass>) @extends Bin, Container, Widget, @implements Buildable, Actionable;
1279
1280 match fn {
1281 type_ => || ffi::gtk_menu_item_get_type(),
1282 }
1283}
1284
1285impl MenuItem {
1286 pub const NONE: Option<&'static MenuItem> = None;
1287
1288 /// Creates a new [`MenuItem`][crate::MenuItem].
1289 ///
1290 /// # Returns
1291 ///
1292 /// the newly created [`MenuItem`][crate::MenuItem]
1293 #[doc(alias = "gtk_menu_item_new")]
1294 pub fn new() -> MenuItem {
1295 assert_initialized_main_thread!();
1296 unsafe { Widget::from_glib_none(ffi::gtk_menu_item_new()).unsafe_cast() }
1297 }
1298
1299 /// Creates a new [`MenuItem`][crate::MenuItem] whose child is a [`Label`][crate::Label].
1300 /// ## `label`
1301 /// the text for the label
1302 ///
1303 /// # Returns
1304 ///
1305 /// the newly created [`MenuItem`][crate::MenuItem]
1306 #[doc(alias = "gtk_menu_item_new_with_label")]
1307 #[doc(alias = "new_with_label")]
1308 pub fn with_label(label: &str) -> MenuItem {
1309 assert_initialized_main_thread!();
1310 unsafe {
1311 Widget::from_glib_none(ffi::gtk_menu_item_new_with_label(label.to_glib_none().0))
1312 .unsafe_cast()
1313 }
1314 }
1315
1316 /// Creates a new [`MenuItem`][crate::MenuItem] containing a label.
1317 ///
1318 /// The label will be created using [`Label::with_mnemonic()`][crate::Label::with_mnemonic()],
1319 /// so underscores in `label` indicate the mnemonic for the menu item.
1320 /// ## `label`
1321 /// The text of the button, with an underscore in front of the
1322 /// mnemonic character
1323 ///
1324 /// # Returns
1325 ///
1326 /// a new [`MenuItem`][crate::MenuItem]
1327 #[doc(alias = "gtk_menu_item_new_with_mnemonic")]
1328 #[doc(alias = "new_with_mnemonic")]
1329 pub fn with_mnemonic(label: &str) -> MenuItem {
1330 assert_initialized_main_thread!();
1331 unsafe {
1332 Widget::from_glib_none(ffi::gtk_menu_item_new_with_mnemonic(label.to_glib_none().0))
1333 .unsafe_cast()
1334 }
1335 }
1336
1337 // rustdoc-stripper-ignore-next
1338 /// Creates a new builder-pattern struct instance to construct [`MenuItem`] objects.
1339 ///
1340 /// This method returns an instance of [`MenuItemBuilder`](crate::builders::MenuItemBuilder) which can be used to create [`MenuItem`] objects.
1341 pub fn builder() -> MenuItemBuilder {
1342 MenuItemBuilder::new()
1343 }
1344}
1345
1346impl Default for MenuItem {
1347 fn default() -> Self {
1348 Self::new()
1349 }
1350}
1351
1352// rustdoc-stripper-ignore-next
1353/// A [builder-pattern] type to construct [`MenuItem`] objects.
1354///
1355/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1356#[must_use = "The builder must be built to be used"]
1357pub struct MenuItemBuilder {
1358 builder: glib::object::ObjectBuilder<'static, MenuItem>,
1359}
1360
1361impl MenuItemBuilder {
1362 fn new() -> Self {
1363 Self {
1364 builder: glib::object::Object::builder(),
1365 }
1366 }
1367
1368 /// Sets the accelerator path of the menu item, through which runtime
1369 /// changes of the menu item's accelerator caused by the user can be
1370 /// identified and saved to persistant storage.
1371 pub fn accel_path(self, accel_path: impl Into<glib::GString>) -> Self {
1372 Self {
1373 builder: self.builder.property("accel-path", accel_path.into()),
1374 }
1375 }
1376
1377 /// The text for the child label.
1378 pub fn label(self, label: impl Into<glib::GString>) -> Self {
1379 Self {
1380 builder: self.builder.property("label", label.into()),
1381 }
1382 }
1383
1384 /// Sets whether the menu item appears justified
1385 /// at the right side of a menu bar.
1386 pub fn right_justified(self, right_justified: bool) -> Self {
1387 Self {
1388 builder: self.builder.property("right-justified", right_justified),
1389 }
1390 }
1391
1392 /// The submenu attached to the menu item, or [`None`] if it has none.
1393 pub fn submenu(self, submenu: &impl IsA<Menu>) -> Self {
1394 Self {
1395 builder: self.builder.property("submenu", submenu.clone().upcast()),
1396 }
1397 }
1398
1399 /// [`true`] if underlines in the text indicate mnemonics.
1400 pub fn use_underline(self, use_underline: bool) -> Self {
1401 Self {
1402 builder: self.builder.property("use-underline", use_underline),
1403 }
1404 }
1405
1406 pub fn border_width(self, border_width: u32) -> Self {
1407 Self {
1408 builder: self.builder.property("border-width", border_width),
1409 }
1410 }
1411
1412 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1413 Self {
1414 builder: self.builder.property("child", child.clone().upcast()),
1415 }
1416 }
1417
1418 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1419 Self {
1420 builder: self.builder.property("resize-mode", resize_mode),
1421 }
1422 }
1423
1424 pub fn app_paintable(self, app_paintable: bool) -> Self {
1425 Self {
1426 builder: self.builder.property("app-paintable", app_paintable),
1427 }
1428 }
1429
1430 pub fn can_default(self, can_default: bool) -> Self {
1431 Self {
1432 builder: self.builder.property("can-default", can_default),
1433 }
1434 }
1435
1436 pub fn can_focus(self, can_focus: bool) -> Self {
1437 Self {
1438 builder: self.builder.property("can-focus", can_focus),
1439 }
1440 }
1441
1442 pub fn events(self, events: gdk::EventMask) -> Self {
1443 Self {
1444 builder: self.builder.property("events", events),
1445 }
1446 }
1447
1448 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1449 pub fn expand(self, expand: bool) -> Self {
1450 Self {
1451 builder: self.builder.property("expand", expand),
1452 }
1453 }
1454
1455 /// Whether the widget should grab focus when it is clicked with the mouse.
1456 ///
1457 /// This property is only relevant for widgets that can take focus.
1458 ///
1459 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1460 /// GtkComboBox) implemented this property individually.
1461 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1462 Self {
1463 builder: self.builder.property("focus-on-click", focus_on_click),
1464 }
1465 }
1466
1467 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1468 pub fn halign(self, halign: Align) -> Self {
1469 Self {
1470 builder: self.builder.property("halign", halign),
1471 }
1472 }
1473
1474 pub fn has_default(self, has_default: bool) -> Self {
1475 Self {
1476 builder: self.builder.property("has-default", has_default),
1477 }
1478 }
1479
1480 pub fn has_focus(self, has_focus: bool) -> Self {
1481 Self {
1482 builder: self.builder.property("has-focus", has_focus),
1483 }
1484 }
1485
1486 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1487 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1488 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1489 /// whether it will provide a tooltip or not.
1490 ///
1491 /// Note that setting this property to [`true`] for the first time will change
1492 /// the event masks of the GdkWindows of this widget to include leave-notify
1493 /// and motion-notify events. This cannot and will not be undone when the
1494 /// property is set to [`false`] again.
1495 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1496 Self {
1497 builder: self.builder.property("has-tooltip", has_tooltip),
1498 }
1499 }
1500
1501 pub fn height_request(self, height_request: i32) -> Self {
1502 Self {
1503 builder: self.builder.property("height-request", height_request),
1504 }
1505 }
1506
1507 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1508 pub fn hexpand(self, hexpand: bool) -> Self {
1509 Self {
1510 builder: self.builder.property("hexpand", hexpand),
1511 }
1512 }
1513
1514 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1515 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1516 Self {
1517 builder: self.builder.property("hexpand-set", hexpand_set),
1518 }
1519 }
1520
1521 pub fn is_focus(self, is_focus: bool) -> Self {
1522 Self {
1523 builder: self.builder.property("is-focus", is_focus),
1524 }
1525 }
1526
1527 /// Sets all four sides' margin at once. If read, returns max
1528 /// margin on any side.
1529 pub fn margin(self, margin: i32) -> Self {
1530 Self {
1531 builder: self.builder.property("margin", margin),
1532 }
1533 }
1534
1535 /// Margin on bottom side of widget.
1536 ///
1537 /// This property adds margin outside of the widget's normal size
1538 /// request, the margin will be added in addition to the size from
1539 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1540 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1541 Self {
1542 builder: self.builder.property("margin-bottom", margin_bottom),
1543 }
1544 }
1545
1546 /// Margin on end of widget, horizontally. This property supports
1547 /// left-to-right and right-to-left text directions.
1548 ///
1549 /// This property adds margin outside of the widget's normal size
1550 /// request, the margin will be added in addition to the size from
1551 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1552 pub fn margin_end(self, margin_end: i32) -> Self {
1553 Self {
1554 builder: self.builder.property("margin-end", margin_end),
1555 }
1556 }
1557
1558 /// Margin on start of widget, horizontally. This property supports
1559 /// left-to-right and right-to-left text directions.
1560 ///
1561 /// This property adds margin outside of the widget's normal size
1562 /// request, the margin will be added in addition to the size from
1563 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1564 pub fn margin_start(self, margin_start: i32) -> Self {
1565 Self {
1566 builder: self.builder.property("margin-start", margin_start),
1567 }
1568 }
1569
1570 /// Margin on top side of widget.
1571 ///
1572 /// This property adds margin outside of the widget's normal size
1573 /// request, the margin will be added in addition to the size from
1574 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1575 pub fn margin_top(self, margin_top: i32) -> Self {
1576 Self {
1577 builder: self.builder.property("margin-top", margin_top),
1578 }
1579 }
1580
1581 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1582 Self {
1583 builder: self.builder.property("name", name.into()),
1584 }
1585 }
1586
1587 pub fn no_show_all(self, no_show_all: bool) -> Self {
1588 Self {
1589 builder: self.builder.property("no-show-all", no_show_all),
1590 }
1591 }
1592
1593 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1594 /// more details about window opacity.
1595 ///
1596 /// Before 3.8 this was only available in GtkWindow
1597 pub fn opacity(self, opacity: f64) -> Self {
1598 Self {
1599 builder: self.builder.property("opacity", opacity),
1600 }
1601 }
1602
1603 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1604 Self {
1605 builder: self.builder.property("parent", parent.clone().upcast()),
1606 }
1607 }
1608
1609 pub fn receives_default(self, receives_default: bool) -> Self {
1610 Self {
1611 builder: self.builder.property("receives-default", receives_default),
1612 }
1613 }
1614
1615 pub fn sensitive(self, sensitive: bool) -> Self {
1616 Self {
1617 builder: self.builder.property("sensitive", sensitive),
1618 }
1619 }
1620
1621 /// Sets the text of tooltip to be the given string, which is marked up
1622 /// with the [Pango text markup language][PangoMarkupFormat].
1623 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1624 ///
1625 /// This is a convenience property which will take care of getting the
1626 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1627 /// will automatically be set to [`true`] and there will be taken care of
1628 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1629 ///
1630 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1631 /// are set, the last one wins.
1632 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1633 Self {
1634 builder: self
1635 .builder
1636 .property("tooltip-markup", tooltip_markup.into()),
1637 }
1638 }
1639
1640 /// Sets the text of tooltip to be the given string.
1641 ///
1642 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1643 ///
1644 /// This is a convenience property which will take care of getting the
1645 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1646 /// will automatically be set to [`true`] and there will be taken care of
1647 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1648 ///
1649 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1650 /// are set, the last one wins.
1651 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1652 Self {
1653 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1654 }
1655 }
1656
1657 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1658 pub fn valign(self, valign: Align) -> Self {
1659 Self {
1660 builder: self.builder.property("valign", valign),
1661 }
1662 }
1663
1664 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1665 pub fn vexpand(self, vexpand: bool) -> Self {
1666 Self {
1667 builder: self.builder.property("vexpand", vexpand),
1668 }
1669 }
1670
1671 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1672 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1673 Self {
1674 builder: self.builder.property("vexpand-set", vexpand_set),
1675 }
1676 }
1677
1678 pub fn visible(self, visible: bool) -> Self {
1679 Self {
1680 builder: self.builder.property("visible", visible),
1681 }
1682 }
1683
1684 pub fn width_request(self, width_request: i32) -> Self {
1685 Self {
1686 builder: self.builder.property("width-request", width_request),
1687 }
1688 }
1689
1690 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1691 Self {
1692 builder: self.builder.property("action-name", action_name.into()),
1693 }
1694 }
1695
1696 pub fn action_target(self, action_target: &glib::Variant) -> Self {
1697 Self {
1698 builder: self
1699 .builder
1700 .property("action-target", action_target.clone()),
1701 }
1702 }
1703
1704 // rustdoc-stripper-ignore-next
1705 /// Build the [`MenuItem`].
1706 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1707 pub fn build(self) -> MenuItem {
1708 self.builder.build()
1709 }
1710}
1711
1712mod sealed {
1713 pub trait Sealed {}
1714 impl<T: super::IsA<super::MenuItem>> Sealed for T {}
1715}
1716
1717/// Trait containing all [`struct@MenuItem`] methods.
1718///
1719/// # Implementors
1720///
1721/// [`CheckMenuItem`][struct@crate::CheckMenuItem], [`MenuItem`][struct@crate::MenuItem], [`SeparatorMenuItem`][struct@crate::SeparatorMenuItem]
1722pub trait GtkMenuItemExt: IsA<MenuItem> + sealed::Sealed + 'static {
1723 /// Emits the [`deselect`][struct@crate::MenuItem#deselect] signal on the given item.
1724 #[doc(alias = "gtk_menu_item_deselect")]
1725 fn deselect(&self) {
1726 unsafe {
1727 ffi::gtk_menu_item_deselect(self.as_ref().to_glib_none().0);
1728 }
1729 }
1730
1731 /// Retrieve the accelerator path that was previously set on `self`.
1732 ///
1733 /// See [`set_accel_path()`][Self::set_accel_path()] for details.
1734 ///
1735 /// # Returns
1736 ///
1737 /// the accelerator path corresponding to
1738 /// this menu item’s functionality, or [`None`] if not set
1739 #[doc(alias = "gtk_menu_item_get_accel_path")]
1740 #[doc(alias = "get_accel_path")]
1741 fn accel_path(&self) -> Option<glib::GString> {
1742 unsafe {
1743 from_glib_none(ffi::gtk_menu_item_get_accel_path(
1744 self.as_ref().to_glib_none().0,
1745 ))
1746 }
1747 }
1748
1749 /// Sets `text` on the `self` label
1750 ///
1751 /// # Returns
1752 ///
1753 /// The text in the `self` label. This is the internal
1754 /// string used by the label, and must not be modified.
1755 #[doc(alias = "gtk_menu_item_get_label")]
1756 #[doc(alias = "get_label")]
1757 fn label(&self) -> Option<glib::GString> {
1758 unsafe { from_glib_none(ffi::gtk_menu_item_get_label(self.as_ref().to_glib_none().0)) }
1759 }
1760
1761 /// Returns whether the `self` reserves space for
1762 /// the submenu indicator, regardless if it has a submenu
1763 /// or not.
1764 ///
1765 /// # Returns
1766 ///
1767 /// [`true`] if `self` always reserves space for the
1768 /// submenu indicator
1769 #[doc(alias = "gtk_menu_item_get_reserve_indicator")]
1770 #[doc(alias = "get_reserve_indicator")]
1771 fn must_reserve_indicator(&self) -> bool {
1772 unsafe {
1773 from_glib(ffi::gtk_menu_item_get_reserve_indicator(
1774 self.as_ref().to_glib_none().0,
1775 ))
1776 }
1777 }
1778
1779 /// Gets the submenu underneath this menu item, if any.
1780 /// See [`set_submenu()`][Self::set_submenu()].
1781 ///
1782 /// # Returns
1783 ///
1784 /// submenu for this menu item, or [`None`] if none
1785 #[doc(alias = "gtk_menu_item_get_submenu")]
1786 #[doc(alias = "get_submenu")]
1787 fn submenu(&self) -> Option<Widget> {
1788 unsafe {
1789 from_glib_none(ffi::gtk_menu_item_get_submenu(
1790 self.as_ref().to_glib_none().0,
1791 ))
1792 }
1793 }
1794
1795 /// Checks if an underline in the text indicates the next character
1796 /// should be used for the mnemonic accelerator key.
1797 ///
1798 /// # Returns
1799 ///
1800 /// [`true`] if an embedded underline in the label
1801 /// indicates the mnemonic accelerator key.
1802 #[doc(alias = "gtk_menu_item_get_use_underline")]
1803 #[doc(alias = "get_use_underline")]
1804 fn uses_underline(&self) -> bool {
1805 unsafe {
1806 from_glib(ffi::gtk_menu_item_get_use_underline(
1807 self.as_ref().to_glib_none().0,
1808 ))
1809 }
1810 }
1811
1812 /// Emits the [`select`][struct@crate::MenuItem#select] signal on the given item.
1813 #[doc(alias = "gtk_menu_item_select")]
1814 fn select(&self) {
1815 unsafe {
1816 ffi::gtk_menu_item_select(self.as_ref().to_glib_none().0);
1817 }
1818 }
1819
1820 /// Set the accelerator path on `self`, through which runtime
1821 /// changes of the menu item’s accelerator caused by the user can be
1822 /// identified and saved to persistent storage (see `gtk_accel_map_save()`
1823 /// on this). To set up a default accelerator for this menu item, call
1824 /// `gtk_accel_map_add_entry()` with the same `accel_path`. See also
1825 /// `gtk_accel_map_add_entry()` on the specifics of accelerator paths,
1826 /// and [`GtkMenuExt::set_accel_path()`][crate::prelude::GtkMenuExt::set_accel_path()] for a more convenient variant of
1827 /// this function.
1828 ///
1829 /// This function is basically a convenience wrapper that handles
1830 /// calling [`WidgetExt::set_accel_path()`][crate::prelude::WidgetExt::set_accel_path()] with the appropriate accelerator
1831 /// group for the menu item.
1832 ///
1833 /// Note that you do need to set an accelerator on the parent menu with
1834 /// [`GtkMenuExt::set_accel_group()`][crate::prelude::GtkMenuExt::set_accel_group()] for this to work.
1835 ///
1836 /// Note that `accel_path` string will be stored in a `GQuark`.
1837 /// Therefore, if you pass a static string, you can save some memory
1838 /// by interning it first with `g_intern_static_string()`.
1839 /// ## `accel_path`
1840 /// accelerator path, corresponding to this menu
1841 /// item’s functionality, or [`None`] to unset the current path.
1842 #[doc(alias = "gtk_menu_item_set_accel_path")]
1843 fn set_accel_path(&self, accel_path: Option<&str>) {
1844 unsafe {
1845 ffi::gtk_menu_item_set_accel_path(
1846 self.as_ref().to_glib_none().0,
1847 accel_path.to_glib_none().0,
1848 );
1849 }
1850 }
1851
1852 /// Sets `text` on the `self` label
1853 /// ## `label`
1854 /// the text you want to set
1855 #[doc(alias = "gtk_menu_item_set_label")]
1856 fn set_label(&self, label: &str) {
1857 unsafe {
1858 ffi::gtk_menu_item_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0);
1859 }
1860 }
1861
1862 /// Sets whether the `self` should reserve space for
1863 /// the submenu indicator, regardless if it actually has
1864 /// a submenu or not.
1865 ///
1866 /// There should be little need for applications to call
1867 /// this functions.
1868 /// ## `reserve`
1869 /// the new value
1870 #[doc(alias = "gtk_menu_item_set_reserve_indicator")]
1871 fn set_reserve_indicator(&self, reserve: bool) {
1872 unsafe {
1873 ffi::gtk_menu_item_set_reserve_indicator(
1874 self.as_ref().to_glib_none().0,
1875 reserve.into_glib(),
1876 );
1877 }
1878 }
1879
1880 /// Sets or replaces the menu item’s submenu, or removes it when a [`None`]
1881 /// submenu is passed.
1882 /// ## `submenu`
1883 /// the submenu, or [`None`]
1884 #[doc(alias = "gtk_menu_item_set_submenu")]
1885 fn set_submenu(&self, submenu: Option<&impl IsA<Menu>>) {
1886 unsafe {
1887 ffi::gtk_menu_item_set_submenu(
1888 self.as_ref().to_glib_none().0,
1889 submenu.map(|p| p.as_ref()).to_glib_none().0,
1890 );
1891 }
1892 }
1893
1894 /// If true, an underline in the text indicates the next character
1895 /// should be used for the mnemonic accelerator key.
1896 /// ## `setting`
1897 /// [`true`] if underlines in the text indicate mnemonics
1898 #[doc(alias = "gtk_menu_item_set_use_underline")]
1899 fn set_use_underline(&self, setting: bool) {
1900 unsafe {
1901 ffi::gtk_menu_item_set_use_underline(
1902 self.as_ref().to_glib_none().0,
1903 setting.into_glib(),
1904 );
1905 }
1906 }
1907
1908 /// Emits the [`toggle-size-allocate`][struct@crate::MenuItem#toggle-size-allocate] signal on the given item.
1909 /// ## `allocation`
1910 /// the allocation to use as signal data.
1911 #[doc(alias = "gtk_menu_item_toggle_size_allocate")]
1912 fn toggle_size_allocate(&self, allocation: i32) {
1913 unsafe {
1914 ffi::gtk_menu_item_toggle_size_allocate(self.as_ref().to_glib_none().0, allocation);
1915 }
1916 }
1917
1918 /// Emits the [`toggle-size-request`][struct@crate::MenuItem#toggle-size-request] signal on the given item.
1919 /// ## `requisition`
1920 /// the requisition to use as signal data.
1921 #[doc(alias = "gtk_menu_item_toggle_size_request")]
1922 fn toggle_size_request(&self, requisition: &mut i32) {
1923 unsafe {
1924 ffi::gtk_menu_item_toggle_size_request(self.as_ref().to_glib_none().0, requisition);
1925 }
1926 }
1927
1928 /// Sets whether the menu item appears justified
1929 /// at the right side of a menu bar.
1930 #[doc(alias = "right-justified")]
1931 fn is_right_justified(&self) -> bool {
1932 ObjectExt::property(self.as_ref(), "right-justified")
1933 }
1934
1935 /// Sets whether the menu item appears justified
1936 /// at the right side of a menu bar.
1937 #[doc(alias = "right-justified")]
1938 fn set_right_justified(&self, right_justified: bool) {
1939 ObjectExt::set_property(self.as_ref(), "right-justified", right_justified)
1940 }
1941
1942 /// Emitted when the item is activated.
1943 #[doc(alias = "activate")]
1944 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1945 unsafe extern "C" fn activate_trampoline<P: IsA<MenuItem>, F: Fn(&P) + 'static>(
1946 this: *mut ffi::GtkMenuItem,
1947 f: glib::ffi::gpointer,
1948 ) {
1949 let f: &F = &*(f as *const F);
1950 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
1951 }
1952 unsafe {
1953 let f: Box_<F> = Box_::new(f);
1954 connect_raw(
1955 self.as_ptr() as *mut _,
1956 b"activate\0".as_ptr() as *const _,
1957 Some(transmute::<_, unsafe extern "C" fn()>(
1958 activate_trampoline::<Self, F> as *const (),
1959 )),
1960 Box_::into_raw(f),
1961 )
1962 }
1963 }
1964
1965 fn emit_activate(&self) {
1966 self.emit_by_name::<()>("activate", &[]);
1967 }
1968
1969 /// Emitted when the item is activated, but also if the menu item has a
1970 /// submenu. For normal applications, the relevant signal is
1971 /// [`activate`][struct@crate::MenuItem#activate].
1972 #[doc(alias = "activate-item")]
1973 fn connect_activate_item<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1974 unsafe extern "C" fn activate_item_trampoline<P: IsA<MenuItem>, F: Fn(&P) + 'static>(
1975 this: *mut ffi::GtkMenuItem,
1976 f: glib::ffi::gpointer,
1977 ) {
1978 let f: &F = &*(f as *const F);
1979 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
1980 }
1981 unsafe {
1982 let f: Box_<F> = Box_::new(f);
1983 connect_raw(
1984 self.as_ptr() as *mut _,
1985 b"activate-item\0".as_ptr() as *const _,
1986 Some(transmute::<_, unsafe extern "C" fn()>(
1987 activate_item_trampoline::<Self, F> as *const (),
1988 )),
1989 Box_::into_raw(f),
1990 )
1991 }
1992 }
1993
1994 #[doc(alias = "deselect")]
1995 fn connect_deselect<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1996 unsafe extern "C" fn deselect_trampoline<P: IsA<MenuItem>, F: Fn(&P) + 'static>(
1997 this: *mut ffi::GtkMenuItem,
1998 f: glib::ffi::gpointer,
1999 ) {
2000 let f: &F = &*(f as *const F);
2001 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
2002 }
2003 unsafe {
2004 let f: Box_<F> = Box_::new(f);
2005 connect_raw(
2006 self.as_ptr() as *mut _,
2007 b"deselect\0".as_ptr() as *const _,
2008 Some(transmute::<_, unsafe extern "C" fn()>(
2009 deselect_trampoline::<Self, F> as *const (),
2010 )),
2011 Box_::into_raw(f),
2012 )
2013 }
2014 }
2015
2016 #[doc(alias = "select")]
2017 fn connect_select<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2018 unsafe extern "C" fn select_trampoline<P: IsA<MenuItem>, F: Fn(&P) + 'static>(
2019 this: *mut ffi::GtkMenuItem,
2020 f: glib::ffi::gpointer,
2021 ) {
2022 let f: &F = &*(f as *const F);
2023 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
2024 }
2025 unsafe {
2026 let f: Box_<F> = Box_::new(f);
2027 connect_raw(
2028 self.as_ptr() as *mut _,
2029 b"select\0".as_ptr() as *const _,
2030 Some(transmute::<_, unsafe extern "C" fn()>(
2031 select_trampoline::<Self, F> as *const (),
2032 )),
2033 Box_::into_raw(f),
2034 )
2035 }
2036 }
2037
2038 #[doc(alias = "toggle-size-allocate")]
2039 fn connect_toggle_size_allocate<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
2040 unsafe extern "C" fn toggle_size_allocate_trampoline<
2041 P: IsA<MenuItem>,
2042 F: Fn(&P, i32) + 'static,
2043 >(
2044 this: *mut ffi::GtkMenuItem,
2045 object: libc::c_int,
2046 f: glib::ffi::gpointer,
2047 ) {
2048 let f: &F = &*(f as *const F);
2049 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref(), object)
2050 }
2051 unsafe {
2052 let f: Box_<F> = Box_::new(f);
2053 connect_raw(
2054 self.as_ptr() as *mut _,
2055 b"toggle-size-allocate\0".as_ptr() as *const _,
2056 Some(transmute::<_, unsafe extern "C" fn()>(
2057 toggle_size_allocate_trampoline::<Self, F> as *const (),
2058 )),
2059 Box_::into_raw(f),
2060 )
2061 }
2062 }
2063
2064 //#[doc(alias = "toggle-size-request")]
2065 //fn connect_toggle_size_request<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
2066 // Unimplemented object: *.Pointer
2067 //}
2068
2069 #[doc(alias = "accel-path")]
2070 fn connect_accel_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2071 unsafe extern "C" fn notify_accel_path_trampoline<P: IsA<MenuItem>, F: Fn(&P) + 'static>(
2072 this: *mut ffi::GtkMenuItem,
2073 _param_spec: glib::ffi::gpointer,
2074 f: glib::ffi::gpointer,
2075 ) {
2076 let f: &F = &*(f as *const F);
2077 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
2078 }
2079 unsafe {
2080 let f: Box_<F> = Box_::new(f);
2081 connect_raw(
2082 self.as_ptr() as *mut _,
2083 b"notify::accel-path\0".as_ptr() as *const _,
2084 Some(transmute::<_, unsafe extern "C" fn()>(
2085 notify_accel_path_trampoline::<Self, F> as *const (),
2086 )),
2087 Box_::into_raw(f),
2088 )
2089 }
2090 }
2091
2092 #[doc(alias = "label")]
2093 fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2094 unsafe extern "C" fn notify_label_trampoline<P: IsA<MenuItem>, F: Fn(&P) + 'static>(
2095 this: *mut ffi::GtkMenuItem,
2096 _param_spec: glib::ffi::gpointer,
2097 f: glib::ffi::gpointer,
2098 ) {
2099 let f: &F = &*(f as *const F);
2100 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
2101 }
2102 unsafe {
2103 let f: Box_<F> = Box_::new(f);
2104 connect_raw(
2105 self.as_ptr() as *mut _,
2106 b"notify::label\0".as_ptr() as *const _,
2107 Some(transmute::<_, unsafe extern "C" fn()>(
2108 notify_label_trampoline::<Self, F> as *const (),
2109 )),
2110 Box_::into_raw(f),
2111 )
2112 }
2113 }
2114
2115 #[doc(alias = "right-justified")]
2116 fn connect_right_justified_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2117 unsafe extern "C" fn notify_right_justified_trampoline<
2118 P: IsA<MenuItem>,
2119 F: Fn(&P) + 'static,
2120 >(
2121 this: *mut ffi::GtkMenuItem,
2122 _param_spec: glib::ffi::gpointer,
2123 f: glib::ffi::gpointer,
2124 ) {
2125 let f: &F = &*(f as *const F);
2126 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
2127 }
2128 unsafe {
2129 let f: Box_<F> = Box_::new(f);
2130 connect_raw(
2131 self.as_ptr() as *mut _,
2132 b"notify::right-justified\0".as_ptr() as *const _,
2133 Some(transmute::<_, unsafe extern "C" fn()>(
2134 notify_right_justified_trampoline::<Self, F> as *const (),
2135 )),
2136 Box_::into_raw(f),
2137 )
2138 }
2139 }
2140
2141 #[doc(alias = "submenu")]
2142 fn connect_submenu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2143 unsafe extern "C" fn notify_submenu_trampoline<P: IsA<MenuItem>, F: Fn(&P) + 'static>(
2144 this: *mut ffi::GtkMenuItem,
2145 _param_spec: glib::ffi::gpointer,
2146 f: glib::ffi::gpointer,
2147 ) {
2148 let f: &F = &*(f as *const F);
2149 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
2150 }
2151 unsafe {
2152 let f: Box_<F> = Box_::new(f);
2153 connect_raw(
2154 self.as_ptr() as *mut _,
2155 b"notify::submenu\0".as_ptr() as *const _,
2156 Some(transmute::<_, unsafe extern "C" fn()>(
2157 notify_submenu_trampoline::<Self, F> as *const (),
2158 )),
2159 Box_::into_raw(f),
2160 )
2161 }
2162 }
2163
2164 #[doc(alias = "use-underline")]
2165 fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2166 unsafe extern "C" fn notify_use_underline_trampoline<
2167 P: IsA<MenuItem>,
2168 F: Fn(&P) + 'static,
2169 >(
2170 this: *mut ffi::GtkMenuItem,
2171 _param_spec: glib::ffi::gpointer,
2172 f: glib::ffi::gpointer,
2173 ) {
2174 let f: &F = &*(f as *const F);
2175 f(MenuItem::from_glib_borrow(this).unsafe_cast_ref())
2176 }
2177 unsafe {
2178 let f: Box_<F> = Box_::new(f);
2179 connect_raw(
2180 self.as_ptr() as *mut _,
2181 b"notify::use-underline\0".as_ptr() as *const _,
2182 Some(transmute::<_, unsafe extern "C" fn()>(
2183 notify_use_underline_trampoline::<Self, F> as *const (),
2184 )),
2185 Box_::into_raw(f),
2186 )
2187 }
2188 }
2189}
2190
2191impl<O: IsA<MenuItem>> GtkMenuItemExt for O {}
2192
2193impl fmt::Display for MenuItem {
2194 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2195 f.write_str("MenuItem")
2196 }
2197}