forked from enlightenment/efl
parent
7c24ebf4e0
commit
229e127911
|
@ -14,9 +14,10 @@
|
||||||
|
|
||||||
long int_val;
|
long int_val;
|
||||||
float flt_val;
|
float flt_val;
|
||||||
int r_val;
|
int a_val;
|
||||||
int g_val;
|
int r_val;
|
||||||
int b_val;
|
int g_val;
|
||||||
|
int b_val;
|
||||||
char *str_val;
|
char *str_val;
|
||||||
char *thm_val;
|
char *thm_val;
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ void get_settings (void) {
|
||||||
int_val = ecore_config_int_get(INT_VAL_KEY);
|
int_val = ecore_config_int_get(INT_VAL_KEY);
|
||||||
flt_val = ecore_config_float_get(FLT_VAL_KEY);
|
flt_val = ecore_config_float_get(FLT_VAL_KEY);
|
||||||
str_val = ecore_config_string_get(STR_VAL_KEY);
|
str_val = ecore_config_string_get(STR_VAL_KEY);
|
||||||
ecore_config_argb_get(RGB_VAL_KEY, NULL, &r_val, &g_val, &b_val);
|
ecore_config_argb_get(RGB_VAL_KEY, &a_val, &r_val, &g_val, &b_val);
|
||||||
thm_val = ecore_config_theme_get(THM_VAL_KEY);
|
thm_val = ecore_config_theme_get(THM_VAL_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ void change_settings(void) {
|
||||||
str_val[4] += 1;
|
str_val[4] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a_val = (a_val + 1) % 256;
|
||||||
r_val = (r_val + 1) % 256;
|
r_val = (r_val + 1) % 256;
|
||||||
g_val = (g_val + 1) % 256;
|
g_val = (g_val + 1) % 256;
|
||||||
b_val = (b_val + 1) % 256;
|
b_val = (b_val + 1) % 256;
|
||||||
|
@ -67,7 +69,7 @@ void save_settings (void) {
|
||||||
ecore_config_int_set(INT_VAL_KEY, int_val);
|
ecore_config_int_set(INT_VAL_KEY, int_val);
|
||||||
ecore_config_float_set(FLT_VAL_KEY, flt_val);
|
ecore_config_float_set(FLT_VAL_KEY, flt_val);
|
||||||
ecore_config_string_set(STR_VAL_KEY, str_val);
|
ecore_config_string_set(STR_VAL_KEY, str_val);
|
||||||
ecore_config_argb_set(RGB_VAL_KEY, 255, r_val, g_val, b_val);
|
ecore_config_argb_set(RGB_VAL_KEY, a_val, r_val, g_val, b_val);
|
||||||
ecore_config_theme_set(THM_VAL_KEY, thm_val);
|
ecore_config_theme_set(THM_VAL_KEY, thm_val);
|
||||||
ecore_config_save();
|
ecore_config_save();
|
||||||
}
|
}
|
||||||
|
@ -76,7 +78,7 @@ void dump_settings (void) {
|
||||||
printf(" Int Value: %li\n", int_val);
|
printf(" Int Value: %li\n", int_val);
|
||||||
printf(" Float Value: %f\n", flt_val);
|
printf(" Float Value: %f\n", flt_val);
|
||||||
printf(" String Value: %s\n", str_val);
|
printf(" String Value: %s\n", str_val);
|
||||||
printf(" RGB Value: %i %i %i\n", r_val, g_val, b_val);
|
printf(" ARGB Value: %i %i %i %i\n", a_val, r_val, g_val, b_val);
|
||||||
printf(" Theme Value: %s\n", thm_val);
|
printf(" Theme Value: %s\n", thm_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <Eet.h>
|
#include <Eet.h>
|
||||||
#include "Ecore_Config.h"
|
#include "Ecore_Config.h"
|
||||||
#include "Ecore_Data.h"
|
#include "Ecore_Data.h"
|
||||||
|
#include "ecore_config_private.h"
|
||||||
|
|
||||||
// strcmp for paths - for sorting folders before files
|
// strcmp for paths - for sorting folders before files
|
||||||
int
|
int
|
||||||
|
@ -57,6 +58,7 @@ int
|
||||||
get(const char *key)
|
get(const char *key)
|
||||||
{
|
{
|
||||||
Ecore_Config_Prop *e;
|
Ecore_Config_Prop *e;
|
||||||
|
char *temp = NULL;
|
||||||
|
|
||||||
if (!(e = ecore_config_get(key)))
|
if (!(e = ecore_config_get(key)))
|
||||||
{
|
{
|
||||||
|
@ -64,33 +66,40 @@ get(const char *key)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("%-10s", ecore_config_type_get(e));
|
||||||
|
|
||||||
switch (e->type)
|
switch (e->type)
|
||||||
{
|
{
|
||||||
case ECORE_CONFIG_NIL:
|
case ECORE_CONFIG_NIL:
|
||||||
printf("\n");
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
case ECORE_CONFIG_INT:
|
case ECORE_CONFIG_INT:
|
||||||
printf("integer %ld\n", ecore_config_int_get(key));
|
printf("%ld\n", _ecore_config_int_get(e));
|
||||||
break;
|
break;
|
||||||
case ECORE_CONFIG_BLN:
|
case ECORE_CONFIG_BLN:
|
||||||
printf("bool %d\n", ecore_config_boolean_get(key));
|
printf("%d\n", _ecore_config_boolean_get(e));
|
||||||
break;
|
break;
|
||||||
case ECORE_CONFIG_FLT:
|
case ECORE_CONFIG_FLT:
|
||||||
printf("float %lf\n", ecore_config_float_get(key));
|
printf("%lf\n", _ecore_config_float_get(e));
|
||||||
break;
|
break;
|
||||||
case ECORE_CONFIG_STR:
|
case ECORE_CONFIG_STR:
|
||||||
printf("string \"%s\"\n", ecore_config_string_get(key));
|
temp = _ecore_config_string_get(e);
|
||||||
break;
|
break;
|
||||||
case ECORE_CONFIG_RGB:
|
case ECORE_CONFIG_RGB:
|
||||||
printf("rgb \"%s\"\n", ecore_config_argbstr_get(key));
|
temp = _ecore_config_argbstr_get(e);
|
||||||
break;
|
break;
|
||||||
case ECORE_CONFIG_THM:
|
case ECORE_CONFIG_THM:
|
||||||
printf("theme \"%s\"\n", ecore_config_theme_get(key));
|
temp = _ecore_config_theme_get(e);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Property has unrecognised type");
|
fprintf(stderr, "Property has unrecognized type");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if(temp)
|
||||||
|
{
|
||||||
|
printf("\"%s\"\n", temp);
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +157,6 @@ usage_and_exit(const char *prog, int ret, const char *msg)
|
||||||
fprintf(stderr, " -b, --bool=VALUE set boolean\n");
|
fprintf(stderr, " -b, --bool=VALUE set boolean\n");
|
||||||
fprintf(stderr, " -f, --float=VALUE set float\n");
|
fprintf(stderr, " -f, --float=VALUE set float\n");
|
||||||
fprintf(stderr, " -i, --int=VALUE set integer\n");
|
fprintf(stderr, " -i, --int=VALUE set integer\n");
|
||||||
fprintf(stderr, " -n, --nil set nil\n");
|
|
||||||
fprintf(stderr, " -r, --rgb=VALUE set RGBA\n");
|
fprintf(stderr, " -r, --rgb=VALUE set RGBA\n");
|
||||||
fprintf(stderr, " -s, --string=VALUE set string\n");
|
fprintf(stderr, " -s, --string=VALUE set string\n");
|
||||||
fprintf(stderr, " -t, --theme=VALUE set theme\n\n");
|
fprintf(stderr, " -t, --theme=VALUE set theme\n\n");
|
||||||
|
@ -158,12 +166,12 @@ usage_and_exit(const char *prog, int ret, const char *msg)
|
||||||
int
|
int
|
||||||
main(int argc, char * const argv[])
|
main(int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
const char *prog, *file, *key;
|
char *prog, *file, *key;
|
||||||
void *value = (void *)NULL;
|
void *value = (void *)NULL;
|
||||||
char cmd = 's';
|
char cmd = 's';
|
||||||
int type = -1;
|
int type = -1;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
long i;
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
file = key = prog = NULL;
|
file = key = prog = NULL;
|
||||||
|
@ -183,7 +191,6 @@ main(int argc, char * const argv[])
|
||||||
{"bool", 1, 0, 'b'},
|
{"bool", 1, 0, 'b'},
|
||||||
{"float", 1, 0, 'f'},
|
{"float", 1, 0, 'f'},
|
||||||
{"int", 1, 0, 'i'},
|
{"int", 1, 0, 'i'},
|
||||||
{"nil", 0, 0, 'n'},
|
|
||||||
{"rgb", 1, 0, 'r'},
|
{"rgb", 1, 0, 'r'},
|
||||||
{"string", 1, 0, 's'},
|
{"string", 1, 0, 's'},
|
||||||
{"theme", 1, 0, 't'},
|
{"theme", 1, 0, 't'},
|
||||||
|
@ -191,7 +198,7 @@ main(int argc, char * const argv[])
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = getopt_long(argc, argv, "c:agdb:f:i:nr:s:t:k:", long_options, NULL);
|
ret = getopt_long(argc, argv, "c:agdb:f:i:r:s:t:k:", long_options, NULL);
|
||||||
if(ret == -1)
|
if(ret == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -201,42 +208,59 @@ main(int argc, char * const argv[])
|
||||||
key = strdup(optarg);
|
key = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
|
if(value)
|
||||||
|
usage_and_exit(prog, 2, "too many commands");
|
||||||
type = ECORE_CONFIG_NIL;
|
type = ECORE_CONFIG_NIL;
|
||||||
value = NULL;
|
value = NULL;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
|
if(value)
|
||||||
|
usage_and_exit(prog, 2, "too many commands");
|
||||||
type = ECORE_CONFIG_BLN;
|
type = ECORE_CONFIG_BLN;
|
||||||
i = atoi(optarg);
|
i = atoi(optarg);
|
||||||
value = &i;
|
value = &i;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
|
if(value)
|
||||||
|
usage_and_exit(prog, 2, "too many commands");
|
||||||
type = ECORE_CONFIG_INT;
|
type = ECORE_CONFIG_INT;
|
||||||
i = atoi(optarg);
|
i = atoi(optarg);
|
||||||
value = &i;
|
value = &i;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
|
if(value)
|
||||||
|
usage_and_exit(prog, 2, "too many commands");
|
||||||
type = ECORE_CONFIG_FLT;
|
type = ECORE_CONFIG_FLT;
|
||||||
f = atof(optarg);
|
f = atof(optarg);
|
||||||
value = &f;
|
value = &f;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
|
if(value)
|
||||||
|
usage_and_exit(prog, 2, "too many commands");
|
||||||
type = ECORE_CONFIG_RGB;
|
type = ECORE_CONFIG_RGB;
|
||||||
value = strdup(optarg);
|
i = (long) strtoul( (*optarg == '#') ? (optarg + 1) : optarg, NULL, 16 );
|
||||||
|
value = &i;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
|
if(value)
|
||||||
|
usage_and_exit(prog, 2, "too many commands");
|
||||||
type = ECORE_CONFIG_STR;
|
type = ECORE_CONFIG_STR;
|
||||||
value = strdup(optarg);
|
value = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
|
if(value)
|
||||||
|
usage_and_exit(prog, 2, "too many commands");
|
||||||
type = ECORE_CONFIG_THM;
|
type = ECORE_CONFIG_THM;
|
||||||
value = strdup(optarg);
|
value = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
if(file)
|
||||||
|
free(file);
|
||||||
file = strdup(optarg);
|
file = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
case ':':
|
case ':':
|
||||||
usage_and_exit(prog, 2, "Bad argument");
|
return 1;
|
||||||
default:
|
default:
|
||||||
cmd = ret;
|
cmd = ret;
|
||||||
break;
|
break;
|
||||||
|
@ -271,6 +295,7 @@ main(int argc, char * const argv[])
|
||||||
} else {
|
} else {
|
||||||
ecore_config_file_save(file);
|
ecore_config_file_save(file);
|
||||||
}
|
}
|
||||||
|
get(key); // display value after setting it
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if(del(key))
|
if(del(key))
|
||||||
|
@ -287,10 +312,18 @@ main(int argc, char * const argv[])
|
||||||
case 'a':
|
case 'a':
|
||||||
if (list(file)) ret = 1;
|
if (list(file)) ret = 1;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
printf("Unhandled command '%c'\n", cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
ecore_config_shutdown();
|
ecore_config_shutdown();
|
||||||
|
|
||||||
|
if(type == ECORE_CONFIG_STR || type == ECORE_CONFIG_THM)
|
||||||
|
free(value);
|
||||||
|
|
||||||
|
if(file)
|
||||||
|
free(file);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -155,7 +155,7 @@ ecore_config_string_get(const char *key)
|
||||||
return _ecore_config_string_get( ecore_config_get(key) );
|
return _ecore_config_string_get( ecore_config_get(key) );
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
EAPI char *
|
||||||
_ecore_config_string_get(Ecore_Config_Prop *e)
|
_ecore_config_string_get(Ecore_Config_Prop *e)
|
||||||
{
|
{
|
||||||
return (e && (e->type == ECORE_CONFIG_STR) && e->ptr) ? strdup(e->ptr) : NULL;
|
return (e && (e->type == ECORE_CONFIG_STR) && e->ptr) ? strdup(e->ptr) : NULL;
|
||||||
|
@ -174,7 +174,7 @@ ecore_config_boolean_get(const char *key)
|
||||||
return _ecore_config_boolean_get( ecore_config_get(key) );
|
return _ecore_config_boolean_get( ecore_config_get(key) );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
EAPI int
|
||||||
_ecore_config_boolean_get(Ecore_Config_Prop *e)
|
_ecore_config_boolean_get(Ecore_Config_Prop *e)
|
||||||
{
|
{
|
||||||
return (e && ((e->type == ECORE_CONFIG_INT) || (e->type == ECORE_CONFIG_BLN))) ? (e->val != 0) : -1;
|
return (e && ((e->type == ECORE_CONFIG_INT) || (e->type == ECORE_CONFIG_BLN))) ? (e->val != 0) : -1;
|
||||||
|
@ -261,7 +261,7 @@ ecore_config_argbstr_get(const char *key)
|
||||||
return _ecore_config_argbstr_get( ecore_config_get(key) );
|
return _ecore_config_argbstr_get( ecore_config_get(key) );
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
EAPI char *
|
||||||
_ecore_config_argbstr_get(Ecore_Config_Prop *e)
|
_ecore_config_argbstr_get(Ecore_Config_Prop *e)
|
||||||
{
|
{
|
||||||
char *r;
|
char *r;
|
||||||
|
@ -284,7 +284,7 @@ ecore_config_theme_get(const char *key)
|
||||||
return _ecore_config_theme_get( ecore_config_get(key) );
|
return _ecore_config_theme_get( ecore_config_get(key) );
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
EAPI char *
|
||||||
_ecore_config_theme_get(Ecore_Config_Prop *e)
|
_ecore_config_theme_get(Ecore_Config_Prop *e)
|
||||||
{
|
{
|
||||||
return (e && (e->type == ECORE_CONFIG_THM)) ? strdup(e->ptr) : NULL;
|
return (e && (e->type == ECORE_CONFIG_THM)) ? strdup(e->ptr) : NULL;
|
||||||
|
@ -749,10 +749,8 @@ ecore_config_float_set(const char *key, float val)
|
||||||
* @param r integer 0..255
|
* @param r integer 0..255
|
||||||
* @param g integer 0..255
|
* @param g integer 0..255
|
||||||
* @param b integer 0..255
|
* @param b integer 0..255
|
||||||
*
|
|
||||||
* @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
|
* @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
|
||||||
* @ingroup Ecore_Config_Set_Group
|
* @ingroup Ecore_Config_Set_Group
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_config_argb_set(const char *key, int a, int r, int g, int b)
|
ecore_config_argb_set(const char *key, int a, int r, int g, int b)
|
||||||
|
@ -1029,7 +1027,6 @@ ecore_config_float_default_bound(const char *key, float val, float low,
|
||||||
* @param b integer 0..255
|
* @param b integer 0..255
|
||||||
* @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
|
* @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
|
||||||
* @ingroup Ecore_Config_Default_Group
|
* @ingroup Ecore_Config_Default_Group
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_config_argb_default(const char *key, int a, int r, int g, int b)
|
ecore_config_argb_default(const char *key, int a, int r, int g, int b)
|
||||||
|
|
Loading…
Reference in New Issue