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