Class CssProvider.Builder<B extends CssProvider.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
BuilderInterface
Enclosing class:
CssProvider

public static class CssProvider.Builder<B extends CssProvider.Builder<B>> extends GObject.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public CssProvider build()
      Finish building the CssProvider object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to CssProvider.
      Overrides:
      build in class GObject.Builder<B extends CssProvider.Builder<B>>
      Returns:
      a new instance of CssProvider with the properties that were set in the Builder object.
    • setPrefersColorScheme

      public B setPrefersColorScheme(InterfaceColorScheme prefersColorScheme)

      Define the color scheme used for rendering the user interface.

      The UI can be set to either Gtk.InterfaceColorScheme.LIGHT, or Gtk.InterfaceColorScheme.DARK mode. Other values will be interpreted the same as Gtk.InterfaceColorScheme.LIGHT.

      This setting is be available for media queries in CSS:

      @media (prefers-color-scheme: dark) {
        // some dark mode styling
      }
      

      Changing this setting will reload the style sheet.

      Parameters:
      prefersColorScheme - the value for the prefers-color-scheme property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.20
    • setPrefersContrast

      public B setPrefersContrast(InterfaceContrast prefersContrast)

      Define the contrast mode to use for the user interface.

      When set to Gtk.InterfaceContrast.MORE or Gtk.InterfaceContrast.LESS, the UI is rendered in high or low contrast.

      When set to Gtk.InterfaceContrast.NO_PREFERENCE (the default), the user interface will be rendered in default mode.

      This setting is be available for media queries in CSS:

      @media (prefers-contrast: more) {
        // some style with high contrast
      }
      

      Changing this setting will reload the style sheet.

      Parameters:
      prefersContrast - the value for the prefers-contrast property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.20
    • setPrefersReducedMotion

      public B setPrefersReducedMotion(ReducedMotion prefersReducedMotion)

      Define the type of reduced motion to use for the user interface.

      When set to Gtk.ReducedMotion.REDUCE the UI is rendered in with reduced motion animations.

      When set to Gtk.ReducedMotion.NO_PREFERENCE (the default), the user interface will be rendered in default mode.

      This setting is be available for media queries in CSS:

      @media (prefers-reduced-motion: reduce) {
        // some style with reduced motion
      }
      

      Changing this setting will reload the style sheet.

      Parameters:
      prefersReducedMotion - the value for the prefers-reduced-motion property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.22
    • onParsingError

      public B onParsingError(CssProvider.ParsingErrorCallback handler)

      Signals that a parsing error occurred.

      The expected error values are in the Gtk.CssParserError and Gtk.CssParserWarning enumerations.

      The path, line and position describe the actual location of the error as accurately as possible.

      Parsing errors are never fatal, so the parsing will resume after the error. Errors may however cause parts of the given data or even all of it to not be parsed at all. So it is a useful idea to check that the parsing succeeds by connecting to this signal.

      Errors in the Gtk.CssParserWarning enumeration should not be treated as fatal errors.

      Note that this signal may be emitted at any time as the css provider may opt to defer parsing parts or all of the input to a later time than when a loading function was called.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: