Handy.StyleManager

g GObject.Object GObject.Object Handy.StyleManager Handy.StyleManager GObject.Object->Handy.StyleManager

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_default ()

class

get_for_display (display)

get_color_scheme ()

get_dark ()

get_display ()

get_high_contrast ()

get_system_supports_color_schemes ()

set_color_scheme (color_scheme)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

color-scheme

Handy.ColorScheme

r/w/en

The current color scheme

dark

bool

r

Whether the application is using dark appearance

display

Gdk.Display

r/w/co

xlib.Display

high-contrast

bool

r

Whether the application is using high contrast appearance

system-supports-color-schemes

bool

r

Whether the system supports color schemes

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Handy.StyleManager(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Handy.StyleManagerClass

A class for managing application-wide styling.

HdyStyleManager provides a way to query and influence the application styles, such as whether to use dark or high contrast appearance.

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

Important: [property`Gtk`.Settings:gtk-application-prefer-dark-theme] should not be used together with HdyStyleManager and will result in a warning. Color schemes should be used instead.

New in version 1.6.

classmethod get_default()
Returns:

the default style manager

Return type:

Handy.StyleManager

Gets the default [class`StyleManager`] instance.

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

See [func`StyleManager`.get_for_display].

New in version 1.6.

classmethod get_for_display(display)
Parameters:

display (Gdk.Display) – a display

Returns:

the style manager for display

Return type:

Handy.StyleManager

Gets the [class`StyleManager`] 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.

New in version 1.6.

get_color_scheme()
Returns:

the color scheme

Return type:

Handy.ColorScheme

Gets the requested application color scheme.

New in version 1.6.

get_dark()
Returns:

whether the application is using dark appearance

Return type:

bool

Gets whether the application is using dark appearance.

New in version 1.6.

get_display()
Returns:

(nullable): the display

Return type:

Gdk.Display

Gets the display the style manager is associated with.

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

New in version 1.6.

get_high_contrast()
Returns:

whether the application is using high contrast appearance

Return type:

bool

Gets whether the application is using high contrast appearance.

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.

New in version 1.6.

set_color_scheme(color_scheme)
Parameters:

color_scheme (Handy.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<Handy.StyleManager.props.dark>] property can be used to query the current effective appearance.

New in version 1.6.

Property Details

Handy.StyleManager.props.color_scheme
Name:

color-scheme

Type:

Handy.ColorScheme

Default Value:

Handy.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<Handy.StyleManager.props.dark>] property can be used to query the current effective appearance.

The HDY_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 HDY_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 HDY_COLOR_SCHEME_FORCE_LIGHT and HDY_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`.:obj:xlib.Display] style manager has its color scheme set to HDY_COLOR_SCHEME_DEFAULT, it will inherit the color scheme from the default style manager.

For the default style manager, HDY_COLOR_SCHEME_DEFAULT is equivalent to HDY_COLOR_SCHEME_FORCE_LIGHT.

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

New in version 1.6.

Handy.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<Handy.StyleManager.props.color_scheme>].

New in version 1.6.

Handy.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].

New in version 1.6.

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

New in version 1.6.

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

It’s only set at startup and cannot change its value later.

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

New in version 1.6.