:right-sidebar: True Carousel =================================================================== .. currentmodule:: gi.repository.Adw .. class:: Carousel(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Adw.Swipeable`, :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget`, :class:`~gi.repository.Gtk.Orientable` :Constructors: :: Carousel(**properties) new() -> Gtk.Widget Constructors ------------ .. rst-class:: interim-class .. class:: Carousel :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a new ``AdwCarousel``. Methods ------- .. rst-class:: interim-class .. class:: Carousel :no-index: .. method:: append(child: ~gi.repository.Gtk.Widget) -> None Appends ``child`` to ``self``. :param child: a widget to add .. method:: get_allow_long_swipes() -> bool Gets whether to allow swiping for more than one page at a time. .. method:: get_allow_mouse_drag() -> bool Sets whether ``self`` can be dragged with mouse pointer. .. method:: get_allow_scroll_wheel() -> bool Gets whether ``self`` will respond to scroll wheel events. .. method:: get_interactive() -> bool Gets whether ``self`` can be navigated. .. method:: get_n_pages() -> int Gets the number of pages in ``self``. .. method:: get_nth_page(n: int) -> ~gi.repository.Gtk.Widget Gets the page at position ``n``. :param n: index of the page .. method:: get_position() -> float Gets current scroll position in ``self``, unitless. 1 matches 1 page. Use :obj:`~gi.repository.Carousel.scroll_to` for changing it. .. method:: get_reveal_duration() -> int Gets the page reveal duration, in milliseconds. .. method:: get_scroll_params() -> ~gi.repository.Adw.SpringParams Gets the scroll animation spring parameters for ``self``. .. method:: get_spacing() -> int Gets spacing between pages in pixels. .. method:: insert(child: ~gi.repository.Gtk.Widget, position: int) -> None Inserts ``child`` into ``self`` at position ``position``. If position is -1, or larger than the number of pages, ``child`` will be appended to the end. :param child: a widget to add :param position: the position to insert ``child`` at .. method:: prepend(child: ~gi.repository.Gtk.Widget) -> None Prepends ``child`` to ``self``. :param child: a widget to add .. method:: remove(child: ~gi.repository.Gtk.Widget) -> None Removes ``child`` from ``self``. :param child: a widget to remove .. method:: reorder(child: ~gi.repository.Gtk.Widget, position: int) -> None Moves ``child`` into position ``position``. If position is -1, or larger than the number of pages, ``child`` will be moved at the end. :param child: a widget to add :param position: the position to move ``child`` to .. method:: scroll_to(widget: ~gi.repository.Gtk.Widget, animate: bool) -> None Scrolls to ``widget``. If ``animate`` is ``TRUE``, the transition will be animated. :param widget: a child of ``self`` :param animate: whether to animate the transition .. method:: set_allow_long_swipes(allow_long_swipes: bool) -> None Sets whether to allow swiping for more than one page at a time. If ``allow_long_swipes`` is ``FALSE``, each swipe can only move to the adjacent pages. :param allow_long_swipes: whether to allow long swipes .. method:: set_allow_mouse_drag(allow_mouse_drag: bool) -> None Sets whether ``self`` can be dragged with mouse pointer. If ``allow_mouse_drag`` is ``FALSE``, dragging is only available on touch. :param allow_mouse_drag: whether ``self`` can be dragged with mouse pointer .. method:: set_allow_scroll_wheel(allow_scroll_wheel: bool) -> None Sets whether ``self`` will respond to scroll wheel events. If ``allow_scroll_wheel`` is ``FALSE``, wheel events will be ignored. :param allow_scroll_wheel: whether ``self`` will respond to scroll wheel events .. method:: set_interactive(interactive: bool) -> None Sets whether ``self`` can be navigated. This can be used to temporarily disable the carousel to only allow navigating it in a certain state. :param interactive: whether ``self`` can be navigated .. method:: set_reveal_duration(reveal_duration: int) -> None Sets the page reveal duration, in milliseconds. Reveal duration is used when animating adding or removing pages. :param reveal_duration: the new reveal duration value .. method:: set_scroll_params(params: ~gi.repository.Adw.SpringParams) -> None Sets the scroll animation spring parameters for ``self``. The default value is equivalent to: .. code-block:: c :dedent: adw_spring_params_new (1, 0.5, 500) :param params: the new parameters .. method:: set_spacing(spacing: int) -> None Sets spacing between pages in pixels. :param spacing: the new spacing value Properties ---------- .. rst-class:: interim-class .. class:: Carousel :no-index: .. attribute:: props.allow_long_swipes :type: bool Whether to allow swiping for more than one page at a time. If the value is ``FALSE``, each swipe can only move to the adjacent pages. .. attribute:: props.allow_mouse_drag :type: bool Sets whether the ``AdwCarousel`` can be dragged with mouse pointer. If the value is ``FALSE``, dragging is only available on touch. .. attribute:: props.allow_scroll_wheel :type: bool Whether the widget will respond to scroll wheel events. If the value is ``FALSE``, wheel events will be ignored. .. attribute:: props.interactive :type: bool Whether the carousel can be navigated. This can be used to temporarily disable the carousel to only allow navigating it in a certain state. .. attribute:: props.n_pages :type: int The number of pages in a ``AdwCarousel``. .. attribute:: props.position :type: float Current scrolling position, unitless. 1 matches 1 page. Use :obj:`~gi.repository.Carousel.scroll_to` for changing it. .. attribute:: props.reveal_duration :type: int Page reveal duration, in milliseconds. Reveal duration is used when animating adding or removing pages. .. attribute:: props.scroll_params :type: ~gi.repository.Adw.SpringParams Scroll animation spring parameters. The default value is equivalent to: .. code-block:: c :dedent: adw_spring_params_new (1, 0.5, 500) .. attribute:: props.spacing :type: int Spacing between pages in pixels. Signals ------- .. rst-class:: interim-class .. class:: Carousel.signals :no-index: .. method:: page_changed(index: int) -> None This signal is emitted after a page has been changed. It can be used to implement "infinite scrolling" by amending the pages after every scroll. ::: note An empty carousel is indicated by `(int)index == -1`. :param index: current page