Class StyleManager
- All Implemented Interfaces:
Proxy
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
Modifier and TypeClassDescriptionstatic class
StyleManager.Builder<B extends StyleManager.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionStyleManager
(MemorySegment address) Create a StyleManager proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected StyleManager
asParent()
Returns this instance as if it were its parent type.static StyleManager.Builder
<? extends StyleManager.Builder> builder()
AStyleManager.Builder
object constructs aStyleManager
with the specified properties.Gets the current system accent color.Gets the current system accent color as aGdkRGBA
.Gets the requested application color scheme.boolean
getDark()
Gets whether the application is using dark appearance.static StyleManager
Gets the defaultAdwStyleManager
instance.Gets the display the style manager is associated with.static StyleManager
getForDisplay
(Display display) Gets theAdwStyleManager
instance managingdisplay
.boolean
Gets whether the application is using high contrast appearance.boolean
Gets whether the system supports accent colors.boolean
Gets whether the system supports color schemes.static Type
getType()
Get the GType of the StyleManager classvoid
setColorScheme
(ColorScheme colorScheme) Sets the requested application color scheme.Methods inherited from class org.gnome.gobject.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, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
StyleManager
Create a StyleManager proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getDefault
Gets the defaultAdwStyleManager
instance.It manages all
Display
instances unless the style manager for that display has an override.- Returns:
- the default style manager
-
getForDisplay
Gets theAdwStyleManager
instance 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
-
getAccentColorRgba
Gets the current system accent color as aGdkRGBA
.Equivalent to calling
AccentColor.toRgba(org.gnome.gdk.RGBA)
on the value ofStyleManager:accent-color
.This is a background color. The matching foreground color is white.
- Returns:
- the current system accent color
-
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
NULL
for the style manager returned bygetDefault()
.- Returns:
- the display
-
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
-
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
-
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: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
andADW_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-
Display
style manager has its color scheme set toADW_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 toADW_COLOR_SCHEME_PREFER_LIGHT
.The
StyleManager:system-supports-color-schemes
property can be used to check if the current environment provides a color scheme preference.- Parameters:
colorScheme
- the color scheme
-
builder
AStyleManager.Builder
object constructs aStyleManager
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withStyleManager.Builder.build()
.
-