:right-sidebar: True Leaflet =================================================================== .. currentmodule:: gi.repository.Adw .. deprecated:: 1.4 See `the migration guide `__ .. class:: Leaflet(**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` An adaptive container acting like a box or a stack. .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/leaflet-narrow.png The ``AdwLeaflet`` widget can display its children like a :obj:`~gi.repository.Gtk.Box` does or like a :obj:`~gi.repository.Gtk.Stack` does, adapting to size changes by switching between the two modes. When there is enough space the children are displayed side by side, otherwise only one is displayed and the leaflet is said to be “folded”. The threshold is dictated by the preferred minimum sizes of the children. When a leaflet is folded, the children can be navigated using swipe gestures. The “over” and “under” transition types stack the children one on top of the other, while the “slide” transition puts the children side by side. While navigating to a child on the side or below can be performed by swiping the current child away, navigating to an upper child requires dragging it from the edge where it resides. This doesn't affect non-dragging swipes. CSS nodes -------------------------------------------------------------------------------- ``AdwLeaflet`` has a single CSS node with name ``leaflet``\. The node will get the style classes ``.folded`` when it is folded, ``.unfolded`` when it's not, or none if it hasn't computed its fold yet. Constructors ------------ .. rst-class:: interim-class .. class:: Leaflet :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a new ``AdwLeaflet``\. .. deprecated:: 1.4 See `the migration guide `__ Methods ------- .. rst-class:: interim-class .. class:: Leaflet :no-index: .. method:: append(child: ~gi.repository.Gtk.Widget) -> ~gi.repository.Adw.LeafletPage Adds a child to ``self``\. .. deprecated:: 1.4 See `the migration guide `__ :param child: the widget to add .. method:: get_adjacent_child(direction: ~gi.repository.Adw.NavigationDirection) -> ~gi.repository.Gtk.Widget | None Finds the previous or next navigatable child. This will be the same child :obj:`~gi.repository.Leaflet.navigate` or swipe gestures will navigate to. If there's no child to navigate to, ``NULL`` will be returned instead. See :obj:`~gi.repository.Adw.LeafletPage.props.navigatable`\. .. deprecated:: 1.4 See `the migration guide `__ :param direction: the direction .. method:: get_can_navigate_back() -> bool Gets whether gestures and shortcuts for navigating backward are enabled. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_can_navigate_forward() -> bool Gets whether gestures and shortcuts for navigating forward are enabled. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_can_unfold() -> bool Gets whether ``self`` can unfold. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_child_by_name(name: str) -> ~gi.repository.Gtk.Widget | None Finds the child of ``self`` with ``name``\. Returns ``NULL`` if there is no child with this name. See :obj:`~gi.repository.Adw.LeafletPage.props.name`\. .. deprecated:: 1.4 See `the migration guide `__ :param name: the name of the child to find .. method:: get_child_transition_params() -> ~gi.repository.Adw.SpringParams Gets the child transition spring parameters for ``self``\. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_child_transition_running() -> bool Gets whether a child transition is currently running for ``self``\. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_fold_threshold_policy() -> ~gi.repository.Adw.FoldThresholdPolicy Gets the fold threshold policy for ``self``\. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_folded() -> bool Gets whether ``self`` is folded. The leaflet will be folded if the size allocated to it is smaller than the sum of the minimum or natural sizes of the children (see :obj:`~gi.repository.Adw.Leaflet.props.fold_threshold_policy`\), it will be unfolded otherwise. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_homogeneous() -> bool Gets whether ``self`` is homogeneous. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_mode_transition_duration() -> int Gets the mode transition animation duration for ``self``\. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_page(child: ~gi.repository.Gtk.Widget) -> ~gi.repository.Adw.LeafletPage Returns the :obj:`~gi.repository.Adw.LeafletPage` object for ``child``\. .. deprecated:: 1.4 See `the migration guide `__ :param child: a child of ``self`` .. method:: get_pages() -> ~gi.repository.Gtk.SelectionModel Returns a :obj:`~gi.repository.Gio.ListModel` that contains the pages of the leaflet. This can be used to keep an up-to-date view. The model also implements :obj:`~gi.repository.Gtk.SelectionModel` and can be used to track and change the visible page. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_transition_type() -> ~gi.repository.Adw.LeafletTransitionType Gets the type of animation used for transitions between modes and children. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_visible_child() -> ~gi.repository.Gtk.Widget | None Gets the widget currently visible when the leaflet is folded. .. deprecated:: 1.4 See `the migration guide `__ .. method:: get_visible_child_name() -> str | None Gets the name of the currently visible child widget. .. deprecated:: 1.4 See `the migration guide `__ .. method:: insert_child_after(child: ~gi.repository.Gtk.Widget, sibling: ~gi.repository.Gtk.Widget | None = None) -> ~gi.repository.Adw.LeafletPage Inserts ``child`` in the position after ``sibling`` in the list of children. If ``sibling`` is ``NULL``\, inserts ``child`` at the first position. .. deprecated:: 1.4 See `the migration guide `__ :param child: the widget to insert :param sibling: the sibling after which to insert ``child`` .. method:: navigate(direction: ~gi.repository.Adw.NavigationDirection) -> bool Navigates to the previous or next child. The child must have the :obj:`~gi.repository.Adw.LeafletPage.props.navigatable` property set to ``TRUE``\, otherwise it will be skipped. This will be the same child as returned by :obj:`~gi.repository.Leaflet.get_adjacent_child` or navigated to via swipe gestures. .. deprecated:: 1.4 See `the migration guide `__ :param direction: the direction .. method:: prepend(child: ~gi.repository.Gtk.Widget) -> ~gi.repository.Adw.LeafletPage Inserts ``child`` at the first position in ``self``\. .. deprecated:: 1.4 See `the migration guide `__ :param child: the widget to prepend .. method:: remove(child: ~gi.repository.Gtk.Widget) -> None Removes a child widget from ``self``\. .. deprecated:: 1.4 See `the migration guide `__ :param child: the child to remove .. method:: reorder_child_after(child: ~gi.repository.Gtk.Widget, sibling: ~gi.repository.Gtk.Widget | None = None) -> None Moves ``child`` to the position after ``sibling`` in the list of children. If ``sibling`` is ``NULL``\, moves ``child`` to the first position. .. deprecated:: 1.4 See `the migration guide `__ :param child: the widget to move, must be a child of ``self`` :param sibling: the sibling to move ``child`` after .. method:: set_can_navigate_back(can_navigate_back: bool) -> None Sets whether gestures and shortcuts for navigating backward are enabled. The supported gestures are: - One-finger swipe on touchscreens - Horizontal scrolling on touchpads (usually two-finger swipe) - Back/forward mouse buttons The keyboard back/forward keys are also supported, as well as the :kbd:`Alt`\+:kbd:`←` shortcut for horizontal orientation, or :kbd:`Alt`\+:kbd:`↑` for vertical orientation. If the orientation is horizontal, for right-to-left locales, gestures and shortcuts are reversed. Only children that have :obj:`~gi.repository.Adw.LeafletPage.props.navigatable` set to ``TRUE`` can be navigated to. .. deprecated:: 1.4 See `the migration guide `__ :param can_navigate_back: the new value .. method:: set_can_navigate_forward(can_navigate_forward: bool) -> None Sets whether gestures and shortcuts for navigating forward are enabled. The supported gestures are: - One-finger swipe on touchscreens - Horizontal scrolling on touchpads (usually two-finger swipe) - Back/forward mouse buttons The keyboard back/forward keys are also supported, as well as the :kbd:`Alt`\+:kbd:`→` shortcut for horizontal orientation, or :kbd:`Alt`\+:kbd:`↓` for vertical orientation. If the orientation is horizontal, for right-to-left locales, gestures and shortcuts are reversed. Only children that have :obj:`~gi.repository.Adw.LeafletPage.props.navigatable` set to ``TRUE`` can be navigated to. .. deprecated:: 1.4 See `the migration guide `__ :param can_navigate_forward: the new value .. method:: set_can_unfold(can_unfold: bool) -> None Sets whether ``self`` can unfold. .. deprecated:: 1.4 See `the migration guide `__ :param can_unfold: whether ``self`` can unfold .. method:: set_child_transition_params(params: ~gi.repository.Adw.SpringParams) -> None Sets the child transition spring parameters for ``self``\. The default value is equivalent to: .. code-block:: c :dedent: adw_spring_params_new (1, 0.5, 500) .. deprecated:: 1.4 See `the migration guide `__ :param params: the new parameters .. method:: set_fold_threshold_policy(policy: ~gi.repository.Adw.FoldThresholdPolicy) -> None Sets the fold threshold policy for ``self``\. If set to ``ADW_FOLD_THRESHOLD_POLICY_MINIMUM``\, it will only fold when the children cannot fit anymore. With ``ADW_FOLD_THRESHOLD_POLICY_NATURAL``\, it will fold as soon as children don't get their natural size. This can be useful if you have a long ellipsizing label and want to let it ellipsize instead of immediately folding. .. deprecated:: 1.4 See `the migration guide `__ :param policy: the policy to use .. method:: set_homogeneous(homogeneous: bool) -> None Sets ``self`` to be homogeneous or not. If set to ``FALSE``\, different children can have different size along the opposite orientation. .. deprecated:: 1.4 See `the migration guide `__ :param homogeneous: whether to make ``self`` homogeneous .. method:: set_mode_transition_duration(duration: int) -> None Sets the mode transition animation duration for ``self``\. .. deprecated:: 1.4 See `the migration guide `__ :param duration: the new duration, in milliseconds .. method:: set_transition_type(transition: ~gi.repository.Adw.LeafletTransitionType) -> None Sets the type of animation used for transitions between modes and children. The transition type can be changed without problems at runtime, so it is possible to change the animation based on the mode or child that is about to become current. .. deprecated:: 1.4 See `the migration guide `__ :param transition: the new transition type .. method:: set_visible_child(visible_child: ~gi.repository.Gtk.Widget) -> None Sets the widget currently visible when the leaflet is folded. The transition is determined by :obj:`~gi.repository.Adw.Leaflet.props.transition_type` and :obj:`~gi.repository.Adw.Leaflet.props.child_transition_params`\. The transition can be cancelled by the user, in which case visible child will change back to the previously visible child. .. deprecated:: 1.4 See `the migration guide `__ :param visible_child: the new child .. method:: set_visible_child_name(name: str) -> None Makes the child with the name ``name`` visible. See :obj:`~gi.repository.Adw.Leaflet.props.visible_child`\. .. deprecated:: 1.4 See `the migration guide `__ :param name: the name of a child Properties ---------- .. rst-class:: interim-class .. class:: Leaflet :no-index: .. attribute:: props.can_navigate_back :type: bool The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.can_navigate_forward :type: bool The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.can_unfold :type: bool The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.child_transition_params :type: ~gi.repository.Adw.SpringParams The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.child_transition_running :type: bool The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.fold_threshold_policy :type: ~gi.repository.Adw.FoldThresholdPolicy The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.folded :type: bool The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.homogeneous :type: bool The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.mode_transition_duration :type: int The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.pages :type: ~gi.repository.Gtk.SelectionModel The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.transition_type :type: ~gi.repository.Adw.LeafletTransitionType The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.visible_child :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__ .. attribute:: props.visible_child_name :type: str The type of the None singleton. .. deprecated:: 1.4 See `the migration guide `__