Added types to default calls - this concludes my planned api additions for now

Made edb only save modified (non-default) properties


SVN revision: 8353
This commit is contained in:
handyande 2004-01-12 16:08:08 +00:00 committed by handyande
parent 19fdd7fbe7
commit 1b485c4149
3 changed files with 31 additions and 3 deletions

View File

@ -128,6 +128,11 @@ int ecore_config_set_float(Ecore_Config_Bundle *t,const char *key,flo
int ecore_config_set_as_string(Ecore_Config_Bundle *t,const char *key,char *val);
int ecore_config_default(Ecore_Config_Bundle *t,const char *key,char *val,float lo,float hi,float step);
int ecore_config_default_int(Ecore_Config_Bundle *t,const char *key,int val,int lo,int hi,int step);
int ecore_config_default_string(Ecore_Config_Bundle *t,const char *key,char *val);
int ecore_config_default_float(Ecore_Config_Bundle *t,const char *key,float val,float lo,float hi,float step);
int ecore_config_default_rgb(Ecore_Config_Bundle *t,const char *key,char *val);
int ecore_config_listen(Ecore_Config_Bundle *t,const char *name,const char *key,Ecore_Config_Listener listener,int tag,void *data);
int ecore_config_deaf(Ecore_Config_Bundle *t,const char *name,const char *key,Ecore_Config_Listener listener);
Ecore_Config_Prop *ecore_config_dst(Ecore_Config_Bundle *t,Ecore_Config_Prop *e);

View File

@ -12,7 +12,7 @@
Ecore_Config_Server *ipc_init(char *name);
int ipc_quit(void);
static char *ecore_config_type[]={ "undefined", "integer", "float", "string", "pointer", "colour" };
static char *ecore_config_type[]={ "undefined", "integer", "float", "string", "colour" };
/* tolower, weed out _ - */
char *prop_canonize_key(char *pn,int modify) {
@ -339,12 +339,12 @@ int ecore_config_set_rgb(Ecore_Config_Bundle *t,const char *key, char* val) {
return ecore_config_set_typed(t,key,(void *)val,PT_RGB); }
int ecore_config_default(Ecore_Config_Bundle *t,const char *key,char *val,float lo,float hi,float step) {
static int ecore_config_default_typed(Ecore_Config_Bundle *t,const char *key,void *val,float lo,float hi,float step, int type) {
int ret=ECORE_CONFIG_ERR_SUCC;
Ecore_Config_Prop *e;
if(!(e=ecore_config_get(t,key))) { /* prop doesn't exist yet */
if((ret=ecore_config_add(t,key,val))!=ECORE_CONFIG_ERR_SUCC) /* try to add it */
if((ret=ecore_config_add_typed(t,key,val,type))!=ECORE_CONFIG_ERR_SUCC) /* try to add it */
return ret; /* ...failed */
if(!(e=ecore_config_get(t,key))) /* get handle */
return ECORE_CONFIG_ERR_FAIL;
@ -365,7 +365,26 @@ int ecore_config_default(Ecore_Config_Bundle *t,const char *key,char *val,float
return ret; }
int ecore_config_default(Ecore_Config_Bundle *t,const char *key,char *val,float lo,float hi,float step) {
int type=ecore_config_guess_type(val);
return ecore_config_default_typed(t, key, val, lo, hi, step, type);
}
int ecore_config_default_int(Ecore_Config_Bundle *t,const char *key,int val,int low,int high,int step) {
return ecore_config_default_typed(t, key, (void *) &val, (float) low, (float) high, (float) step, PT_INT);
}
int ecore_config_default_string(Ecore_Config_Bundle *t,const char *key,char *val) {
return ecore_config_default_typed(t, key, (void *) val, (float) 0, (float) 0, (float) 0, PT_STR);
}
int ecore_config_default_float(Ecore_Config_Bundle *t,const char *key,float val,float low,float high,float step) {
return ecore_config_default_typed(t, key, (void *) &val, low, high, step, PT_FLT);
}
int ecore_config_default_rgb(Ecore_Config_Bundle *t,const char *key,char *val) {
return ecore_config_default_typed(t, key, (void *) val, (float) 0, (float) 0, (float) 0, PT_RGB);
}
int ecore_config_listen(Ecore_Config_Bundle *t,const char *name,const char *key,
Ecore_Config_Listener listener,int tag,void *data) {

View File

@ -87,6 +87,10 @@ int ecore_config_save_file(Ecore_Config_Bundle *b, char *file) {
}
while (next) {
if (!(next->flags&PF_MODIFIED)) {
next=next->next;
continue;
}
switch (next->type) {
case PT_INT:
e_db_int_set(db, next->key, ecore_config_get_int(b, next->key));