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