gnome-config

Name

gnome-config -- Access to configuration files.

Synopsis


#include <libgnome/libgnome.h>


#define     gnome_config_get_string         (path)
#define     gnome_config_get_string_with_default(path,def)
#define     gnome_config_get_translated_string(path)
#define     gnome_config_get_translated_string_with_default(path,def)
#define     gnome_config_private_get_string (path)
#define     gnome_config_private_get_string_with_default(path,def)
#define     gnome_config_private_get_translated_string(path)
#define     gnome_config_private_get_translated_string_with_default(path,def)
#define     gnome_config_set_string         (path,new_value)
#define     gnome_config_set_translated_string(path,value)
#define     gnome_config_private_set_string (path,new_value)
#define     gnome_config_private_set_translated_string(path,new_value)

#define     gnome_config_get_int            (path)
#define     gnome_config_get_int_with_default(path,def)
#define     gnome_config_private_get_int    (path)
#define     gnome_config_private_get_int_with_default(path,def)
#define     gnome_config_set_int            (path,new_value)
#define     gnome_config_private_set_int    (path,new_value)

#define     gnome_config_get_float          (path)
#define     gnome_config_get_float_with_default(path,def)
#define     gnome_config_private_get_float  (path)
#define     gnome_config_private_get_float_with_default(path,def)
#define     gnome_config_set_float          (path,new_value)
#define     gnome_config_private_set_float  (path,new_value)

#define     gnome_config_get_bool           (path)
#define     gnome_config_get_bool_with_default(path,def)
#define     gnome_config_private_get_bool   (path)
#define     gnome_config_private_get_bool_with_default(path,def)
#define     gnome_config_set_bool           (path,new_value)
#define     gnome_config_private_set_bool   (path,new_value)

#define     gnome_config_get_vector         (path, argcp, argvp)
#define     gnome_config_get_vector_with_default(path, argcp, argvp, def)
#define     gnome_config_private_get_vector (path, argcp, argvp)
#define     gnome_config_private_get_vector_with_default(path, argcp, argvp, def)
#define     gnome_config_set_vector         (path,argc,argv)
#define     gnome_config_private_set_vector (path,argc,argv)
char*       gnome_config_assemble_vector    (int argc,
                                             const char *const argv[]);

#define     gnome_config_has_section        (path)
#define     gnome_config_private_has_section(path)
#define     gnome_config_init_iterator      (path)
#define     gnome_config_private_init_iterator(path)
#define     gnome_config_init_iterator_sections(path)
#define     gnome_config_private_init_iterator_sections(path)
void*       gnome_config_iterator_next      (void *iterator_handle,
                                             char **key,
                                             char **value);

void        gnome_config_drop_all           (void);
gboolean    gnome_config_sync               (void);
#define     gnome_config_sync_file          (path)
#define     gnome_config_private_sync_file  (path)
#define     gnome_config_drop_file          (path)
#define     gnome_config_private_drop_file  (path)
#define     gnome_config_clean_file         (path)
#define     gnome_config_private_clean_file (path)
#define     gnome_config_clean_section      (path)
#define     gnome_config_private_clean_section(path)
#define     gnome_config_clean_key          (path)
#define     gnome_config_private_clean_key  (path)
#define     gnome_config_get_real_path      (path)
#define     gnome_config_private_get_real_path(path)
void        gnome_config_push_prefix        (const char *path);
void        gnome_config_pop_prefix         (void);
void        gnome_config_make_vector        (const char *string,
                                             int *argcp,
                                             char ***argvp);

Description

This module provides a simple method of retrieving and storing configuration data that resides in files. It also provides the ability to supply default values for the configuration parameters to simply client code.

Note: The purpose of this module is different in GNOME 2 from what it was in GNOME 1. General applications should use the gnome-gconf module for their configuration requirements.

