Created
January 29, 2019 21:15
-
-
Save brpaz/1caf842d6ea64b2bb250d1a52c9d7968 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main () { | |
var settings = new Settings ("org.example.my-app"); | |
// Getting keys | |
var greeting = settings.get_string ("greeting"); | |
var bottles = settings.get_int ("bottles-of-beer"); | |
var lighting = settings.get_boolean ("lighting"); | |
print ("%s\n", greeting); | |
print ("%d bottles of beer on the wall\n", bottles); | |
print ("Is the light switched on? %s\n", lighting ? "yes" : "no"); | |
// Change notification for any key in the schema | |
settings.changed.connect ((key) => { | |
print ("Key '%s' changed\n", key); | |
}); | |
// Change notification for a single key | |
settings.changed["greeting"].connect (() => { | |
print ("New greeting: %s\n", settings.get_string ("greeting")); | |
}); | |
// Setting keys | |
settings.set_int ("bottles-of-beer", bottles - 1); | |
settings.set_boolean ("lighting", !lighting); | |
settings.set_string ("greeting", "hello, world"); | |
print ("Please start 'dconf-editor' and edit keys in /org/example/my-app/\n"); | |
new MainLoop ().run (); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment