/** * Sets the indicated property to the value indicated by @a val. * @param key The property key. * @param val String representation of value to set. * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_set(const char *key, const char *val) { int type; int tmpi; float tmpf; long tmpl; type = ecore_config_type_guess(key, val); if (type == ECORE_CONFIG_INT || type == ECORE_CONFIG_BLN) { tmpi = atoi(val); return ecore_config_typed_set(key, &tmpi, type); } else if (type == ECORE_CONFIG_FLT) { tmpf = atof(val); return ecore_config_typed_set(key, &tmpf, type); } else if (type == ECORE_CONFIG_RGB) { __ecore_argbstr_to_long(val, &tmpl); return ecore_config_typed_set(key, &tmpl, type); } else return ecore_config_typed_set(key, val, type); }
EAPI int ecore_config_typed_default(const char *key, const void *val, int type) { int ret; Ecore_Config_Prop *e; ret = ECORE_CONFIG_ERR_SUCC; if (!(e = ecore_config_get(key))) { /* prop doesn't exist yet */ if ((ret = ecore_config_typed_add(key, val, type)) != ECORE_CONFIG_ERR_SUCC) /* try to add it */ return ret; /* ...failed */ if (!(e = ecore_config_get(key))) /* get handle */ return ECORE_CONFIG_ERR_FAIL; e->flags = e->flags & ~ECORE_CONFIG_FLAG_MODIFIED; } else if (!(e->flags & ECORE_CONFIG_FLAG_MODIFIED) && !(e->flags & ECORE_CONFIG_FLAG_SYSTEM)) { ecore_config_typed_set(key, val, type); if (!(e = ecore_config_get(key))) /* get handle */ return ECORE_CONFIG_ERR_FAIL; e->flags = e->flags & ~ECORE_CONFIG_FLAG_MODIFIED; } return ret; }
int _ecore_config_db_read(Ecore_Config_DB_File *db, const char *key) { char *data, *value; int size; Ecore_Config_Type type; data = eet_read(db->ef, (char*)key, &size); if (data) { int l; char *prev_locale; if (size <= 2) { free(data); return 0; } if (data[size - 1] != 0) { free(data); return 0; } /* "type" NIL 1242 NIL */ l = strlen(data); if (l >= (size - 1)) { free(data); return 0; } type = data[0]; value = data + l + 1; switch (type) { case ECORE_CONFIG_INT: case ECORE_CONFIG_BLN: { int tmp; prev_locale = setlocale(LC_NUMERIC, "C"); tmp = atoi(value); if (prev_locale) setlocale(LC_NUMERIC, prev_locale); ecore_config_typed_set(key, (void *)&tmp, type); break; } case ECORE_CONFIG_FLT: { float tmp; prev_locale = setlocale(LC_NUMERIC, "C"); tmp = atof(value); if (prev_locale) setlocale(LC_NUMERIC, prev_locale); ecore_config_typed_set(key, (void *)&tmp, type); break; } case ECORE_CONFIG_RGB: ecore_config_argbstr_set(key, value); break; case ECORE_CONFIG_STR: case ECORE_CONFIG_THM: ecore_config_typed_set(key, (void *)value, type); break; case ECORE_CONFIG_SCT: INF("loading struct %s", key); break; default: WRN("Type %d not handled", type); } free(data); return 1; } return 0; }
/** * Sets the indicated property to a theme name. * @param key The property key. * @param val String giving the name of the theme. * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_theme_set(const char *key, const char *val) { return ecore_config_typed_set(key, val, ECORE_CONFIG_THM); }
/** * Sets the indicated property to a color value. * @param key The property key * @param val Color value in ARGB format. * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_argbstr_set(const char *key, const char *val) { long v = 0; return ecore_config_typed_set(key, __ecore_argbstr_to_long(val, &v), ECORE_CONFIG_RGB); }
/** * Sets the indicated property to a color value. * @param key The property key * @param argb ARGB data as long * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_argbint_set(const char *key, long argb) { return ecore_config_typed_set(key, &argb, ECORE_CONFIG_RGB); }
/** * Sets the indicated property to a color value. * @param key The property key * @param a integer 0..255 * @param r integer 0..255 * @param g integer 0..255 * @param b integer 0..255 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_argb_set(const char *key, int a, int r, int g, int b) { long v = 0; return ecore_config_typed_set(key, __ecore_argb_to_long(a,r,g,b, &v), ECORE_CONFIG_RGB); }
/** * Sets the indicated property to the given float value. * @param key The property key. * @param val Float to set the property to. * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_float_set(const char *key, float val) { return ecore_config_typed_set(key, &val, ECORE_CONFIG_FLT); }
/** * Sets the indicated property to the given string. * @param key The property key. * @param val String to set the property to. * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_string_set(const char *key, const char *val) { return ecore_config_typed_set(key, val, ECORE_CONFIG_STR); }
/** * Sets the indicated property to the given integer. * @param key The property key. * @param val Integer to set the property to. * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_int_set(const char *key, int val) { return ecore_config_typed_set(key, &val, ECORE_CONFIG_INT); }
/** * Sets the indicated property to the given boolean. * @param key The property key. * @param val Boolean integer to set the property to. * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @ingroup Ecore_Config_Set_Group */ EAPI int ecore_config_boolean_set(const char *key, int val) { val = val ? 1 : 0; return ecore_config_typed_set(key, &val, ECORE_CONFIG_BLN); }