GLib.Settings. GSettings allows your app to save certain stateful information in the form of booleans, strings, arrays, and more. It's a great solution for window size and position as well as whether certain modes are enabled or not. Note that GSettings is ideal for small amounts of configuration or stateful data, but user data (i.e. documents) should be stored on the disk.
data/folder, create a new file named
gschema.xml. Inside it, let's define a key for the switch:
idattributes are your app's ID (
idis the standard dot-separated format). Note the key's
typeattributes: the name is a string to reference the setting, while in this case
type="b"defines the setting as a boolean. The key's summary and description are developer-facing and are exposed in developer tools like dconf Editor.
GLib.Settings.bind ()on Valadoc, but for now this will bind the
activeproperty of the switch to the value of
useless-settingin GSettings. When one changes, the other will stay in sync to reflect it.
data/meson.buildand type the following:
meson/post_install.pythat contains the following:
useless-settingupdate in real time when you toggle your switch.