gboolean gnc_gconf_schemas_found (void) { GConfSchema* schema; GError *err = NULL; gchar *key; if (our_client == NULL) our_client = gconf_client_get_default(); key = gnc_gconf_make_schema_key(GCONF_GENERAL_REGISTER, "use_theme_colors"); schema = gconf_client_get_schema(our_client, key, &err); g_free(key); if (schema == NULL) { return FALSE; } gconf_schema_free(schema); /* Set up convenience callback for general section */ gconf_general_cb_id = gnc_gconf_add_anon_notification(GCONF_GENERAL, gnc_gconf_general_changed, NULL); return TRUE; }
static void install_default_macros_list (GConfClient *client, const char *key, int offset) { GConfSchema *schema; GConfValue *value; GSList *list = NULL; GError *error; int i; error = NULL; schema = gconf_client_get_schema (client, key, &error); if (error) { g_warning (_("Cannot get schema for %s: %s"), key, error->message); g_error_free (error); return; } /* gconf has started to return NULL with no error set. */ g_return_if_fail (schema != NULL); /* Some sanity checks */ g_assert (gconf_schema_get_type (schema) == GCONF_VALUE_LIST); g_assert (gconf_schema_get_list_type (schema) == GCONF_VALUE_STRING); value = gconf_value_new (GCONF_VALUE_LIST); gconf_value_set_list_type (value, GCONF_VALUE_STRING); for (i = 0; i < G_N_ELEMENTS (mc_default_macros); i++) list = g_slist_prepend (list, gconf_value_new_from_string (GCONF_VALUE_STRING, G_STRUCT_MEMBER (char *, &mc_default_macros [i], offset), NULL)); list = g_slist_reverse (list); gconf_value_set_list_nocopy (value, list); list = NULL; gconf_schema_set_default_value_nocopy (schema, value); value = NULL; error = NULL; gconf_client_set_schema (client, key, schema, &error); if (error) { g_warning (_("Cannot set schema for %s: %s"), key, error->message); g_error_free (error); } gconf_schema_free (schema); printf (_("Set default list value for %s\n"), key); }
static GConfSchema* gconf_dialog_safely_get_schema (GConfDialog* self, GConfEntry* entry) { GConfSchema* result = NULL; GError * _inner_error_; const char* schema_name; GConfSchema* rt; GConfSchema* _tmp3_; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (entry != NULL, NULL); _inner_error_ = NULL; schema_name = gconf_entry_get_schema_name (entry); rt = NULL; if (schema_name != NULL) { { GConfSchema* _tmp0_; GConfSchema* _tmp2_; GConfSchema* _tmp1_; _tmp0_ = gconf_client_get_schema (self->priv->_default_client, schema_name, &_inner_error_); if (_inner_error_ != NULL) { goto __catch24_g_error; } rt = (_tmp2_ = gconf_schema_copy (_tmp1_ = _tmp0_), _gconf_schema_free0 (rt), _tmp2_); _gconf_schema_free0 (_tmp1_); result = rt; return result; } goto __finally24; __catch24_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { _g_error_free0 (e); } } __finally24: if (_inner_error_ != NULL) { _gconf_schema_free0 (rt); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } g_critical ("gtkextra-gconfdialog.vala:161: schema not found for entry %s", gconf_entry_get_key (entry)); rt = (_tmp3_ = gconf_schema_new (), _gconf_schema_free0 (rt), _tmp3_); gconf_schema_set_short_desc (rt, gconf_entry_get_key (entry)); gconf_schema_set_long_desc (rt, "This key lacks a schema"); gconf_schema_set_type (rt, GCONF_VALUE_STRING); result = rt; return result; }
void* nsvn_gconf_read_config_entry (const char *key, const char *schema, GConfClient *gcc) { GConfSchema *gcs; GConfValueType gct; GError *err=NULL; void *ret=NULL; gboolean *bval = NULL; if (gcc == NULL || key == NULL) return NULL; /* Check for the presense of schema, if not return fail. */ /* Get key details from schema. */ /* Check for the presense of dir, if not create it. */ /* if already present update it with new value. */ gcs = gconf_client_get_schema (gcc, schema, &err); if (!gcs) return NULL; gct = gconf_schema_get_type (gcs); switch (gct) { case GCONF_VALUE_STRING: ret = (void*) gconf_client_get_string (gcc, key, &err); break; case GCONF_VALUE_INT: break; case GCONF_VALUE_FLOAT: break; case GCONF_VALUE_BOOL: bval = (gboolean*)g_malloc0(sizeof(gboolean)); *bval = gconf_client_get_bool (gcc, key, &err); ret = (void*)bval; break; case GCONF_VALUE_LIST: break; case GCONF_VALUE_PAIR: break; default: break; } return ret; }
int nsvn_gconf_write_config_entry (const char *key, const char *schema, void *value, GConfClient *gcc) { GConfSchema *gcs; GConfValueType gct; if (gcc == NULL || key == NULL) return 0; /* Check for the presense of schema, if not return fail. */ /* Get key details from schema. */ /* Check for the presense of dir, if not create it. */ /* if already present update it with new value. */ gcs = gconf_client_get_schema (gcc, schema, NULL); if (!gcs) return TRUE; gct = gconf_schema_get_type (gcs); switch (gct) { case GCONF_VALUE_STRING: gconf_client_set_string (gcc, key, (const char*)value, NULL); break; case GCONF_VALUE_INT: break; case GCONF_VALUE_FLOAT: break; case GCONF_VALUE_BOOL: gconf_client_set_bool (gcc, key, *((gboolean*)value), NULL); break; case GCONF_VALUE_LIST: break; case GCONF_VALUE_PAIR: break; default: break; } return 1; }
GConfSchema * gnc_gconf_get_schema (const gchar *section, const gchar *name, GError **caller_error) { GError *error = NULL; GConfSchema *value; gchar *key; if (our_client == NULL) our_client = gconf_client_get_default(); key = gnc_gconf_make_key(section, name); value = gconf_client_get_schema(our_client, key, &error); if (error) { gnc_gconf_load_error(key, caller_error, error); } g_free(key); return value; }