libadwaita/auto/
carousel.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, SpringParams, Swipeable};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    /// A paginated scrolling widget.
17    ///
18    /// <picture>
19    ///   <source srcset="carousel-dark.png" media="(prefers-color-scheme: dark)">
20    ///   <img src="carousel.png" alt="carousel">
21    /// </picture>
22    ///
23    /// The [`Carousel`][crate::Carousel] widget can be used to display a set of pages with
24    /// swipe-based navigation between them.
25    ///
26    /// [`CarouselIndicatorDots`][crate::CarouselIndicatorDots] and [`CarouselIndicatorLines`][crate::CarouselIndicatorLines] can be used
27    /// to provide page indicators for [`Carousel`][crate::Carousel].
28    ///
29    /// ## CSS nodes
30    ///
31    /// [`Carousel`][crate::Carousel] has a single CSS node with name `carousel`.
32    ///
33    /// ## Properties
34    ///
35    ///
36    /// #### `allow-long-swipes`
37    ///  Whether to allow swiping for more than one page at a time.
38    ///
39    /// If the value is `FALSE`, each swipe can only move to the adjacent pages.
40    ///
41    /// Readable | Writeable
42    ///
43    ///
44    /// #### `allow-mouse-drag`
45    ///  Sets whether the [`Carousel`][crate::Carousel] can be dragged with mouse pointer.
46    ///
47    /// If the value is `FALSE`, dragging is only available on touch.
48    ///
49    /// Readable | Writeable
50    ///
51    ///
52    /// #### `allow-scroll-wheel`
53    ///  Whether the widget will respond to scroll wheel events.
54    ///
55    /// If the value is `FALSE`, wheel events will be ignored.
56    ///
57    /// Readable | Writeable
58    ///
59    ///
60    /// #### `interactive`
61    ///  Whether the carousel can be navigated.
62    ///
63    /// This can be used to temporarily disable the carousel to only allow
64    /// navigating it in a certain state.
65    ///
66    /// Readable | Writeable
67    ///
68    ///
69    /// #### `n-pages`
70    ///  The number of pages in a [`Carousel`][crate::Carousel].
71    ///
72    /// Readable
73    ///
74    ///
75    /// #### `position`
76    ///  Current scrolling position, unitless.
77    ///
78    /// 1 matches 1 page. Use [`Carousel::scroll_to()`][crate::Carousel::scroll_to()] for changing it.
79    ///
80    /// Readable
81    ///
82    ///
83    /// #### `reveal-duration`
84    ///  Page reveal duration, in milliseconds.
85    ///
86    /// Reveal duration is used when animating adding or removing pages.
87    ///
88    /// Readable | Writeable
89    ///
90    ///
91    /// #### `scroll-params`
92    ///  Scroll animation spring parameters.
93    ///
94    /// The default value is equivalent to:
95    ///
96    /// **⚠️ The following code is in c ⚠️**
97    ///
98    /// ```c
99    /// adw_spring_params_new (1, 0.5, 500)
100    /// ```
101    ///
102    /// Readable | Writeable
103    ///
104    ///
105    /// #### `spacing`
106    ///  Spacing between pages in pixels.
107    ///
108    /// Readable | Writeable
109    /// <details><summary><h4>Widget</h4></summary>
110    ///
111    ///
112    /// #### `can-focus`
113    ///  Whether the widget or any of its descendents can accept
114    /// the input focus.
115    ///
116    /// This property is meant to be set by widget implementations,
117    /// typically in their instance init function.
118    ///
119    /// Readable | Writeable
120    ///
121    ///
122    /// #### `can-target`
123    ///  Whether the widget can receive pointer events.
124    ///
125    /// Readable | Writeable
126    ///
127    ///
128    /// #### `css-classes`
129    ///  A list of css classes applied to this widget.
130    ///
131    /// Readable | Writeable
132    ///
133    ///
134    /// #### `css-name`
135    ///  The name of this widget in the CSS tree.
136    ///
137    /// This property is meant to be set by widget implementations,
138    /// typically in their instance init function.
139    ///
140    /// Readable | Writeable | Construct Only
141    ///
142    ///
143    /// #### `cursor`
144    ///  The cursor used by @widget.
145    ///
146    /// Readable | Writeable
147    ///
148    ///
149    /// #### `focus-on-click`
150    ///  Whether the widget should grab focus when it is clicked with the mouse.
151    ///
152    /// This property is only relevant for widgets that can take focus.
153    ///
154    /// Readable | Writeable
155    ///
156    ///
157    /// #### `focusable`
158    ///  Whether this widget itself will accept the input focus.
159    ///
160    /// Readable | Writeable
161    ///
162    ///
163    /// #### `halign`
164    ///  How to distribute horizontal space if widget gets extra space.
165    ///
166    /// Readable | Writeable
167    ///
168    ///
169    /// #### `has-default`
170    ///  Whether the widget is the default widget.
171    ///
172    /// Readable
173    ///
174    ///
175    /// #### `has-focus`
176    ///  Whether the widget has the input focus.
177    ///
178    /// Readable
179    ///
180    ///
181    /// #### `has-tooltip`
182    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
183    /// signal on @widget.
184    ///
185    /// A true value indicates that @widget can have a tooltip, in this case
186    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
187    /// determine whether it will provide a tooltip or not.
188    ///
189    /// Readable | Writeable
190    ///
191    ///
192    /// #### `height-request`
193    ///  Overrides for height request of the widget.
194    ///
195    /// If this is -1, the natural request will be used.
196    ///
197    /// Readable | Writeable
198    ///
199    ///
200    /// #### `hexpand`
201    ///  Whether to expand horizontally.
202    ///
203    /// Readable | Writeable
204    ///
205    ///
206    /// #### `hexpand-set`
207    ///  Whether to use the `hexpand` property.
208    ///
209    /// Readable | Writeable
210    ///
211    ///
212    /// #### `layout-manager`
213    ///  The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
214    /// the preferred size of the widget, and allocate its children.
215    ///
216    /// This property is meant to be set by widget implementations,
217    /// typically in their instance init function.
218    ///
219    /// Readable | Writeable
220    ///
221    ///
222    /// #### `limit-events`
223    ///  Makes this widget act like a modal dialog, with respect to
224    /// event delivery.
225    ///
226    /// Global event controllers will not handle events with targets
227    /// inside the widget, unless they are set up to ignore propagation
228    /// limits. See `Gtk::EventController::set_propagation_limit()`.
229    ///
230    /// Readable | Writeable
231    ///
232    ///
233    /// #### `margin-bottom`
234    ///  Margin on bottom side of widget.
235    ///
236    /// This property adds margin outside of the widget's normal size
237    /// request, the margin will be added in addition to the size from
238    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
239    ///
240    /// Readable | Writeable
241    ///
242    ///
243    /// #### `margin-end`
244    ///  Margin on end of widget, horizontally.
245    ///
246    /// This property supports left-to-right and right-to-left text
247    /// directions.
248    ///
249    /// This property adds margin outside of the widget's normal size
250    /// request, the margin will be added in addition to the size from
251    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
252    ///
253    /// Readable | Writeable
254    ///
255    ///
256    /// #### `margin-start`
257    ///  Margin on start of widget, horizontally.
258    ///
259    /// This property supports left-to-right and right-to-left text
260    /// directions.
261    ///
262    /// This property adds margin outside of the widget's normal size
263    /// request, the margin will be added in addition to the size from
264    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
265    ///
266    /// Readable | Writeable
267    ///
268    ///
269    /// #### `margin-top`
270    ///  Margin on top side of widget.
271    ///
272    /// This property adds margin outside of the widget's normal size
273    /// request, the margin will be added in addition to the size from
274    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
275    ///
276    /// Readable | Writeable
277    ///
278    ///
279    /// #### `name`
280    ///  The name of the widget.
281    ///
282    /// Readable | Writeable
283    ///
284    ///
285    /// #### `opacity`
286    ///  The requested opacity of the widget.
287    ///
288    /// Readable | Writeable
289    ///
290    ///
291    /// #### `overflow`
292    ///  How content outside the widget's content area is treated.
293    ///
294    /// This property is meant to be set by widget implementations,
295    /// typically in their instance init function.
296    ///
297    /// Readable | Writeable
298    ///
299    ///
300    /// #### `parent`
301    ///  The parent widget of this widget.
302    ///
303    /// Readable
304    ///
305    ///
306    /// #### `receives-default`
307    ///  Whether the widget will receive the default action when it is focused.
308    ///
309    /// Readable | Writeable
310    ///
311    ///
312    /// #### `root`
313    ///  The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
314    ///
315    /// This will be `NULL` if the widget is not contained in a root widget.
316    ///
317    /// Readable
318    ///
319    ///
320    /// #### `scale-factor`
321    ///  The scale factor of the widget.
322    ///
323    /// Readable
324    ///
325    ///
326    /// #### `sensitive`
327    ///  Whether the widget responds to input.
328    ///
329    /// Readable | Writeable
330    ///
331    ///
332    /// #### `tooltip-markup`
333    ///  Sets the text of tooltip to be the given string, which is marked up
334    /// with Pango markup.
335    ///
336    /// Also see `Gtk::Tooltip::set_markup()`.
337    ///
338    /// This is a convenience property which will take care of getting the
339    /// tooltip shown if the given string is not `NULL`:
340    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
341    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
342    /// the default signal handler.
343    ///
344    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
345    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
346    ///
347    /// Readable | Writeable
348    ///
349    ///
350    /// #### `tooltip-text`
351    ///  Sets the text of tooltip to be the given string.
352    ///
353    /// Also see `Gtk::Tooltip::set_text()`.
354    ///
355    /// This is a convenience property which will take care of getting the
356    /// tooltip shown if the given string is not `NULL`:
357    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
358    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
359    /// the default signal handler.
360    ///
361    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
362    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
363    ///
364    /// Readable | Writeable
365    ///
366    ///
367    /// #### `valign`
368    ///  How to distribute vertical space if widget gets extra space.
369    ///
370    /// Readable | Writeable
371    ///
372    ///
373    /// #### `vexpand`
374    ///  Whether to expand vertically.
375    ///
376    /// Readable | Writeable
377    ///
378    ///
379    /// #### `vexpand-set`
380    ///  Whether to use the `vexpand` property.
381    ///
382    /// Readable | Writeable
383    ///
384    ///
385    /// #### `visible`
386    ///  Whether the widget is visible.
387    ///
388    /// Readable | Writeable
389    ///
390    ///
391    /// #### `width-request`
392    ///  Overrides for width request of the widget.
393    ///
394    /// If this is -1, the natural request will be used.
395    ///
396    /// Readable | Writeable
397    /// </details>
398    /// <details><summary><h4>Accessible</h4></summary>
399    ///
400    ///
401    /// #### `accessible-role`
402    ///  The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
403    ///
404    /// The accessible role cannot be changed once set.
405    ///
406    /// Readable | Writeable
407    /// </details>
408    /// <details><summary><h4>Orientable</h4></summary>
409    ///
410    ///
411    /// #### `orientation`
412    ///  The orientation of the orientable.
413    ///
414    /// Readable | Writeable
415    /// </details>
416    ///
417    /// ## Signals
418    ///
419    ///
420    /// #### `page-changed`
421    ///  This signal is emitted after a page has been changed.
422    ///
423    /// It can be used to implement "infinite scrolling" by amending the pages
424    /// after every scroll.
425    ///
426    /// ::: note
427    ///     An empty carousel is indicated by `(int)index == -1`.
428    ///
429    ///
430    /// <details><summary><h4>Widget</h4></summary>
431    ///
432    ///
433    /// #### `destroy`
434    ///  Signals that all holders of a reference to the widget should release
435    /// the reference that they hold.
436    ///
437    /// May result in finalization of the widget if all references are released.
438    ///
439    /// This signal is not suitable for saving widget state.
440    ///
441    ///
442    ///
443    ///
444    /// #### `direction-changed`
445    ///  Emitted when the text direction of a widget changes.
446    ///
447    ///
448    ///
449    ///
450    /// #### `hide`
451    ///  Emitted when @widget is hidden.
452    ///
453    ///
454    ///
455    ///
456    /// #### `keynav-failed`
457    ///  Emitted if keyboard navigation fails.
458    ///
459    /// See [`WidgetExtManual::keynav_failed()`][crate::gtk::prelude::WidgetExtManual::keynav_failed()] for details.
460    ///
461    ///
462    ///
463    ///
464    /// #### `map`
465    ///  Emitted when @widget is going to be mapped.
466    ///
467    /// A widget is mapped when the widget is visible (which is controlled with
468    /// [`visible`][struct@crate::gtk::Widget#visible]) and all its parents up to the toplevel widget
469    /// are also visible.
470    ///
471    /// The `::map` signal can be used to determine whether a widget will be drawn,
472    /// for instance it can resume an animation that was stopped during the
473    /// emission of [`unmap`][struct@crate::gtk::Widget#unmap].
474    ///
475    ///
476    ///
477    ///
478    /// #### `mnemonic-activate`
479    ///  Emitted when a widget is activated via a mnemonic.
480    ///
481    /// The default handler for this signal activates @widget if @group_cycling
482    /// is false, or just makes @widget grab focus if @group_cycling is true.
483    ///
484    ///
485    ///
486    ///
487    /// #### `move-focus`
488    ///  Emitted when the focus is moved.
489    ///
490    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
491    ///
492    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
493    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
494    ///
495    /// Action
496    ///
497    ///
498    /// #### `query-tooltip`
499    ///  Emitted when the widget’s tooltip is about to be shown.
500    ///
501    /// This happens when the [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] property
502    /// is true and the hover timeout has expired with the cursor hovering
503    /// above @widget; or emitted when @widget got focus in keyboard mode.
504    ///
505    /// Using the given coordinates, the signal handler should determine
506    /// whether a tooltip should be shown for @widget. If this is the case
507    /// true should be returned, false otherwise. Note that if @keyboard_mode
508    /// is true, the values of @x and @y are undefined and should not be used.
509    ///
510    /// The signal handler is free to manipulate @tooltip with the therefore
511    /// destined function calls.
512    ///
513    ///
514    ///
515    ///
516    /// #### `realize`
517    ///  Emitted when @widget is associated with a `GdkSurface`.
518    ///
519    /// This means that [`WidgetExtManual::realize()`][crate::gtk::prelude::WidgetExtManual::realize()] has been called
520    /// or the widget has been mapped (that is, it is going to be drawn).
521    ///
522    ///
523    ///
524    ///
525    /// #### `show`
526    ///  Emitted when @widget is shown.
527    ///
528    ///
529    ///
530    ///
531    /// #### `state-flags-changed`
532    ///  Emitted when the widget state changes.
533    ///
534    /// See [`WidgetExtManual::state_flags()`][crate::gtk::prelude::WidgetExtManual::state_flags()].
535    ///
536    ///
537    ///
538    ///
539    /// #### `unmap`
540    ///  Emitted when @widget is going to be unmapped.
541    ///
542    /// A widget is unmapped when either it or any of its parents up to the
543    /// toplevel widget have been set as hidden.
544    ///
545    /// As `::unmap` indicates that a widget will not be shown any longer,
546    /// it can be used to, for example, stop an animation on the widget.
547    ///
548    ///
549    ///
550    ///
551    /// #### `unrealize`
552    ///  Emitted when the `GdkSurface` associated with @widget is destroyed.
553    ///
554    /// This means that [`WidgetExtManual::unrealize()`][crate::gtk::prelude::WidgetExtManual::unrealize()] has been called
555    /// or the widget has been unmapped (that is, it is going to be hidden).
556    ///
557    ///
558    /// </details>
559    ///
560    /// # Implements
561    ///
562    /// [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`SwipeableExt`][trait@crate::prelude::SwipeableExt], [`trait@gtk::prelude::OrientableExt`]
563    #[doc(alias = "AdwCarousel")]
564    pub struct Carousel(Object<ffi::AdwCarousel, ffi::AdwCarouselClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, Swipeable, gtk::Orientable;
565
566    match fn {
567        type_ => || ffi::adw_carousel_get_type(),
568    }
569}
570
571impl Carousel {
572    /// Creates a new [`Carousel`][crate::Carousel].
573    ///
574    /// # Returns
575    ///
576    /// the newly created [`Carousel`][crate::Carousel]
577    #[doc(alias = "adw_carousel_new")]
578    pub fn new() -> Carousel {
579        assert_initialized_main_thread!();
580        unsafe { gtk::Widget::from_glib_none(ffi::adw_carousel_new()).unsafe_cast() }
581    }
582
583    // rustdoc-stripper-ignore-next
584    /// Creates a new builder-pattern struct instance to construct [`Carousel`] objects.
585    ///
586    /// This method returns an instance of [`CarouselBuilder`](crate::builders::CarouselBuilder) which can be used to create [`Carousel`] objects.
587    pub fn builder() -> CarouselBuilder {
588        CarouselBuilder::new()
589    }
590
591    /// Appends @child to @self.
592    /// ## `child`
593    /// a widget to add
594    #[doc(alias = "adw_carousel_append")]
595    pub fn append(&self, child: &impl IsA<gtk::Widget>) {
596        unsafe {
597            ffi::adw_carousel_append(self.to_glib_none().0, child.as_ref().to_glib_none().0);
598        }
599    }
600
601    /// Gets whether to allow swiping for more than one page at a time.
602    ///
603    /// # Returns
604    ///
605    /// `TRUE` if long swipes are allowed
606    #[doc(alias = "adw_carousel_get_allow_long_swipes")]
607    #[doc(alias = "get_allow_long_swipes")]
608    #[doc(alias = "allow-long-swipes")]
609    pub fn allows_long_swipes(&self) -> bool {
610        unsafe {
611            from_glib(ffi::adw_carousel_get_allow_long_swipes(
612                self.to_glib_none().0,
613            ))
614        }
615    }
616
617    /// Sets whether @self can be dragged with mouse pointer.
618    ///
619    /// # Returns
620    ///
621    /// whether @self can be dragged with mouse pointer
622    #[doc(alias = "adw_carousel_get_allow_mouse_drag")]
623    #[doc(alias = "get_allow_mouse_drag")]
624    #[doc(alias = "allow-mouse-drag")]
625    pub fn allows_mouse_drag(&self) -> bool {
626        unsafe {
627            from_glib(ffi::adw_carousel_get_allow_mouse_drag(
628                self.to_glib_none().0,
629            ))
630        }
631    }
632
633    /// Gets whether @self will respond to scroll wheel events.
634    ///
635    /// # Returns
636    ///
637    /// `TRUE` if @self will respond to scroll wheel events
638    #[doc(alias = "adw_carousel_get_allow_scroll_wheel")]
639    #[doc(alias = "get_allow_scroll_wheel")]
640    #[doc(alias = "allow-scroll-wheel")]
641    pub fn allows_scroll_wheel(&self) -> bool {
642        unsafe {
643            from_glib(ffi::adw_carousel_get_allow_scroll_wheel(
644                self.to_glib_none().0,
645            ))
646        }
647    }
648
649    /// Gets whether @self can be navigated.
650    ///
651    /// # Returns
652    ///
653    /// whether @self can be navigated
654    #[doc(alias = "adw_carousel_get_interactive")]
655    #[doc(alias = "get_interactive")]
656    #[doc(alias = "interactive")]
657    pub fn is_interactive(&self) -> bool {
658        unsafe { from_glib(ffi::adw_carousel_get_interactive(self.to_glib_none().0)) }
659    }
660
661    /// Gets the number of pages in @self.
662    ///
663    /// # Returns
664    ///
665    /// the number of pages in @self
666    #[doc(alias = "adw_carousel_get_n_pages")]
667    #[doc(alias = "get_n_pages")]
668    #[doc(alias = "n-pages")]
669    pub fn n_pages(&self) -> u32 {
670        unsafe { ffi::adw_carousel_get_n_pages(self.to_glib_none().0) }
671    }
672
673    /// Gets current scroll position in @self, unitless.
674    ///
675    /// 1 matches 1 page. Use [`scroll_to()`][Self::scroll_to()] for changing it.
676    ///
677    /// # Returns
678    ///
679    /// the scroll position
680    #[doc(alias = "adw_carousel_get_position")]
681    #[doc(alias = "get_position")]
682    pub fn position(&self) -> f64 {
683        unsafe { ffi::adw_carousel_get_position(self.to_glib_none().0) }
684    }
685
686    /// Gets the page reveal duration, in milliseconds.
687    ///
688    /// # Returns
689    ///
690    /// the duration
691    #[doc(alias = "adw_carousel_get_reveal_duration")]
692    #[doc(alias = "get_reveal_duration")]
693    #[doc(alias = "reveal-duration")]
694    pub fn reveal_duration(&self) -> u32 {
695        unsafe { ffi::adw_carousel_get_reveal_duration(self.to_glib_none().0) }
696    }
697
698    /// Gets the scroll animation spring parameters for @self.
699    ///
700    /// # Returns
701    ///
702    /// the animation parameters
703    #[doc(alias = "adw_carousel_get_scroll_params")]
704    #[doc(alias = "get_scroll_params")]
705    #[doc(alias = "scroll-params")]
706    pub fn scroll_params(&self) -> SpringParams {
707        unsafe { from_glib_full(ffi::adw_carousel_get_scroll_params(self.to_glib_none().0)) }
708    }
709
710    /// Gets spacing between pages in pixels.
711    ///
712    /// # Returns
713    ///
714    /// spacing between pages
715    #[doc(alias = "adw_carousel_get_spacing")]
716    #[doc(alias = "get_spacing")]
717    pub fn spacing(&self) -> u32 {
718        unsafe { ffi::adw_carousel_get_spacing(self.to_glib_none().0) }
719    }
720
721    /// Inserts @child into @self at position @position.
722    ///
723    /// If position is -1, or larger than the number of pages,
724    /// @child will be appended to the end.
725    /// ## `child`
726    /// a widget to add
727    /// ## `position`
728    /// the position to insert @child at
729    #[doc(alias = "adw_carousel_insert")]
730    pub fn insert(&self, child: &impl IsA<gtk::Widget>, position: i32) {
731        unsafe {
732            ffi::adw_carousel_insert(
733                self.to_glib_none().0,
734                child.as_ref().to_glib_none().0,
735                position,
736            );
737        }
738    }
739
740    /// Prepends @child to @self.
741    /// ## `child`
742    /// a widget to add
743    #[doc(alias = "adw_carousel_prepend")]
744    pub fn prepend(&self, child: &impl IsA<gtk::Widget>) {
745        unsafe {
746            ffi::adw_carousel_prepend(self.to_glib_none().0, child.as_ref().to_glib_none().0);
747        }
748    }
749
750    /// Removes @child from @self.
751    /// ## `child`
752    /// a widget to remove
753    #[doc(alias = "adw_carousel_remove")]
754    pub fn remove(&self, child: &impl IsA<gtk::Widget>) {
755        unsafe {
756            ffi::adw_carousel_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
757        }
758    }
759
760    /// Moves @child into position @position.
761    ///
762    /// If position is -1, or larger than the number of pages, @child will be moved
763    /// at the end.
764    /// ## `child`
765    /// a widget to add
766    /// ## `position`
767    /// the position to move @child to
768    #[doc(alias = "adw_carousel_reorder")]
769    pub fn reorder(&self, child: &impl IsA<gtk::Widget>, position: i32) {
770        unsafe {
771            ffi::adw_carousel_reorder(
772                self.to_glib_none().0,
773                child.as_ref().to_glib_none().0,
774                position,
775            );
776        }
777    }
778
779    /// Scrolls to @widget.
780    ///
781    /// If @animate is `TRUE`, the transition will be animated.
782    /// ## `widget`
783    /// a child of @self
784    /// ## `animate`
785    /// whether to animate the transition
786    #[doc(alias = "adw_carousel_scroll_to")]
787    pub fn scroll_to(&self, widget: &impl IsA<gtk::Widget>, animate: bool) {
788        unsafe {
789            ffi::adw_carousel_scroll_to(
790                self.to_glib_none().0,
791                widget.as_ref().to_glib_none().0,
792                animate.into_glib(),
793            );
794        }
795    }
796
797    /// Sets whether to allow swiping for more than one page at a time.
798    ///
799    /// If @allow_long_swipes is `FALSE`, each swipe can only move to the adjacent
800    /// pages.
801    /// ## `allow_long_swipes`
802    /// whether to allow long swipes
803    #[doc(alias = "adw_carousel_set_allow_long_swipes")]
804    #[doc(alias = "allow-long-swipes")]
805    pub fn set_allow_long_swipes(&self, allow_long_swipes: bool) {
806        unsafe {
807            ffi::adw_carousel_set_allow_long_swipes(
808                self.to_glib_none().0,
809                allow_long_swipes.into_glib(),
810            );
811        }
812    }
813
814    /// Sets whether @self can be dragged with mouse pointer.
815    ///
816    /// If @allow_mouse_drag is `FALSE`, dragging is only available on touch.
817    /// ## `allow_mouse_drag`
818    /// whether @self can be dragged with mouse pointer
819    #[doc(alias = "adw_carousel_set_allow_mouse_drag")]
820    #[doc(alias = "allow-mouse-drag")]
821    pub fn set_allow_mouse_drag(&self, allow_mouse_drag: bool) {
822        unsafe {
823            ffi::adw_carousel_set_allow_mouse_drag(
824                self.to_glib_none().0,
825                allow_mouse_drag.into_glib(),
826            );
827        }
828    }
829
830    /// Sets whether @self will respond to scroll wheel events.
831    ///
832    /// If @allow_scroll_wheel is `FALSE`, wheel events will be ignored.
833    /// ## `allow_scroll_wheel`
834    /// whether @self will respond to scroll wheel events
835    #[doc(alias = "adw_carousel_set_allow_scroll_wheel")]
836    #[doc(alias = "allow-scroll-wheel")]
837    pub fn set_allow_scroll_wheel(&self, allow_scroll_wheel: bool) {
838        unsafe {
839            ffi::adw_carousel_set_allow_scroll_wheel(
840                self.to_glib_none().0,
841                allow_scroll_wheel.into_glib(),
842            );
843        }
844    }
845
846    /// Sets whether @self can be navigated.
847    ///
848    /// This can be used to temporarily disable the carousel to only allow navigating
849    /// it in a certain state.
850    /// ## `interactive`
851    /// whether @self can be navigated
852    #[doc(alias = "adw_carousel_set_interactive")]
853    #[doc(alias = "interactive")]
854    pub fn set_interactive(&self, interactive: bool) {
855        unsafe {
856            ffi::adw_carousel_set_interactive(self.to_glib_none().0, interactive.into_glib());
857        }
858    }
859
860    /// Sets the page reveal duration, in milliseconds.
861    ///
862    /// Reveal duration is used when animating adding or removing pages.
863    /// ## `reveal_duration`
864    /// the new reveal duration value
865    #[doc(alias = "adw_carousel_set_reveal_duration")]
866    #[doc(alias = "reveal-duration")]
867    pub fn set_reveal_duration(&self, reveal_duration: u32) {
868        unsafe {
869            ffi::adw_carousel_set_reveal_duration(self.to_glib_none().0, reveal_duration);
870        }
871    }
872
873    /// Sets the scroll animation spring parameters for @self.
874    ///
875    /// The default value is equivalent to:
876    ///
877    /// **⚠️ The following code is in c ⚠️**
878    ///
879    /// ```c
880    /// adw_spring_params_new (1, 0.5, 500)
881    /// ```
882    /// ## `params`
883    /// the new parameters
884    #[doc(alias = "adw_carousel_set_scroll_params")]
885    #[doc(alias = "scroll-params")]
886    pub fn set_scroll_params(&self, params: &SpringParams) {
887        unsafe {
888            ffi::adw_carousel_set_scroll_params(self.to_glib_none().0, params.to_glib_none().0);
889        }
890    }
891
892    /// Sets spacing between pages in pixels.
893    /// ## `spacing`
894    /// the new spacing value
895    #[doc(alias = "adw_carousel_set_spacing")]
896    #[doc(alias = "spacing")]
897    pub fn set_spacing(&self, spacing: u32) {
898        unsafe {
899            ffi::adw_carousel_set_spacing(self.to_glib_none().0, spacing);
900        }
901    }
902
903    /// This signal is emitted after a page has been changed.
904    ///
905    /// It can be used to implement "infinite scrolling" by amending the pages
906    /// after every scroll.
907    ///
908    /// ::: note
909    ///     An empty carousel is indicated by `(int)index == -1`.
910    /// ## `index`
911    /// current page
912    #[doc(alias = "page-changed")]
913    pub fn connect_page_changed<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
914        unsafe extern "C" fn page_changed_trampoline<F: Fn(&Carousel, u32) + 'static>(
915            this: *mut ffi::AdwCarousel,
916            index: std::ffi::c_uint,
917            f: glib::ffi::gpointer,
918        ) {
919            let f: &F = &*(f as *const F);
920            f(&from_glib_borrow(this), index)
921        }
922        unsafe {
923            let f: Box_<F> = Box_::new(f);
924            connect_raw(
925                self.as_ptr() as *mut _,
926                c"page-changed".as_ptr() as *const _,
927                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
928                    page_changed_trampoline::<F> as *const (),
929                )),
930                Box_::into_raw(f),
931            )
932        }
933    }
934
935    #[doc(alias = "allow-long-swipes")]
936    pub fn connect_allow_long_swipes_notify<F: Fn(&Self) + 'static>(
937        &self,
938        f: F,
939    ) -> SignalHandlerId {
940        unsafe extern "C" fn notify_allow_long_swipes_trampoline<F: Fn(&Carousel) + 'static>(
941            this: *mut ffi::AdwCarousel,
942            _param_spec: glib::ffi::gpointer,
943            f: glib::ffi::gpointer,
944        ) {
945            let f: &F = &*(f as *const F);
946            f(&from_glib_borrow(this))
947        }
948        unsafe {
949            let f: Box_<F> = Box_::new(f);
950            connect_raw(
951                self.as_ptr() as *mut _,
952                c"notify::allow-long-swipes".as_ptr() as *const _,
953                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
954                    notify_allow_long_swipes_trampoline::<F> as *const (),
955                )),
956                Box_::into_raw(f),
957            )
958        }
959    }
960
961    #[doc(alias = "allow-mouse-drag")]
962    pub fn connect_allow_mouse_drag_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
963        unsafe extern "C" fn notify_allow_mouse_drag_trampoline<F: Fn(&Carousel) + 'static>(
964            this: *mut ffi::AdwCarousel,
965            _param_spec: glib::ffi::gpointer,
966            f: glib::ffi::gpointer,
967        ) {
968            let f: &F = &*(f as *const F);
969            f(&from_glib_borrow(this))
970        }
971        unsafe {
972            let f: Box_<F> = Box_::new(f);
973            connect_raw(
974                self.as_ptr() as *mut _,
975                c"notify::allow-mouse-drag".as_ptr() as *const _,
976                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
977                    notify_allow_mouse_drag_trampoline::<F> as *const (),
978                )),
979                Box_::into_raw(f),
980            )
981        }
982    }
983
984    #[doc(alias = "allow-scroll-wheel")]
985    pub fn connect_allow_scroll_wheel_notify<F: Fn(&Self) + 'static>(
986        &self,
987        f: F,
988    ) -> SignalHandlerId {
989        unsafe extern "C" fn notify_allow_scroll_wheel_trampoline<F: Fn(&Carousel) + 'static>(
990            this: *mut ffi::AdwCarousel,
991            _param_spec: glib::ffi::gpointer,
992            f: glib::ffi::gpointer,
993        ) {
994            let f: &F = &*(f as *const F);
995            f(&from_glib_borrow(this))
996        }
997        unsafe {
998            let f: Box_<F> = Box_::new(f);
999            connect_raw(
1000                self.as_ptr() as *mut _,
1001                c"notify::allow-scroll-wheel".as_ptr() as *const _,
1002                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1003                    notify_allow_scroll_wheel_trampoline::<F> as *const (),
1004                )),
1005                Box_::into_raw(f),
1006            )
1007        }
1008    }
1009
1010    #[doc(alias = "interactive")]
1011    pub fn connect_interactive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1012        unsafe extern "C" fn notify_interactive_trampoline<F: Fn(&Carousel) + 'static>(
1013            this: *mut ffi::AdwCarousel,
1014            _param_spec: glib::ffi::gpointer,
1015            f: glib::ffi::gpointer,
1016        ) {
1017            let f: &F = &*(f as *const F);
1018            f(&from_glib_borrow(this))
1019        }
1020        unsafe {
1021            let f: Box_<F> = Box_::new(f);
1022            connect_raw(
1023                self.as_ptr() as *mut _,
1024                c"notify::interactive".as_ptr() as *const _,
1025                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1026                    notify_interactive_trampoline::<F> as *const (),
1027                )),
1028                Box_::into_raw(f),
1029            )
1030        }
1031    }
1032
1033    #[doc(alias = "n-pages")]
1034    pub fn connect_n_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1035        unsafe extern "C" fn notify_n_pages_trampoline<F: Fn(&Carousel) + 'static>(
1036            this: *mut ffi::AdwCarousel,
1037            _param_spec: glib::ffi::gpointer,
1038            f: glib::ffi::gpointer,
1039        ) {
1040            let f: &F = &*(f as *const F);
1041            f(&from_glib_borrow(this))
1042        }
1043        unsafe {
1044            let f: Box_<F> = Box_::new(f);
1045            connect_raw(
1046                self.as_ptr() as *mut _,
1047                c"notify::n-pages".as_ptr() as *const _,
1048                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1049                    notify_n_pages_trampoline::<F> as *const (),
1050                )),
1051                Box_::into_raw(f),
1052            )
1053        }
1054    }
1055
1056    #[doc(alias = "position")]
1057    pub fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1058        unsafe extern "C" fn notify_position_trampoline<F: Fn(&Carousel) + 'static>(
1059            this: *mut ffi::AdwCarousel,
1060            _param_spec: glib::ffi::gpointer,
1061            f: glib::ffi::gpointer,
1062        ) {
1063            let f: &F = &*(f as *const F);
1064            f(&from_glib_borrow(this))
1065        }
1066        unsafe {
1067            let f: Box_<F> = Box_::new(f);
1068            connect_raw(
1069                self.as_ptr() as *mut _,
1070                c"notify::position".as_ptr() as *const _,
1071                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1072                    notify_position_trampoline::<F> as *const (),
1073                )),
1074                Box_::into_raw(f),
1075            )
1076        }
1077    }
1078
1079    #[doc(alias = "reveal-duration")]
1080    pub fn connect_reveal_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1081        unsafe extern "C" fn notify_reveal_duration_trampoline<F: Fn(&Carousel) + 'static>(
1082            this: *mut ffi::AdwCarousel,
1083            _param_spec: glib::ffi::gpointer,
1084            f: glib::ffi::gpointer,
1085        ) {
1086            let f: &F = &*(f as *const F);
1087            f(&from_glib_borrow(this))
1088        }
1089        unsafe {
1090            let f: Box_<F> = Box_::new(f);
1091            connect_raw(
1092                self.as_ptr() as *mut _,
1093                c"notify::reveal-duration".as_ptr() as *const _,
1094                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1095                    notify_reveal_duration_trampoline::<F> as *const (),
1096                )),
1097                Box_::into_raw(f),
1098            )
1099        }
1100    }
1101
1102    #[doc(alias = "scroll-params")]
1103    pub fn connect_scroll_params_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1104        unsafe extern "C" fn notify_scroll_params_trampoline<F: Fn(&Carousel) + 'static>(
1105            this: *mut ffi::AdwCarousel,
1106            _param_spec: glib::ffi::gpointer,
1107            f: glib::ffi::gpointer,
1108        ) {
1109            let f: &F = &*(f as *const F);
1110            f(&from_glib_borrow(this))
1111        }
1112        unsafe {
1113            let f: Box_<F> = Box_::new(f);
1114            connect_raw(
1115                self.as_ptr() as *mut _,
1116                c"notify::scroll-params".as_ptr() as *const _,
1117                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1118                    notify_scroll_params_trampoline::<F> as *const (),
1119                )),
1120                Box_::into_raw(f),
1121            )
1122        }
1123    }
1124
1125    #[doc(alias = "spacing")]
1126    pub fn connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1127        unsafe extern "C" fn notify_spacing_trampoline<F: Fn(&Carousel) + 'static>(
1128            this: *mut ffi::AdwCarousel,
1129            _param_spec: glib::ffi::gpointer,
1130            f: glib::ffi::gpointer,
1131        ) {
1132            let f: &F = &*(f as *const F);
1133            f(&from_glib_borrow(this))
1134        }
1135        unsafe {
1136            let f: Box_<F> = Box_::new(f);
1137            connect_raw(
1138                self.as_ptr() as *mut _,
1139                c"notify::spacing".as_ptr() as *const _,
1140                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1141                    notify_spacing_trampoline::<F> as *const (),
1142                )),
1143                Box_::into_raw(f),
1144            )
1145        }
1146    }
1147}
1148
1149impl Default for Carousel {
1150    fn default() -> Self {
1151        Self::new()
1152    }
1153}
1154
1155// rustdoc-stripper-ignore-next
1156/// A [builder-pattern] type to construct [`Carousel`] objects.
1157///
1158/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1159#[must_use = "The builder must be built to be used"]
1160pub struct CarouselBuilder {
1161    builder: glib::object::ObjectBuilder<'static, Carousel>,
1162}
1163
1164impl CarouselBuilder {
1165    fn new() -> Self {
1166        Self {
1167            builder: glib::object::Object::builder(),
1168        }
1169    }
1170
1171    /// Whether to allow swiping for more than one page at a time.
1172    ///
1173    /// If the value is `FALSE`, each swipe can only move to the adjacent pages.
1174    pub fn allow_long_swipes(self, allow_long_swipes: bool) -> Self {
1175        Self {
1176            builder: self
1177                .builder
1178                .property("allow-long-swipes", allow_long_swipes),
1179        }
1180    }
1181
1182    /// Sets whether the [`Carousel`][crate::Carousel] can be dragged with mouse pointer.
1183    ///
1184    /// If the value is `FALSE`, dragging is only available on touch.
1185    pub fn allow_mouse_drag(self, allow_mouse_drag: bool) -> Self {
1186        Self {
1187            builder: self.builder.property("allow-mouse-drag", allow_mouse_drag),
1188        }
1189    }
1190
1191    /// Whether the widget will respond to scroll wheel events.
1192    ///
1193    /// If the value is `FALSE`, wheel events will be ignored.
1194    pub fn allow_scroll_wheel(self, allow_scroll_wheel: bool) -> Self {
1195        Self {
1196            builder: self
1197                .builder
1198                .property("allow-scroll-wheel", allow_scroll_wheel),
1199        }
1200    }
1201
1202    /// Whether the carousel can be navigated.
1203    ///
1204    /// This can be used to temporarily disable the carousel to only allow
1205    /// navigating it in a certain state.
1206    pub fn interactive(self, interactive: bool) -> Self {
1207        Self {
1208            builder: self.builder.property("interactive", interactive),
1209        }
1210    }
1211
1212    /// Page reveal duration, in milliseconds.
1213    ///
1214    /// Reveal duration is used when animating adding or removing pages.
1215    pub fn reveal_duration(self, reveal_duration: u32) -> Self {
1216        Self {
1217            builder: self.builder.property("reveal-duration", reveal_duration),
1218        }
1219    }
1220
1221    /// Scroll animation spring parameters.
1222    ///
1223    /// The default value is equivalent to:
1224    ///
1225    /// **⚠️ The following code is in c ⚠️**
1226    ///
1227    /// ```c
1228    /// adw_spring_params_new (1, 0.5, 500)
1229    /// ```
1230    pub fn scroll_params(self, scroll_params: &SpringParams) -> Self {
1231        Self {
1232            builder: self
1233                .builder
1234                .property("scroll-params", scroll_params.clone()),
1235        }
1236    }
1237
1238    /// Spacing between pages in pixels.
1239    pub fn spacing(self, spacing: u32) -> Self {
1240        Self {
1241            builder: self.builder.property("spacing", spacing),
1242        }
1243    }
1244
1245    /// Whether the widget or any of its descendents can accept
1246    /// the input focus.
1247    ///
1248    /// This property is meant to be set by widget implementations,
1249    /// typically in their instance init function.
1250    pub fn can_focus(self, can_focus: bool) -> Self {
1251        Self {
1252            builder: self.builder.property("can-focus", can_focus),
1253        }
1254    }
1255
1256    /// Whether the widget can receive pointer events.
1257    pub fn can_target(self, can_target: bool) -> Self {
1258        Self {
1259            builder: self.builder.property("can-target", can_target),
1260        }
1261    }
1262
1263    /// A list of css classes applied to this widget.
1264    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1265        Self {
1266            builder: self.builder.property("css-classes", css_classes.into()),
1267        }
1268    }
1269
1270    /// The name of this widget in the CSS tree.
1271    ///
1272    /// This property is meant to be set by widget implementations,
1273    /// typically in their instance init function.
1274    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1275        Self {
1276            builder: self.builder.property("css-name", css_name.into()),
1277        }
1278    }
1279
1280    /// The cursor used by @widget.
1281    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1282        Self {
1283            builder: self.builder.property("cursor", cursor.clone()),
1284        }
1285    }
1286
1287    /// Whether the widget should grab focus when it is clicked with the mouse.
1288    ///
1289    /// This property is only relevant for widgets that can take focus.
1290    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1291        Self {
1292            builder: self.builder.property("focus-on-click", focus_on_click),
1293        }
1294    }
1295
1296    /// Whether this widget itself will accept the input focus.
1297    pub fn focusable(self, focusable: bool) -> Self {
1298        Self {
1299            builder: self.builder.property("focusable", focusable),
1300        }
1301    }
1302
1303    /// How to distribute horizontal space if widget gets extra space.
1304    pub fn halign(self, halign: gtk::Align) -> Self {
1305        Self {
1306            builder: self.builder.property("halign", halign),
1307        }
1308    }
1309
1310    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
1311    /// signal on @widget.
1312    ///
1313    /// A true value indicates that @widget can have a tooltip, in this case
1314    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
1315    /// determine whether it will provide a tooltip or not.
1316    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1317        Self {
1318            builder: self.builder.property("has-tooltip", has_tooltip),
1319        }
1320    }
1321
1322    /// Overrides for height request of the widget.
1323    ///
1324    /// If this is -1, the natural request will be used.
1325    pub fn height_request(self, height_request: i32) -> Self {
1326        Self {
1327            builder: self.builder.property("height-request", height_request),
1328        }
1329    }
1330
1331    /// Whether to expand horizontally.
1332    pub fn hexpand(self, hexpand: bool) -> Self {
1333        Self {
1334            builder: self.builder.property("hexpand", hexpand),
1335        }
1336    }
1337
1338    /// Whether to use the `hexpand` property.
1339    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1340        Self {
1341            builder: self.builder.property("hexpand-set", hexpand_set),
1342        }
1343    }
1344
1345    /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
1346    /// the preferred size of the widget, and allocate its children.
1347    ///
1348    /// This property is meant to be set by widget implementations,
1349    /// typically in their instance init function.
1350    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
1351        Self {
1352            builder: self
1353                .builder
1354                .property("layout-manager", layout_manager.clone().upcast()),
1355        }
1356    }
1357
1358    /// Makes this widget act like a modal dialog, with respect to
1359    /// event delivery.
1360    ///
1361    /// Global event controllers will not handle events with targets
1362    /// inside the widget, unless they are set up to ignore propagation
1363    /// limits. See `Gtk::EventController::set_propagation_limit()`.
1364    #[cfg(feature = "gtk_v4_18")]
1365    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
1366    pub fn limit_events(self, limit_events: bool) -> Self {
1367        Self {
1368            builder: self.builder.property("limit-events", limit_events),
1369        }
1370    }
1371
1372    /// Margin on bottom side of widget.
1373    ///
1374    /// This property adds margin outside of the widget's normal size
1375    /// request, the margin will be added in addition to the size from
1376    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1377    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1378        Self {
1379            builder: self.builder.property("margin-bottom", margin_bottom),
1380        }
1381    }
1382
1383    /// Margin on end of widget, horizontally.
1384    ///
1385    /// This property supports left-to-right and right-to-left text
1386    /// directions.
1387    ///
1388    /// This property adds margin outside of the widget's normal size
1389    /// request, the margin will be added in addition to the size from
1390    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1391    pub fn margin_end(self, margin_end: i32) -> Self {
1392        Self {
1393            builder: self.builder.property("margin-end", margin_end),
1394        }
1395    }
1396
1397    /// Margin on start of widget, horizontally.
1398    ///
1399    /// This property supports left-to-right and right-to-left text
1400    /// directions.
1401    ///
1402    /// This property adds margin outside of the widget's normal size
1403    /// request, the margin will be added in addition to the size from
1404    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1405    pub fn margin_start(self, margin_start: i32) -> Self {
1406        Self {
1407            builder: self.builder.property("margin-start", margin_start),
1408        }
1409    }
1410
1411    /// Margin on top side of widget.
1412    ///
1413    /// This property adds margin outside of the widget's normal size
1414    /// request, the margin will be added in addition to the size from
1415    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1416    pub fn margin_top(self, margin_top: i32) -> Self {
1417        Self {
1418            builder: self.builder.property("margin-top", margin_top),
1419        }
1420    }
1421
1422    /// The name of the widget.
1423    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1424        Self {
1425            builder: self.builder.property("name", name.into()),
1426        }
1427    }
1428
1429    /// The requested opacity of the widget.
1430    pub fn opacity(self, opacity: f64) -> Self {
1431        Self {
1432            builder: self.builder.property("opacity", opacity),
1433        }
1434    }
1435
1436    /// How content outside the widget's content area is treated.
1437    ///
1438    /// This property is meant to be set by widget implementations,
1439    /// typically in their instance init function.
1440    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
1441        Self {
1442            builder: self.builder.property("overflow", overflow),
1443        }
1444    }
1445
1446    /// Whether the widget will receive the default action when it is focused.
1447    pub fn receives_default(self, receives_default: bool) -> Self {
1448        Self {
1449            builder: self.builder.property("receives-default", receives_default),
1450        }
1451    }
1452
1453    /// Whether the widget responds to input.
1454    pub fn sensitive(self, sensitive: bool) -> Self {
1455        Self {
1456            builder: self.builder.property("sensitive", sensitive),
1457        }
1458    }
1459
1460    /// Sets the text of tooltip to be the given string, which is marked up
1461    /// with Pango markup.
1462    ///
1463    /// Also see `Gtk::Tooltip::set_markup()`.
1464    ///
1465    /// This is a convenience property which will take care of getting the
1466    /// tooltip shown if the given string is not `NULL`:
1467    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1468    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1469    /// the default signal handler.
1470    ///
1471    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1472    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1473    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1474        Self {
1475            builder: self
1476                .builder
1477                .property("tooltip-markup", tooltip_markup.into()),
1478        }
1479    }
1480
1481    /// Sets the text of tooltip to be the given string.
1482    ///
1483    /// Also see `Gtk::Tooltip::set_text()`.
1484    ///
1485    /// This is a convenience property which will take care of getting the
1486    /// tooltip shown if the given string is not `NULL`:
1487    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1488    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1489    /// the default signal handler.
1490    ///
1491    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1492    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1493    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1494        Self {
1495            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1496        }
1497    }
1498
1499    /// How to distribute vertical space if widget gets extra space.
1500    pub fn valign(self, valign: gtk::Align) -> Self {
1501        Self {
1502            builder: self.builder.property("valign", valign),
1503        }
1504    }
1505
1506    /// Whether to expand vertically.
1507    pub fn vexpand(self, vexpand: bool) -> Self {
1508        Self {
1509            builder: self.builder.property("vexpand", vexpand),
1510        }
1511    }
1512
1513    /// Whether to use the `vexpand` property.
1514    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1515        Self {
1516            builder: self.builder.property("vexpand-set", vexpand_set),
1517        }
1518    }
1519
1520    /// Whether the widget is visible.
1521    pub fn visible(self, visible: bool) -> Self {
1522        Self {
1523            builder: self.builder.property("visible", visible),
1524        }
1525    }
1526
1527    /// Overrides for width request of the widget.
1528    ///
1529    /// If this is -1, the natural request will be used.
1530    pub fn width_request(self, width_request: i32) -> Self {
1531        Self {
1532            builder: self.builder.property("width-request", width_request),
1533        }
1534    }
1535
1536    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
1537    ///
1538    /// The accessible role cannot be changed once set.
1539    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1540        Self {
1541            builder: self.builder.property("accessible-role", accessible_role),
1542        }
1543    }
1544
1545    /// The orientation of the orientable.
1546    pub fn orientation(self, orientation: gtk::Orientation) -> Self {
1547        Self {
1548            builder: self.builder.property("orientation", orientation),
1549        }
1550    }
1551
1552    // rustdoc-stripper-ignore-next
1553    /// Build the [`Carousel`].
1554    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1555    pub fn build(self) -> Carousel {
1556        assert_initialized_main_thread!();
1557        self.builder.build()
1558    }
1559}