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