Object Hierarchy:

Object hierarchy for Settings


public abstract class Settings : Object

Class for interacting with an internal GLib.Settings using native Vala properties. Clients of this class should not connect to the GLib.Object.notify signal. Instead, they should connect to the Granite.Services.Settings.changed signal.

For example, if a developer wanted to interact with desktop.Wallpaper's (http:/ schema, this is what his/her subclass might look like:

   public class WallpaperSettings : Granite.Services.Settings {

public PictureMode picture_mode { get; set; }

public string picture_path { get; set; }

public string background_color { get; set; }

public WallpaperSettings () {
base ("desktop.Wallpaper");

protected override void verify (string key) {

switch (key) {

case "background-color":
Gdk.Color bg;
if (!Gdk.Color.parse (background_color, out bg))
background_color = "#000000";


Keep in mind that the developer must define his/her enums to match the schema's.

The following is a simplified explanation of how this library works:

  1. Any subclass looks at all properties it contains, and loads their initial values from the keys they represent.

    Because Vala properties are stored as GLib properties, the string representation of a property replaces underscores with

    hyphens (i.e. property_name becomes "property-name"). This is how this library knows which keys to load from. If the key

    does not exist, it will result in a fatal error.

  2. When a property of the subclass changes, the library will first verify the data before emitting a changed signal. If necessary,

    the library will change the value of the property while verifying.

    This is why developers should only act upon emissions of the changed () signal and never the native GLib.Object.notify signal.

  3. When the corresponding key of one of the properties of the subclass changes, it will also verify the data and change it, if necessary,

    before loading it into as the corresponding property's value.

Namespace: Granite.Services
Package: granite



Creation methods:



Inherited Members: