1.12 <AdwBreakpoint>

Class: <AdwBreakpoint>

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‘ as ‘GtkBuildable‘:

<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>

Properties

Property: breakpoint:condition self

The breakpoint’s condition.

Its value is a <AdwBreakpointCondition>, or #f.

Set it with (set! (breakpoint:condition self) value).

Procedures

Method: breakpoint:add-setter self object property [value]
Method: add-setter self object property [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);
self

Passed: a <AdwBreakpoint>.

a breakpoint

object

Passed: a <GObject>.

the target object

property

Passed: a string.

the target property

value

Passed, or left out: a <GValue>, or #f.

the value to set

Method: breakpoint:add-setters self objects names values
Method: add-setters self objects names values

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);
self

Passed: a <AdwBreakpoint>.

a breakpoint

objects

Passed: a list or vector, each a <GObject>.

names

Passed: a list or vector, each a string.

values

Passed: a list or vector, each a <GValue>.

n-setters

Not passed: guile-gi gives the length of values.

first-object

the first target object

first-property

the first target property

...

the value of the first setter, followed by a list of object, property and value triplets, terminated by NULL

Method: breakpoint:get-condition self ⇒ %return
Method: get-condition self ⇒ %return

Gets the condition for self.

self

Passed: a <AdwBreakpoint>.

a breakpoint

%return

Returned: a <AdwBreakpointCondition>, or #f.

the condition

Procedure: breakpoint:new condition ⇒ %return

Creates a new <AdwBreakpoint> with condition.

condition

Passed: a <AdwBreakpointCondition>.

the condition

%return

Returned: a <AdwBreakpoint>.

the newly created <AdwBreakpoint>

Method: breakpoint:set-condition self [condition]
Method: set-condition self [condition]

Sets the condition for self.

self

Passed: a <AdwBreakpoint>.

a breakpoint

condition

Passed, or left out: a <AdwBreakpointCondition>, or #f.

the new condition

Signals

Signal: breakpoint:apply

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.

self

Passed: a <AdwBreakpoint>.

Signal: breakpoint:unapply

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.

self

Passed: a <AdwBreakpoint>.