Adw.Breakpoint

g Adw.Breakpoint Adw.Breakpoint GObject.GInterface GObject.GInterface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.Object GObject.Object GObject.Object->Adw.Breakpoint Gtk.Buildable->Adw.Breakpoint

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gtk.Buildable (1)

Structs:

GObject.ObjectClass (5)

class

new (condition)

add_setter (object, property, value)

add_setters (objects, names, values)

get_condition ()

set_condition (condition)

Virtual Methods

Inherited:

GObject.Object (7), Gtk.Buildable (9)

Properties

Name

Type

Flags

Short Description

condition

Adw.BreakpointCondition

r/w/en

Signals

Inherited:

GObject.Object (1)

Name

Short Description

apply

Emitted when the breakpoint is applied.

unapply

Emitted when the breakpoint is unapplied.

Fields

Inherited:

GObject.Object (1)

Class Details

class Adw.Breakpoint(**kwargs)
Bases:

GObject.Object, Gtk.Buildable

Abstract:

No

Structure:

Adw.BreakpointClass

Describes a breakpoint for [class`Window`] or [class`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, [signal`Breakpoint`:py:func:::apply<Adw.Breakpoint.signals.apply>] and [signal`Breakpoint`:py:func:::unapply<Adw.Breakpoint.signals.unapply>] can be used instead.

Breakpoints can be used within [class`Window`], [class`ApplicationWindow`], [class`Dialog`] or [class`BreakpointBin`].

Adw.Breakpoint as Gtk.Buildable:

AdwBreakpoint supports specifying its condition via the <condition> element. The contents of the element must be a string in a format accepted by [func`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:

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

New in version 1.4.

classmethod new(condition)
Parameters:

condition (Adw.BreakpointCondition) – the condition

Returns:

the newly created AdwBreakpoint

Return type:

Adw.Breakpoint

Creates a new AdwBreakpoint with condition.

New in version 1.4.

add_setter(object, property, value)
Parameters:

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 [property`Gtk`.Button:label] while [property`Gtk`.Button:icon-name] is set will reset the icon. However, resetting the label will not set icon-name to its original value.

Use the [signal`Breakpoint`:py:func:::apply<Adw.Breakpoint.signals.apply>] and [signal`Breakpoint`:py:func:::unapply<Adw.Breakpoint.signals.unapply>] signals for those properties instead, as follows:

```c 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); ```

New in version 1.4.

add_setters(objects, names, values)
Parameters:

Adds n_setters setters to self.

This is a convenience function for adding multiple setters at once.

See [method`Breakpoint`.add_setter].

This function is meant to be used by language bindings.

New in version 1.4.

get_condition()
Returns:

the condition

Return type:

Adw.BreakpointCondition or None

Gets the condition for self.

New in version 1.4.

set_condition(condition)
Parameters:

condition (Adw.BreakpointCondition or None) – the new condition

Sets the condition for self.

New in version 1.4.

Signal Details

Adw.Breakpoint.signals.apply(breakpoint)
Signal Name:

apply

Flags:

RUN_LAST

Parameters:

breakpoint (Adw.Breakpoint) – The object which received the signal

Emitted when the breakpoint is applied.

This signal is emitted after the setters have been applied.

New in version 1.4.

Adw.Breakpoint.signals.unapply(breakpoint)
Signal Name:

unapply

Flags:

RUN_LAST

Parameters:

breakpoint (Adw.Breakpoint) – The object which received the signal

Emitted when the breakpoint is unapplied.

This signal is emitted before resetting the setter values.

New in version 1.4.

Property Details

Adw.Breakpoint.props.condition
Name:

condition

Type:

Adw.BreakpointCondition

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The breakpoint’s condition.

New in version 1.4.