forked from enlightenment/enventor
file_browser/file_tab: ++ multi file support implementaion
This commit is contained in:
parent
bd0aa1a81e
commit
f0623301d9
|
@ -55,6 +55,51 @@ static Eina_List *sub_brows_file_list_create(brows_file *file);
|
|||
static void brows_file_list_free(Eina_List *file_list);
|
||||
static void refresh_btn_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
|
||||
|
||||
static void
|
||||
gl_clicked_double_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Elm_Object_Item *it = event_info;
|
||||
brows_file *file = elm_object_item_data_get(it);
|
||||
if (!file)
|
||||
{
|
||||
EINA_LOG_ERR("No item data??");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file->path)
|
||||
{
|
||||
EINA_LOG_ERR("No item file path??");
|
||||
return;
|
||||
}
|
||||
|
||||
// Open a double clicked edc file.
|
||||
if (!eina_str_has_extension(file->path, "edc")) return;
|
||||
int selected_file_len = strlen(file->path);
|
||||
|
||||
//Let's check if the file is already opened or not.
|
||||
Eina_List *sub_items =
|
||||
(Eina_List *)enventor_object_sub_items_get(base_enventor_get());
|
||||
Eina_List *l;
|
||||
Enventor_Item *eit;
|
||||
EINA_LIST_FOREACH(sub_items, l, eit)
|
||||
{
|
||||
const char *it_file_path = enventor_item_file_get(eit);
|
||||
if (!it_file_path) continue;
|
||||
if (selected_file_len != strlen(it_file_path)) continue;
|
||||
|
||||
//Ok, This selected file is already openend, let's activte the item.
|
||||
if (!strcmp(file->path, it_file_path))
|
||||
{
|
||||
//TODO:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//This selected file hasn't been opened yet, so let's open this file newly.
|
||||
facade_sub_file_set(file->path);
|
||||
}
|
||||
|
||||
static Elm_Object_Item *
|
||||
file_genlist_item_append(brows_file *file, Elm_Object_Item *parent_it,
|
||||
Elm_Genlist_Item_Type it_type)
|
||||
|
@ -663,6 +708,8 @@ file_browser_init(Evas_Object *parent)
|
|||
evas_object_smart_callback_add(genlist, "expanded", gl_expanded_cb, NULL);
|
||||
evas_object_smart_callback_add(genlist, "contracted", gl_contracted_cb,
|
||||
NULL);
|
||||
evas_object_smart_callback_add(genlist, "clicked,double",
|
||||
gl_clicked_double_cb, NULL);
|
||||
evas_object_show(genlist);
|
||||
elm_box_pack_end(main_box, genlist);
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ file_tab_disabled_set(Eina_Bool disabled)
|
|||
{
|
||||
file_data *fd = g_fd;
|
||||
if (!fd) return;
|
||||
elm_object_disabled_set(fd->box, disabled);
|
||||
elm_object_disabled_set(fd->list, disabled);
|
||||
|
||||
if (disabled) return;
|
||||
|
||||
|
|
|
@ -13,6 +13,20 @@ void mem_fail_msg(void)
|
|||
EINA_LOG_ERR("Failed to allocate Memory!");
|
||||
}
|
||||
|
||||
Enventor_Item *facade_sub_file_set(const char *path)
|
||||
{
|
||||
Enventor_Item *it = enventor_object_sub_file_add(base_enventor_get(), path);
|
||||
if (!it) return NULL;
|
||||
|
||||
file_tab_it_add(it);
|
||||
file_tab_it_selected_set(it);
|
||||
|
||||
base_text_editor_set(it);
|
||||
base_title_set(path);
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
Enventor_Item *facade_main_file_set(const char *path)
|
||||
{
|
||||
Enventor_Item *it = enventor_object_main_file_set(base_enventor_get(), path);
|
||||
|
|
|
@ -4,3 +4,4 @@ extern Eina_Prefix *PREFIX;
|
|||
extern const char *ENVENTOR_NAME;
|
||||
void mem_fail_msg(void);
|
||||
Enventor_Item *facade_main_file_set(const char *path);
|
||||
Enventor_Item *facade_sub_file_set(const char *path);
|
||||
|
|
|
@ -4,7 +4,8 @@ EAPI Evas_Object *enventor_object_add(Evas_Object *parent);
|
|||
|
||||
//FIXME: Should be eofied.
|
||||
EAPI Enventor_Item *enventor_object_main_file_set(Evas_Object *obj, const char *file);
|
||||
EAPI Enventor_Item *enventor_object_sub_file_add(Evas_Object *obj, const char *file);
|
||||
EAPI const Eina_List *enventor_object_sub_items_get(const Evas_Object *obj);
|
||||
EAPI Evas_Object *enventor_item_editor_get(const Enventor_Item *it);
|
||||
EAPI const char *enventor_item_file_get(const Enventor_Item *it);
|
||||
|
||||
#include "enventor_object.eo.legacy.h"
|
||||
|
|
|
@ -37,6 +37,7 @@ struct _Enventor_Object_Data
|
|||
{
|
||||
Enventor_Object *obj;
|
||||
Enventor_Item_Data main_it;
|
||||
Eina_List *sub_its;
|
||||
|
||||
Eina_Stringshare *group_name;
|
||||
|
||||
|
@ -947,6 +948,43 @@ enventor_object_add(Enventor_Object *parent)
|
|||
return obj;
|
||||
}
|
||||
|
||||
EAPI Enventor_Item *
|
||||
enventor_object_sub_file_add(Enventor_Object *obj, const char *file)
|
||||
{
|
||||
Enventor_Object_Data *pd = eo_data_scope_get(obj, ENVENTOR_OBJECT_CLASS);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
EINA_LOG_ERR("No file path!!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Enventor_Item_Data *it = calloc(1, sizeof(Enventor_Item_Data));
|
||||
if (!it)
|
||||
{
|
||||
mem_fail_msg();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pd->sub_its = eina_list_append(pd->sub_its, it);
|
||||
|
||||
it->enventor = obj;
|
||||
it->ed = edit_init(obj);
|
||||
|
||||
autocomp_target_set(it->ed);
|
||||
edit_load(it->ed, file);
|
||||
edit_changed_set(it->ed, EINA_FALSE);
|
||||
|
||||
//Update Editor State
|
||||
if (pd->linenumber != DEFAULT_LINENUMBER)
|
||||
edit_linenumber_set(it->ed, pd->linenumber);
|
||||
if (pd->font_scale != DEFAULT_FONT_SCALE)
|
||||
edit_font_scale_set(it->ed, pd->font_scale);
|
||||
if (pd->disabled) edit_disabled_set(it->ed, EINA_TRUE);
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
EAPI Enventor_Item *
|
||||
enventor_object_main_file_set(Enventor_Object *obj, const char *file)
|
||||
{
|
||||
|
@ -975,6 +1013,13 @@ enventor_object_main_file_set(Enventor_Object *obj, const char *file)
|
|||
return &pd->main_it;
|
||||
}
|
||||
|
||||
EAPI const Eina_List *
|
||||
enventor_object_sub_items_get(const Enventor_Object *obj)
|
||||
{
|
||||
Enventor_Object_Data *pd = eo_data_scope_get(obj, ENVENTOR_OBJECT_CLASS);
|
||||
return pd->sub_its;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/* Enventor_Item Functions. */
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue