Settings
Object Hierarchy:
Granite.Services.Settings
Granite.Services.Settings
Granite.Services.Settings
GLib.Object
GLib.Object
GLib.Object->Granite.Services.Settings
Description:
[ Version ( deprecated = true , deprecated_since = "5.4.0" , replacement = "GLib.Settings" ) ]public abstract class Settings : Object
Warning: Settings is deprecated since 5.4.0. Use GLib.Settings.
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:/www.launchpad.net/pantheon-wallpaper) 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" ; break ; } } }
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:
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.
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.
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.
Content:
Properties:
public Settings schema { get ; construct ; }
Creation methods:
protected Settings (string schema)
Creates a new Granite.Services.Settings
object for the supplied schema.
protected Settings.with_backend (string schema, SettingsBackend backend)
Creates a new Granite.Services.Settings
object for the supplied schema and GLib.SettingsBackend .
protected Settings.with_backend_and_path (string schema, SettingsBackend backend, string path)
Creates a new Granite.Services.Settings
object for the supplied schema, GLib.SettingsBackend , and path.
protected Settings.with_path (string schema, string path)
Creates a new Granite.Services.Settings
object for the supplied schema, and path.
Methods:
Signals:
Inherited Members:
All known members inherited from class GLib.Object
@get
@new
@ref
@set
add_toggle_ref
add_weak_pointer
bind_property
connect
constructed
disconnect
dispose
dup_data
dup_qdata
force_floating
freeze_notify
get_class
get_data
get_property
get_qdata
get_type
getv
interface_find_property
interface_install_property
interface_list_properties
is_floating
new_valist
new_with_properties
newv
notify
notify_property
ref_count
ref_sink
remove_toggle_ref
remove_weak_pointer
replace_data
replace_qdata
set_data
set_data_full
set_property
set_qdata
set_qdata_full
set_valist
setv
steal_data
steal_qdata
thaw_notify
unref
watch_closure
weak_ref
weak_unref