Add theme type for exciting features in examine

Add property descriptions,
For the (beginnings of) help text / input parser


SVN revision: 9869
This commit is contained in:
handyande 2004-04-22 23:38:19 +00:00 committed by handyande
parent 67a3d2f391
commit 61bb6beaba
5 changed files with 80 additions and 17 deletions

View File

@ -55,7 +55,8 @@ typedef enum Ecore_Config_Type {
PT_INT=1,
PT_FLT=2,
PT_STR=3,
PT_RGB=4
PT_RGB=4,
PT_THM=5
} Ecore_Config_Type;
@ -126,14 +127,17 @@ char *ecore_config_get_string(const char *key);
long ecore_config_get_int(const char *key);
int ecore_config_get_rgb(const char *key,int *r, int *g, int *b);
float ecore_config_get_float(const char *key);
char *ecore_config_get_theme(const char *key);
char *ecore_config_get_as_string(const char *key);
char *ecore_config_canonize_key(char *,int modify);
void ecore_config_describe(const char *key, char *desc);
int ecore_config_set(Ecore_Config_Bundle *t,const char *key,char *val);
int ecore_config_set_string(const char *key,char *val);
int ecore_config_set_int(const char *key,int val);
int ecore_config_set_rgb(const char *key,char *val);
char *ecore_config_get_rgbstr(const char *key);
int ecore_config_set_float(const char *key,float val);
int ecore_config_set_theme(const char *key,char *val);
int ecore_config_set_as_string(const char *key,char *val);
int ecore_config_default(const char *key,char *val,float lo,float hi,float step);
@ -143,11 +147,12 @@ int ecore_config_default_string(const char *key,char *val);
int ecore_config_default_float(const char *key,float val);
int ecore_config_default_float_bound(const char *key,float val,float lo,float hi,float step);
int ecore_config_default_rgb(const char *key,char *val);
int ecore_config_default_theme(const char *key,char *val);
int ecore_config_listen(const char *name,const char *key,Ecore_Config_Listener listener,int tag,void *data);
int ecore_config_deaf(const char *name,const char *key,Ecore_Config_Listener listener);
Ecore_Config_Prop *ecore_config_dst(Ecore_Config_Prop *e);
int ecore_config_guess_type(char *val);
int ecore_config_guess_type(const char *key, char *val);
Ecore_Config_Bundle *ecore_config_bundle_new(Ecore_Config_Server *srv, const char *id);
Ecore_Config_Bundle *ecore_config_bundle_get_1st(Ecore_Config_Server *srv);
@ -190,3 +195,4 @@ int ecore_config_save_file(char *file);
/* convenience mathods in convenience.c */
int ecore_config_evas_font_path_apply(Evas *evas);
void ecore_config_prop_list_describe(void);

View File

@ -35,3 +35,23 @@ printf("appending font %s\n", font_path_tmp);
return ECORE_CONFIG_ERR_SUCC;
}
static char *_ecore_config_short_types[]={ "nil", "int", "flt", "str", "rgb", "str"};
void
ecore_config_prop_list_describe(void)
{
Ecore_Config_Prop *props;
if (!__ecore_config_bundle_local) return;
props = __ecore_config_bundle_local->data;
while (props)
{
if (props->flags&PF_SYSTEM) {
props = props->next;
continue;
}
printf(" --%s\t [%s] %s\n", props->key, _ecore_config_short_types[props->type], props->description);
props = props->next;
}
}

View File

