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