The gnome-config module exists for applications that

  • need to provide a backwards-compatible version of their configuration files, or

  • need to run independently of a user and access configuration files at absolute locations (for example, a login manager), or

  • need to parse .desktop-style files, or

  • need to parse user- or shell-editable/readable files.

Definitions.

How Config Items are Read. The gnome-config module 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:

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.

Every function in this module comes in at least two forms. There is the gnome_config_get_foo() version which retrieves the configuration data from the ~/.gnome directory (unless an absolute configuration key is given, as defined above). Then there is the gnome_config_private_get_foo() version, which retrieves the information from the user's ~/.gnome-private directory.

For functions dealing with strings, there is a third form of each function which returns the translated version of the string for the current locale.

Details

gnome_config_get_string()

#define     gnome_config_get_string(path)

Retrieves the value of a configuration item as a string. This value should be freed with g_free() when no longer needed.


gnome_config_get_string_with_default()

#define     gnome_config_get_string_with_default(path,def)

Retrieves the value of a configuration item as a string. This value should be freed with g_free() when no longer needed.


gnome_config_get_translated_string()

#define     gnome_config_get_translated_string(path)

Retrieves the value of a configuration item as a string appropriate for the current language. The returned value should be freed with g_free() when no longer needed.


gnome_config_get_translated_string_with_default()

#define     gnome_config_get_translated_string_with_default(path,def)

Retrieves the value of a configuration item as a string appropriate for the current language. The returned value should be freed with g_free() when no longer needed.


gnome_config_private_get_string()

#define     gnome_config_private_get_string(path)

Retrieves the value of a configuration item from the user's private configuration directory as a string. This value should be freed with g_free() when no longer needed.


gnome_config_private_get_string_with_default()

#define     gnome_config_private_get_string_with_default(path,def)

Retrieves the value of a configuration item from the user's private configuration directory as a string. This value should be freed with g_free() when no longer needed.


gnome_config_private_get_translated_string()

#define     gnome_config_private_get_translated_string(path)

Retrieves the value of a configuration item as a string appropriate for the current language. The returned value should be freed with g_free() when no longer needed. The item is retrieved from the user's private configuration storage area.


gnome_config_private_get_translated_string_with_default()

#define     gnome_config_private_get_translated_string_with_default(path,def)

Retrieves the value of a configuration item as a string appropriate for the current language. The returned value should be freed with g_free() when no longer needed. The item is retrieved from the user's private configuration storage area.


gnome_config_set_string()

#define     gnome_config_set_string(path,new_value)

Stores the string value new_value in the file/section/key defined by the path.


gnome_config_set_translated_string()

#define     gnome_config_set_translated_string(path,value)

Stores the string value value in the file/section/key defined by the path on the proper section for the current language set by by the user.


gnome_config_private_set_string()

#define     gnome_config_private_set_string(path,new_value)

Stores the string value new_value in the file/section/key defined by the path. The configuration value is stored in the user's private storage area.


gnome_config_private_set_translated_string()

#define     gnome_config_private_set_translated_string(path,new_value)

Stores the string value new_value in the file/section/key defined by the path on the proper section for the current language set by by the user. The configuration value is stored in the user's private storage area.


gnome_config_get_int()

#define     gnome_config_get_int(path)


gnome_config_get_int_with_default()

#define     gnome_config_get_int_with_default(path,def)


gnome_config_private_get_int()

#define     gnome_config_private_get_int(path)

Retrieves a configuration item as an int from the user's private configuration storage area.


gnome_config_private_get_int_with_default()

#define     gnome_config_private_get_int_with_default(path,def)

Retrieves a configuration item as an int from the user's private configuration storage area.


gnome_config_set_int()

#define     gnome_config_set_int(path,new_value)

Stores the integer value new_value in the file/section/key defined by the path.


gnome_config_private_set_int()

#define     gnome_config_private_set_int(path,new_value)

Stores the integer value new_value in the file/section/key defined by the path. The value is stored in the user's private configuration storage area.


gnome_config_get_float()

#define     gnome_config_get_float(path)


