Adw.BreakpointCondition

Fields

None

Methods

class

new_and (condition_1, condition_2)

class

new_length (type, value, unit)

class

new_or (condition_1, condition_2)

class

new_ratio (type, width, height)

class

parse (str)

copy ()

free ()

to_string ()

Details

class Adw.BreakpointCondition

Describes condition for an [class`Breakpoint`].

New in version 1.4.

classmethod new_and(condition_1, condition_2)
Parameters:
Returns:

the newly created condition

Return type:

Adw.BreakpointCondition

Creates a condition that triggers when condition_1 and condition_2 are both true.

New in version 1.4.

classmethod new_length(type, value, unit)
Parameters:
Returns:

the newly created condition

Return type:

Adw.BreakpointCondition

Creates a condition that triggers on length changes.

New in version 1.4.

classmethod new_or(condition_1, condition_2)
Parameters:
Returns:

the newly created condition

Return type:

Adw.BreakpointCondition

Creates a condition that triggers when either condition_1 or condition_2 is true.

New in version 1.4.

classmethod new_ratio(type, width, height)
Parameters:
Returns:

the newly created condition

Return type:

Adw.BreakpointCondition

Creates a condition that triggers on ratio changes.

The ratio is represented as width divided by height.

New in version 1.4.

classmethod parse(str)
Parameters:

str (str) – the string specifying the condition

Returns:

the parsed condition

Return type:

Adw.BreakpointCondition

Parses a condition from a string.

Length conditions are specified as <type>: <value>[<unit>], where:

  • <type> can be min-width, max-width, min-height or max-height

  • <value> is a fractional number

  • <unit> can be px, pt or sp

If the unit is omitted, px is assumed.

See [ctor`BreakpointCondition`.new_length].

Examples:

  • min-width: 500px

  • min-height: 400pt

  • max-width: 100sp

  • max-height: 500

Ratio conditions are specified as <type>: <width>[/<height>], where:

  • <type> can be min-aspect-ratio or max-aspect-ratio

  • <width> and <height> are integer numbers

See [ctor`BreakpointCondition`.new_ratio].

The ratio is represented as <width> divided by <height>.

If <height> is omitted, it’s assumed to be 1.

Examples:

  • min-aspect-ratio: 4/3

  • max-aspect-ratio: 1

The logical operators and, or can be used to compose a complex condition as follows:

  • <condition> and <condition>: the condition is true when both ``<condition>``s are true, same as when using [ctor`BreakpointCondition`.new_and]

  • <condition> or <condition>: the condition is true when either of the ``<condition>``s is true, same as when using [ctor`BreakpointCondition`.new_or]

Examples:

  • min-width: 400px and max-aspect-ratio: 4/3

  • max-width: 360sp or max-width: 360px

Conditions can be further nested using parentheses, for example:

  • min-width: 400px and (max-aspect-ratio: 4/3 or max-height: 400px)

If parentheses are omitted, the first operator takes priority.

New in version 1.4.

copy()
Returns:

a copy of self

Return type:

Adw.BreakpointCondition

Copies self.

New in version 1.4.

free()

Frees self.

New in version 1.4.

to_string()
Returns:

A newly allocated text string

Return type:

str

Returns a textual representation of self.

The returned string can be parsed by [func`BreakpointCondition`.parse].

New in version 1.4.