What is gsettings




















Particular care should be paid to ensure that modifications are not made during startup -- for example, when setting the initial value of preferences widgets.

When creating a GSettings instance, you have to specify a schema that describes the keys in your settings and their types and default values, as well as some other information. Normally, a schema has as fixed path that determines where the settings are stored in the conceptual global tree of settings. However, schemas can also be 'relocatable', i.

This is useful e. Paths should be chosen based on a domain name associated with the program or library to which the settings belong. Unlike other configuration systems like GConf , GSettings does not restrict keys to basic types like strings and numbers. Key names are restricted to lowercase characters, numbers and '-'. Furthermore, the names must begin with a lowercase character, must not end with a '-', and must not contain consecutive dashes.

GSettings uses schemas in a compact binary form that is created by the glib-compile-schemas utility. The convention for schema ids is to use a dotted name, similar in style to a D-Bus bus name, e. In particular, if the settings are for a specific service that owns a D-Bus bus name, the D-Bus bus name and schema id should match. For schemas which deal with settings not associated with one named application, the id should not use StudlyCaps, e. In addition to GVariant types, keys can have types that have enumerated types.

Default values are defined in the schemas that get installed by an application. Sometimes, it is necessary for a vendor or distributor to adjust these defaults. Since patching the XML source for the schema is inconvenient and error-prone, glib-compile-schemas reads so-called 'vendor override' files.

These are keyfiles in the same directory as the XML schema sources which can override default values. The schema id serves as the group name in the key file, and the values are expected in serialized GVariant form, as in the following example:. Once a GObject property has been bound to a setting, changes on either side are automatically propagated to the other side. GSettings handles details like mapping between GObject and GVariant types, and preventing infinite cycles.

This makes it very easy to hook up a preferences dialog to the underlying settings. To make this even more convenient, GSettings looks for a boolean property with the name "sensitivity" and automatically binds it to the writability of the bound setting. The new GSettings will hold a reference on the context. You only need to do this if you want to directly create a settings object with a schema that doesn't have a specified path of its own.

That's quite rare. It is a programmer error to call this function for a schema that has an explicitly specified path. Creating a GSettings object with a different backend allows accessing settings from a database other than the usual one. For example, it may make sense to pass a backend corresponding to the "defaults" settings database on the system to get a settings object that modifies the system default settings instead of the settings for this user.

Creates a new GSettings object with a given schema, backend and path. It should be extremely rare that you ever want to use this function. It is made available for advanced use-cases such as plugin systems that want to provide access to schemas loaded from custom locations, etc.

This constructor therefore gives you full control over constructing GSettings instances. If backend is NULL then the default backend is used. If path is NULL then the path from the schema is used. Writes made to a GSettings are handled asynchronously. This call will block until all of the writes have made it to the backend. Since the mainloop is not running, no change notifications will be dispatched during this call but some may be queued by the time the call is done.

Gets the value that is stored in settings for key. It is a programmer error to give a key that isn't contained in the schema for settings. Sets key in settings to value. It is a programmer error to give a key that isn't contained in the schema for settings or for value to have the incorrect type, per the schema. If value is floating then this function consumes the reference. Changes the GSettings object into 'delay-apply' mode.

Applies any changes that have been made to the settings. In the normal case settings are always applied immediately. Reverts all non-applied changes to the settings. Returns whether the GSettings object has any unapplied changes. This can only be the case if it is in 'delayed-apply' mode. Can I use dconf-editor to modify Gconf settings? GSettingsMigration on gnome. Tags: Gconf Dconf Gsettings. Related How to change gnome-terminal profile preferences using dconf or gsettings?

H: good question. I've asked it here: askubuntu. I'm sorry that I forgot to answer your comment: I can't comment on Unity because I'm on Xubuntu, but Flimm has asked a separate question which should get some good answers. But what on earth makes dconf incompatible with Qt, a GUI toolkit? Show 1 more comment. It's not only gnome equivalent, but all DE Desktop Environment equivalent. Prado Not true, not all DE use dconf. You completed my comment. What is the relationship between dconf and gconf?

The question in psusi 's comment above is partially answered in the answers to the question " Why the controversy about dconf and gconf? I'm sure psusi is aware of it, having commented on the question, but in case anyone else wants to know more, there it is. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. This is almost always wrong. You should absolutely never use intltool or itstool-based XML "translation merging" functionality with schema files. For our example, we will create a file named " org. Meson Edit the appropriate meson.

Add this line to your configure.



0コメント

  • 1000 / 1000