HdyStyleManager: Handy Reference Manual

## HdyStyleManager HdyStyleManager — A class for managing application-wide styling |

## Functions

HdyStyleManager * | hdy_style_manager_get_default ()
HdyStyleManager * | hdy_style_manager_get_for_display ()
GdkDisplay * | hdy_style_manager_get_display ()
HdyColorScheme | hdy_style_manager_get_color_scheme ()
void | hdy_style_manager_set_color_scheme ()
gboolean | hdy_style_manager_get_system_supports_color_schemes ()
gboolean | hdy_style_manager_get_dark ()
gboolean | hdy_style_manager_get_high_contrast ()

## Properties

HdyColorScheme | color-scheme | Read / Write
gboolean | dark | Read
GdkDisplay * | display | Read / Write / Construct Only
gboolean | high-contrast | Read
gboolean | system-supports-color-schemes | Read

## Types and Values

#define | HDY_TYPE_STYLE_MANAGER
enum | HdyColorScheme
| HdyStyleManager

## Object Hierarchy

        GObject
        ╰── HdyStyleManager

## Description

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 “color-scheme” property, and to query the current appearance, as well as whether a system-wide color scheme preference exists.

Important: “gtk-application-prefer-dark-theme” should not be used together with `HdyStyleManager` and will result in a warning. Color schemes should be used instead.

## Functions

### hdy_style_manager_get_default ()

    HdyStyleManager *
    hdy_style_manager_get_default (void);

Gets the default HdyStyleManager instance.

It manages all GdkDisplay instances unless the style manager for that display has an override.

See `hdy_style_manager_get_for_display()`.

#### Returns

the default style manager.

[transfer none]

Since: 1.6

### hdy_style_manager_get_for_display ()

    HdyStyleManager *
    hdy_style_manager_get_for_display (GdkDisplay *display);

Gets the HdyStyleManager instance managing `display` .

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

Most applications should use `hdy_style_manager_get_default()` instead.

#### Parameters

display | a GdkDisplay |

#### Returns

the style manager for `display` .

[transfer none]

Since: 1.6

### hdy_style_manager_get_display ()

    GdkDisplay *
    hdy_style_manager_get_display (HdyStyleManager *self);

Gets the display the style manager is associated with.

The display will be `NULL` for the style manager returned by `hdy_style_manager_get_default()`.

#### Parameters

self | a HdyStyleManager |

#### Returns

(nullable): the display.

[transfer none]

Since: 1.6

### hdy_style_manager_get_color_scheme ()

    HdyColorScheme
    hdy_style_manager_get_color_scheme (HdyStyleManager *self);

Gets the requested application color scheme.

#### Parameters

self | a HdyStyleManager |

#### Returns

the color scheme

Since: 1.6

### hdy_style_manager_set_color_scheme ()

    void
    hdy_style_manager_set_color_scheme (HdyStyleManager *self,
                                        HdyColorScheme 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 “dark” property can be used to query the current effective appearance.

#### Parameters

self | a HdyStyleManager |
color_scheme | the color scheme |

Since: 1.6

### hdy_style_manager_get_system_supports_color_schemes ()

    gboolean
    hdy_style_manager_get_system_supports_color_schemes
                                   (HdyStyleManager *self);

Gets whether the system supports color schemes.

#### Parameters

self | a HdyStyleManager |

#### Returns

whether the system supports color schemes

Since: 1.6

### hdy_style_manager_get_dark ()

    gboolean
    hdy_style_manager_get_dark (HdyStyleManager *self);

Gets whether the application is using dark appearance.

#### Parameters

self | a HdyStyleManager |

#### Returns

whether the application is using dark appearance

Since: 1.6

### hdy_style_manager_get_high_contrast ()

    gboolean
    hdy_style_manager_get_high_contrast (HdyStyleManager *self);

Gets whether the application is using high contrast appearance.

#### Parameters

self | a HdyStyleManager |

#### Returns

whether the application is using high contrast appearance

Since: 1.6

## Types and Values

### HDY_TYPE_STYLE_MANAGER

    #define HDY_TYPE_STYLE_MANAGER (hdy_style_manager_get_type())

### enum HdyColorScheme

Application color schemes for “color-scheme”.

#### Members

HDY_COLOR_SCHEME_DEFAULT | Inherit the parent color-scheme. When set on the HdyStyleManager returned by `hdy_style_manager_get_default()`, it's equivalent to `HDY_COLOR_SCHEME_FORCE_LIGHT`. |
HDY_COLOR_SCHEME_FORCE_LIGHT | Always use light appearance. |
HDY_COLOR_SCHEME_PREFER_LIGHT | Use light appearance unless the system prefers dark colors. |
HDY_COLOR_SCHEME_PREFER_DARK | Use dark appearance unless the system prefers light colors. |
HDY_COLOR_SCHEME_FORCE_DARK | Always use dark appearance. |

Since: 1.6

### HdyStyleManager

    typedef struct _HdyStyleManager HdyStyleManager;

## Property Details

### The `“color-scheme”` property

      “color-scheme”             HdyColorScheme

The requested application color scheme.

The effective appearance will be decided based on the application color scheme and the system preferred color scheme. The “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-GdkDisplay 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 “system-supports-color-schemes” property can be used to check if the current environment provides a color scheme dddpreference.

Owner: HdyStyleManager

Flags: Read / Write

Default value: HDY_COLOR_SCHEME_DEFAULT

Since: 1.6

### The `“dark”` property

      “dark”                     gboolean

Whether the application is using dark appearance.

This property can be used to query the current appearance, as requested via “color-scheme”.

Owner: HdyStyleManager

Flags: Read

Default value: FALSE

Since: 1.6

### The `“display”` property

      “display”                  GdkDisplay *

The display the style manager is associated with.

The display will be `NULL` for the style manager returned by `hdy_style_manager_get_default()`.

Owner: HdyStyleManager

Flags: Read / Write / Construct Only

Since: 1.6

### The `“high-contrast”` property

      “high-contrast”            gboolean

Whether the application is using high contrast appearance.

This cannot be overridden by applications.

Owner: HdyStyleManager

Flags: Read

Default value: FALSE

Since: 1.6

### The `“system-supports-color-schemes”` property

      “system-supports-color-schemes” gboolean

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 “color-scheme”.

Owner: HdyStyleManager

Flags: Read

Default value: FALSE

Since: 1.6