forked from enlightenment/edi
config: Store relative paths for open files
Avoid problems with moving project or having multiple copies of the same codebase!
This commit is contained in:
parent
1b2ee9a372
commit
14498afdaa
|
@ -508,7 +508,13 @@ _edi_project_config_tab_add(const char *path, Eina_Bool windowed)
|
|||
}
|
||||
|
||||
tab = malloc(sizeof(*tab));
|
||||
tab->path = eina_stringshare_add(path);
|
||||
|
||||
// let's keep paths relative
|
||||
if (!strncmp(path, edi_project_get(), strlen(edi_project_get())))
|
||||
tab->path = eina_stringshare_add(path + strlen(edi_project_get()) + 1);
|
||||
else
|
||||
tab->path = eina_stringshare_add(path);
|
||||
|
||||
tab->windowed = windowed;
|
||||
_edi_project_config->tabs = eina_list_append(_edi_project_config->tabs, tab);
|
||||
_edi_project_config_save_no_notify();
|
||||
|
@ -524,6 +530,9 @@ _edi_project_config_tab_remove(const char *path)
|
|||
{
|
||||
if (!strncmp(tab->path, path, strlen(tab->path)))
|
||||
break;
|
||||
if (!strncmp(path, edi_project_get(), strlen(edi_project_get())) &&
|
||||
!strncmp(path + strlen(edi_project_get()) + 1, tab->path, strlen(tab->path)))
|
||||
break;
|
||||
}
|
||||
|
||||
_edi_project_config->tabs = eina_list_remove(_edi_project_config->tabs, tab);
|
||||
|
|
|
@ -1004,15 +1004,22 @@ _edi_open_tabs()
|
|||
{
|
||||
Edi_Project_Config_Tab *tab;
|
||||
Eina_List *tabs, *list;
|
||||
char *path;
|
||||
|
||||
tabs = _edi_project_config->tabs;
|
||||
_edi_project_config->tabs = NULL;
|
||||
EINA_LIST_FOREACH(tabs, list, tab)
|
||||
{
|
||||
if (tab->windowed)
|
||||
edi_mainview_open_window_path(tab->path);
|
||||
if (!strncmp(tab->path, edi_project_get(), strlen(edi_project_get())))
|
||||
path = strdup(tab->path);
|
||||
else
|
||||
edi_mainview_open_path(tab->path);
|
||||
path = edi_path_append(edi_project_get(), tab->path);
|
||||
|
||||
if (tab->windowed)
|
||||
edi_mainview_open_window_path(eina_stringshare_add(path));
|
||||
else
|
||||
edi_mainview_open_path(eina_stringshare_add(path));
|
||||
free(path);
|
||||
}
|
||||
|
||||
EINA_LIST_FREE(tabs, tab)
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
static Eina_Bool
|
||||
_relative_path_exists(const char *base, const char *relative)
|
||||
{
|
||||
const char *path;
|
||||
char *path;
|
||||
Eina_Bool ret;
|
||||
|
||||
path = edi_path_append(base, relative);
|
||||
ret = ecore_file_exists(path);
|
||||
|
||||
free((void *)path);
|
||||
free(path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ edi_path_options_create(const char *input)
|
|||
return ret;
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
EAPI char *
|
||||
edi_path_append(const char *path, const char *file)
|
||||
{
|
||||
char *concat;
|
||||
|
|
|
@ -49,7 +49,7 @@ EAPI Edi_Path_Options *edi_path_options_create(const char *input);
|
|||
* @return a newly allocated string that merges the items to a path using the
|
||||
* correct separator for the current platform.
|
||||
*/
|
||||
EAPI const char *edi_path_append(const char *path, const char *file);
|
||||
EAPI char *edi_path_append(const char *path, const char *file);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
Loading…
Reference in New Issue