forked from enlightenment/edi
editor: Remember open tabs and windows.
Store per-project to open what you were last working on in the project
This commit is contained in:
parent
5cbab1fa72
commit
1bcb2cbf95
|
@ -52,6 +52,7 @@ static Edi_Config_DD *_edi_cfg_proj_edd = NULL;
|
||||||
static Edi_Config_DD *_edi_cfg_mime_edd = NULL;
|
static Edi_Config_DD *_edi_cfg_mime_edd = NULL;
|
||||||
|
|
||||||
static Edi_Project_Config_DD *_edi_proj_cfg_edd = NULL;
|
static Edi_Project_Config_DD *_edi_proj_cfg_edd = NULL;
|
||||||
|
static Edi_Project_Config_DD *_edi_proj_cfg_tab_edd = NULL;
|
||||||
|
|
||||||
/* external variables */
|
/* external variables */
|
||||||
Edi_Config *_edi_config = NULL;
|
Edi_Config *_edi_config = NULL;
|
||||||
|
@ -120,6 +121,14 @@ _edi_config_cb_free(void)
|
||||||
static void
|
static void
|
||||||
_edi_project_config_cb_free(void)
|
_edi_project_config_cb_free(void)
|
||||||
{
|
{
|
||||||
|
Edi_Project_Config_Tab *tab;
|
||||||
|
|
||||||
|
EINA_LIST_FREE(_edi_project_config->tabs, tab)
|
||||||
|
{
|
||||||
|
if (tab->path) eina_stringshare_del(tab->path);
|
||||||
|
free(tab);
|
||||||
|
}
|
||||||
|
|
||||||
free(_edi_project_config);
|
free(_edi_project_config);
|
||||||
_edi_project_config = NULL;
|
_edi_project_config = NULL;
|
||||||
}
|
}
|
||||||
|
@ -209,6 +218,14 @@ _edi_config_init(void)
|
||||||
EDI_CONFIG_LIST(D, T, projects, _edi_cfg_proj_edd);
|
EDI_CONFIG_LIST(D, T, projects, _edi_cfg_proj_edd);
|
||||||
EDI_CONFIG_LIST(D, T, mime_assocs, _edi_cfg_mime_edd);
|
EDI_CONFIG_LIST(D, T, mime_assocs, _edi_cfg_mime_edd);
|
||||||
|
|
||||||
|
_edi_proj_cfg_tab_edd = EDI_CONFIG_DD_NEW("Project_Config_Tab", Edi_Project_Config_Tab);
|
||||||
|
#undef T
|
||||||
|
#undef D
|
||||||
|
#define T Edi_Project_Config_Tab
|
||||||
|
#define D _edi_proj_cfg_tab_edd
|
||||||
|
EDI_CONFIG_VAL(D, T, path, EET_T_STRING);
|
||||||
|
EDI_CONFIG_VAL(D, T, windowed, EET_T_UCHAR);
|
||||||
|
|
||||||
_edi_proj_cfg_edd = EDI_CONFIG_DD_NEW("Project_Config", Edi_Project_Config);
|
_edi_proj_cfg_edd = EDI_CONFIG_DD_NEW("Project_Config", Edi_Project_Config);
|
||||||
#undef T
|
#undef T
|
||||||
#undef D
|
#undef D
|
||||||
|
@ -228,6 +245,8 @@ _edi_config_init(void)
|
||||||
EDI_CONFIG_VAL(D, T, gui.width_marker, EET_T_UINT);
|
EDI_CONFIG_VAL(D, T, gui.width_marker, EET_T_UINT);
|
||||||
EDI_CONFIG_VAL(D, T, gui.tabstop, EET_T_UINT);
|
EDI_CONFIG_VAL(D, T, gui.tabstop, EET_T_UINT);
|
||||||
|
|
||||||
|
EDI_CONFIG_LIST(D, T, tabs, _edi_proj_cfg_tab_edd);
|
||||||
|
|
||||||
_edi_config_load();
|
_edi_config_load();
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
@ -244,6 +263,7 @@ _edi_config_shutdown(void)
|
||||||
EDI_CONFIG_DD_FREE(_edi_cfg_edd);
|
EDI_CONFIG_DD_FREE(_edi_cfg_edd);
|
||||||
|
|
||||||
EDI_CONFIG_DD_FREE(_edi_proj_cfg_edd);
|
EDI_CONFIG_DD_FREE(_edi_proj_cfg_edd);
|
||||||
|
EDI_CONFIG_DD_FREE(_edi_proj_cfg_tab_edd);
|
||||||
|
|
||||||
efreet_shutdown();
|
efreet_shutdown();
|
||||||
|
|
||||||
|
@ -420,6 +440,8 @@ _edi_project_config_load()
|
||||||
|
|
||||||
_edi_project_config->gui.width_marker = 80;
|
_edi_project_config->gui.width_marker = 80;
|
||||||
_edi_project_config->gui.tabstop = 8;
|
_edi_project_config->gui.tabstop = 8;
|
||||||
|
|
||||||
|
_edi_project_config->tabs = NULL;
|
||||||
IFPCFGEND;
|
IFPCFGEND;
|
||||||
|
|
||||||
/* limit config values so they are sane */
|
/* limit config values so they are sane */
|
||||||
|
@ -435,10 +457,53 @@ _edi_project_config_load()
|
||||||
if (save) _edi_project_config_save();
|
if (save) _edi_project_config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_edi_project_config_save_no_notify()
|
||||||
|
{
|
||||||
|
return _edi_config_domain_save(_edi_project_config_dir_get(), PACKAGE_NAME, _edi_proj_cfg_edd, _edi_project_config);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_edi_project_config_save()
|
_edi_project_config_save()
|
||||||
{
|
{
|
||||||
if (_edi_config_domain_save(_edi_project_config_dir_get(), PACKAGE_NAME, _edi_proj_cfg_edd, _edi_project_config))
|
if (_edi_project_config_save_no_notify())
|
||||||
ecore_event_add(EDI_EVENT_CONFIG_CHANGED, NULL, NULL, NULL);
|
ecore_event_add(EDI_EVENT_CONFIG_CHANGED, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_edi_project_config_tab_add(const char *path, Eina_Bool windowed)
|
||||||
|
{
|
||||||
|
Edi_Project_Config_Tab *tab;
|
||||||
|
Eina_List *list, *next;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH_SAFE(_edi_project_config->tabs, list, next, tab)
|
||||||
|
{
|
||||||
|
if (!strncmp(tab->path, path, strlen(tab->path)))
|
||||||
|
_edi_project_config->tabs = eina_list_remove_list(_edi_project_config->tabs, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
tab = malloc(sizeof(*tab));
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_edi_project_config_tab_remove(const char *path)
|
||||||
|
{
|
||||||
|
Edi_Project_Config_Tab *tab;
|
||||||
|
Eina_List *list, *next;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH_SAFE(_edi_project_config->tabs, list, next, tab)
|
||||||
|
{
|
||||||
|
if (!strncmp(tab->path, path, strlen(tab->path)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_edi_project_config->tabs = eina_list_remove(_edi_project_config->tabs, tab);
|
||||||
|
_edi_project_config_save_no_notify();
|
||||||
|
|
||||||
|
eina_stringshare_del(tab->path);
|
||||||
|
free(tab);
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ typedef struct _Edi_Config_Mime_Association Edi_Config_Mime_Association;
|
||||||
typedef struct _Edi_Config Edi_Config;
|
typedef struct _Edi_Config Edi_Config;
|
||||||
|
|
||||||
typedef struct _Edi_Project_Config Edi_Project_Config;
|
typedef struct _Edi_Project_Config Edi_Project_Config;
|
||||||
|
typedef struct _Edi_Project_Config_Tab Edi_Project_Config_Tab;
|
||||||
|
|
||||||
struct _Edi_Config_Project
|
struct _Edi_Config_Project
|
||||||
{
|
{
|
||||||
|
@ -39,6 +40,12 @@ struct _Edi_Config
|
||||||
Eina_List *mime_assocs;
|
Eina_List *mime_assocs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _Edi_Project_Config_Tab
|
||||||
|
{
|
||||||
|
const char *path;
|
||||||
|
Eina_Bool windowed;
|
||||||
|
};
|
||||||
|
|
||||||
struct _Edi_Project_Config
|
struct _Edi_Project_Config
|
||||||
{
|
{
|
||||||
int version;
|
int version;
|
||||||
|
@ -57,17 +64,22 @@ struct _Edi_Project_Config
|
||||||
Eina_Bool show_whitespace;
|
Eina_Bool show_whitespace;
|
||||||
unsigned int width_marker, tabstop;
|
unsigned int width_marker, tabstop;
|
||||||
} gui;
|
} gui;
|
||||||
|
|
||||||
|
Eina_List *tabs;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Edi_Config *_edi_config;
|
extern Edi_Config *_edi_config;
|
||||||
extern Edi_Project_Config *_edi_project_config;
|
extern Edi_Project_Config *_edi_project_config;
|
||||||
|
|
||||||
|
// General configuration management
|
||||||
|
|
||||||
Eina_Bool _edi_config_init(void);
|
Eina_Bool _edi_config_init(void);
|
||||||
Eina_Bool _edi_config_shutdown(void);
|
Eina_Bool _edi_config_shutdown(void);
|
||||||
|
|
||||||
|
// Global configuration handling
|
||||||
|
|
||||||
void _edi_config_load(void);
|
void _edi_config_load(void);
|
||||||
void _edi_config_save(void);
|
void _edi_config_save(void);
|
||||||
void _edi_project_config_load();
|
|
||||||
void _edi_project_config_save();
|
|
||||||
|
|
||||||
void _edi_config_project_add(const char *path);
|
void _edi_config_project_add(const char *path);
|
||||||
void _edi_config_project_remove(const char *path);
|
void _edi_config_project_remove(const char *path);
|
||||||
|
@ -75,6 +87,14 @@ void _edi_config_project_remove(const char *path);
|
||||||
void _edi_config_mime_add(const char *mime, const char* id);
|
void _edi_config_mime_add(const char *mime, const char* id);
|
||||||
const char* _edi_config_mime_search(const char *mime);
|
const char* _edi_config_mime_search(const char *mime);
|
||||||
|
|
||||||
|
// Project based configuration handling
|
||||||
|
|
||||||
|
void _edi_project_config_load(void);
|
||||||
|
void _edi_project_config_save(void);
|
||||||
|
|
||||||
|
void _edi_project_config_tab_add(const char *path, Eina_Bool windowed);
|
||||||
|
void _edi_project_config_tab_remove(const char *path);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -760,6 +760,21 @@ _edi_resize_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
|
||||||
_edi_project_config_save();
|
_edi_project_config_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_edi_open_tabs()
|
||||||
|
{
|
||||||
|
Edi_Project_Config_Tab *tab;
|
||||||
|
Eina_List *list, *next;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH_SAFE(_edi_project_config->tabs, list, next, tab)
|
||||||
|
{
|
||||||
|
if (tab->windowed)
|
||||||
|
edi_mainview_open_window_path(tab->path);
|
||||||
|
else
|
||||||
|
edi_mainview_open_path(tab->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Evas_Object *
|
Evas_Object *
|
||||||
edi_open(const char *inputpath)
|
edi_open(const char *inputpath)
|
||||||
{
|
{
|
||||||
|
@ -807,6 +822,7 @@ edi_open(const char *inputpath)
|
||||||
evas_object_show(win);
|
evas_object_show(win);
|
||||||
|
|
||||||
_edi_config_project_add(path);
|
_edi_config_project_add(path);
|
||||||
|
_edi_open_tabs();
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
return win;
|
return win;
|
||||||
|
|
|
@ -196,6 +196,7 @@ _edi_mainview_item_tab_add(Edi_Path_Options *options, const char *mime)
|
||||||
|
|
||||||
if (options->line)
|
if (options->line)
|
||||||
edi_mainview_goto(options->line);
|
edi_mainview_goto(options->line);
|
||||||
|
_edi_project_config_tab_add(options->path, EINA_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -207,6 +208,8 @@ _edi_mainview_win_exit(void *data EINA_UNUSED, Evas_Object *obj, void *event_inf
|
||||||
|
|
||||||
it = evas_object_data_get(obj, "edi_mainview_item");
|
it = evas_object_data_get(obj, "edi_mainview_item");
|
||||||
_edi_mainview_items = eina_list_remove(_edi_mainview_items, it);
|
_edi_mainview_items = eina_list_remove(_edi_mainview_items, it);
|
||||||
|
|
||||||
|
_edi_project_config_tab_remove(it->path);
|
||||||
eina_stringshare_del(it->path);
|
eina_stringshare_del(it->path);
|
||||||
free(it);
|
free(it);
|
||||||
}
|
}
|
||||||
|
@ -248,6 +251,7 @@ _edi_mainview_item_win_add(Edi_Path_Options *options, const char *mime)
|
||||||
|
|
||||||
evas_object_resize(win, 380 * elm_config_scale_get(), 260 * elm_config_scale_get());
|
evas_object_resize(win, 380 * elm_config_scale_get(), 260 * elm_config_scale_get());
|
||||||
evas_object_show(win);
|
evas_object_show(win);
|
||||||
|
_edi_project_config_tab_add(options->path, EINA_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -507,6 +511,7 @@ edi_mainview_close()
|
||||||
elm_object_item_del(elm_toolbar_selected_item_get(tb));
|
elm_object_item_del(elm_toolbar_selected_item_get(tb));
|
||||||
_edi_mainview_items = eina_list_remove(_edi_mainview_items, item);
|
_edi_mainview_items = eina_list_remove(_edi_mainview_items, item);
|
||||||
|
|
||||||
|
_edi_project_config_tab_remove(item->path);
|
||||||
eina_stringshare_del(item->path);
|
eina_stringshare_del(item->path);
|
||||||
free(item);
|
free(item);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue