Class StyleManager
- All Implemented Interfaces:
Proxy
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
StyleManager:color-scheme property, and to query the current
appearance, as well as whether a system-wide color scheme and accent color
preferences exists.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classStyleManager.Builder<B extends StyleManager.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new StyleManager.StyleManager(MemorySegment address) Create a StyleManager instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected StyleManagerasParent()Return this instance as if it were its parent type.static StyleManager.Builder<? extends StyleManager.Builder> builder()AStyleManager.Builderobject constructs aStyleManagerwith the specified properties.Gets the current system accent color.Gets the current system accent color as aGdkRGBA.Gets the requested application color scheme.booleangetDark()Gets whether the application is using dark appearance.static StyleManagerGets the defaultAdwStyleManagerinstance.@Nullable DisplayGets the display the style manager is associated with.Gets the system document font.static StyleManagergetForDisplay(Display display) Gets theAdwStyleManagerinstance managingdisplay.booleanGets whether the application is using high contrast appearance.static MemoryLayoutThe memory layout of the native struct.Gets the system monospace font.booleanGets whether the system supports accent colors.booleanGets whether the system supports color schemes.static @Nullable TypegetType()Get the GType of the StyleManager class.voidsetColorScheme(ColorScheme colorScheme) Sets the requested application color scheme.Methods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
StyleManager
Create a StyleManager instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
StyleManager
public StyleManager()Create a new StyleManager.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
getDefault
Gets the default
AdwStyleManagerinstance.It manages all
Displayinstances unless the style manager for that display has an override.- Returns:
- the default style manager
-
getForDisplay
Gets the
AdwStyleManagerinstance managingdisplay.It can be used to override styles for that specific display instead of the whole application.
Most applications should use
getDefault()instead.- Parameters:
display- aGdkDisplay- Returns:
- the style manager for
display
-
getAccentColor
Gets the current system accent color.
See also
StyleManager:accent-color-rgba.- Returns:
- the current system accent color
- Since:
- 1.6
-
getAccentColorRgba
Gets the current system accent color as a
GdkRGBA.Equivalent to calling
AccentColor.toRgba(RGBA)on the value ofStyleManager:accent-color.This is a background color. The matching foreground color is white.
- Returns:
- the current system accent color
- Since:
- 1.6
-
getColorScheme
Gets the requested application color scheme.- Returns:
- the color scheme
-
getDark
public boolean getDark()Gets whether the application is using dark appearance.
This can be used to query the current appearance, as requested via
StyleManager:color-scheme.- Returns:
- whether the application is using dark appearance
-
getDisplay
Gets the display the style manager is associated with.
The display will be
NULLfor the style manager returned bygetDefault().- Returns:
- the display
-
getDocumentFontName
Gets the system document font.
The font is in the same format as
Gtk.Settings:gtk-font-name, e.g. "Adwaita Sans 12".Use FontDescription#fromString to parse it.
- Returns:
- the system document font
- Since:
- 1.7
-
getHighContrast
public boolean getHighContrast()Gets whether the application is using high contrast appearance.
This cannot be overridden by applications.
- Returns:
- whether the application is using high contrast appearance
-
getMonospaceFontName
Gets the system monospace font.
The font is in the same format as
Gtk.Settings:gtk-font-name, e.g. "Adwaita Mono 11".Use FontDescription#fromString to parse it.
- Returns:
- the system monospace font
- Since:
- 1.7
-
getSystemSupportsAccentColors
public boolean getSystemSupportsAccentColors()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
StyleManager:accent-color.- Returns:
- whether the system supports accent colors
- Since:
- 1.6
-
getSystemSupportsColorSchemes
public boolean getSystemSupportsColorSchemes()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.- Returns:
- whether the system supports color schemes
-
setColorScheme
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:darkproperty can be used to query the current effective appearance.The
Adw.ColorScheme.prefer-lightcolor scheme results in the application using light appearance unless the system prefers dark colors. This is the default value.The
Adw.ColorScheme.prefer-darkcolor 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.ColorScheme.force-lightandAdw.ColorScheme.force-darkvalues 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-
Displaystyle manager has its color scheme set toAdw.ColorScheme.default, it will inherit the color scheme from the default style manager.For the default style manager,
Adw.ColorScheme.defaultis equivalent toAdw.ColorScheme.prefer-light.The
StyleManager:system-supports-color-schemesproperty can be used to check if the current environment provides a color scheme preference.- Parameters:
colorScheme- the color scheme
-
builder
AStyleManager.Builderobject constructs aStyleManagerwith the specified properties. Use the variousset...()methods to set properties, and finish construction withStyleManager.Builder.build().- Returns:
- the builder object
-