@ -21,7 +21,7 @@ char *__ecore_config_app_name = NULL;
Ecore_Config_Server *_ecore_config_ipc_init(char *name);
int _ecore_config_ipc_exit(void);
static char *_ecore_config_type[]={ "undefined", "integer", "float", "string", "colour" };
static char *_ecore_config_type[]={ "undefined", "integer", "float", "string", "colour", "theme" };
Ecore_Config_Prop *ecore_config_dst(Ecore_Config_Prop *e) {
Ecore_Config_Bundle *t;
@ -120,6 +120,12 @@ char *ecore_config_get_rgbstr(const char *key) {
esprintf(&r,"#%06x",ecore_config_get_int(key));
return r; }
char *ecore_config_get_theme(const char *key) {
Ecore_Config_Prop *e;
e=ecore_config_get(__ecore_config_bundle_local,key);
return (e&&(e->type==PT_THM))?e->ptr:NULL; }
char *ecore_config_get_as_string(const char *key) {
Ecore_Config_Bundle *t;
Ecore_Config_Prop *e;
@ -141,6 +147,8 @@ char *ecore_config_get_as_string(const char *key) {
esprintf(&r,"%s:%s=\"%s\"",key,type,ecore_config_get_string(key)); break;
case PT_RGB:
esprintf(&r,"%s:%s=#%06x",key,type,ecore_config_get_int(key)); break;
case PT_THM:
esprintf(&r,"%s:%s=\"%s\"",key,type,ecore_config_get_theme(key)); break;
default:
esprintf(&r,"%s:unknown_type",key); break; }}
return r; }
@ -179,11 +187,15 @@ static int ecore_config_bound(Ecore_Config_Prop *e) {
return ret; }
int ecore_config_guess_type(char *val) {
int ecore_config_guess_type(const char *key,char *val) {
Ecore_Config_Prop *p;
char *l;
long v;
l=NULL;
if ((p=ecore_config_get(__ecore_config_bundle_local, key)) && p->type!=PT_NIL)
return p->type;
if(!val)
return PT_NIL;
if (val[0]=='#')
@ -206,7 +218,6 @@ static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) {
l=NULL;
v=0;
e->type=PT_NIL;
if(!(val))
e->ptr=NULL;
@ -215,10 +226,11 @@ static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) {
i = (int *)val;
e->val=(long)*i;
e->type=PT_INT;
} else if (type==PT_STR) {
} else if (type==PT_STR || type==PT_THM) {
if(!(e->ptr=strdup(val)))
return ECORE_CONFIG_ERR_OOM;
e->type=PT_STR;
if (e->type==PT_NIL)
e->type=type;
} else if (type==PT_RGB) {
if (((char *)val)[0]=='#') {
if((v=strtol(&((char *)val)[1],&l,16))<0) {
@ -240,7 +252,8 @@ static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) {
f = (float *)val;
e->val=(long)((*f)*ECORE_CONFIG_FLOAT_PRECISION);
e->type=PT_FLT;
}
} else
e->type=PT_NIL;
ecore_config_bound(e);
e->flags|=PF_MODIFIED;
@ -282,9 +295,16 @@ static int ecore_config_add_typed(Ecore_Config_Bundle *t, const char *key, void*
static int ecore_config_add(Ecore_Config_Bundle *t,const char *key,char *val) {
int type;
type=ecore_config_guess_type(val);
type=ecore_config_guess_type(key, val);
return ecore_config_add_typed(t,key,val,type); }
void ecore_config_describe(const char *key, char *desc) {
Ecore_Config_Prop *e;
if ((e=ecore_config_get(__ecore_config_bundle_local, key)))
e->description = strdup(desc);
}
int ecore_config_set_typed(Ecore_Config_Bundle *t,const char *key,void *val,int type) {
Ecore_Config_Prop *e;
Ecore_Config_Listener_List *l;
@ -318,7 +338,7 @@ int ecore_config_set(Ecore_Config_Bundle *t,const char *key,char *val) {
int type;
int tmpi;
float tmpf;
type=ecore_config_guess_type(val);
type=ecore_config_guess_type(key, val);
if (type == PT_INT) {
tmpi = atoi(val);
return ecore_config_set_typed(t,key,(void*) &tmpi,type);
@ -343,6 +363,8 @@ int ecore_config_set_float(const char *key, float val) {
int ecore_config_set_rgb(const char *key, char* val) {
return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)val,PT_RGB); }
int ecore_config_set_theme(const char *key, char* val) {
return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)val,PT_THM); }
static int ecore_config_default_typed(Ecore_Config_Bundle *t,const char *key,void *val,int type) {
int ret;
@ -364,7 +386,7 @@ int ecore_config_default(const char *key,char *val,float lo,float hi,float step)
Ecore_Config_Prop *e;
t = __ecore_config_bundle_local;
type=ecore_config_guess_type(val);
type=ecore_config_guess_type(key, val);
ret=ecore_config_default_typed(t, key, val, type);
e=ecore_config_get(t,key);
if (e) {
@ -438,6 +460,11 @@ int ecore_config_default_rgb(const char *key,char *val) {
return ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) val, PT_RGB);
}
int ecore_config_default_theme(const char *key,char *val) {
return ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) val, PT_THM);
}
int ecore_config_listen(const char *name,const char *key,
Ecore_Config_Listener listener,int tag,void *data) {
Ecore_Config_Bundle *t;

View File

@ -62,10 +62,17 @@ int ecore_config_load_file(char *file) {
} else if (!strcmp(type, "str")) {
data = e_db_str_get(db, keys[x]);
if (data) {
if (ecore_config_guess_type(data)==PT_RGB)
ecore_config_set_rgb(keys[x],data);
else
ecore_config_set_string(keys[x],data);
itmp = ecore_config_guess_type(keys[x],data);
switch (itmp) {
case PT_RGB:
ecore_config_set_rgb(keys[x],data);
break;
case PT_THM:
ecore_config_set_theme(keys[x],data);
break;
default:
ecore_config_set_string(keys[x],data);
}
free(data);
} else {
E(0, "Could not read key %s!\n", keys[x]);
@ -135,6 +142,9 @@ int ecore_config_save_file(char *file) {
case PT_STR:
e_db_str_set(db, next->key, ecore_config_get_string(next->key));
break;
case PT_THM:
e_db_str_set(db, next->key, ecore_config_get_theme(next->key));
break;
case PT_NIL:
/* currently we do nothing for undefined ojects */
break;

View File

@ -81,7 +81,7 @@ char *_ecore_config_ipc_global_prop_list(Ecore_Config_Server *srv, const long se
else if (!strcmp(type, "str")) {
data = e_db_str_get(db, keys[x]);
if (data) {
if (ecore_config_guess_type(data)==PT_RGB)
if (ecore_config_guess_type(keys[x], data)==PT_RGB)
estring_appendf(s,"%s%s: colour",f?"\n":"",keys[x]);
else
estring_appendf(s,"%s%s: string",f?"\n":"",keys[x]);