It derives from <GObject>.
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
BreakpointCondition.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>
The breakpoint’s condition.
Its value is a
<AdwBreakpointCondition>, or
#f.
Set it with (set! (breakpoint:condition self) value).
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
button:label while
button:icon-name is set will
reset the icon. However, resetting the label will not set
icon-name to its original value.
Use the "apply" and "unapply" signals 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);
Passed: a <AdwBreakpoint>.
a breakpoint
Passed: a <GObject>.
the target object
Passed: a string.
the target property
Passed, or left out: a <GValue>, or
#f.
the value to set
Adds multiple setters to self.
See Breakpoint.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);
Passed: a <AdwBreakpoint>.
a breakpoint
Passed: a list or vector, each a <GObject>.
Passed: a list or vector, each a string.
Passed: a list or vector, each a <GValue>.
Not passed: guile-gi gives the length of values.
the first target object
the first target property
the value of the first setter, followed by a list of object, property
and value triplets, terminated by NULL
Gets the condition for self.
Passed: a <AdwBreakpoint>.
a breakpoint
Returned: a <AdwBreakpointCondition>,
or #f.
the condition
Creates a new <AdwBreakpoint> with
condition.
Passed: a <AdwBreakpointCondition>.
the condition
Returned: a <AdwBreakpoint>.
the newly created <AdwBreakpoint>
Sets the condition for self.
Passed: a <AdwBreakpoint>.
a breakpoint
Passed, or left out: a
<AdwBreakpointCondition>, or
#f.
the new condition
Connect a handler with (connect object breakpoint:apply handler).
It is called as (handler self).
Emitted when the breakpoint is applied.
This signal is emitted after the setters have been applied.
Passed: a <AdwBreakpoint>.
Connect a handler with (connect object breakpoint:unapply
handler). It is called as (handler self).
Emitted when the breakpoint is unapplied.
This signal is emitted before resetting the setter values.
Passed: a <AdwBreakpoint>.