Adw.StyleManager

g Adw.StyleManager Adw.StyleManager GObject.Object GObject.Object GObject.Object->Adw.StyleManager

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_default ()

class

get_for_display (display)

get_accent_color ()

get_accent_color_rgba ()

get_color_scheme ()

get_dark ()

get_display ()

get_document_font_name ()

get_high_contrast ()

get_monospace_font_name ()

get_system_supports_accent_colors ()

get_system_supports_color_schemes ()

set_color_scheme (color_scheme)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

accent-color

Adw.AccentColor

r

accent-color-rgba

Gdk.RGBA

r

color-scheme

Adw.ColorScheme

r/w/en

dark

bool

r

display

Gdk.Display

r/w/co

document-font-name

str

r

high-contrast

bool

r

monospace-font-name

str

r

system-supports-accent-colors

bool

r

system-supports-color-schemes

bool

r

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Adw.StyleManager(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Adw.StyleManagerClass

A class for managing application-wide styling.

AdwStyleManager provides a way to query and influence the application styles, such as whether to use dark style, the system accent color or high contrast appearance.

It allows to set the color scheme via the [property`StyleManager`:py:data::color-scheme<Adw.StyleManager.props.color_scheme>] property, and to query the current appearance, as well as whether a system-wide color scheme and accent color preferences exists.

classmethod get_default()
Returns:

the default style manager

Return type:

Adw.StyleManager

Gets the default AdwStyleManager instance.

It manages all [class`Gdk`.Display] instances unless the style manager for that display has an override.

See [func`StyleManager`.get_for_display].

classmethod get_for_display(display)
Parameters:

display (Gdk.Display) – a GdkDisplay

Returns:

the style manager for display

Return type:

Adw.StyleManager

Gets the AdwStyleManager instance managing display.

It can be used to override styles for that specific display instead of the whole application.

Most applications should use [func`StyleManager`.get_default] instead.

get_accent_color()
Returns:

the current system accent color

Return type:

Adw.AccentColor

Gets the current system accent color.

See also [property`StyleManager`:py:data::accent-color-rgba<Adw.StyleManager.props.accent_color_rgba>].

New in version 1.6.

get_accent_color_rgba()
Returns:

the current system accent color

Return type:

Gdk.RGBA

Gets the current system accent color as a GdkRGBA.

Equivalent to calling [func`AccentColor`.to_rgba] on the value of [property`StyleManager`:py:data::accent-color<Adw.StyleManager.props.accent_color>].

This is a background color. The matching foreground color is white.

New in version 1.6.

get_color_scheme()
Returns:

the color scheme

Return type:

Adw.ColorScheme

Gets the requested application color scheme.

get_dark()
Returns:

whether the application is using dark appearance

Return type:

bool

Gets whether the application is using dark appearance.

This can be used to query the current appearance, as requested via [property`StyleManager`:py:data::color-scheme<Adw.StyleManager.props.color_scheme>].

get_display()
Returns:

the display

Return type:

Gdk.Display or None

Gets the display the style manager is associated with.

The display will be NULL for the style manager returned by [func`StyleManager`.get_default].

get_document_font_name()
Returns:

the system document font

Return type:

str

Gets the system document font.

The font is in the same format as [property`Gtk`.Settings:gtk-font-name], e.g. “Adwaita Sans 11”.

New in version 1.7.

get_high_contrast()
Returns:

whether the application is using high contrast appearance

Return type:

bool

Gets whether the application is using high contrast appearance.

This cannot be overridden by applications.

get_monospace_font_name()
Returns:

the system monospace font

Return type:

str

Gets the system monospace font.

The font is in the same format as [property`Gtk`.Settings:gtk-font-name], e.g. “Adwaita Mono 11”.

New in version 1.7.

get_system_supports_accent_colors()
Returns:

whether the system supports accent colors

Return type:

bool

Gets whether the system supports accent colors.

This can be used to check if the current environment provides an accent color preference. For example, applications might want to show a preference for choosing accent color if it’s set to FALSE.

See [property`StyleManager`:py:data::accent-color<Adw.StyleManager.props.accent_color>].

New in version 1.6.

get_system_supports_color_schemes()
Returns:

whether the system supports color schemes

Return type:

bool

Gets whether the system supports color schemes.

This can be used to check if the current environment provides a color scheme preference. For example, applications might want to show a separate appearance switcher if it’s set to FALSE.

set_color_scheme(color_scheme)
Parameters:

color_scheme (Adw.ColorScheme) – the color scheme

Sets the requested application color scheme.

The effective appearance will be decided based on the application color scheme and the system preferred color scheme. The [property`StyleManager`:py:data::dark<Adw.StyleManager.props.dark>] property can be used to query the current effective appearance.

The ADW_COLOR_SCHEME_PREFER_LIGHT color scheme results in the application using light appearance unless the system prefers dark colors. This is the default value.

The ADW_COLOR_SCHEME_PREFER_DARK color scheme results in the application using dark appearance, but can still switch to the light appearance if the system can prefers it, for example, when the high contrast preference is enabled.

The ADW_COLOR_SCHEME_FORCE_LIGHT and ADW_COLOR_SCHEME_FORCE_DARK values ignore the system preference entirely. They are useful if the application wants to match its UI to its content or to provide a separate color scheme switcher.

If a per-[class`Gdk`.Display] style manager has its color scheme set to ADW_COLOR_SCHEME_DEFAULT, it will inherit the color scheme from the default style manager.

For the default style manager, ADW_COLOR_SCHEME_DEFAULT is equivalent to ADW_COLOR_SCHEME_PREFER_LIGHT.

The [property`StyleManager`:py:data::system-supports-color-schemes<Adw.StyleManager.props.system_supports_color_schemes>] property can be used to check if the current environment provides a color scheme preference.

Property Details

Adw.StyleManager.props.accent_color
Name:

accent-color

Type:

Adw.AccentColor

Default Value:

Adw.AccentColor.BLUE

Flags:

READABLE

The current system accent color.

See also [property`StyleManager`:py:data::accent-color-rgba<Adw.StyleManager.props.accent_color_rgba>].

New in version 1.6.

Adw.StyleManager.props.accent_color_rgba
Name:

accent-color-rgba

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE

The current system accent color as a GdkRGBA.

Equivalent to calling [func`AccentColor`.to_rgba] on the value of [property`StyleManager`:py:data::accent-color<Adw.StyleManager.props.accent_color>].

This is a background color. The matching foreground color is white.

New in version 1.6.

Adw.StyleManager.props.color_scheme
Name:

color-scheme

Type:

Adw.ColorScheme

Default Value:

Adw.ColorScheme.DEFAULT

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The requested application color scheme.

The effective appearance will be decided based on the application color scheme and the system preferred color scheme. The [property`StyleManager`:py:data::dark<Adw.StyleManager.props.dark>] property can be used to query the current effective appearance.

The ADW_COLOR_SCHEME_PREFER_LIGHT color scheme results in the application using light appearance unless the system prefers dark colors. This is the default value.

The ADW_COLOR_SCHEME_PREFER_DARK color scheme results in the application using dark appearance, but can still switch to the light appearance if the system can prefers it, for example, when the high contrast preference is enabled.

The ADW_COLOR_SCHEME_FORCE_LIGHT and ADW_COLOR_SCHEME_FORCE_DARK values ignore the system preference entirely. They are useful if the application wants to match its UI to its content or to provide a separate color scheme switcher.

If a per-[class`Gdk`.Display] style manager has its color scheme set to ADW_COLOR_SCHEME_DEFAULT, it will inherit the color scheme from the default style manager.

For the default style manager, ADW_COLOR_SCHEME_DEFAULT is equivalent to ADW_COLOR_SCHEME_PREFER_LIGHT.

The [property`StyleManager`:py:data::system-supports-color-schemes<Adw.StyleManager.props.system_supports_color_schemes>] property can be used to check if the current environment provides a color scheme preference.

Adw.StyleManager.props.dark
Name:

dark

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the application is using dark appearance.

This property can be used to query the current appearance, as requested via [property`StyleManager`:py:data::color-scheme<Adw.StyleManager.props.color_scheme>].

Adw.StyleManager.props.display
Name:

display

Type:

Gdk.Display

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The display the style manager is associated with.

The display will be NULL for the style manager returned by [func`StyleManager`.get_default].

Adw.StyleManager.props.document_font_name
Name:

document-font-name

Type:

str

Default Value:

'Sans 10'

Flags:

READABLE

The system document font.

The font is in the same format as [property`Gtk`.Settings:gtk-font-name], e.g. “Adwaita Sans 11”.

New in version 1.7.

Adw.StyleManager.props.high_contrast
Name:

high-contrast

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the application is using high contrast appearance.

This cannot be overridden by applications.

Adw.StyleManager.props.monospace_font_name
Name:

monospace-font-name

Type:

str

Default Value:

'Monospace 10'

Flags:

READABLE

The system monospace font.

The font is in the same format as [property`Gtk`.Settings:gtk-font-name], e.g. “Adwaita Mono 11”.

New in version 1.7.

Adw.StyleManager.props.system_supports_accent_colors
Name:

system-supports-accent-colors

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the system supports accent colors.

This property can be used to check if the current environment provides an accent color preference. For example, applications might want to show a preference for choosing accent color if it’s set to FALSE.

See [property`StyleManager`:py:data::accent-color<Adw.StyleManager.props.accent_color>].

New in version 1.6.

Adw.StyleManager.props.system_supports_color_schemes
Name:

system-supports-color-schemes

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the system supports color schemes.

This property can be used to check if the current environment provides a color scheme preference. For example, applications might want to show a separate appearance switcher if it’s set to FALSE.

See [property`StyleManager`:py:data::color-scheme<Adw.StyleManager.props.color_scheme>].