Whole document tree Chapter 5. GNOME library.This chapter is intended to be a reference to the libgnome. 5.1. gnome-config5.1.1. Author(s)Miguel de Icaza <miguel@nuclecu.unam.mx> 5.1.2. DescriptionA set of routines for manipulating the database of configuration information. 5.1.3. Glossary
5.1.4. gnome_config_*get_* - routines to retrieve information for a specified config path.5.1.4.1. DescriptionRoutine to retrieve a config item. 'typename' would be one of string, translated_string, int, bool, float, or vector. In the case of the gnome_config_get_string(), gnome_config_get_translated_string(), and gnome_config_get_vector(), ownership of the memory used by the returned value is given over to the application. When the application is done with it, it should be freed using g_free() or g_string_array_free() as appropriate. Combinations of "private" and "with_default" versions of these routines exist. For example, there are gnome_config_get_string(), gnome_config_get_string_with_default() gnome_config_private_get_string(), and gnome_config_private_get_string_with_default() routines. 5.1.4.2. Usagechar *myitem; gboolean is_default; myitem = gnome_config_get_string_with_default("/foo/blah=DefaultValue", &is_default); 5.1.4.3. Parameters
5.1.5. gnome_config_set_* - routines to store information for a specified config path.5.1.5.1. Description>Stores the specified value into the configuration database at the specified config path. Note that there are "private" variations on all the regular routines, e.g. gnome_config_set_string() and gnome_config_private_set_string(). 5.1.5.2. Usagechar *values[] = {"A one", "a two", "a three"}; gnome_config_set_vector("/foo/bar/baz", 3, values); 5.1.6. gnome_config_has_section - Checks whether a config section exists5.1.6.1. DescriptionThis routine returns TRUE if the specified section/item exists, xor FALSE if it does not. A parallel gnome_config_private_has_section() routine also is available. 5.1.6.2. Usageif(gnome_config_has_section("/foo/bar/baz")) { g_print("You have saved preferences.\n"); } else { g_print("You haven't saved preferences yet.\n"); } 5.1.6.3. Parameters
5.1.7. gnome_config_init_iterator - Setup an iterator to get a listing of items in a specified config section.5.1.7.1. DescriptionThis routine is used to begin a loop over all the items in a config section. gnome_config_iterator_next() is used to advance to the next item. Note that a gnome_config_private_init_iterator() variant exists. 5.1.7.2. UsageSee the gnome_config_iterator_next() usage example 5.1.7.3. Parameters
5.1.8. gnome_config_init_iterator - Setup an iterator to get a listing of sections in a specified config section.5.1.8.1. DescriptionThis routine is used to begin a loop over all the items in a config section. gnome_config_iterator_next() is used to advance to the next item. Note that a gnome_config_private_init_iterator_sections() variant exists. 5.1.8.2. UsageSee the gnome_config_iterator_next() usage example 5.1.8.3. Parameters
5.1.9. gnome_config_iterator_next - get the next item from an iterator5.1.9.1. DescriptionThis function normally serves as the loop update for a config item or section iterator. The return value is an opaque pointer needed by gnome_config_iterator_next, or NULL if there are no more available data in the iterator. 5.1.9.2. Usagechar *section_name, *key, *value; void *section_iter, *item_iter; GString *tmpstr; tmpstr = g_string_new(NULL); for(section_iter = gnome_config_init_iterator_sections("/foo"); section_iter != NULL; section_iter = gnome_config_iterator_next(section_iter, NULL, §ion_name)) { g_string_sprintf(tmpstr, "/foo/%s", section_name); for(item_iter = gnome_config_init_iterator(tmpstr->str); item_iter; item_iter = gnome_config_iterator_next(item_iter, &key, &value)) { g_print("Got key %s -> value %s in section %s of /foo\n", key, value, section_name); g_free(key); g_free(value); } g_free(section_name); } g_string_free(tmpstr); 5.1.9.3. Parameters
5.1.10. gnome_config_drop_all - drops all the cached config data from the in-memory cache5.1.10.1. DescriptionThe gnome_config routines cache the configuration entries in memory to increase speed. Calling gnome_config_drop_all() causes the cache to be cleared. 5.1.11. gnome_config_sync - writes all unwritten config entries to the config database5.1.11.1. DescriptionAs previously stated, the gnome_config routines cache configuration entries in memory to increase speed. This routine flushes the cache to disk - you would ordinarily use it after a number of gnome_config_set_* operations. 5.1.12. gnome_config_*clean_* - routines for removing a configuration database entry or subtree altogether5.1.12.1. DescriptionThese routines delete all the configuration entries associated with the specified entity (either a file, section, or key). 5.1.12.2. Usagechar *val1, *val2; gnome_config_set_string("/foo/bar", "baz"); val1 = gnome_config_get_string("/foo/bar"); gnome_config_clean_section("/foo"); val2 = gnome_config_get_string("/foo/bar"); if(val1 && val2 && !strcmp(val1, val2)) { g_error("The values match! gnome_config_clean_section is broken!"); } else { g_message("gnome_config_clean_section worked."); } 5.1.12.3. Parameters
5.1.13. gnome_config_*get_real_path5.1.13.1. DescriptionOccasionally an application writer may want to get the local filename where a config item is stored. When passed a config path, these routines (currently implemented as macros) return that filename. 5.1.13.2. Usagechar *filename = gnome_config_get_real_path("/foo/bar"); FILE *filehandle = fopen(filename, "w"); /* do devious things with the file */ 5.1.13.3. Parameters
|