A lightweight wrapper for gconf library. More...
#include <string.h>
#include <gconf/gconf-client.h>
#include "er_error.h"
#include "log.h"
#include "gconf_utils.h"
Go to the source code of this file.
Data Structures | |
struct | FindKeyInfo |
Defines | |
#define | UNUSED(x) (void)(x) |
Functions | |
static void | find_gconf_key (gpointer key, gpointer value, gpointer user_data) |
static void | write_properties_stringhash (gpointer key, gpointer value, gpointer user_data) |
static void | on_value_changed (GConfClient *client, const gchar *key, GConfValue *value) |
void | ergconf_initialize () |
Initialize GConf client. Note that GConf client talks to GConf daemon and has no access to files on disk. Changes are communicated to GConf daemon, who sends these values to every other client that is interested. The timing of writing changed values to disk is determined by GConf daemon and cannot be influenced through a GConf client. | |
void | ergconf_finalize () |
Release GConf client. Note this does not guarantee changes are written to disk now, because this is determined by the GConf daemon. | |
void | ergconf_set_cb_value_changed (gconf_cb_value_changed_t callback) |
Set callback function for gconf value changed. | |
void | ergconf_add_monitor_dir (const gchar *dir) |
Adds a gconf directory to be monitored. Value changes in this directory will be reported through the value-changed callback. | |
void | ergconf_unset (const gchar *key) |
Unset the value of the specified key. This function clears the value of the key and set it to the default value defined in the schema file. If schema file doesn't define a default one then it will be set to gconf default (e.g. for integer it will be 0). | |
void | ergconf_recursive_unset (const gchar *dir) |
Recursively unset all values in the specified directory and its sub-directories. This function clears the value of the keys and sets them to the default value defined in the schema file. If schema file doesn't define a default one then it will be set to gconf default (e.g. for integer it will be 0). | |
int | ergconf_get_int (const gchar *key) |
Request the integer value stored at the specified key. | |
int | ergconf_set_int (const gchar *key, int new_value) |
Change the value of key to new_value. | |
gboolean | ergconf_get_bool (const gchar *key) |
Request the boolean value stored at the specified key. | |
int | ergconf_set_bool (const gchar *key, gboolean new_value) |
Change the value of key to new_value. | |
gchar * | ergconf_get_string (const gchar *key) |
Request the string value stored at the specified key. | |
int | ergconf_set_string (const gchar *key, const gchar *new_value) |
Change the value of key to new_value. | |
GSList * | ergconf_get_string_list (const gchar *key) |
Request the string list value stored at the specified key. | |
int | ergconf_set_string_list (const gchar *key, const GSList *new_value) |
Change the value of key to new_value. | |
GByteArray * | ergconf_get_byte_array (const gchar *key) |
Request the byte array value stored at the specified key. | |
int | ergconf_set_byte_array (const gchar *key, const GByteArray *new_value) |
Change the value of key to new_value. | |
GHashTable * | ergconf_get_string_hash (const gchar *dir) |
Get all key-value pairs from the specified GConf directory formatted as a hash table. | |
int | ergconf_set_string_hash (const gchar *dir, const GHashTable *new_value) |
Set all key-value pairs in the specified GConf directory, assuming all key-value pairs in this GConf directory are of type string. Keys not present in new_value will be removed from the GConf directory. Sub-directories of the GConf directory are not affected. | |
GArray * | ergconf_get_int_array (const gchar *key) |
Get the integer array stored at the specified GConf key. | |
int | ergconf_set_int_array (const gchar *key, const GArray *new_value) |
Change value of specified GConf key into the supplied integer array. | |
GPtrArray * | ergconf_get_int_tuples (const gchar *key, guint tuple_len) |
Get the list of integer tuples stored at the specified GConf key. | |
int | ergconf_set_int_tuples (const gchar *key, const GPtrArray *value, guint tuple_len) |
Change value of the specified GConf key into the supplied array of integer tuples. | |
void | ergconf_free_int_tuples (GPtrArray *tuple_list) |
Free a list of integer tuples. | |
GSList * | ergconf_get_sub_dirs (const gchar *dir) |
Get a list of sub-directories in the specified GConf directory. | |
void | ergconf_free_string_list (GSList *str_list) |
Free string list returned by e.g. get_value_string_list(). | |
gboolean | ergconf_dir_exist (const gchar *dir) |
Query whether the directory dir exists in the GConf database. | |
gboolean | ergconf_is_default (const gchar *key) |
Returns if the key is set to the schema default value. | |
Variables | |
static GConfClient * | client = NULL |
static gconf_cb_value_changed_t | g_cb_value_changed = NULL |
A lightweight wrapper for gconf library.
Definition in file gconf_utils.c.
#define UNUSED | ( | x | ) | (void)(x) |
Copyright (C) 2009 iRex Technologies B.V. All rights reserved.
Definition at line 45 of file gconf_utils.c.
void ergconf_add_monitor_dir | ( | const gchar * | dir | ) |
Adds a gconf directory to be monitored. Value changes in this directory will be reported through the value-changed callback.
---------------------------------------------------------------------------
Name : ergconf_add_monitor_dir
-- |
--------------------------------------------------------------------------
Definition at line 120 of file gconf_utils.c.
References client.
gboolean ergconf_dir_exist | ( | const gchar * | dir | ) |
Query whether the directory dir exists in the GConf database.
---------------------------------------------------------------------------
Name : ergconf_dir_exist
[in] | dir | - The specified directory to be checked. |
--------------------------------------------------------------------------
Definition at line 591 of file gconf_utils.c.
References client.
00592 { 00593 return gconf_client_dir_exists(client, dir, NULL); 00594 }
void ergconf_finalize | ( | ) |
Release GConf client. Note this does not guarantee changes are written to disk now, because this is determined by the GConf daemon.
---------------------------------------------------------------------------
Name : ergconf_finalize
-- |
--------------------------------------------------------------------------
Definition at line 97 of file gconf_utils.c.
References client.
Referenced by main_quit().
00098 { 00099 if (client) 00100 { 00101 g_object_unref(client); 00102 client = NULL; 00103 } 00104 }
void ergconf_free_int_tuples | ( | GPtrArray * | tuple_list | ) |
Free a list of integer tuples.
---------------------------------------------------------------------------
Name : ergconf_free_int_tuples
[in] | tuple_list | - An array of integer tuples. The array holds a set of pointers to a tuple, each tuple is a GArray of 'guint32' values. |
--------------------------------------------------------------------------
Definition at line 545 of file gconf_utils.c.
void ergconf_free_string_list | ( | GSList * | str_list | ) |
Free string list returned by e.g. get_value_string_list().
---------------------------------------------------------------------------
Name : ergconf_free_string_list
[in] | str_list | - The string list to be freed. |
--------------------------------------------------------------------------
Definition at line 576 of file gconf_utils.c.
References client.
00577 { 00578 GSList* p = str_list; 00579 00580 g_assert(client); 00581 00582 while (p) 00583 { 00584 g_free(p->data); 00585 p = p->next; 00586 } 00587 00588 g_slist_free(str_list); 00589 }
gboolean ergconf_get_bool | ( | const gchar * | key | ) |
Request the boolean value stored at the specified key.
---------------------------------------------------------------------------
Name : ergconf_get_bool
[in] | key | - The GConf path of the key. |
--------------------------------------------------------------------------
Definition at line 159 of file gconf_utils.c.
References client.
GByteArray* ergconf_get_byte_array | ( | const gchar * | key | ) |
Request the byte array value stored at the specified key.
---------------------------------------------------------------------------
Name : ergconf_get_byte_array
[in] | key | - The GConf path of the key. |
--------------------------------------------------------------------------
Definition at line 219 of file gconf_utils.c.
References client.
00220 { 00221 g_assert(client); 00222 g_assert(key && *key); 00223 00224 GByteArray *ret = NULL; 00225 GConfValue *gc_value = gconf_client_get (client, key, NULL); 00226 if (gc_value == NULL ) 00227 { 00228 return NULL; 00229 } 00230 00231 if (gc_value->type == GCONF_VALUE_LIST && 00232 gconf_value_get_list_type (gc_value) == GCONF_VALUE_INT) 00233 { 00234 GSList *elt; 00235 00236 ret = g_byte_array_new (); 00237 for (elt = gconf_value_get_list (gc_value); elt != NULL; elt = g_slist_next (elt)) 00238 { 00239 int i = gconf_value_get_int ((GConfValue *) elt->data); 00240 guint8 val = (guint8) (i & 0xFF); 00241 00242 if (i < 0 || i > 255) 00243 { 00244 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, 00245 "value %d out-of-range for a byte value", i); 00246 g_byte_array_free (ret, TRUE); 00247 ret = NULL; 00248 break; // exit for loop 00249 } 00250 00251 g_byte_array_append (ret, &val, 1); 00252 } 00253 } 00254 00255 if (gc_value != NULL) 00256 { 00257 gconf_value_free (gc_value); 00258 } 00259 return ret; 00260 }
int ergconf_get_int | ( | const gchar * | key | ) |
Request the integer value stored at the specified key.
---------------------------------------------------------------------------
Name : ergconf_get_int
[in] | key | - The GConf path of the key. |
--------------------------------------------------------------------------
Definition at line 141 of file gconf_utils.c.
References client.
GArray* ergconf_get_int_array | ( | const gchar * | key | ) |
Get the integer array stored at the specified GConf key.
---------------------------------------------------------------------------
Name : ergconf_get_int_array
[in] | key | - The GConf path of the key. |
--------------------------------------------------------------------------
Definition at line 396 of file gconf_utils.c.
References client.
00397 { 00398 GConfValue *gc_value = NULL; 00399 GArray *ret = NULL; 00400 00401 g_assert(client); 00402 g_assert(key && *key); 00403 00404 gc_value = gconf_client_get (client, key, NULL); 00405 if (gc_value == NULL) 00406 { 00407 return NULL; 00408 } 00409 00410 if (gc_value->type == GCONF_VALUE_LIST 00411 && gconf_value_get_list_type (gc_value) == GCONF_VALUE_INT) 00412 { 00413 GSList *elt; 00414 00415 ret = g_array_new (FALSE, FALSE, sizeof (gint)); 00416 for (elt = gconf_value_get_list (gc_value); elt != NULL; elt = g_slist_next (elt)) 00417 { 00418 int i = gconf_value_get_int ((GConfValue *) elt->data); 00419 g_array_append_val (ret, i); 00420 } 00421 } 00422 00423 if (gc_value != NULL) 00424 { 00425 gconf_value_free (gc_value); 00426 } 00427 return ret; 00428 }
GPtrArray* ergconf_get_int_tuples | ( | const gchar * | key, | |
guint | tuple_len | |||
) |
Get the list of integer tuples stored at the specified GConf key.
---------------------------------------------------------------------------
Name : ergconf_get_int_tuples
[in] | key | - The specified GConf key. [in] tuple_len - Number of integers in a tuple. |
--------------------------------------------------------------------------
Definition at line 452 of file gconf_utils.c.
References client.
00453 { 00454 GConfValue *gc_value = NULL; 00455 GPtrArray *ret = NULL; 00456 GSList *values, *iter; 00457 GArray *tuple = NULL; 00458 00459 g_assert(client); 00460 g_assert(key && *key); 00461 g_return_val_if_fail (tuple_len > 0, FALSE); 00462 00463 if (!(gc_value = gconf_client_get (client, key, NULL))) 00464 { 00465 goto out; 00466 } 00467 00468 if ( (gc_value->type != GCONF_VALUE_LIST) 00469 || (gconf_value_get_list_type (gc_value) != GCONF_VALUE_INT)) 00470 { 00471 goto out; 00472 } 00473 00474 values = gconf_value_get_list (gc_value); 00475 if (g_slist_length (values) % tuple_len != 0) 00476 { 00477 g_warning ("%s: %s format invalid; # elements not divisible by %d", 00478 __func__, key, tuple_len); 00479 goto out; 00480 } 00481 00482 ret = g_ptr_array_sized_new (1); 00483 for (iter = values; iter; iter = g_slist_next (iter)) 00484 { 00485 int i = gconf_value_get_int ((GConfValue *) iter->data); 00486 00487 if (tuple == NULL) 00488 { 00489 tuple = g_array_sized_new (FALSE, TRUE, sizeof (guint32), tuple_len); 00490 } 00491 00492 g_array_append_val (tuple, i); 00493 00494 /* Got all members; add to the array */ 00495 if (tuple->len == tuple_len) 00496 { 00497 g_ptr_array_add (ret, tuple); 00498 tuple = NULL; 00499 } 00500 } 00501 00502 out: 00503 if (gc_value) 00504 { 00505 gconf_value_free (gc_value); 00506 } 00507 return ret; 00508 }
gchar* ergconf_get_string | ( | const gchar * | key | ) |
Request the string value stored at the specified key.
---------------------------------------------------------------------------
Name : ergconf_get_string
[in] | key | - The GConf path of the key. |
--------------------------------------------------------------------------
Definition at line 177 of file gconf_utils.c.
References client.
Referenced by load_settings().
00178 { 00179 g_assert(client); 00180 g_assert(key && *key); 00181 return gconf_client_get_string(client, key, NULL); 00182 }
GHashTable* ergconf_get_string_hash | ( | const gchar * | dir | ) |
Get all key-value pairs from the specified GConf directory formatted as a hash table.
---------------------------------------------------------------------------
Name : ergconf_get_string_hash
[in] | dir | - The specified GConf directory. |
--------------------------------------------------------------------------
Definition at line 282 of file gconf_utils.c.
References client.
00283 { 00284 g_assert(client); 00285 g_assert(dir && *dir); 00286 00287 char *gc_key = NULL; 00288 int prefix_len = strlen (dir); 00289 GSList *iter; 00290 GSList *gconf_entries = gconf_client_all_entries (client, dir, NULL); 00291 00292 if (gconf_entries == NULL) 00293 { 00294 return NULL; 00295 } 00296 00297 GHashTable *ret = g_hash_table_new_full (g_str_hash, 00298 g_str_equal, 00299 (GDestroyNotify) g_free, 00300 (GDestroyNotify) g_free); 00301 00302 for (iter = gconf_entries; iter; iter = iter->next) 00303 { 00304 GConfEntry *entry = (GConfEntry *) iter->data; 00305 00306 gc_key = (char *) gconf_entry_get_key (entry); 00307 gc_key += prefix_len + 1; /* get rid of the full path */ 00308 00309 const GConfValue *gc_val = gconf_entry_get_value (entry); 00310 00311 if (gc_val) 00312 { 00313 const char *gc_str = gconf_value_get_string (gc_val); 00314 00315 if (gc_str != NULL && strlen (gc_str) > 0) 00316 { 00317 g_hash_table_insert (ret, gconf_unescape_key (gc_key, -1), g_strdup (gc_str)); 00318 } 00319 } 00320 gconf_entry_free (entry); 00321 } 00322 00323 g_slist_free (gconf_entries); 00324 return ret; 00325 }
GSList* ergconf_get_string_list | ( | const gchar * | key | ) |
Request the string list value stored at the specified key.
---------------------------------------------------------------------------
Name : ergconf_get_string_list
[in] | key | - The GConf path of the key. |
--------------------------------------------------------------------------
Definition at line 196 of file gconf_utils.c.
References client.
GSList* ergconf_get_sub_dirs | ( | const gchar * | dir | ) |
Get a list of sub-directories in the specified GConf directory.
---------------------------------------------------------------------------
Name : ergconf_get_sub_dirs
[in] | dir | - The specified GConf directory. |
--------------------------------------------------------------------------
Definition at line 558 of file gconf_utils.c.
References client.
00559 { 00560 g_assert(client); 00561 g_assert(dir && *dir); 00562 00563 GError *err = NULL; 00564 GSList *list = gconf_client_all_dirs(client, dir, &err); 00565 00566 if (err != NULL ) 00567 { 00568 g_warning ("Error while reading connection: %s", err->message); 00569 g_error_free (err); 00570 return NULL; 00571 } 00572 00573 return list; 00574 }
void ergconf_initialize | ( | ) |
Initialize GConf client. Note that GConf client talks to GConf daemon and has no access to files on disk. Changes are communicated to GConf daemon, who sends these values to every other client that is interested. The timing of writing changed values to disk is determined by GConf daemon and cannot be influenced through a GConf client.
---------------------------------------------------------------------------
Name : ergconf_initialize
-- |
--------------------------------------------------------------------------
Definition at line 88 of file gconf_utils.c.
References client, and on_value_changed().
Referenced by main().
00089 { 00090 if (client == NULL) 00091 { 00092 client = gconf_client_get_default(); 00093 g_signal_connect(G_OBJECT(client), "value-changed", G_CALLBACK(on_value_changed), NULL); 00094 } 00095 }
gboolean ergconf_is_default | ( | const gchar * | key | ) |
Returns if the key is set to the schema default value.
---------------------------------------------------------------------------
Name : ergconf_is_default
[in] | key | - The GConf path of the key. |
--------------------------------------------------------------------------
Definition at line 596 of file gconf_utils.c.
References client.
void ergconf_recursive_unset | ( | const gchar * | dir | ) |
Recursively unset all values in the specified directory and its sub-directories. This function clears the value of the keys and sets them to the default value defined in the schema file. If schema file doesn't define a default one then it will be set to gconf default (e.g. for integer it will be 0).
---------------------------------------------------------------------------
Name : ergconf_recursive_unset
[in] | dir | - The specified directory. |
--------------------------------------------------------------------------
Definition at line 134 of file gconf_utils.c.
References client.
int ergconf_set_bool | ( | const gchar * | key, | |
gboolean | new_value | |||
) |
Change the value of key to new_value.
---------------------------------------------------------------------------
Name : ergconf_set_bool
[in] | key | - The GConf path of the key. [in] new_value - The new value to be set. |
--------------------------------------------------------------------------
Definition at line 166 of file gconf_utils.c.
int ergconf_set_byte_array | ( | const gchar * | key, | |
const GByteArray * | new_value | |||
) |
Change the value of key to new_value.
---------------------------------------------------------------------------
Name : ergconf_set_byte_array
[in] | key | - The GConf path of the key. [in] new_value - The new value to be set, formatted as a byte array. |
--------------------------------------------------------------------------
Definition at line 262 of file gconf_utils.c.
References client, ER_FAIL, and ER_OK.
00263 { 00264 gboolean ok; 00265 GSList *list = NULL; 00266 00267 g_assert(client); 00268 g_assert(key && *key); 00269 00270 unsigned int i; 00271 for (i = 0; i < new_value->len; i++) 00272 { 00273 list = g_slist_append(list, GINT_TO_POINTER ((int) new_value->data[i])); 00274 } 00275 00276 ok = gconf_client_set_list (client, key, GCONF_VALUE_INT, list, NULL); 00277 00278 g_slist_free (list); 00279 return (ok ? ER_OK : ER_FAIL); 00280 }
void ergconf_set_cb_value_changed | ( | gconf_cb_value_changed_t | callback | ) |
Set callback function for gconf value changed.
---------------------------------------------------------------------------
Name : ergconf_set_cb_value_changed
[in] | callback | - Function to be called on a value change in one of the directories set with ergconf_add_monitor_dir. |
--------------------------------------------------------------------------
Definition at line 106 of file gconf_utils.c.
References g_cb_value_changed.
00107 { 00108 g_cb_value_changed = callback; 00109 }
int ergconf_set_int | ( | const gchar * | key, | |
int | new_value | |||
) |
Change the value of key to new_value.
---------------------------------------------------------------------------
Name : ergconf_set_int
[in] | key | - The GConf path of the key. [in] new_value - The new value to be set. |
--------------------------------------------------------------------------
Definition at line 148 of file gconf_utils.c.
int ergconf_set_int_array | ( | const gchar * | key, | |
const GArray * | new_value | |||
) |
Change value of specified GConf key into the supplied integer array.
---------------------------------------------------------------------------
Name : ergconf_set_int_array
[in] | key | - The GConf path of the key. [in] new_value - An array holding 'gint' values to be stored at the specified GConf path. |
--------------------------------------------------------------------------
Definition at line 430 of file gconf_utils.c.
References client, ER_FAIL, and ER_OK.
00431 { 00432 gboolean ret = FALSE; 00433 GSList *list = NULL; 00434 00435 g_assert(client); 00436 g_assert(key && *key); 00437 g_return_val_if_fail(new_value != NULL, FALSE); 00438 00439 unsigned int i; 00440 for (i = 0; i < new_value->len; i++) 00441 { 00442 gint val = g_array_index (new_value, gint, i); 00443 list = g_slist_append (list, GINT_TO_POINTER(val)); 00444 } 00445 00446 ret = gconf_client_set_list (client, key, GCONF_VALUE_INT, list, NULL); 00447 00448 g_slist_free (list); 00449 return ret == TRUE ? ER_OK : ER_FAIL; 00450 }
int ergconf_set_int_tuples | ( | const gchar * | key, | |
const GPtrArray * | value, | |||
guint | tuple_len | |||
) |
Change value of the specified GConf key into the supplied array of integer tuples.
---------------------------------------------------------------------------
Name : ergconf_set_int_tuples
[in] | key | - The specified GConf key. [in] value - An array of integer tuples, each length 'tuple_len'. The array holds a set of pointers to a tuple, each tuple is a GArray of 'guint32' values with length 'tuple_len'. [in] tuple_len - Number of integers in a tuple. |
--------------------------------------------------------------------------
Definition at line 510 of file gconf_utils.c.
References client, ER_FAIL, and ER_OK.
00511 { 00512 GSList *list = NULL; 00513 gboolean ret = FALSE; 00514 00515 g_assert(client); 00516 g_assert(key && *key); 00517 g_return_val_if_fail(value != NULL, FALSE); 00518 g_return_val_if_fail (tuple_len > 0, FALSE); 00519 00520 unsigned int i; 00521 for (i = 0; i < value->len; i++) 00522 { 00523 GArray *tuple = g_ptr_array_index (value, i); 00524 00525 if (tuple->len != tuple_len) 00526 { 00527 g_warning ("%s: invalid IPv4 address/route structure!", __func__); 00528 goto out; 00529 } 00530 00531 unsigned int j; 00532 for (j = 0; j < tuple_len; j++) 00533 { 00534 list = g_slist_append (list, GUINT_TO_POINTER (g_array_index (tuple, guint32, j))); 00535 } 00536 } 00537 00538 ret = gconf_client_set_list (client, key, GCONF_VALUE_INT, list, NULL); 00539 00540 out: 00541 g_slist_free (list); 00542 return ret == TRUE ? ER_OK : ER_FAIL; 00543 }
int ergconf_set_string | ( | const gchar * | key, | |
const gchar * | new_value | |||
) |
Change the value of key to new_value.
---------------------------------------------------------------------------
Name : ergconf_set_string
[in] | key | - The GConf path of the key. [in] new_value - The new value to be set. |
--------------------------------------------------------------------------
Definition at line 184 of file gconf_utils.c.
References client, ER_FAIL, and ER_OK.
Referenced by save_settings().
00185 { 00186 gboolean ok; 00187 00188 g_assert(client); 00189 g_assert(key && *key); 00190 g_assert(new_value); 00191 00192 ok = gconf_client_set_string(client, key, new_value, NULL); 00193 return (ok ? ER_OK : ER_FAIL); 00194 }
int ergconf_set_string_hash | ( | const gchar * | dir, | |
const GHashTable * | new_value | |||
) |
Set all key-value pairs in the specified GConf directory, assuming all key-value pairs in this GConf directory are of type string. Keys not present in new_value will be removed from the GConf directory. Sub-directories of the GConf directory are not affected.
---------------------------------------------------------------------------
Name : ergconf_set_string_hash
[in] | dir | - The specified GConf directory. [in] new_value - A hash table holding all key-value pairs to be set |
--------------------------------------------------------------------------
Definition at line 327 of file gconf_utils.c.
References client, ER_OK, ergconf_unset(), find_gconf_key(), FindKeyInfo::found, and write_properties_stringhash().
00328 { 00329 GSList *existing = NULL; 00330 GSList *iter; 00331 00332 g_assert(client); 00333 g_assert(dir && *dir); 00334 g_return_val_if_fail(new_value != NULL, FALSE); 00335 00336 /* Delete GConf entries that are not in the hash table to be written */ 00337 existing = gconf_client_all_entries (client, dir, NULL); 00338 for (iter = existing; iter; iter = g_slist_next (iter)) 00339 { 00340 GConfEntry *entry = (GConfEntry *) iter->data; 00341 char *basename = g_path_get_basename (entry->key); 00342 FindKeyInfo fk_info = { basename, FALSE }; 00343 00344 g_hash_table_foreach ( (GHashTable*)new_value, // const_cast 00345 find_gconf_key, 00346 &fk_info ); 00347 //TODO: Why not use g_hash_table_lookup_extended() here ?? 00348 //TODO Seems we don't need FindKeyInfo and find_gconf_key then. 00349 /* Be sure to never delete "special" VPN keys */ 00350 if (fk_info.found == FALSE) 00351 { 00352 ergconf_unset (entry->key); 00353 } 00354 00355 gconf_entry_free (entry); 00356 g_free (basename); 00357 } 00358 g_slist_free (existing); 00359 00360 /* Now update entries and write new ones */ 00361 g_hash_table_foreach ( (GHashTable*)new_value, // const_cast 00362 write_properties_stringhash, 00363 (gpointer)dir ); 00364 return ER_OK; 00365 }
int ergconf_set_string_list | ( | const gchar * | key, | |
const GSList * | new_value | |||
) |
Change the value of key to new_value.
---------------------------------------------------------------------------
Name : ergconf_set_string_list
[in] | key | - The GConf path of the key. [in] new_value - The new value to be set, formatted as a list of strings, each one a gchar*. |
--------------------------------------------------------------------------
Definition at line 203 of file gconf_utils.c.
References client, ER_FAIL, and ER_OK.
00204 { 00205 gboolean ok; 00206 00207 g_assert(client); 00208 g_assert(key && *key); 00209 g_return_val_if_fail (new_value != NULL, FALSE); 00210 00211 ok = gconf_client_set_list ( client, 00212 key, 00213 GCONF_VALUE_STRING, 00214 (GSList*)new_value, // const_cast 00215 NULL ); 00216 return (ok ? ER_OK : ER_FAIL); 00217 }
void ergconf_unset | ( | const gchar * | key | ) |
Unset the value of the specified key. This function clears the value of the key and set it to the default value defined in the schema file. If schema file doesn't define a default one then it will be set to gconf default (e.g. for integer it will be 0).
---------------------------------------------------------------------------
Name : ergconf_unset
[in] | key | - The GConf path of the key. |
--------------------------------------------------------------------------
Definition at line 127 of file gconf_utils.c.
References client.
Referenced by ergconf_set_string_hash().
00128 { 00129 g_assert(client); 00130 g_assert(key && *key); 00131 gconf_client_unset(client, key, NULL); 00132 }
static void find_gconf_key | ( | gpointer | key, | |
gpointer | value, | |||
gpointer | user_data | |||
) | [static] |
Definition at line 367 of file gconf_utils.c.
References FindKeyInfo::found, FindKeyInfo::key, and UNUSED.
Referenced by ergconf_set_string_hash().
00368 { 00369 UNUSED(value); 00370 FindKeyInfo *info = (FindKeyInfo *) user_data; 00371 00372 if ( !info->found 00373 && strcmp ((char *) key, info->key) == 0 ) 00374 { 00375 info->found = TRUE; 00376 } 00377 }
void on_value_changed | ( | GConfClient * | client, | |
const gchar * | key, | |||
GConfValue * | value | |||
) | [static] |
Definition at line 111 of file gconf_utils.c.
References g_cb_value_changed, and UNUSED.
Referenced by ergconf_initialize().
00112 { 00113 UNUSED(client); 00114 if (g_cb_value_changed) 00115 { 00116 (*g_cb_value_changed)(key, value); 00117 } 00118 }
static void write_properties_stringhash | ( | gpointer | key, | |
gpointer | value, | |||
gpointer | user_data | |||
) | [static] |
Definition at line 379 of file gconf_utils.c.
Referenced by ergconf_set_string_hash().
00380 { 00381 char *esc_key; 00382 char *full_key; 00383 const char *path = (const char*) user_data; 00384 const char *str_value = (const char *) value; 00385 00386 if (str_value && *str_value) 00387 { 00388 esc_key = gconf_escape_key ((char *) key, -1); 00389 full_key = g_strconcat (path, "/", esc_key, NULL); 00390 gconf_client_set_string (client, full_key, (char *) str_value, NULL); 00391 g_free (esc_key); 00392 g_free (full_key); 00393 } 00394 }
GConfClient* client = NULL [static] |
Definition at line 67 of file gconf_utils.c.
Referenced by add_filetypes_from_gconf(), ergconf_add_monitor_dir(), ergconf_dir_exist(), ergconf_finalize(), ergconf_free_string_list(), ergconf_get_bool(), ergconf_get_byte_array(), ergconf_get_int(), ergconf_get_int_array(), ergconf_get_int_tuples(), ergconf_get_string(), ergconf_get_string_hash(), ergconf_get_string_list(), ergconf_get_sub_dirs(), ergconf_initialize(), ergconf_is_default(), ergconf_recursive_unset(), ergconf_set_bool(), ergconf_set_byte_array(), ergconf_set_int(), ergconf_set_int_array(), ergconf_set_int_tuples(), ergconf_set_string(), ergconf_set_string_hash(), ergconf_set_string_list(), ergconf_unset(), get_viewtype_from_registry(), save_viewtype_to_registry(), and write_properties_stringhash().
gconf_cb_value_changed_t g_cb_value_changed = NULL [static] |
Definition at line 68 of file gconf_utils.c.
Referenced by ergconf_set_cb_value_changed(), and on_value_changed().