Gnome Library Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up |
#include gnome.h #define |
gnome-config routines provide a simple way of retrieving and storing configuration values (the routines provide handling of default values to simplify the code).
Definitions.
config path: a string that specifies which item to retrieve from the configuration database. The config path is composed of three elements: the first one is the filename where the information is stored, the second component is the section and the third one is the key inside the section
For example, a config path of "/myapp/toolbox/showit" could be used to retrieve the setting for whether 'myapp' should display its toolbox or not. In this example "myapp" is the file name (which is stored in ~/.gnome directory), "toolbox" is the section and "showit" is the key.
If you want to access an absolute file instead of a ~/.gnome-relative file, then you need to surround the filename with equal signs, for example, to access the key "mykey" from the section "mysection" in a configuration file located in /gnome/var/myconfig you need to use this path: "=/gnome/var/myconfig=/mysection/mykey".
default: when retrieving a config item, specifies the value to be used if the item is not found.
private configuration data - Normally, config item data is located in files under the ~user/.gnome directory in a .ini-like format. These files are world-readable. Items that have security or privacy implications are stored and retrieved using the "private" versions of the gnome-config routines, and the data for these items is stored in files under the ~user/.gnome_private directory, which is not accessable by anyone except that user and the system administrator.
"translated" strings - GNOME's multilingual
support means that multiple languages must be supported for
configuration items. The
gnome_config_*
"section" - a group of config items and other config sections
How Config Items are Read.
GNOME has a versatile method of storing config items. When a config item is written by a program, it is written to a file under the ~/.gnome hierarchy. However, when config items are read, the process is a little more complicated. There are a number of places that are searched. If the config item is not found in one, then the next place is checked, finally falling back to the default value provided by the application. The locations are as follows:
$(sysconfdir)/gnome/config-override - a system administrator would put config items in this directory that they don't want to be configurable.
~/.gnome - this is where the user's config items are written to and is the next place that is searched
$(sysconfdir)/gnome/config - this directory would hold system wide default configuration values.
Possible uses for this are setting system wide defaults such as proxy servers for the system (either using config-override to enforce such a policy or the config directory to suggest such a default). It is also possible to configure the application through its graphical interface, and then copy the configuration file accross to the appropriate system-wide directory. The config-override directory should be used sparingly, as it could annoy or confuse some users. Note also that some applications will not read the config items every time they are needed, so putting defaults into the config-override directory will not always completely enforce a setting.
There are two types of routines
FIXME: Finish this. Explain the different types of routines, explain the _private versions, explain the vector use, etc
#define gnome_config_get_string_with_default(path,def) |
Retrieves returns the value of a configuration item as a string.
The returned value should be
#define gnome_config_get_translated_string_with_default(path,def) |
Retrieves returns the value of a configuration item as a string appropriate for the current language. The returned value should be