forked from enlightenment/enlightenment
config wites are atomic - either all or nothing. if nothing - u keep your old
config. SVN revision: 24730
This commit is contained in:
parent
eb49750bf0
commit
20a1d9b0a4
|
@ -15,7 +15,7 @@ EAPI E_Config *e_config = NULL;
|
||||||
static int _e_config_save_cb(void *data);
|
static int _e_config_save_cb(void *data);
|
||||||
static void _e_config_free(void);
|
static void _e_config_free(void);
|
||||||
static int _e_config_cb_timer(void *data);
|
static int _e_config_cb_timer(void *data);
|
||||||
static void _e_config_eet_close_handle(Eet_File *ef, char *file);
|
static int _e_config_eet_close_handle(Eet_File *ef, char *file);
|
||||||
|
|
||||||
/* local subsystem globals */
|
/* local subsystem globals */
|
||||||
static int _e_config_save_block = 0;
|
static int _e_config_save_block = 0;
|
||||||
|
@ -1496,7 +1496,7 @@ EAPI int
|
||||||
e_config_profile_save(void)
|
e_config_profile_save(void)
|
||||||
{
|
{
|
||||||
Eet_File *ef;
|
Eet_File *ef;
|
||||||
char buf[4096];
|
char buf[4096], buf2[4096];
|
||||||
char *homedir;
|
char *homedir;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
|
||||||
|
@ -1504,14 +1504,18 @@ e_config_profile_save(void)
|
||||||
homedir = e_user_homedir_get();
|
homedir = e_user_homedir_get();
|
||||||
snprintf(buf, sizeof(buf), "%s/.e/e/config/profile.cfg",
|
snprintf(buf, sizeof(buf), "%s/.e/e/config/profile.cfg",
|
||||||
homedir);
|
homedir);
|
||||||
|
snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
|
||||||
free(homedir);
|
free(homedir);
|
||||||
|
|
||||||
ef = eet_open(buf, EET_FILE_MODE_WRITE);
|
ef = eet_open(buf2, EET_FILE_MODE_WRITE);
|
||||||
if (ef)
|
if (ef)
|
||||||
{
|
{
|
||||||
ok = eet_write(ef, "config", _e_config_profile,
|
ok = eet_write(ef, "config", _e_config_profile,
|
||||||
strlen(_e_config_profile), 0);
|
strlen(_e_config_profile), 0);
|
||||||
_e_config_eet_close_handle(ef, buf);
|
if (_e_config_eet_close_handle(ef, buf2))
|
||||||
|
ecore_file_mv(buf2, buf);
|
||||||
|
else
|
||||||
|
ecore_file_unlink(buf2);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -1520,7 +1524,7 @@ EAPI int
|
||||||
e_config_domain_save(char *domain, E_Config_DD *edd, void *data)
|
e_config_domain_save(char *domain, E_Config_DD *edd, void *data)
|
||||||
{
|
{
|
||||||
Eet_File *ef;
|
Eet_File *ef;
|
||||||
char buf[4096];
|
char buf[4096], buf2[4096];
|
||||||
char *homedir;
|
char *homedir;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
|
||||||
|
@ -1532,12 +1536,16 @@ e_config_domain_save(char *domain, E_Config_DD *edd, void *data)
|
||||||
ecore_file_mkpath(buf);
|
ecore_file_mkpath(buf);
|
||||||
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/%s.cfg",
|
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/%s.cfg",
|
||||||
homedir, _e_config_profile, domain);
|
homedir, _e_config_profile, domain);
|
||||||
|
snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
|
||||||
E_FREE(homedir);
|
E_FREE(homedir);
|
||||||
ef = eet_open(buf, EET_FILE_MODE_WRITE);
|
ef = eet_open(buf, EET_FILE_MODE_WRITE);
|
||||||
if (ef)
|
if (ef)
|
||||||
{
|
{
|
||||||
ok = eet_data_write(ef, edd, "config", data, 1);
|
ok = eet_data_write(ef, edd, "config", data, 1);
|
||||||
_e_config_eet_close_handle(ef, buf);
|
if (_e_config_eet_close_handle(ef, buf2))
|
||||||
|
ecore_file_mv(buf2, buf);
|
||||||
|
else
|
||||||
|
ecore_file_unlink(buf2);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -1860,7 +1868,7 @@ _e_config_cb_timer(void *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
_e_config_eet_close_handle(Eet_File *ef, char *file)
|
_e_config_eet_close_handle(Eet_File *ef, char *file)
|
||||||
{
|
{
|
||||||
Eet_Error err;
|
Eet_Error err;
|
||||||
|
@ -1935,5 +1943,7 @@ _e_config_eet_close_handle(Eet_File *ef, char *file)
|
||||||
ecore_file_unlink(file);
|
ecore_file_unlink(file);
|
||||||
e_util_dialog_show(_("Enlightenment Configration Write Problems"),
|
e_util_dialog_show(_("Enlightenment Configration Write Problems"),
|
||||||
erstr, file);
|
erstr, file);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ _e_wid_fsel_files_selection_change(void *data, Evas_Object *obj, void *event_inf
|
||||||
}
|
}
|
||||||
wd->path = strdup(buf);
|
wd->path = strdup(buf);
|
||||||
if (wd->preview)
|
if (wd->preview)
|
||||||
_e_wid_fsel_preview_file(wd);
|
_e_wid_fsel_preview_file(wd);
|
||||||
e_widget_entry_text_set(wd->o_entry, ici->file);
|
e_widget_entry_text_set(wd->o_entry, ici->file);
|
||||||
evas_list_free(selected);
|
evas_list_free(selected);
|
||||||
if (wd->chg_func) wd->chg_func(wd->chg_data, wd->obj);
|
if (wd->chg_func) wd->chg_func(wd->chg_data, wd->obj);
|
||||||
|
@ -194,7 +194,8 @@ _e_wid_fsel_files_selected(void *data, Evas_Object *obj, void *event_info)
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
e_widget_fsel_add(Evas *evas, char *dev, char *path, char *selected, char *filter,
|
e_widget_fsel_add(Evas *evas, char *dev, char *path, char *selected, char *filter,
|
||||||
void (*sel_func) (void *data, Evas_Object *obj), void *sel_data,
|
void (*sel_func) (void *data, Evas_Object *obj), void *sel_data,
|
||||||
void (*chg_func) (void *data, Evas_Object *obj), void *chg_data, int preview)
|
void (*chg_func) (void *data, Evas_Object *obj), void *chg_data,
|
||||||
|
int preview)
|
||||||
{
|
{
|
||||||
Evas_Object *obj, *o;
|
Evas_Object *obj, *o;
|
||||||
E_Widget_Data *wd;
|
E_Widget_Data *wd;
|
||||||
|
|
Loading…
Reference in New Issue