gnome_config_get_float_with_default()

#define     gnome_config_get_float_with_default(path,def)


gnome_config_private_get_float()

#define     gnome_config_private_get_float(path)

Retrieves a configuration item from the user's private configuration storage area.


gnome_config_private_get_float_with_default()

#define     gnome_config_private_get_float_with_default(path,def)

Retrieves a configuration item from the user's private configuration storage area.


gnome_config_set_float()

#define     gnome_config_set_float(path,new_value)

Stores the double value new_value in the file/section/key defined by the path.


gnome_config_private_set_float()

#define     gnome_config_private_set_float(path,new_value)

Stores the double value new_value in the file/section/key defined by the path. The value is stored in the user's private configuration storage area.


gnome_config_get_bool()

#define     gnome_config_get_bool(path)


gnome_config_get_bool_with_default()

#define     gnome_config_get_bool_with_default(path,def)


gnome_config_private_get_bool()

#define     gnome_config_private_get_bool(path)

Retrieves the item from the user's private configuration storage area.


gnome_config_private_get_bool_with_default()

#define     gnome_config_private_get_bool_with_default(path,def)

Retrieves the item from the user's private configuration storage area.


gnome_config_set_bool()

#define     gnome_config_set_bool(path,new_value)

Stores boolean value new_value in the file/section/key defined by path.


gnome_config_private_set_bool()

#define     gnome_config_private_set_bool(path,new_value)

Stores boolean value new_value in the file/section/key defined by path. The value is stored in the user's private configuration storage area.


gnome_config_get_vector()

#define     gnome_config_get_vector(path, argcp, argvp)

Retrieves the value of a configuration item as a string array. The returned vector should be freed with g_free() when no longer needed.


gnome_config_get_vector_with_default()

#define     gnome_config_get_vector_with_default(path, argcp, argvp, def)

Retrieves the value of a configuration item as a string array. The returned vector should be freed with g_free() when no longer needed.


gnome_config_private_get_vector()

#define     gnome_config_private_get_vector(path, argcp, argvp)

Retrieves the value of a configuration item as a string array. The returned vector should be freed with g_free() when no longer needed. The configuration value is retrieved from the user's private configuration storage area.


gnome_config_private_get_vector_with_default()

#define     gnome_config_private_get_vector_with_default(path, argcp, argvp, def)

Retrieves the value of a configuration item as a string array. The returned vector should be freed with g_free() when no longer needed. The configuration value is retrieved from the user's private configuration storage area.


gnome_config_set_vector()

#define     gnome_config_set_vector(path,argc,argv)

Stores vector argv in the file/section/key defined by path.


gnome_config_private_set_vector()

#define     gnome_config_private_set_vector(path,argc,argv)

Stores vector argv in the file/section/key defined by path. The configuration value is set in the user's private storage area.


gnome_config_assemble_vector ()

char*       gnome_config_assemble_vector    (int argc,
                                             const char *const argv[]);

This routine returns the the strings in the array contactenated by spaces. The return value should be freed with g_free() when it is no longer required.


gnome_config_has_section()

#define     gnome_config_has_section(path)

Queries the gnome configuration file for the presence of the section specified in path.


gnome_config_private_has_section()

#define     gnome_config_private_has_section(path)

Queries the private gnome configuration file for the presence of the section specified in path.


gnome_config_init_iterator()

#define     gnome_config_init_iterator(path)

Creates an iterator handle that can be used to iterate over the keys in a section in a gnome configuration file. path must refer to a section. The returned value can be used as an iterator for gnome_config_iterator_next().


gnome_config_private_init_iterator()

#define     gnome_config_private_init_iterator(path)

Creates an iterator handle that can be used to iterate over the keys in a section in a private gnome configuration file. path must refer to a section. The returned value can be used as an iterator for gnome_config_iterator_next().


gnome_config_init_iterator_sections()

#define     gnome_config_init_iterator_sections(path)

