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 /// call `gtk_activatable_do_set_related_action()` when it changes.
365 ///
366 /// Readable | Writable
367 ///
368 ///
369 /// #### `use-action-appearance`
370 /// widget when it changes.
371 ///
372 /// Readable | Writable
373 /// </details>
374 /// <details><summary><h4>Actionable</h4></summary>
375 ///
376 ///
377 /// #### `action-name`
378 /// Readable | Writable
379 ///
380 ///
381 /// #### `action-target`
382 /// Readable | Writable
383 /// </details>
384 ///
385 /// ## Signals
386 ///
387 ///
388 /// #### `toggled`
389 /// Emitted whenever the toggle tool button changes state.
390 ///
391 ///
392 /// <details><summary><h4>ToolButton</h4></summary>
393 ///
394 ///
395 /// #### `clicked`
396 /// This signal is emitted when the tool button is clicked with the mouse
397 /// or activated with the keyboard.
398 ///
399 /// Action
400 /// </details>
401 /// <details><summary><h4>ToolItem</h4></summary>
402 ///
403 ///
404 /// #### `create-menu-proxy`
405 /// This signal is emitted when the toolbar needs information from `tool_item`
406 /// about whether the item should appear in the toolbar overflow menu. In
407 /// response the tool item should either
408 ///
409 /// - call [`ToolItemExt::set_proxy_menu_item()`][crate::prelude::ToolItemExt::set_proxy_menu_item()] with a [`None`]
410 /// pointer and return [`true`] to indicate that the item should not appear
411 /// in the overflow menu
412 ///
413 /// - call [`ToolItemExt::set_proxy_menu_item()`][crate::prelude::ToolItemExt::set_proxy_menu_item()] with a new menu
414 /// item and return [`true`], or
415 ///
416 /// - return [`false`] to indicate that the signal was not handled by the item.
417 /// This means that the item will not appear in the overflow menu unless
418 /// a later handler installs a menu item.
419 ///
420 /// The toolbar may cache the result of this signal. When the tool item changes
421 /// how it will respond to this signal it must call [`ToolItemExt::rebuild_menu()`][crate::prelude::ToolItemExt::rebuild_menu()]
422 /// to invalidate the cache and ensure that the toolbar rebuilds its overflow
423 /// menu.
424 ///
425 ///
426 ///
427 ///
428 /// #### `toolbar-reconfigured`
429 /// This signal is emitted when some property of the toolbar that the
430 /// item is a child of changes. For custom subclasses of [`ToolItem`][crate::ToolItem],
431 /// the default handler of this signal use the functions
432 /// - [`ToolShellExt::orientation()`][crate::prelude::ToolShellExt::orientation()]
433 /// - [`ToolShellExt::style()`][crate::prelude::ToolShellExt::style()]
434 /// - [`ToolShellExt::icon_size()`][crate::prelude::ToolShellExt::icon_size()]
435 /// - [`ToolShellExt::relief_style()`][crate::prelude::ToolShellExt::relief_style()]
436 /// to find out what the toolbar should look like and change
437 /// themselves accordingly.
438 ///
439 ///
440 /// </details>
441 /// <details><summary><h4>Container</h4></summary>
442 ///
443 ///
444 /// #### `add`
445 ///
446 ///
447 ///
448 /// #### `check-resize`
449 ///
450 ///
451 ///
452 /// #### `remove`
453 ///
454 ///
455 ///
456 /// #### `set-focus-child`
457 ///
458 /// </details>
459 /// <details><summary><h4>Widget</h4></summary>
460 ///
461 ///
462 /// #### `accel-closures-changed`
463 ///
464 ///
465 ///
466 /// #### `button-press-event`
467 /// The ::button-press-event signal will be emitted when a button
468 /// (typically from a mouse) is pressed.
469 ///
470 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
471 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
472 ///
473 /// This signal will be sent to the grab widget if there is one.
474 ///
475 ///
476 ///
477 ///
478 /// #### `button-release-event`
479 /// The ::button-release-event signal will be emitted when a button
480 /// (typically from a mouse) is released.
481 ///
482 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
483 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
484 ///
485 /// This signal will be sent to the grab widget if there is one.
486 ///
487 ///
488 ///
489 ///
490 /// #### `can-activate-accel`
491 /// Determines whether an accelerator that activates the signal
492 /// identified by `signal_id` can currently be activated.
493 /// This signal is present to allow applications and derived
494 /// widgets to override the default [`Widget`][crate::Widget] handling
495 /// for determining whether an accelerator can be activated.
496 ///
497 ///
498 ///
499 ///
500 /// #### `child-notify`
501 /// The ::child-notify signal is emitted for each
502 /// [child property][child-properties] that has
503 /// changed on an object. The signal's detail holds the property name.
504 ///
505 /// Detailed
506 ///
507 ///
508 /// #### `composited-changed`
509 /// The ::composited-changed signal is emitted when the composited
510 /// status of `widgets` screen changes.
511 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
512 ///
513 /// Action
514 ///
515 ///
516 /// #### `configure-event`
517 /// The ::configure-event signal will be emitted when the size, position or
518 /// stacking of the `widget`'s window has changed.
519 ///
520 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
521 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
522 /// automatically for all new windows.
523 ///
524 ///
525 ///
526 ///
527 /// #### `damage-event`
528 /// Emitted when a redirected window belonging to `widget` gets drawn into.
529 /// The region/area members of the event shows what area of the redirected
530 /// drawable was drawn into.
531 ///
532 ///
533 ///
534 ///
535 /// #### `delete-event`
536 /// The ::delete-event signal is emitted if a user requests that
537 /// a toplevel window is closed. The default handler for this signal
538 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
539 /// this signal will cause the window to be hidden instead, so that
540 /// it can later be shown again without reconstructing it.
541 ///
542 ///
543 ///
544 ///
545 /// #### `destroy`
546 /// Signals that all holders of a reference to the widget should release
547 /// the reference that they hold. May result in finalization of the widget
548 /// if all references are released.
549 ///
550 /// This signal is not suitable for saving widget state.
551 ///
552 ///
553 ///
554 ///
555 /// #### `destroy-event`
556 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
557 /// You rarely get this signal, because most widgets disconnect themselves
558 /// from their window before they destroy it, so no widget owns the
559 /// window at destroy time.
560 ///
561 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
562 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
563 /// automatically for all new windows.
564 ///
565 ///
566 ///
567 ///
568 /// #### `direction-changed`
569 /// The ::direction-changed signal is emitted when the text direction
570 /// of a widget changes.
571 ///
572 ///
573 ///
574 ///
575 /// #### `drag-begin`
576 /// The ::drag-begin signal is emitted on the drag source when a drag is
577 /// started. A typical reason to connect to this signal is to set up a
578 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
579 ///
580 /// Note that some widgets set up a drag icon in the default handler of
581 /// this signal, so you may have to use `g_signal_connect_after()` to
582 /// override what the default handler did.
583 ///
584 ///
585 ///
586 ///
587 /// #### `drag-data-delete`
588 /// The ::drag-data-delete signal is emitted on the drag source when a drag
589 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
590 /// handler is responsible for deleting the data that has been dropped. What
591 /// "delete" means depends on the context of the drag operation.
592 ///
593 ///
594 ///
595 ///
596 /// #### `drag-data-get`
597 /// The ::drag-data-get signal is emitted on the drag source when the drop
598 /// site requests the data which is dragged. It is the responsibility of
599 /// the signal handler to fill `data` with the data in the format which
600 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
601 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
602 ///
603 ///
604 ///
605 ///
606 /// #### `drag-data-received`
607 /// format == 8))
608 /// {
609 /// GdkDragAction action;
610 ///
611 /// // handle data here
612 ///
613 /// action = gdk_drag_context_get_selected_action (context);
614 /// if (action == GDK_ACTION_ASK)
615 /// {
616 /// GtkWidget *dialog;
617 /// gint response;
618 ///
619 /// dialog = gtk_message_dialog_new (NULL,
620 /// GTK_DIALOG_MODAL |
621 /// GTK_DIALOG_DESTROY_WITH_PARENT,
622 /// GTK_MESSAGE_INFO,
623 /// GTK_BUTTONS_YES_NO,
624 /// "Move the data ?\n");
625 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
626 /// gtk_widget_destroy (dialog);
627 ///
628 /// if (response == GTK_RESPONSE_YES)
629 /// action = GDK_ACTION_MOVE;
630 /// else
631 /// action = GDK_ACTION_COPY;
632 /// }
633 ///
634 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
635 /// }
636 /// else
637 /// gtk_drag_finish (context, FALSE, FALSE, time);
638 /// }
639 /// ]|
640 ///
641 ///
642 ///
643 ///
644 /// #### `drag-drop`
645 /// The ::drag-drop signal is emitted on the drop site when the user drops
646 /// the data onto the widget. The signal handler must determine whether
647 /// the cursor position is in a drop zone or not. If it is not in a drop
648 /// zone, it returns [`false`] and no further processing is necessary.
649 /// Otherwise, the handler returns [`true`]. In this case, the handler must
650 /// ensure that `gtk_drag_finish()` is called to let the source know that
651 /// the drop is done. The call to `gtk_drag_finish()` can be done either
652 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
653 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
654 /// or more of the supported targets.
655 ///
656 ///
657 ///
658 ///
659 /// #### `drag-end`
660 /// The ::drag-end signal is emitted on the drag source when a drag is
661 /// finished. A typical reason to connect to this signal is to undo
662 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
663 ///
664 ///
665 ///
666 ///
667 /// #### `drag-failed`
668 /// The ::drag-failed signal is emitted on the drag source when a drag has
669 /// failed. The signal handler may hook custom code to handle a failed DnD
670 /// operation based on the type of error, it returns [`true`] is the failure has
671 /// been already handled (not showing the default "drag operation failed"
672 /// animation), otherwise it returns [`false`].
673 ///
674 ///
675 ///
676 ///
677 /// #### `drag-leave`
678 /// The ::drag-leave signal is emitted on the drop site when the cursor
679 /// leaves the widget. A typical reason to connect to this signal is to
680 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
681 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
682 ///
683 ///
684 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
685 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
686 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
687 ///
688 ///
689 ///
690 ///
691 /// #### `drag-motion`
692 /// suggested_action,
693 /// time);
694 /// }
695 /// else
696 /// {
697 /// // accept the drop
698 /// }
699 /// }
700 /// ]|
701 ///
702 ///
703 ///
704 ///
705 /// #### `draw`
706 /// This signal is emitted when a widget is supposed to render itself.
707 /// The `widget`'s top left corner must be painted at the origin of
708 /// the passed in context and be sized to the values returned by
709 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
710 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
711 ///
712 /// Signal handlers connected to this signal can modify the cairo
713 /// context passed as `cr` in any way they like and don't need to
714 /// restore it. The signal emission takes care of calling `cairo_save()`
715 /// before and `cairo_restore()` after invoking the handler.
716 ///
717 /// The signal handler will get a `cr` with a clip region already set to the
718 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
719 /// widgets that want to avoid redrawing themselves completely can get the full
720 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
721 /// get a finer-grained representation of the dirty region with
722 /// `cairo_copy_clip_rectangle_list()`.
723 ///
724 ///
725 ///
726 ///
727 /// #### `enter-notify-event`
728 /// The ::enter-notify-event will be emitted when the pointer enters
729 /// the `widget`'s window.
730 ///
731 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
732 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
733 ///
734 /// This signal will be sent to the grab widget if there is one.
735 ///
736 ///
737 ///
738 ///
739 /// #### `event`
740 /// The GTK+ main loop will emit three signals for each GDK event delivered
741 /// to a widget: one generic ::event signal, another, more specific,
742 /// signal that matches the type of event delivered (e.g.
743 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
744 /// [`event-after`][struct@crate::Widget#event-after] signal.
745 ///
746 ///
747 ///
748 ///
749 /// #### `event-after`
750 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
751 /// the second more specific signal, ::event-after will be emitted
752 /// regardless of the previous two signals handlers return values.
753 ///
754 ///
755 ///
756 ///
757 /// #### `focus`
758 ///
759 ///
760 ///
761 /// #### `focus-in-event`
762 /// The ::focus-in-event signal will be emitted when the keyboard focus
763 /// enters the `widget`'s window.
764 ///
765 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
766 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
767 ///
768 ///
769 ///
770 ///
771 /// #### `focus-out-event`
772 /// The ::focus-out-event signal will be emitted when the keyboard focus
773 /// leaves the `widget`'s window.
774 ///
775 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
776 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
777 ///
778 ///
779 ///
780 ///
781 /// #### `grab-broken-event`
782 /// Emitted when a pointer or keyboard grab on a window belonging
783 /// to `widget` gets broken.
784 ///
785 /// On X11, this happens when the grab window becomes unviewable
786 /// (i.e. it or one of its ancestors is unmapped), or if the same
787 /// application grabs the pointer or keyboard again.
788 ///
789 ///
790 ///
791 ///
792 /// #### `grab-focus`
793 /// Action
794 ///
795 ///
796 /// #### `grab-notify`
797 /// The ::grab-notify signal is emitted when a widget becomes
798 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
799 /// another widget, or when it becomes unshadowed due to a grab
800 /// being removed.
801 ///
802 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
803 /// grab widget in the grab stack of its window group is not
804 /// its ancestor.
805 ///
806 ///
807 ///
808 ///
809 /// #### `hide`
810 /// The ::hide signal is emitted when `widget` is hidden, for example with
811 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
812 ///
813 ///
814 ///
815 ///
816 /// #### `hierarchy-changed`
817 /// The ::hierarchy-changed signal is emitted when the
818 /// anchored state of a widget changes. A widget is
819 /// “anchored” when its toplevel
820 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
821 /// a widget changes from un-anchored to anchored or vice-versa.
822 ///
823 ///
824 ///
825 ///
826 /// #### `key-press-event`
827 /// The ::key-press-event signal is emitted when a key is pressed. The signal
828 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
829 ///
830 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
831 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
832 ///
833 /// This signal will be sent to the grab widget if there is one.
834 ///
835 ///
836 ///
837 ///
838 /// #### `key-release-event`
839 /// The ::key-release-event signal is emitted when a key is released.
840 ///
841 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
842 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
843 ///
844 /// This signal will be sent to the grab widget if there is one.
845 ///
846 ///
847 ///
848 ///
849 /// #### `keynav-failed`
850 /// Gets emitted if keyboard navigation fails.
851 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
852 ///
853 ///
854 ///
855 ///
856 /// #### `leave-notify-event`
857 /// The ::leave-notify-event will be emitted when the pointer leaves
858 /// the `widget`'s window.
859 ///
860 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
861 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
862 ///
863 /// This signal will be sent to the grab widget if there is one.
864 ///
865 ///
866 ///
867 ///
868 /// #### `map`
869 /// The ::map signal is emitted when `widget` is going to be mapped, that is
870 /// when the widget is visible (which is controlled with
871 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
872 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
873 /// be emitted.
874 ///
875 /// The ::map signal can be used to determine whether a widget will be drawn,
876 /// for instance it can resume an animation that was stopped during the
877 /// emission of [`unmap`][struct@crate::Widget#unmap].
878 ///
879 ///
880 ///
881 ///
882 /// #### `map-event`
883 /// The ::map-event signal will be emitted when the `widget`'s window is
884 /// mapped. A window is mapped when it becomes visible on the screen.
885 ///
886 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
887 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
888 /// automatically for all new windows.
889 ///
890 ///
891 ///
892 ///
893 /// #### `mnemonic-activate`
894 /// The default handler for this signal activates `widget` if `group_cycling`
895 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
896 ///
897 ///
898 ///
899 ///
900 /// #### `motion-notify-event`
901 /// The ::motion-notify-event signal is emitted when the pointer moves
902 /// over the widget's [`gdk::Window`][crate::gdk::Window].
903 ///
904 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
905 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
906 ///
907 /// This signal will be sent to the grab widget if there is one.
908 ///
909 ///
910 ///
911 ///
912 /// #### `move-focus`
913 /// Action
914 ///
915 ///
916 /// #### `parent-set`
917 /// The ::parent-set signal is emitted when a new parent
918 /// has been set on a widget.
919 ///
920 ///
921 ///
922 ///
923 /// #### `popup-menu`
924 /// This signal gets emitted whenever a widget should pop up a context
925 /// menu. This usually happens through the standard key binding mechanism;
926 /// by pressing a certain key while a widget is focused, the user can cause
927 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
928 /// a menu with clipboard commands. See the
929 /// [Popup Menu Migration Checklist][checklist-popup-menu]
930 /// for an example of how to use this signal.
931 ///
932 /// Action
933 ///
934 ///
935 /// #### `property-notify-event`
936 /// The ::property-notify-event signal will be emitted when a property on
937 /// the `widget`'s window has been changed or deleted.
938 ///
939 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
940 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
941 ///
942 ///
943 ///
944 ///
945 /// #### `proximity-in-event`
946 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
947 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
948 ///
949 /// This signal will be sent to the grab widget if there is one.
950 ///
951 ///
952 ///
953 ///
954 /// #### `proximity-out-event`
955 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
956 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
957 ///
958 /// This signal will be sent to the grab widget if there is one.
959 ///
960 ///
961 ///
962 ///
963 /// #### `query-tooltip`
964 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
965 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
966 /// focus in keyboard mode.
967 ///
968 /// Using the given coordinates, the signal handler should determine
969 /// whether a tooltip should be shown for `widget`. If this is the case
970 /// [`true`] should be returned, [`false`] otherwise. Note that if
971 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
972 /// should not be used.
973 ///
974 /// The signal handler is free to manipulate `tooltip` with the therefore
975 /// destined function calls.
976 ///
977 ///
978 ///
979 ///
980 /// #### `realize`
981 /// The ::realize signal is emitted when `widget` is associated with a
982 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
983 /// widget has been mapped (that is, it is going to be drawn).
984 ///
985 ///
986 ///
987 ///
988 /// #### `screen-changed`
989 /// The ::screen-changed signal gets emitted when the
990 /// screen of a widget has changed.
991 ///
992 ///
993 ///
994 ///
995 /// #### `scroll-event`
996 /// The ::scroll-event signal is emitted when a button in the 4 to 7
997 /// range is pressed. Wheel mice are usually configured to generate
998 /// button press events for buttons 4 and 5 when the wheel is turned.
999 ///
1000 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1001 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1002 ///
1003 /// This signal will be sent to the grab widget if there is one.
1004 ///
1005 ///
1006 ///
1007 ///
1008 /// #### `selection-clear-event`
1009 /// The ::selection-clear-event signal will be emitted when the
1010 /// the `widget`'s window has lost ownership of a selection.
1011 ///
1012 ///
1013 ///
1014 ///
1015 /// #### `selection-get`
1016 ///
1017 ///
1018 ///
1019 /// #### `selection-notify-event`
1020 ///
1021 ///
1022 ///
1023 /// #### `selection-received`
1024 ///
1025 ///
1026 ///
1027 /// #### `selection-request-event`
1028 /// The ::selection-request-event signal will be emitted when
1029 /// another client requests ownership of the selection owned by
1030 /// the `widget`'s window.
1031 ///
1032 ///
1033 ///
1034 ///
1035 /// #### `show`
1036 /// The ::show signal is emitted when `widget` is shown, for example with
1037 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1038 ///
1039 ///
1040 ///
1041 ///
1042 /// #### `show-help`
1043 /// Action
1044 ///
1045 ///
1046 /// #### `size-allocate`
1047 ///
1048 ///
1049 ///
1050 /// #### `state-changed`
1051 /// The ::state-changed signal is emitted when the widget state changes.
1052 /// See `gtk_widget_get_state()`.
1053 ///
1054 ///
1055 ///
1056 ///
1057 /// #### `state-flags-changed`
1058 /// The ::state-flags-changed signal is emitted when the widget state
1059 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1060 ///
1061 ///
1062 ///
1063 ///
1064 /// #### `style-set`
1065 /// The ::style-set signal is emitted when a new style has been set
1066 /// on a widget. Note that style-modifying functions like
1067 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1068 ///
1069 /// Note that this signal is emitted for changes to the deprecated
1070 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1071 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1072 ///
1073 ///
1074 ///
1075 ///
1076 /// #### `style-updated`
1077 /// The ::style-updated signal is a convenience signal that is emitted when the
1078 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1079 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1080 ///
1081 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1082 /// cause this signal to be emitted.
1083 ///
1084 ///
1085 ///
1086 ///
1087 /// #### `touch-event`
1088 ///
1089 ///
1090 ///
1091 /// #### `unmap`
1092 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1093 /// means that either it or any of its parents up to the toplevel widget have
1094 /// been set as hidden.
1095 ///
1096 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1097 /// used to, for example, stop an animation on the widget.
1098 ///
1099 ///
1100 ///
1101 ///
1102 /// #### `unmap-event`
1103 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1104 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1105 ///
1106 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1107 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1108 /// automatically for all new windows.
1109 ///
1110 ///
1111 ///
1112 ///
1113 /// #### `unrealize`
1114 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1115 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1116 /// called or the widget has been unmapped (that is, it is going to be
1117 /// hidden).
1118 ///
1119 ///
1120 ///
1121 ///
1122 /// #### `visibility-notify-event`
1123 /// The ::visibility-notify-event will be emitted when the `widget`'s
1124 /// window is obscured or unobscured.
1125 ///
1126 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1127 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1128 ///
1129 ///
1130 ///
1131 ///
1132 /// #### `window-state-event`
1133 /// The ::window-state-event will be emitted when the state of the
1134 /// toplevel window associated to the `widget` changes.
1135 ///
1136 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1137 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1138 /// this mask automatically for all new windows.
1139 ///
1140 ///
1141 /// </details>
1142 ///
1143 /// # Implements
1144 ///
1145 /// [`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]
1146 #[doc(alias = "GtkToggleToolButton")]
1147 pub struct ToggleToolButton(Object<ffi::GtkToggleToolButton, ffi::GtkToggleToolButtonClass>) @extends ToolButton, ToolItem, Bin, Container, Widget, @implements Buildable, Actionable;
1148
1149 match fn {
1150 type_ => || ffi::gtk_toggle_tool_button_get_type(),
1151 }
1152}
1153
1154impl ToggleToolButton {
1155 pub const NONE: Option<&'static ToggleToolButton> = None;
1156
1157 /// Returns a new [`ToggleToolButton`][crate::ToggleToolButton]
1158 ///
1159 /// # Returns
1160 ///
1161 /// a newly created [`ToggleToolButton`][crate::ToggleToolButton]
1162 #[doc(alias = "gtk_toggle_tool_button_new")]
1163 pub fn new() -> ToggleToolButton {
1164 assert_initialized_main_thread!();
1165 unsafe { ToolItem::from_glib_none(ffi::gtk_toggle_tool_button_new()).unsafe_cast() }
1166 }
1167
1168 // rustdoc-stripper-ignore-next
1169 /// Creates a new builder-pattern struct instance to construct [`ToggleToolButton`] objects.
1170 ///
1171 /// This method returns an instance of [`ToggleToolButtonBuilder`](crate::builders::ToggleToolButtonBuilder) which can be used to create [`ToggleToolButton`] objects.
1172 pub fn builder() -> ToggleToolButtonBuilder {
1173 ToggleToolButtonBuilder::new()
1174 }
1175}
1176
1177impl Default for ToggleToolButton {
1178 fn default() -> Self {
1179 Self::new()
1180 }
1181}
1182
1183// rustdoc-stripper-ignore-next
1184/// A [builder-pattern] type to construct [`ToggleToolButton`] objects.
1185///
1186/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1187#[must_use = "The builder must be built to be used"]
1188pub struct ToggleToolButtonBuilder {
1189 builder: glib::object::ObjectBuilder<'static, ToggleToolButton>,
1190}
1191
1192impl ToggleToolButtonBuilder {
1193 fn new() -> Self {
1194 Self {
1195 builder: glib::object::Object::builder(),
1196 }
1197 }
1198
1199 /// If the toggle tool button should be pressed in.
1200 pub fn active(self, active: bool) -> Self {
1201 Self {
1202 builder: self.builder.property("active", active),
1203 }
1204 }
1205
1206 /// The name of the themed icon displayed on the item.
1207 /// This property only has an effect if not overridden by
1208 /// [`label-widget`][struct@crate::ToolButton#label-widget], [`icon-widget`][struct@crate::ToolButton#icon-widget] or
1209 /// [`stock-id`][struct@crate::ToolButton#stock-id] properties.
1210 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1211 Self {
1212 builder: self.builder.property("icon-name", icon_name.into()),
1213 }
1214 }
1215
1216 pub fn icon_widget(self, icon_widget: &impl IsA<Widget>) -> Self {
1217 Self {
1218 builder: self
1219 .builder
1220 .property("icon-widget", icon_widget.clone().upcast()),
1221 }
1222 }
1223
1224 pub fn label(self, label: impl Into<glib::GString>) -> Self {
1225 Self {
1226 builder: self.builder.property("label", label.into()),
1227 }
1228 }
1229
1230 pub fn label_widget(self, label_widget: &impl IsA<Widget>) -> Self {
1231 Self {
1232 builder: self
1233 .builder
1234 .property("label-widget", label_widget.clone().upcast()),
1235 }
1236 }
1237
1238 pub fn use_underline(self, use_underline: bool) -> Self {
1239 Self {
1240 builder: self.builder.property("use-underline", use_underline),
1241 }
1242 }
1243
1244 pub fn is_important(self, is_important: bool) -> Self {
1245 Self {
1246 builder: self.builder.property("is-important", is_important),
1247 }
1248 }
1249
1250 pub fn visible_horizontal(self, visible_horizontal: bool) -> Self {
1251 Self {
1252 builder: self
1253 .builder
1254 .property("visible-horizontal", visible_horizontal),
1255 }
1256 }
1257
1258 pub fn visible_vertical(self, visible_vertical: bool) -> Self {
1259 Self {
1260 builder: self.builder.property("visible-vertical", visible_vertical),
1261 }
1262 }
1263
1264 pub fn border_width(self, border_width: u32) -> Self {
1265 Self {
1266 builder: self.builder.property("border-width", border_width),
1267 }
1268 }
1269
1270 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1271 Self {
1272 builder: self.builder.property("child", child.clone().upcast()),
1273 }
1274 }
1275
1276 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1277 Self {
1278 builder: self.builder.property("resize-mode", resize_mode),
1279 }
1280 }
1281
1282 pub fn app_paintable(self, app_paintable: bool) -> Self {
1283 Self {
1284 builder: self.builder.property("app-paintable", app_paintable),
1285 }
1286 }
1287
1288 pub fn can_default(self, can_default: bool) -> Self {
1289 Self {
1290 builder: self.builder.property("can-default", can_default),
1291 }
1292 }
1293
1294 pub fn can_focus(self, can_focus: bool) -> Self {
1295 Self {
1296 builder: self.builder.property("can-focus", can_focus),
1297 }
1298 }
1299
1300 pub fn events(self, events: gdk::EventMask) -> Self {
1301 Self {
1302 builder: self.builder.property("events", events),
1303 }
1304 }
1305
1306 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1307 pub fn expand(self, expand: bool) -> Self {
1308 Self {
1309 builder: self.builder.property("expand", expand),
1310 }
1311 }
1312
1313 /// Whether the widget should grab focus when it is clicked with the mouse.
1314 ///
1315 /// This property is only relevant for widgets that can take focus.
1316 ///
1317 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1318 /// GtkComboBox) implemented this property individually.
1319 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1320 Self {
1321 builder: self.builder.property("focus-on-click", focus_on_click),
1322 }
1323 }
1324
1325 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1326 pub fn halign(self, halign: Align) -> Self {
1327 Self {
1328 builder: self.builder.property("halign", halign),
1329 }
1330 }
1331
1332 pub fn has_default(self, has_default: bool) -> Self {
1333 Self {
1334 builder: self.builder.property("has-default", has_default),
1335 }
1336 }
1337
1338 pub fn has_focus(self, has_focus: bool) -> Self {
1339 Self {
1340 builder: self.builder.property("has-focus", has_focus),
1341 }
1342 }
1343
1344 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1345 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1346 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1347 /// whether it will provide a tooltip or not.
1348 ///
1349 /// Note that setting this property to [`true`] for the first time will change
1350 /// the event masks of the GdkWindows of this widget to include leave-notify
1351 /// and motion-notify events. This cannot and will not be undone when the
1352 /// property is set to [`false`] again.
1353 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1354 Self {
1355 builder: self.builder.property("has-tooltip", has_tooltip),
1356 }
1357 }
1358
1359 pub fn height_request(self, height_request: i32) -> Self {
1360 Self {
1361 builder: self.builder.property("height-request", height_request),
1362 }
1363 }
1364
1365 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1366 pub fn hexpand(self, hexpand: bool) -> Self {
1367 Self {
1368 builder: self.builder.property("hexpand", hexpand),
1369 }
1370 }
1371
1372 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1373 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1374 Self {
1375 builder: self.builder.property("hexpand-set", hexpand_set),
1376 }
1377 }
1378
1379 pub fn is_focus(self, is_focus: bool) -> Self {
1380 Self {
1381 builder: self.builder.property("is-focus", is_focus),
1382 }
1383 }
1384
1385 /// Sets all four sides' margin at once. If read, returns max
1386 /// margin on any side.
1387 pub fn margin(self, margin: i32) -> Self {
1388 Self {
1389 builder: self.builder.property("margin", margin),
1390 }
1391 }
1392
1393 /// Margin on bottom side of widget.
1394 ///
1395 /// This property adds margin outside of the widget's normal size
1396 /// request, the margin will be added in addition to the size from
1397 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1398 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1399 Self {
1400 builder: self.builder.property("margin-bottom", margin_bottom),
1401 }
1402 }
1403
1404 /// Margin on end of widget, horizontally. This property supports
1405 /// left-to-right and right-to-left text directions.
1406 ///
1407 /// This property adds margin outside of the widget's normal size
1408 /// request, the margin will be added in addition to the size from
1409 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1410 pub fn margin_end(self, margin_end: i32) -> Self {
1411 Self {
1412 builder: self.builder.property("margin-end", margin_end),
1413 }
1414 }
1415
1416 /// Margin on start of widget, horizontally. This property supports
1417 /// left-to-right and right-to-left text directions.
1418 ///
1419 /// This property adds margin outside of the widget's normal size
1420 /// request, the margin will be added in addition to the size from
1421 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1422 pub fn margin_start(self, margin_start: i32) -> Self {
1423 Self {
1424 builder: self.builder.property("margin-start", margin_start),
1425 }
1426 }
1427
1428 /// Margin on top side of widget.
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_top(self, margin_top: i32) -> Self {
1434 Self {
1435 builder: self.builder.property("margin-top", margin_top),
1436 }
1437 }
1438
1439 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1440 Self {
1441 builder: self.builder.property("name", name.into()),
1442 }
1443 }
1444
1445 pub fn no_show_all(self, no_show_all: bool) -> Self {
1446 Self {
1447 builder: self.builder.property("no-show-all", no_show_all),
1448 }
1449 }
1450
1451 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1452 /// more details about window opacity.
1453 ///
1454 /// Before 3.8 this was only available in GtkWindow
1455 pub fn opacity(self, opacity: f64) -> Self {
1456 Self {
1457 builder: self.builder.property("opacity", opacity),
1458 }
1459 }
1460
1461 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1462 Self {
1463 builder: self.builder.property("parent", parent.clone().upcast()),
1464 }
1465 }
1466
1467 pub fn receives_default(self, receives_default: bool) -> Self {
1468 Self {
1469 builder: self.builder.property("receives-default", receives_default),
1470 }
1471 }
1472
1473 pub fn sensitive(self, sensitive: bool) -> Self {
1474 Self {
1475 builder: self.builder.property("sensitive", sensitive),
1476 }
1477 }
1478
1479 /// Sets the text of tooltip to be the given string, which is marked up
1480 /// with the [Pango text markup language][PangoMarkupFormat].
1481 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1482 ///
1483 /// This is a convenience property which will take care of getting the
1484 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1485 /// will automatically be set to [`true`] and there will be taken care of
1486 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1487 ///
1488 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1489 /// are set, the last one wins.
1490 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1491 Self {
1492 builder: self
1493 .builder
1494 .property("tooltip-markup", tooltip_markup.into()),
1495 }
1496 }
1497
1498 /// Sets the text of tooltip to be the given string.
1499 ///
1500 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1501 ///
1502 /// This is a convenience property which will take care of getting the
1503 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1504 /// will automatically be set to [`true`] and there will be taken care of
1505 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1506 ///
1507 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1508 /// are set, the last one wins.
1509 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1510 Self {
1511 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1512 }
1513 }
1514
1515 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1516 pub fn valign(self, valign: Align) -> Self {
1517 Self {
1518 builder: self.builder.property("valign", valign),
1519 }
1520 }
1521
1522 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1523 pub fn vexpand(self, vexpand: bool) -> Self {
1524 Self {
1525 builder: self.builder.property("vexpand", vexpand),
1526 }
1527 }
1528
1529 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1530 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1531 Self {
1532 builder: self.builder.property("vexpand-set", vexpand_set),
1533 }
1534 }
1535
1536 pub fn visible(self, visible: bool) -> Self {
1537 Self {
1538 builder: self.builder.property("visible", visible),
1539 }
1540 }
1541
1542 pub fn width_request(self, width_request: i32) -> Self {
1543 Self {
1544 builder: self.builder.property("width-request", width_request),
1545 }
1546 }
1547
1548 pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
1549 Self {
1550 builder: self.builder.property("action-name", action_name.into()),
1551 }
1552 }
1553
1554 pub fn action_target(self, action_target: &glib::Variant) -> Self {
1555 Self {
1556 builder: self
1557 .builder
1558 .property("action-target", action_target.clone()),
1559 }
1560 }
1561
1562 // rustdoc-stripper-ignore-next
1563 /// Build the [`ToggleToolButton`].
1564 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1565 pub fn build(self) -> ToggleToolButton {
1566 assert_initialized_main_thread!();
1567 self.builder.build()
1568 }
1569}
1570
1571/// Trait containing all [`struct@ToggleToolButton`] methods.
1572///
1573/// # Implementors
1574///
1575/// [`RadioToolButton`][struct@crate::RadioToolButton], [`ToggleToolButton`][struct@crate::ToggleToolButton]
1576pub trait ToggleToolButtonExt: IsA<ToggleToolButton> + 'static {
1577 /// Queries a [`ToggleToolButton`][crate::ToggleToolButton] and returns its current state.
1578 /// Returns [`true`] if the toggle button is pressed in and [`false`] if it is raised.
1579 ///
1580 /// # Returns
1581 ///
1582 /// [`true`] if the toggle tool button is pressed in, [`false`] if not
1583 #[doc(alias = "gtk_toggle_tool_button_get_active")]
1584 #[doc(alias = "get_active")]
1585 #[doc(alias = "active")]
1586 fn is_active(&self) -> bool {
1587 unsafe {
1588 from_glib(ffi::gtk_toggle_tool_button_get_active(
1589 self.as_ref().to_glib_none().0,
1590 ))
1591 }
1592 }
1593
1594 /// Sets the status of the toggle tool button. Set to [`true`] if you
1595 /// want the GtkToggleButton to be “pressed in”, and [`false`] to raise it.
1596 /// This action causes the toggled signal to be emitted.
1597 /// ## `is_active`
1598 /// whether `self` should be active
1599 #[doc(alias = "gtk_toggle_tool_button_set_active")]
1600 #[doc(alias = "active")]
1601 fn set_active(&self, is_active: bool) {
1602 unsafe {
1603 ffi::gtk_toggle_tool_button_set_active(
1604 self.as_ref().to_glib_none().0,
1605 is_active.into_glib(),
1606 );
1607 }
1608 }
1609
1610 /// Emitted whenever the toggle tool button changes state.
1611 #[doc(alias = "toggled")]
1612 fn connect_toggled<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1613 unsafe extern "C" fn toggled_trampoline<P: IsA<ToggleToolButton>, F: Fn(&P) + 'static>(
1614 this: *mut ffi::GtkToggleToolButton,
1615 f: glib::ffi::gpointer,
1616 ) {
1617 unsafe {
1618 let f: &F = &*(f as *const F);
1619 f(ToggleToolButton::from_glib_borrow(this).unsafe_cast_ref())
1620 }
1621 }
1622 unsafe {
1623 let f: Box_<F> = Box_::new(f);
1624 connect_raw(
1625 self.as_ptr() as *mut _,
1626 c"toggled".as_ptr(),
1627 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1628 toggled_trampoline::<Self, F> as *const (),
1629 )),
1630 Box_::into_raw(f),
1631 )
1632 }
1633 }
1634
1635 #[doc(alias = "active")]
1636 fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1637 unsafe extern "C" fn notify_active_trampoline<
1638 P: IsA<ToggleToolButton>,
1639 F: Fn(&P) + 'static,
1640 >(
1641 this: *mut ffi::GtkToggleToolButton,
1642 _param_spec: glib::ffi::gpointer,
1643 f: glib::ffi::gpointer,
1644 ) {
1645 unsafe {
1646 let f: &F = &*(f as *const F);
1647 f(ToggleToolButton::from_glib_borrow(this).unsafe_cast_ref())
1648 }
1649 }
1650 unsafe {
1651 let f: Box_<F> = Box_::new(f);
1652 connect_raw(
1653 self.as_ptr() as *mut _,
1654 c"notify::active".as_ptr(),
1655 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1656 notify_active_trampoline::<Self, F> as *const (),
1657 )),
1658 Box_::into_raw(f),
1659 )
1660 }
1661 }
1662}
1663
1664impl<O: IsA<ToggleToolButton>> ToggleToolButtonExt for O {}