Breakpoint#
Added in version 1.4.
Superclasses: Object
Implemented Interfaces: Buildable
Describes a breakpoint for Window or 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, apply and
unapply can be used instead.
Breakpoints can be used within Window, ApplicationWindow,
Dialog or BreakpointBin.
AdwBreakpoint supports specifying its condition via the <condition>
element. The contents of the element must be a string in a format accepted by
parse.
It also supports adding setters via the <setter> element. Each <setter>
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:
<object class="AdwBreakpoint">
<condition>max-width: 400px</condition>
<setter object="button" property="visible">True</setter>
<setter object="box" property="orientation">vertical</setter>
<setter object="page" property="title" translatable="yes">Example</setter>
</object>
Constructors#
- class Breakpoint
- classmethod new(condition: BreakpointCondition) Breakpoint#
Creates a new
AdwBreakpointwithcondition.Added in version 1.4.
- Parameters:
condition – the condition
Methods#
- class Breakpoint
- add_setter(object: Object, property: str, value: Value | None = None) None#
Adds a setter to
self.The setter will automatically set
propertyonobjecttovaluewhen 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
labelwhileicon_nameis set will reset the icon. However, resetting the label will not seticon-nameto its original value.
Use the
applyandunapplysignals for those properties instead, as follows: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);
Added in version 1.4.
- Parameters:
object – the target object
property – the target property
value – the value to set
- add_setters(objects: list[Object], names: list[str], values: list[Value]) None#
Adds multiple setters to
self.See
add_setter.Example:
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);
Added in version 1.4.
- Parameters:
objects
names
values
- get_condition() BreakpointCondition | None#
Gets the condition for
self.Added in version 1.4.
- set_condition(condition: BreakpointCondition | None = None) None#
Sets the condition for
self.Added in version 1.4.
- Parameters:
condition – the new condition
Properties#
- class Breakpoint
- props.condition: BreakpointCondition#
The type of the None singleton.
Added in version 1.4.