7.1 Overview


7.1 Overview

GConf solves the problems described in the preceding section with a central database containing a directory hierarchy of keys attached to configuration values. You need only do the following to add GConf support to your application:

  1. Break your configuration data into GConf values, assigning keys to the values.

  2. Attach signal handlers to the pieces of your application that use the configuration values.

  3. Write your settings dialog so that it modifies the values behind the GConf keys.

When your configuration signal handlers work properly, your application reacts to changes in values regardless of when and where the change happened . You don't need to export any variables or worry about other application-specific infrastructure; all access to the values goes through the configuration database. Furthermore, you don't need to worry about how to store the keys and values. A pleasant side effect is that you can also configure the application with an external tool (systems administrators take heart in hearing this).

The application-side implementation is in the libgconf-2 library, with a gconfd-2 daemon to handle database-application communication. Each user on the system has exactly one gconfd-2 process when logged in.

User database files are in XML format, located in a directory hierarchy. Take a look at your .gconf directory if you want to see the format for keys and values.

There is more to the database than .gconf . For the full story, look at the GConf path file, normally $(PREFIX)/etc/gconf/2/path .

 # Look first in systemwide mandatory settings directory xml:readonly:/opt/gnome/etc/gconf/gconf.xml.mandatory # Add any user sources include "$(HOME)/.gconf.path" # Default user storage location xml:readwrite:$(HOME)/.gconf # System default values, in case none of the above exist xml:readonly:/opt/gnome/etc/gconf/gconf.xml.defaults 

Each line defines a configuration source with a back-end type ( xml at the moment), permissions ( readonly or readwrite ), and a location (directory name ). Every time the application accesses a configuration value, GConf reads path from top to bottom, looking for the configuration value in each source. You can force certain configuration values by placing them in a read-only source at the top of path . In addition, you can provide defaults with an all-inclusive source at the bottom. Finally, users can define their own source path files with the include directive.

Note  

GConf does not guarantee read-write access to its database. GConf-aware applications should work properly if they cannot write to the database. You might encounter this in public X terminals, Internet kiosk systems, and other such installations where complete read-only access is necessary.




The Official GNOME 2 Developers Guide
The Official GNOME 2 Developers Guide
ISBN: 1593270305
EAN: 2147483647
Year: 2004
Pages: 108

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net