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