:right-sidebar: True Breakpoint =================================================================== .. currentmodule:: gi.repository.Adw .. versionadded:: 1.4 .. class:: Breakpoint(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Buildable` Describes a breakpoint for :obj:`~gi.repository.Adw.Window` or :obj:`~gi.repository.Adw.Dialog`\. Breakpoints are used to create adaptive UI, allowing to change the layout depending on available size. Breakpoint is a size threshold, specified by its condition, as well as one or more setters. Each setter has a target object, a property and a value. When a breakpoint is applied, each setter sets the target property on their target object to the specified value, and reset it back to the original value when it's unapplied. For more complicated scenarios, :obj:`~gi.repository.Adw.Breakpoint.signals.apply` and :obj:`~gi.repository.Adw.Breakpoint.signals.unapply` can be used instead. Breakpoints can be used within :obj:`~gi.repository.Adw.Window`\, :obj:`~gi.repository.Adw.ApplicationWindow`\, :obj:`~gi.repository.Adw.Dialog` or :obj:`~gi.repository.Adw.BreakpointBin`\. -------------------------------------------------------------------------------- ``AdwBreakpoint`` supports specifying its condition via the ```` element. The contents of the element must be a string in a format accepted by :obj:`~gi.repository.BreakpointCondition.parse`\. It also supports adding setters via the ```` element. Each ```` element must have the ``object`` attribute specifying the target object, and the ``property`` attribute specifying the property name. The contents of the element are used as the setter value. For ``G_TYPE_OBJECT`` and ``G_TYPE_BOXED`` derived properties, empty contents are treated as ``NULL``\. Setter values can be translated with the usual ``translatable``\, ``context`` and ``comments`` attributes. Example of an ``AdwBreakpoint`` UI definition: .. code-block:: xml :dedent: max-width: 400px True vertical Example Constructors ------------ .. rst-class:: interim-class .. class:: Breakpoint :no-index: .. classmethod:: new(condition: ~gi.repository.Adw.BreakpointCondition) -> ~gi.repository.Adw.Breakpoint Creates a new ``AdwBreakpoint`` with ``condition``\. .. versionadded:: 1.4 :param condition: the condition Methods ------- .. rst-class:: interim-class .. class:: Breakpoint :no-index: .. method:: add_setter(object: ~gi.repository.GObject.Object, property: str, value: ~gi.repository.GObject.Value | None = None) -> None Adds a setter to ``self``\. The setter will automatically set ``property`` on ``object`` to ``value`` when applying the breakpoint, and set it back to its original value upon unapplying it. ::: note Setting properties to their original values does not work for properties that have irreversible side effects. For example, changing :obj:`~gi.repository.Gtk.Button.props.label` while :obj:`~gi.repository.Gtk.Button.props.icon_name` is set will reset the icon. However, resetting the label will not set ``icon-name`` to its original value. Use the :obj:`~gi.repository.Adw.Breakpoint.signals.apply` and :obj:`~gi.repository.Adw.Breakpoint.signals.unapply` signals for those properties instead, as follows: .. code-block:: c :dedent: static void breakpoint_apply_cb (MyWidget *self) { gtk_button_set_icon_name (self->button, "go-previous-symbolic"); } static void breakpoint_apply_cb (MyWidget *self) { gtk_button_set_label (self->button, _("_Back")); } // ... g_signal_connect_swapped (breakpoint, "apply", G_CALLBACK (breakpoint_apply_cb), self); g_signal_connect_swapped (breakpoint, "unapply", G_CALLBACK (breakpoint_unapply_cb), self); .. versionadded:: 1.4 :param object: the target object :param property: the target property :param value: the value to set .. method:: add_setters(objects: list[~gi.repository.GObject.Object], names: list[str], values: list[~gi.repository.GObject.Value]) -> None Adds multiple setters to ``self``\. See :obj:`~gi.repository.Breakpoint.add_setter`\. Example: .. code-block:: c :dedent: adw_breakpoint_add_setters (breakpoint, G_OBJECT (box), "orientation", GTK_ORIENTATION_VERTICAL, G_OBJECT (button), "halign", GTK_ALIGN_FILL, G_OBJECT (button), "valign", GTK_ALIGN_END, NULL); .. versionadded:: 1.4 :param objects: :param names: :param values: .. method:: get_condition() -> ~gi.repository.Adw.BreakpointCondition | None Gets the condition for ``self``\. .. versionadded:: 1.4 .. method:: set_condition(condition: ~gi.repository.Adw.BreakpointCondition | None = None) -> None Sets the condition for ``self``\. .. versionadded:: 1.4 :param condition: the new condition Properties ---------- .. rst-class:: interim-class .. class:: Breakpoint :no-index: .. attribute:: props.condition :type: ~gi.repository.Adw.BreakpointCondition The type of the None singleton. .. versionadded:: 1.4 Signals ------- .. rst-class:: interim-class .. class:: Breakpoint.signals :no-index: .. method:: apply() -> None The type of the None singleton. .. versionadded:: 1.4 .. method:: unapply() -> None The type of the None singleton. .. versionadded:: 1.4