Adw.Breakpoint¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when the breakpoint is applied. |
|
Emitted when the breakpoint is unapplied. |
Fields¶
- Inherited:
Class Details¶
- class Adw.Breakpoint(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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`].
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 theobject
attribute specifying the target object, and theproperty
attribute specifying the property name. The contents of the element are used as the setter value.For
G_TYPE_OBJECT
andG_TYPE_BOXED
derived properties, empty contents are treated asNULL
.Setter values can be translated with the usual
translatable
,context
andcomments
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:
Creates a new
AdwBreakpoint
with condition.New in version 1.4.
- add_setter(object, property, value)¶
- Parameters:
object (
GObject.Object
) – the target objectproperty (
str
) – the target propertyvalue (
GObject.Value
orNone
) – the value to set
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:
objects ([
GObject.Object
]) – setter target objectnames ([
str
]) – setter target propertiesvalues ([
GObject.Value
]) – setter values
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:
Gets the condition for self.
New in version 1.4.
- set_condition(condition)¶
- Parameters:
condition (
Adw.BreakpointCondition
orNone
) – the new condition
Sets the condition for self.
New in version 1.4.
Signal Details¶
- Adw.Breakpoint.signals.apply(breakpoint)¶
- Signal Name:
apply
- Flags:
- 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:
- 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:
- Default Value:
- Flags:
The breakpoint’s condition.
New in version 1.4.