diff options
Diffstat (limited to 'pango/pango-utils.c')
-rw-r--r-- | pango/pango-utils.c | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/pango/pango-utils.c b/pango/pango-utils.c index 44ec353d..8177dab2 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -532,6 +532,7 @@ pango_scan_int (const char **pos, int *out) } static GHashTable *config_hash = NULL; +static gboolean did_read_user_config = FALSE; static void read_config_file (const char *filename, gboolean enoent_error) @@ -604,23 +605,41 @@ read_config_file (const char *filename, gboolean enoent_error) } static void -read_config (void) +ensure_config_hash (void) { if (!config_hash) - { - char *filename; - const char *home; - const char *envvar; - - config_hash = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify)g_free, - (GDestroyNotify)g_free); - filename = g_build_filename (pango_get_sysconf_subdirectory (), - "pangorc", - NULL); - read_config_file (filename, FALSE); - g_free (filename); + config_hash = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify)g_free, + (GDestroyNotify)g_free); +} + +static void +read_config_system (void) +{ + char *filename; + + ensure_config_hash (); + + filename = g_build_filename (pango_get_sysconf_subdirectory (), + "pangorc", + NULL); + read_config_file (filename, FALSE); + g_free (filename); +} + +static void +read_config (void) +{ + char *filename; + const char *home; + const char *envvar; + read_config_system (); + + if (!did_read_user_config) + { + did_read_user_config = TRUE; + home = g_get_home_dir (); if (home && *home) { @@ -636,6 +655,26 @@ read_config (void) } /** + * pango_config_key_get_system: + * @key: Key to look up, in the form "SECTION/KEY". + * + * Looks up a key, consulting only the Pango system config database + * in $sysconfdir/pango/pangorc. + * + * Return value: the value, if found, otherwise %NULL. The value is a + * newly-allocated string and must be freed with g_free(). + **/ +char * +pango_config_key_get_system (const char *key) +{ + g_return_val_if_fail (key != NULL, NULL); + + read_config_system (); + + return g_strdup (g_hash_table_lookup (config_hash, key)); +} + +/** * pango_config_key_get: * @key: Key to look up, in the form "SECTION/KEY". * |