Class StyleManager

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class StyleManager extends GObject

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.

  • Constructor Details

    • StyleManager

      public StyleManager(MemorySegment address)
      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

      public static @Nullable Type getType()
      Get the GType of the StyleManager class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected StyleManager asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getDefault

      public static StyleManager getDefault()

      Gets the default AdwStyleManager instance.

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

      See getForDisplay(Display).

      Returns:
      the default style manager
    • getForDisplay

      public static StyleManager getForDisplay(Display display)

      Gets the AdwStyleManager instance managing display.

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

      Most applications should use getDefault() instead.

      Parameters:
      display - a GdkDisplay
      Returns:
      the style manager for display
    • getAccentColor

      public AccentColor getAccentColor()

      Gets the current system accent color.

      See also StyleManager:accent-color-rgba.

      Returns:
      the current system accent color
      Since:
      1.6
    • getAccentColorRgba

      public RGBA getAccentColorRgba()

      Gets the current system accent color as a GdkRGBA.

      Equivalent to calling AccentColor.toRgba(RGBA) on the value of StyleManager:accent-color.

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

      Returns:
      the current system accent color
      Since:
      1.6
    • getColorScheme

      public ColorScheme 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

      public @Nullable Display getDisplay()

      Gets the display the style manager is associated with.

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

      Returns:
      the display
    • getDocumentFontName

      public String 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

      public String 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

      public void setColorScheme(ColorScheme colorScheme)

      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.ColorScheme.prefer-light color scheme results in the application using light appearance unless the system prefers dark colors. This is the default value.

      The Adw.ColorScheme.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.ColorScheme.force-light and Adw.ColorScheme.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 to Adw.ColorScheme.default, it will inherit the color scheme from the default style manager.

      For the default style manager, Adw.ColorScheme.default is equivalent to Adw.ColorScheme.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

      public static StyleManager.Builder<? extends StyleManager.Builder> builder()
      A StyleManager.Builder object constructs a StyleManager with the specified properties. Use the various set...() methods to set properties, and finish construction with StyleManager.Builder.build().
      Returns:
      the builder object