2014-10-23 21:21:10 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <Eio.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
2016-08-15 00:49:35 -07:00
|
|
|
#define FILE_QUEUE_CNT 20
|
|
|
|
|
2014-10-23 21:21:10 -07:00
|
|
|
typedef struct file_mgr_s {
|
2016-08-15 00:49:35 -07:00
|
|
|
Eina_List *file_queue;
|
2014-10-23 21:21:10 -07:00
|
|
|
Evas_Object *warning_layout;
|
2016-08-15 00:49:35 -07:00
|
|
|
Enventor_Item *focused_it;
|
2015-07-03 04:22:36 -07:00
|
|
|
Eina_Bool edc_modified : 1;
|
2016-08-15 00:49:35 -07:00
|
|
|
Eina_Bool no_queue : 1; //file queueing?
|
2014-10-23 21:21:10 -07:00
|
|
|
} file_mgr_data;
|
|
|
|
|
|
|
|
static file_mgr_data *g_fmd = NULL;
|
|
|
|
|
2016-07-01 02:58:26 -07:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Internal method implementation */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2014-10-23 21:21:10 -07:00
|
|
|
static void
|
|
|
|
warning_dismiss_done(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = data;
|
|
|
|
evas_object_del(fmd->warning_layout);
|
2016-01-22 02:53:32 -08:00
|
|
|
enventor_object_focus_set(base_enventor_get(), EINA_TRUE);
|
2014-10-23 21:21:10 -07:00
|
|
|
fmd->warning_layout = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
warning_close(file_mgr_data *fmd)
|
|
|
|
{
|
|
|
|
elm_object_signal_emit(fmd->warning_layout, "elm,state,dismiss", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-10-23 21:35:17 -07:00
|
|
|
warning_ignore_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2014-10-23 21:21:10 -07:00
|
|
|
{
|
|
|
|
file_mgr_data *fmd = data;
|
2016-07-03 23:09:26 -07:00
|
|
|
|
|
|
|
//FIXME: Specify which file has been changed?
|
|
|
|
Enventor_Item *it = enventor_object_focused_item_get(base_enventor_get());
|
|
|
|
enventor_item_modified_set(it, EINA_TRUE);
|
|
|
|
|
2014-10-23 21:21:10 -07:00
|
|
|
warning_close(fmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-10-23 21:35:17 -07:00
|
|
|
warning_save_as_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2014-10-23 21:21:10 -07:00
|
|
|
{
|
|
|
|
file_mgr_data *fmd = data;
|
2016-07-03 23:09:26 -07:00
|
|
|
|
|
|
|
//FIXME: Sepcify which file has been changed?
|
|
|
|
Enventor_Item *it = enventor_object_focused_item_get(base_enventor_get());
|
|
|
|
enventor_item_modified_set(it, EINA_TRUE);
|
|
|
|
|
2014-10-23 21:21:10 -07:00
|
|
|
menu_edc_save();
|
|
|
|
warning_close(fmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-10-23 21:35:17 -07:00
|
|
|
warning_replace_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2014-10-23 21:21:10 -07:00
|
|
|
{
|
|
|
|
file_mgr_data *fmd = data;
|
2016-07-03 23:09:26 -07:00
|
|
|
|
|
|
|
//FIXME: Specify which file has been changed?
|
2016-07-01 23:39:10 -07:00
|
|
|
file_mgr_main_file_set(config_input_path_get());
|
2016-07-03 23:09:26 -07:00
|
|
|
|
2014-10-23 21:21:10 -07:00
|
|
|
warning_close(fmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-10-23 21:35:17 -07:00
|
|
|
warning_open(file_mgr_data *fmd)
|
2014-10-23 21:21:10 -07:00
|
|
|
{
|
|
|
|
if (fmd->warning_layout) return;
|
|
|
|
|
|
|
|
//Layout
|
|
|
|
Evas_Object *layout = elm_layout_add(base_win_get());
|
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "warning_layout");
|
|
|
|
elm_object_part_text_set(layout, "elm.text.desc",
|
2015-11-17 09:39:22 -08:00
|
|
|
_("EDC has been changed on the file system."));
|
2014-10-23 21:21:10 -07:00
|
|
|
elm_object_part_text_set(layout, "elm.text.question",
|
2015-11-17 09:39:22 -08:00
|
|
|
_("Do you want to replace the contents?"));
|
2014-10-23 21:21:10 -07:00
|
|
|
elm_object_signal_callback_add(layout, "elm,state,dismiss,done", "",
|
|
|
|
warning_dismiss_done, fmd);
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_show(layout);
|
|
|
|
base_win_resize_object_add(layout);
|
|
|
|
|
|
|
|
Evas_Object *btn;
|
|
|
|
|
2014-10-23 21:35:17 -07:00
|
|
|
//Save As Button
|
2014-10-23 21:21:10 -07:00
|
|
|
btn = elm_button_add(layout);
|
2015-11-17 09:39:22 -08:00
|
|
|
elm_object_text_set(btn, _("Save As"));
|
2014-10-23 21:35:17 -07:00
|
|
|
evas_object_smart_callback_add(btn, "clicked", warning_save_as_btn_cb, fmd);
|
2014-10-23 21:21:10 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.btn1", btn);
|
2014-11-01 01:10:36 -07:00
|
|
|
evas_object_show(btn);
|
|
|
|
elm_object_focus_set(btn, EINA_TRUE);
|
2014-10-23 21:21:10 -07:00
|
|
|
|
2014-10-23 21:35:17 -07:00
|
|
|
//Replace Button
|
2014-10-23 21:21:10 -07:00
|
|
|
btn = elm_button_add(layout);
|
2015-11-17 09:39:22 -08:00
|
|
|
elm_object_text_set(btn, _("Replace"));
|
2014-10-23 21:35:17 -07:00
|
|
|
evas_object_smart_callback_add(btn, "clicked", warning_replace_btn_cb, fmd);
|
2014-10-23 21:21:10 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.btn2", btn);
|
|
|
|
|
2014-10-23 21:35:17 -07:00
|
|
|
//Igrore Button
|
2014-10-23 21:21:10 -07:00
|
|
|
btn = elm_button_add(layout);
|
2015-11-17 09:39:22 -08:00
|
|
|
elm_object_text_set(btn, _("Ignore"));
|
2014-10-23 21:35:17 -07:00
|
|
|
evas_object_smart_callback_add(btn, "clicked", warning_ignore_btn_cb, fmd);
|
2014-10-23 21:21:10 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.btn3", btn);
|
|
|
|
|
|
|
|
fmd->warning_layout = layout;
|
2014-11-01 02:21:13 -07:00
|
|
|
|
2015-07-03 04:22:36 -07:00
|
|
|
fmd->edc_modified = EINA_FALSE;
|
2014-10-23 21:21:10 -07:00
|
|
|
}
|
|
|
|
|
2014-10-23 21:36:46 -07:00
|
|
|
static void
|
2014-11-01 01:23:20 -07:00
|
|
|
enventor_edc_modified_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
2014-10-23 21:21:10 -07:00
|
|
|
{
|
2014-11-01 01:23:20 -07:00
|
|
|
file_mgr_data *fmd = data;
|
2014-11-01 01:31:02 -07:00
|
|
|
Enventor_EDC_Modified *modified = event_info;
|
2014-10-23 21:21:10 -07:00
|
|
|
|
2015-02-12 20:42:33 -08:00
|
|
|
//Reset console messages.
|
|
|
|
base_console_reset();
|
|
|
|
|
2014-10-23 21:21:10 -07:00
|
|
|
if (modified->self_changed)
|
|
|
|
{
|
2015-07-03 04:22:36 -07:00
|
|
|
fmd->edc_modified = EINA_FALSE;
|
2014-10-23 21:36:46 -07:00
|
|
|
return;
|
2014-10-23 21:21:10 -07:00
|
|
|
}
|
|
|
|
|
2015-07-03 04:22:36 -07:00
|
|
|
fmd->edc_modified = EINA_TRUE;
|
2014-11-01 02:21:13 -07:00
|
|
|
|
2016-09-01 04:07:37 -07:00
|
|
|
/* FIXME: Here ignore edc changes, if any menu is closed,
|
2014-11-01 02:21:13 -07:00
|
|
|
then we need to open warning box. */
|
|
|
|
if (menu_activated_get()) return;
|
2014-10-23 21:21:10 -07:00
|
|
|
|
2014-10-23 21:35:17 -07:00
|
|
|
warning_open(fmd);
|
2014-11-01 02:21:13 -07:00
|
|
|
}
|
2014-10-23 21:35:17 -07:00
|
|
|
|
2016-08-15 00:49:35 -07:00
|
|
|
static void
|
|
|
|
file_mgr_file_push(file_mgr_data *fmd, const char *file)
|
|
|
|
{
|
|
|
|
if (!file) return;
|
|
|
|
if (fmd->no_queue) return;
|
|
|
|
|
|
|
|
//Prevent overflow. Remove first node.
|
|
|
|
if (eina_list_count(fmd->file_queue) >= FILE_QUEUE_CNT)
|
|
|
|
fmd->file_queue = eina_list_remove_list(fmd->file_queue, fmd->file_queue);
|
|
|
|
|
|
|
|
//Append new file.
|
|
|
|
Eina_Stringshare *tmp = eina_stringshare_add(file);
|
|
|
|
fmd->file_queue = eina_list_append(fmd->file_queue, tmp);
|
|
|
|
}
|
|
|
|
|
2016-07-01 02:58:26 -07:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Externally accessible calls */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2014-11-01 02:21:13 -07:00
|
|
|
void
|
|
|
|
file_mgr_reset(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
2016-07-01 02:58:26 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(fmd);
|
|
|
|
|
2015-07-03 04:22:36 -07:00
|
|
|
fmd->edc_modified = EINA_FALSE;
|
2014-11-01 02:21:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
file_mgr_edc_modified_get(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
2016-07-01 22:09:42 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(fmd, 0);
|
2016-07-01 02:58:26 -07:00
|
|
|
|
2015-07-03 04:22:36 -07:00
|
|
|
return fmd->edc_modified;
|
2014-10-23 21:21:10 -07:00
|
|
|
}
|
|
|
|
|
2015-02-25 21:22:30 -08:00
|
|
|
void
|
|
|
|
file_mgr_edc_save(void)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2016-07-02 16:50:47 -07:00
|
|
|
Enventor_Item *it = file_mgr_focused_item_get();
|
|
|
|
Eina_Bool save_success = enventor_item_file_save(it, NULL);
|
2015-02-28 21:11:00 -08:00
|
|
|
if (!config_stats_bar_get()) return;
|
|
|
|
|
|
|
|
if (save_success)
|
2015-11-17 09:39:22 -08:00
|
|
|
snprintf(buf, sizeof(buf), _("File saved. \"%s\""), config_input_path_get());
|
2015-02-25 21:22:30 -08:00
|
|
|
else
|
2015-11-17 09:39:22 -08:00
|
|
|
snprintf(buf, sizeof(buf), _("Already saved. \"%s\""), config_input_path_get());
|
2015-02-25 21:22:30 -08:00
|
|
|
|
|
|
|
stats_info_msg_update(buf);
|
|
|
|
}
|
|
|
|
|
2014-10-31 08:56:56 -07:00
|
|
|
Eina_Bool
|
|
|
|
file_mgr_warning_is_opened(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
2016-07-01 02:58:26 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(fmd, EINA_FALSE);
|
|
|
|
|
|
|
|
return (fmd->warning_layout ? EINA_TRUE : EINA_FALSE);
|
2014-10-31 08:56:56 -07:00
|
|
|
}
|
|
|
|
|
2014-11-01 02:21:13 -07:00
|
|
|
void
|
|
|
|
file_mgr_warning_open(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
2016-07-01 02:58:26 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(fmd);
|
|
|
|
|
2014-11-01 02:21:13 -07:00
|
|
|
warning_open(fmd);
|
|
|
|
}
|
|
|
|
|
2014-10-31 08:56:56 -07:00
|
|
|
void
|
|
|
|
file_mgr_warning_close(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
2016-07-01 02:58:26 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(fmd);
|
2014-10-31 08:56:56 -07:00
|
|
|
|
|
|
|
if (fmd->warning_layout)
|
|
|
|
warning_close(fmd);
|
|
|
|
}
|
|
|
|
|
2014-10-23 21:21:10 -07:00
|
|
|
void
|
2016-01-22 02:53:32 -08:00
|
|
|
file_mgr_init(void)
|
2014-10-23 21:21:10 -07:00
|
|
|
{
|
|
|
|
file_mgr_data *fmd = calloc(1, sizeof(file_mgr_data));
|
|
|
|
if (!fmd)
|
|
|
|
{
|
2016-06-29 04:41:39 -07:00
|
|
|
mem_fail_msg();
|
2014-10-23 21:21:10 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_fmd = fmd;
|
|
|
|
|
2016-01-22 02:53:32 -08:00
|
|
|
evas_object_smart_callback_add(base_enventor_get(), "edc,modified",
|
2014-10-23 21:21:10 -07:00
|
|
|
enventor_edc_modified_cb, fmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_mgr_term(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
2016-08-05 12:58:16 -07:00
|
|
|
if (!fmd) return;
|
2016-07-01 02:58:26 -07:00
|
|
|
|
2016-08-15 00:49:35 -07:00
|
|
|
//Remove file queue
|
|
|
|
Eina_Stringshare *file;
|
|
|
|
EINA_LIST_FREE(fmd->file_queue, file)
|
|
|
|
eina_stringshare_del(file);
|
|
|
|
|
2014-10-23 21:21:10 -07:00
|
|
|
free(fmd);
|
|
|
|
}
|
2016-07-01 23:39:10 -07:00
|
|
|
|
2016-08-08 07:58:08 -07:00
|
|
|
void
|
|
|
|
file_mgr_file_del(Enventor_Item *it)
|
|
|
|
{
|
|
|
|
if (!it) return;
|
2016-08-19 00:22:04 -07:00
|
|
|
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
|
|
|
|
|
|
|
if (fmd->focused_it == it)
|
|
|
|
fmd->focused_it = NULL;
|
|
|
|
|
2016-08-08 07:58:08 -07:00
|
|
|
file_tab_it_remove(it);
|
|
|
|
}
|
|
|
|
|
2016-07-01 23:39:10 -07:00
|
|
|
Enventor_Item *
|
2016-08-08 09:10:27 -07:00
|
|
|
file_mgr_sub_file_add(const char *path, Eina_Bool focus)
|
2016-07-01 23:39:10 -07:00
|
|
|
{
|
|
|
|
Enventor_Item *it = enventor_object_sub_item_add(base_enventor_get(), path);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(it, NULL);
|
|
|
|
|
|
|
|
file_tab_it_add(it);
|
2016-08-15 00:49:35 -07:00
|
|
|
if (focus) file_mgr_file_focus(it);
|
2016-07-01 23:39:10 -07:00
|
|
|
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
|
|
|
Enventor_Item *
|
|
|
|
file_mgr_main_file_set(const char *path)
|
|
|
|
{
|
2016-08-15 00:49:35 -07:00
|
|
|
file_mgr_data *fmd = g_fmd;
|
|
|
|
if (!fmd) return NULL;
|
|
|
|
|
2016-08-08 07:58:08 -07:00
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("No path??");
|
|
|
|
return NULL;
|
|
|
|
}
|
2016-07-01 23:39:10 -07:00
|
|
|
|
2016-08-08 09:02:46 -07:00
|
|
|
char *realpath;
|
|
|
|
|
|
|
|
if (ecore_file_exists(path))
|
|
|
|
realpath = ecore_file_realpath(path);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//This main file is not created yet.
|
|
|
|
FILE *fp = fopen(path, "w");
|
|
|
|
if (fp) fclose(fp);
|
|
|
|
realpath = ecore_file_realpath(path);
|
|
|
|
}
|
2016-08-08 07:58:08 -07:00
|
|
|
|
|
|
|
//If this file is already openend with sub file, remove it.
|
|
|
|
Eina_List *sub_its =
|
|
|
|
(Eina_List *) enventor_object_sub_items_get(base_enventor_get());
|
|
|
|
Eina_List *l;
|
2016-08-11 11:55:51 -07:00
|
|
|
Enventor_Item *it;
|
2016-08-15 00:49:35 -07:00
|
|
|
Eina_Bool replace_focus = EINA_FALSE;
|
2016-08-11 11:55:51 -07:00
|
|
|
|
2016-08-08 07:58:08 -07:00
|
|
|
EINA_LIST_FOREACH(sub_its, l, it)
|
|
|
|
{
|
|
|
|
const char *path2 = enventor_item_file_get(it);
|
|
|
|
if (!path2) continue;
|
|
|
|
if (strcmp(realpath, path2)) continue;
|
2016-08-11 11:55:51 -07:00
|
|
|
file_mgr_file_del(it);
|
2016-08-23 07:34:39 -07:00
|
|
|
if (!fmd->focused_it)
|
2016-08-15 00:49:35 -07:00
|
|
|
replace_focus = EINA_TRUE;
|
2016-08-08 07:58:08 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-11 11:55:51 -07:00
|
|
|
//Replace the current main file to a sub file.
|
|
|
|
Enventor_Item *main_it = file_mgr_main_item_get();
|
|
|
|
if (main_it)
|
2016-08-08 07:58:08 -07:00
|
|
|
{
|
2016-08-11 11:55:51 -07:00
|
|
|
const char *prev_path = enventor_item_file_get(main_it);
|
|
|
|
if (prev_path)
|
|
|
|
{
|
2016-08-23 07:47:28 -07:00
|
|
|
//Replace the current main file if it is not the new main file.
|
|
|
|
if (strcmp(realpath, prev_path))
|
|
|
|
{
|
|
|
|
Enventor_Item *it2 = file_mgr_sub_file_add(prev_path,
|
|
|
|
EINA_FALSE);
|
|
|
|
if (fmd->focused_it == main_it)
|
|
|
|
fmd->focused_it = it2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
replace_focus = EINA_TRUE;
|
|
|
|
|
2016-08-11 11:55:51 -07:00
|
|
|
file_mgr_file_del(main_it);
|
|
|
|
}
|
2016-08-08 07:58:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
main_it = enventor_object_main_item_set(base_enventor_get(), realpath);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(main_it, NULL);
|
|
|
|
|
2016-08-15 00:49:35 -07:00
|
|
|
if (replace_focus)
|
|
|
|
fmd->focused_it = main_it;
|
|
|
|
|
2016-08-08 07:58:08 -07:00
|
|
|
file_tab_it_add(main_it);
|
|
|
|
file_mgr_file_focus(main_it);
|
2016-07-01 23:39:10 -07:00
|
|
|
base_console_reset();
|
|
|
|
|
2016-08-08 07:58:08 -07:00
|
|
|
free(realpath);
|
|
|
|
|
|
|
|
return main_it;
|
2016-07-01 23:39:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
file_mgr_file_focus(Enventor_Item *it)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(it);
|
|
|
|
|
2016-08-15 00:49:35 -07:00
|
|
|
file_mgr_data *fmd = g_fmd;
|
|
|
|
|
|
|
|
if (fmd->focused_it && (fmd->focused_it != it))
|
|
|
|
file_mgr_file_push(fmd, enventor_item_file_get(fmd->focused_it));
|
|
|
|
|
2016-07-01 23:39:10 -07:00
|
|
|
file_tab_it_select(it);
|
2016-07-07 04:34:42 -07:00
|
|
|
enventor_item_represent(it);
|
2016-07-01 23:39:10 -07:00
|
|
|
base_title_set(enventor_item_file_get(it));
|
2016-07-21 21:26:51 -07:00
|
|
|
base_edc_navigator_group_update();
|
2016-08-15 00:49:35 -07:00
|
|
|
fmd->focused_it = it;
|
2016-07-02 01:32:11 -07:00
|
|
|
|
2016-07-21 21:26:51 -07:00
|
|
|
//Reset file based contexts.
|
2016-07-02 01:32:11 -07:00
|
|
|
search_reset();
|
2016-07-21 21:26:51 -07:00
|
|
|
goto_close();
|
2016-07-20 02:51:53 -07:00
|
|
|
live_edit_cancel(EINA_FALSE);
|
2016-07-02 01:32:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Enventor_Item *
|
|
|
|
file_mgr_focused_item_get(void)
|
|
|
|
{
|
|
|
|
return enventor_object_focused_item_get(base_enventor_get());
|
2016-07-01 23:39:10 -07:00
|
|
|
}
|
2016-07-02 16:50:47 -07:00
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
file_mgr_save_all(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(fmd, EINA_FALSE);
|
|
|
|
|
|
|
|
if (!fmd->edc_modified) return EINA_TRUE;
|
|
|
|
|
|
|
|
Enventor_Item *it;
|
|
|
|
Eina_Bool ret = EINA_TRUE;
|
|
|
|
|
|
|
|
//Main file.
|
|
|
|
it = file_mgr_main_item_get();
|
|
|
|
if (!enventor_item_file_save(it, NULL)) ret = EINA_FALSE;
|
|
|
|
|
2016-07-03 23:09:26 -07:00
|
|
|
//Sub files.
|
2016-07-02 16:50:47 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Eina_List *sub_its =
|
|
|
|
(Eina_List *) enventor_object_sub_items_get(base_enventor_get());
|
|
|
|
EINA_LIST_FOREACH(sub_its, l, it)
|
|
|
|
{
|
|
|
|
if (!enventor_item_file_save(it, NULL)) ret = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fmd->edc_modified = EINA_FALSE;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
Enventor_Item *
|
|
|
|
file_mgr_main_item_get(void)
|
|
|
|
{
|
|
|
|
return enventor_object_main_item_get(base_enventor_get());
|
|
|
|
}
|
2016-07-03 23:09:26 -07:00
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
file_mgr_modified_get(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(fmd, EINA_FALSE);
|
|
|
|
|
|
|
|
Enventor_Item *it;
|
|
|
|
|
|
|
|
//Main file.
|
|
|
|
it = file_mgr_main_item_get();
|
|
|
|
if (enventor_item_modified_get(it)) return EINA_TRUE;
|
|
|
|
|
|
|
|
//Sub files.
|
|
|
|
Eina_List *l;
|
|
|
|
Eina_List *sub_its =
|
|
|
|
(Eina_List *) enventor_object_sub_items_get(base_enventor_get());
|
|
|
|
EINA_LIST_FOREACH(sub_its, l, it)
|
|
|
|
{
|
|
|
|
if (enventor_item_modified_get(it)) return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2016-07-22 00:13:50 -07:00
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
file_mgr_file_open(const char *file_path)
|
|
|
|
{
|
|
|
|
if (!file_path) return EINA_FALSE;
|
|
|
|
|
|
|
|
//skip non edc nor header files.
|
|
|
|
if (!(eina_str_has_extension(file_path, "edc") ||
|
|
|
|
eina_str_has_extension(file_path, "h"))) return EINA_FALSE;
|
|
|
|
|
|
|
|
Enventor_Item *eit;
|
|
|
|
const char *it_file_path;
|
|
|
|
|
|
|
|
//Case 1. main file.
|
|
|
|
eit = file_mgr_main_item_get();
|
|
|
|
if (eit)
|
|
|
|
{
|
|
|
|
it_file_path = enventor_item_file_get(eit);
|
|
|
|
if (!it_file_path)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("No main item file path??");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
//Ok, This selected file is already openend, let's activate the item.
|
2016-08-08 09:02:46 -07:00
|
|
|
if (!strcmp(file_path, it_file_path))
|
2016-07-22 00:13:50 -07:00
|
|
|
{
|
|
|
|
file_mgr_file_focus(eit);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Case 2. sub files.
|
|
|
|
Eina_List *sub_items =
|
|
|
|
(Eina_List *)enventor_object_sub_items_get(base_enventor_get());
|
|
|
|
Eina_List *l;
|
|
|
|
EINA_LIST_FOREACH(sub_items, l, eit)
|
|
|
|
{
|
|
|
|
it_file_path = enventor_item_file_get(eit);
|
|
|
|
if (!it_file_path) continue;
|
|
|
|
|
|
|
|
//Ok, This selected file is already openend, let's activate the item.
|
2016-08-08 09:02:46 -07:00
|
|
|
if (!strcmp(file_path, it_file_path))
|
2016-07-22 00:13:50 -07:00
|
|
|
{
|
|
|
|
file_mgr_file_focus(eit);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//This selected file hasn't been opened yet, so let's open this file newly.
|
2016-08-08 09:10:27 -07:00
|
|
|
file_mgr_sub_file_add(file_path, EINA_TRUE);
|
2016-08-09 23:05:13 -07:00
|
|
|
return EINA_TRUE;
|
2016-07-22 00:13:50 -07:00
|
|
|
}
|
2016-08-15 00:49:35 -07:00
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
file_mgr_file_backward(void)
|
|
|
|
{
|
|
|
|
file_mgr_data *fmd = g_fmd;
|
|
|
|
if (!fmd) return EINA_FALSE;
|
|
|
|
|
|
|
|
Eina_List *last = eina_list_last(fmd->file_queue);
|
|
|
|
if (!last) return EINA_FALSE;
|
|
|
|
|
|
|
|
Eina_Stringshare *file = eina_list_data_get(last);
|
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("No file path??");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fmd->file_queue = eina_list_remove_list(fmd->file_queue, last);
|
|
|
|
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
fmd->no_queue = EINA_TRUE;
|
|
|
|
ret = file_mgr_file_open(file);
|
|
|
|
fmd->no_queue = EINA_FALSE;
|
|
|
|
|
|
|
|
eina_stringshare_del(file);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|