class Adw::StyleManager

Overview

A class for managing application-wide styling.

Adw::StyleManager 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:color-scheme] property, and to query the current appearance, as well as whether a system-wide color scheme and accent color preferences exists.

Defined in:

lib/gi-crystal/src/auto/adw-1/style_manager.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new #

Initialize a new StyleManager.


def self.new(*, accent_color : Adw::AccentColor | Nil = nil, accent_color_rgba : Gdk::RGBA | Nil = nil, color_scheme : Adw::ColorScheme | Nil = nil, dark : Bool | Nil = nil, display : Gdk::Display | Nil = nil, document_font_name : String | Nil = nil, high_contrast : Bool | Nil = nil, monospace_font_name : String | Nil = nil, system_supports_accent_colors : Bool | Nil = nil, system_supports_color_schemes : Bool | Nil = nil) #

Class Method Detail

def self.default : Adw::StyleManager #

Gets the default Adw::StyleManager instance.

It manages all Gdk::Display instances unless the style manager for that display has an override.

See StyleManager#for_display.


def self.for_display(display : Gdk::Display) : Adw::StyleManager #

Gets the Adw::StyleManager instance managing display.

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

Most applications should use StyleManager#default instead.


def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def accent_color : Adw::AccentColor #

Gets the current system accent color.

See also [property@StyleManager:accent-color-rgba].


def accent_color_rgba : Gdk::RGBA #

Gets the current system accent color as a Gdk::RGBA.

Equivalent to calling AccentColor::to_rgba on the value of [property@StyleManager:accent-color].

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


def color_scheme : Adw::ColorScheme #

Gets the requested application color scheme.


def color_scheme=(color_scheme : Adw::ColorScheme) : Nil #

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 StyleManager::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-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:system-supports-color-schemes] property can be used to check if the current environment provides a color scheme preference.


def dark : Bool #

Gets whether the application is using dark appearance.

This can be used to query the current appearance, as requested via [property@StyleManager:color-scheme].


def dark? : Bool #

def display : Gdk::Display | Nil #

Gets the display the style manager is associated with.

The display will be NULL for the style manager returned by StyleManager#default.


def display=(value : Gdk::Display | Nil) : Gdk::Display | Nil #

def document_font_name : String #

Gets the system document font.

The font is in the same format as [property@Gtk.Settings:gtk-font-name], e.g. "Adw::aita Sans 11".

Use Pango::FontDescription#to_string to parse it.


def document_font_name? : String | Nil #

Same as #document_font_name, but can return nil.


def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def high_contrast : Bool #

Gets whether the application is using high contrast appearance.

This cannot be overridden by applications.


def high_contrast? : Bool #

def monospace_font_name : String #

Gets the system monospace font.

The font is in the same format as [property@Gtk.Settings:gtk-font-name], e.g. "Adw::aita Mono 11".

Use Pango::FontDescription#to_string to parse it.


def monospace_font_name? : String | Nil #

Same as #monospace_font_name, but can return nil.


def system_supports_accent_colors : 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:accent-color].


def system_supports_accent_colors? : Bool #

def system_supports_color_schemes : 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.


def system_supports_color_schemes? : Bool #