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