Creates an iterator handle that can be used to iterate over the sections in a gnome configuration file. path must refer to a gnome configuration file. The returned value can be used as an iterator for gnome_config_iterator_next().


gnome_config_private_init_iterator_sections()

#define     gnome_config_private_init_iterator_sections(path)

Creates an iterator handle that can be used to iterate over the sections in a private gnome configuration file. path must refer to a gnome configuration file. The returned value can be used as an iterator for gnome_config_iterator_next().


gnome_config_iterator_next ()

void*       gnome_config_iterator_next      (void *iterator_handle,
                                             char **key,
                                             char **value);

If key is non-NULL, then key will point to a g_malloc()ed region that holds the key.

If value is non-NULL, then value will point to a g_malloc()ed region that holds the key.


gnome_config_drop_all ()

void        gnome_config_drop_all           (void);

Drops any information cached in memory that was fetched with gnome config. Any pending information that has not been written to disk is discarded.


gnome_config_sync ()

gboolean    gnome_config_sync               (void);

Writes all of the information modified by gnome-config to the disk.

Note: the gnome-config code does not write anything to the configuration files until this routine is actually invoked.


gnome_config_sync_file()

#define     gnome_config_sync_file(path)

Writes all of the information modified by gnome-config to the disk for the given file.

Note: the gnome-config code does not write anything to the configuration files until this routine or gnome_config_sync() is actually invoked.


gnome_config_private_sync_file()

#define     gnome_config_private_sync_file(path)

Writes all of the information modified by gnome-config to the disk for the given private file.

Note: the gnome-config code does not write anything to the configuration files until this routine or gnome_config_sync() is actually invoked.


gnome_config_drop_file()

#define     gnome_config_drop_file(path)

Releases any memory resources that were allocated from accessing the configuration file in path. Changes will take place after gnome_config_sync() has been invoked


gnome_config_private_drop_file()

#define     gnome_config_private_drop_file(path)

Releases any memory resources that were allocated from accessing the private configuration file in path.


gnome_config_clean_file()

#define     gnome_config_clean_file(path)

Cleans up the configuration file specified by path from any configuration information.

Changes will take place after gnome_config_sync() has been invoked.


gnome_config_private_clean_file()

#define     gnome_config_private_clean_file(path)

Cleans up the private configuration file specified by path from any configuration information.

Changes will take place after gnome_config_sync() has been invoked.


gnome_config_clean_section()

#define     gnome_config_clean_section(path)

Cleans up the section specified by path from any configuration information. Changes will only take place after gnome_config_sync() has been invoked.


gnome_config_private_clean_section()

#define     gnome_config_private_clean_section(path)

Cleans up the section specified by path in a private file from any configuration information. Changes will only take place after gnome_config_sync() has been invoked.


gnome_config_clean_key()

#define     gnome_config_clean_key(path)

Removes the definition for the key on a gnome configuration file.

Changes will take place after gnome_config_sync() has been invoked.


gnome_config_private_clean_key()

#define     gnome_config_private_clean_key(path)

Removes the definition for the key on a private gnome configuration file.

Changes will take place after gnome_config_sync() has been invoked.


gnome_config_get_real_path()

#define     gnome_config_get_real_path(path)


gnome_config_private_get_real_path()

#define     gnome_config_private_get_real_path(path)


gnome_config_push_prefix ()

void        gnome_config_push_prefix        (const char *path);

path is a prefix that will be prepended automatically to any non-absolute configuration path in gnome config.

This is used to simplify application loading code.

Library code will usually have to set the prefix before doing any gnome-configuration access, since the application might be using their own prefix.


gnome_config_pop_prefix ()

void        gnome_config_pop_prefix         (void);

Call this routine to remove the current configuration prefix from the stack.


gnome_config_make_vector ()

void        gnome_config_make_vector        (const char *string,
                                             int *argcp,
                                             char ***argvp);

Creates a new vector from a string as it stored in the config file, breaks the string on spaces except if the space is escaped with a backslash.