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