add open files in new tab.
Summary: focus chanegs on click of tab in panel. closing last tab closes panel. Exit and open remembers tabs. etc. Reviewers: ajwillia.ms Reviewed By: ajwillia.ms Differential Revision: https://phab.enlightenment.org/D5034
This commit is contained in:
parent
24f9dc79fa
commit
be333dee6f
|
@ -35,6 +35,7 @@ edi_searchpanel.h \
|
|||
edi_consolepanel.h \
|
||||
edi_debugpanel.h \
|
||||
mainview/edi_mainview_item.h \
|
||||
mainview/edi_mainview_panel.h \
|
||||
mainview/edi_mainview.h
|
||||
|
||||
edi_SOURCES = \
|
||||
|
@ -58,6 +59,7 @@ edi_searchpanel.c \
|
|||
edi_consolepanel.c \
|
||||
edi_debugpanel.c \
|
||||
mainview/edi_mainview_item.c \
|
||||
mainview/edi_mainview_panel.c \
|
||||
mainview/edi_mainview.c \
|
||||
edi_main.c \
|
||||
edi_private.h
|
||||
|
|
|
@ -234,6 +234,7 @@ _edi_config_init(void)
|
|||
EDI_CONFIG_VAL(D, T, path, EET_T_STRING);
|
||||
EDI_CONFIG_VAL(D, T, type, EET_T_STRING);
|
||||
EDI_CONFIG_VAL(D, T, windowed, EET_T_UCHAR);
|
||||
EDI_CONFIG_VAL(D, T, panel_id, EET_T_INT);
|
||||
|
||||
_edi_proj_cfg_edd = EDI_CONFIG_DD_NEW("Project_Config", Edi_Project_Config);
|
||||
#undef T
|
||||
|
@ -504,7 +505,7 @@ _edi_project_config_save()
|
|||
|
||||
void
|
||||
_edi_project_config_tab_add(const char *path, const char *type,
|
||||
Eina_Bool windowed)
|
||||
Eina_Bool windowed, int panel_id)
|
||||
{
|
||||
Edi_Project_Config_Tab *tab;
|
||||
Eina_List *list, *next;
|
||||
|
@ -525,6 +526,8 @@ _edi_project_config_tab_add(const char *path, const char *type,
|
|||
|
||||
tab->type = eina_stringshare_add(type);
|
||||
tab->windowed = windowed;
|
||||
tab->panel_id = panel_id;
|
||||
|
||||
_edi_project_config->tabs = eina_list_append(_edi_project_config->tabs, tab);
|
||||
_edi_project_config_save_no_notify();
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ struct _Edi_Project_Config_Tab
|
|||
const char *path;
|
||||
const char *type;
|
||||
Eina_Bool windowed;
|
||||
int panel_id;
|
||||
};
|
||||
|
||||
struct _Edi_Project_Config_Launch
|
||||
|
@ -114,7 +115,7 @@ void _edi_project_config_load(void);
|
|||
void _edi_project_config_save(void);
|
||||
|
||||
void _edi_project_config_tab_add(const char *path, const char *type,
|
||||
Eina_Bool windowed);
|
||||
Eina_Bool windowed, int panel_id);
|
||||
void _edi_project_config_tab_remove(const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -134,6 +134,20 @@ _item_menu_open_as_image_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
_open_cb(sd->path, "image", EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_open_panel_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Edi_Mainview_Panel *panel;
|
||||
Edi_Path_Options *options;
|
||||
Edi_Dir_Data *sd = data;
|
||||
|
||||
options = edi_path_options_create(sd->path);
|
||||
panel = edi_mainview_panel_append();
|
||||
|
||||
edi_mainview_panel_open(panel, options);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_rename_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
@ -224,11 +238,14 @@ _item_menu_create(Evas_Object *win, Edi_Dir_Data *sd)
|
|||
|
||||
menu_it = elm_menu_item_add(menu, NULL, "gtk-execute", "open external",
|
||||
_item_menu_xdgopen_cb, sd);
|
||||
|
||||
menu_it = elm_menu_item_add(menu, NULL, NULL, "open as", NULL, NULL);
|
||||
_item_menu_filetype_create(menu, menu_it, "text", _item_menu_open_as_text_cb, sd);
|
||||
_item_menu_filetype_create(menu, menu_it, "code", _item_menu_open_as_code_cb, sd);
|
||||
_item_menu_filetype_create(menu, menu_it, "image", _item_menu_open_as_image_cb, sd);
|
||||
|
||||
menu_it = elm_menu_item_add(menu, NULL, NULL, "open in new panel", _item_menu_open_panel_cb, sd);
|
||||
|
||||
if (edi_scm_enabled())
|
||||
{
|
||||
menu_it = elm_menu_item_add(menu, NULL, NULL, "source control", NULL, NULL);
|
||||
|
|
|
@ -351,7 +351,7 @@ static Evas_Object *
|
|||
edi_content_setup(Evas_Object *win, const char *path)
|
||||
{
|
||||
Evas_Object *filepane, *logpane, *logpanels, *content_out, *content_in, *tb;
|
||||
Evas_Object *icon, *button;
|
||||
Evas_Object *icon, *button, *mainview;
|
||||
|
||||
filepane = elm_panes_add(win);
|
||||
evas_object_size_hint_weight_set(filepane, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
@ -396,8 +396,14 @@ edi_content_setup(Evas_Object *win, const char *path)
|
|||
elm_box_pack_end(content_in, button);
|
||||
evas_object_show(button);
|
||||
|
||||
edi_mainview_add(content_in, win);
|
||||
evas_object_show(content_in);
|
||||
mainview = elm_box_add(content_in);
|
||||
evas_object_size_hint_weight_set(mainview, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(mainview, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(mainview);
|
||||
elm_box_pack_end(content_in, mainview);
|
||||
|
||||
edi_mainview_add(mainview, win);
|
||||
|
||||
elm_object_part_content_set(filepane, "right", content_in);
|
||||
elm_box_pack_end(content_out, filepane);
|
||||
|
||||
|
@ -830,13 +836,6 @@ _edi_menu_save_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
edi_mainview_save();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_open_window_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_mainview_new_window();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_close_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
@ -848,7 +847,7 @@ static void
|
|||
_edi_menu_closeall_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_mainview_closeall();
|
||||
edi_mainview_close_all();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -921,14 +920,6 @@ _edi_menu_findfile_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
edi_filepanel_search();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_tasks_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_taskspanel_show();
|
||||
edi_taskspanel_find();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_goto_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
@ -936,6 +927,28 @@ _edi_menu_goto_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
edi_mainview_goto_popup_show();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_view_open_window_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_mainview_new_window();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_view_split_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_mainview_panel_append();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_view_tasks_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_taskspanel_show();
|
||||
edi_taskspanel_find();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_build_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
@ -1088,7 +1101,6 @@ _edi_menu_setup(Evas_Object *win)
|
|||
elm_menu_item_add(menu, menu_it, "document-new", "New ...", _edi_menu_new_cb, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "folder-new", "New Directory ...", _edi_menu_new_dir_cb, NULL);
|
||||
_edi_menu_save = elm_menu_item_add(menu, menu_it, "document-save", "Save", _edi_menu_save_cb, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "window-new", "New window", _edi_menu_open_window_cb, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "document-close", "Close", _edi_menu_close_cb, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "document-close", "Close all", _edi_menu_closeall_cb, NULL);
|
||||
elm_menu_item_separator_add(menu, menu_it);
|
||||
|
@ -1109,7 +1121,12 @@ _edi_menu_setup(Evas_Object *win)
|
|||
elm_menu_item_add(menu, menu_it, "go-jump", "Goto Line ...", _edi_menu_goto_cb, NULL);
|
||||
elm_menu_item_separator_add(menu, menu_it);
|
||||
elm_menu_item_add(menu, menu_it, "edit-find", "Find in project ...", _edi_menu_find_project_cb, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "edit-find", "Open Tasks", _edi_menu_tasks_cb, NULL);
|
||||
|
||||
menu_it = elm_menu_item_add(menu, NULL, NULL, "View", NULL, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "window-new", "New window", _edi_menu_view_open_window_cb, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "object-flip-horizontal", "Split pane", _edi_menu_view_split_cb, NULL);
|
||||
elm_menu_item_separator_add(menu, menu_it);
|
||||
elm_menu_item_add(menu, menu_it, "edit-find", "Open Tasks", _edi_menu_view_tasks_cb, NULL);
|
||||
|
||||
menu_it = elm_menu_item_add(menu, NULL, NULL, "Build", NULL, NULL);
|
||||
elm_menu_item_add(menu, menu_it, "system-run", "Build", _edi_menu_build_cb, NULL);
|
||||
|
@ -1293,6 +1310,7 @@ _edi_open_tabs()
|
|||
Edi_Project_Config_Tab *tab;
|
||||
Edi_Path_Options *options;
|
||||
Eina_List *tabs, *list;
|
||||
Edi_Mainview_Panel *panel;
|
||||
char *path;
|
||||
|
||||
tabs = _edi_project_config->tabs;
|
||||
|
@ -1307,10 +1325,26 @@ _edi_open_tabs()
|
|||
options = edi_path_options_create(path);
|
||||
options->type = eina_stringshare_add(tab->type);
|
||||
options->background = EINA_TRUE;
|
||||
if (tab->windowed)
|
||||
edi_mainview_open_window(options);
|
||||
if (tab->panel_id == 0)
|
||||
{
|
||||
if (tab->windowed)
|
||||
edi_mainview_open_window(options);
|
||||
else
|
||||
edi_mainview_open(options);
|
||||
|
||||
}
|
||||
else
|
||||
edi_mainview_open(options);
|
||||
{
|
||||
while (edi_mainview_panel_count() <= tab->panel_id)
|
||||
{
|
||||
/* Make sure we have enough panels */
|
||||
edi_mainview_panel_append();
|
||||
}
|
||||
panel = edi_mainview_panel_by_index(tab->panel_id);
|
||||
options = edi_path_options_create(path);
|
||||
edi_mainview_panel_open(panel, options);
|
||||
}
|
||||
|
||||
free(path);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,6 +7,7 @@
|
|||
#include "Edi.h"
|
||||
|
||||
#include "mainview/edi_mainview_item.h"
|
||||
#include "mainview/edi_mainview_panel.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -251,6 +252,10 @@ void edi_mainview_project_search_popup_show();
|
|||
|
||||
Edi_Mainview_Item *edi_mainview_item_current_get();
|
||||
|
||||
Edi_Mainview_Panel *edi_mainview_panel_current_get();
|
||||
|
||||
void edi_mainview_tab_select(unsigned int id);
|
||||
|
||||
/**
|
||||
* Select the passed item in the mainview UI.
|
||||
* By definition this will already be an open file as the Edi_Mainview_Item will
|
||||
|
@ -277,8 +282,14 @@ void edi_mainview_item_prev();
|
|||
*/
|
||||
void edi_mainview_item_next();
|
||||
|
||||
void edi_mainview_tab_select(unsigned int id);
|
||||
Edi_Mainview_Panel *edi_mainview_panel_append();
|
||||
|
||||
Edi_Mainview_Panel *edi_mainview_panel_for_item_get(Edi_Mainview_Item *item);
|
||||
Edi_Mainview_Panel *edi_mainview_panel_by_index(int index);
|
||||
int edi_mainview_panel_count(void);
|
||||
int edi_mainview_panel_id(Edi_Mainview_Panel *panel);
|
||||
void edi_mainview_panel_focus(Edi_Mainview_Panel *panel);
|
||||
void edi_mainview_panel_remove(Edi_Mainview_Panel *panel);
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
|
|
@ -13,3 +13,20 @@
|
|||
|
||||
#include "edi_private.h"
|
||||
|
||||
Edi_Mainview_Item *
|
||||
edi_mainview_item_add(Edi_Path_Options *path, const char *mime,
|
||||
Elm_Object_Item *tab, Evas_Object *win)
|
||||
{
|
||||
Edi_Mainview_Item *item;
|
||||
|
||||
item = malloc(sizeof(Edi_Mainview_Item));
|
||||
item->path = eina_stringshare_add(path->path);
|
||||
item->editortype = path->type;
|
||||
item->mimetype = mime;
|
||||
item->tab = tab;
|
||||
item->win = win;
|
||||
|
||||
item->view = NULL;
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@ typedef struct _Edi_Mainview_Item
|
|||
Eina_Bool loaded;
|
||||
} Edi_Mainview_Item;
|
||||
|
||||
Edi_Mainview_Item * edi_mainview_item_add(Edi_Path_Options *path, const char *mime,
|
||||
Elm_Object_Item *tab, Evas_Object *win);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,873 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <libgen.h>
|
||||
|
||||
#include <Eina.h>
|
||||
#include <Eio.h>
|
||||
#include <Elementary.h>
|
||||
|
||||
#include "mainview/edi_mainview_item.h"
|
||||
#include "mainview/edi_mainview_panel.h"
|
||||
#include "mainview/edi_mainview.h"
|
||||
|
||||
#include "editor/edi_editor.h"
|
||||
#include "edi_content_provider.h"
|
||||
|
||||
#include "edi_private.h"
|
||||
#include "edi_config.h"
|
||||
|
||||
static Evas_Object *_main_win;
|
||||
static Evas_Object *_edi_mainview_goto_popup;
|
||||
|
||||
static void
|
||||
dummy()
|
||||
{}
|
||||
|
||||
Edi_Mainview_Item *
|
||||
edi_mainview_panel_item_current_get(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
return panel->current;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
edi_mainview_panel_item_current_tab_get(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it;
|
||||
unsigned int i = 0;
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (!it->win)
|
||||
i++;
|
||||
if (it && it == panel->current)
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
Edi_Mainview_Item *
|
||||
_edi_mainview_panel_item_for_view_get(Edi_Mainview_Panel *panel, Evas_Object *view)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it;
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (it->view == view)
|
||||
return it;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
edi_mainview_panel_item_contains(Edi_Mainview_Panel *panel, Edi_Mainview_Item *item)
|
||||
{
|
||||
Eina_List *it;
|
||||
Edi_Mainview_Item *panel_item;
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, it, panel_item)
|
||||
{
|
||||
if (panel_item == item)
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_item_prev(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it, *first, *prev = NULL;
|
||||
|
||||
first = (Edi_Mainview_Item *)eina_list_nth(panel->items, 0);
|
||||
if (first == panel->current)
|
||||
{
|
||||
prev = eina_list_nth(panel->items, eina_list_count(panel->items)-1);
|
||||
edi_mainview_panel_item_select(panel, prev);
|
||||
return;
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (it && it == panel->current)
|
||||
{
|
||||
if (prev)
|
||||
edi_mainview_panel_item_select(panel, prev);
|
||||
return;
|
||||
}
|
||||
|
||||
prev = it;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_item_next(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it, *last, *next;
|
||||
Eina_Bool open_next = EINA_FALSE;
|
||||
|
||||
last = eina_list_nth(panel->items, eina_list_count(panel->items)-1);
|
||||
|
||||
if (last == panel->current)
|
||||
{
|
||||
next = eina_list_nth(panel->items, 0);
|
||||
edi_mainview_panel_item_select(panel, next);
|
||||
return;
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (it && open_next)
|
||||
{
|
||||
edi_mainview_panel_item_select(panel, it);
|
||||
return;
|
||||
}
|
||||
|
||||
if (it && it == panel->current)
|
||||
open_next = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_tab_select(Edi_Mainview_Panel *panel, unsigned int id)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it;
|
||||
unsigned int i = 0;
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (!it->win)
|
||||
i++;
|
||||
if (i == id)
|
||||
edi_mainview_panel_item_select(panel, it);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_mainview_panel_show(Edi_Mainview_Panel *panel, Evas_Object *view)
|
||||
{
|
||||
if (panel->current)
|
||||
{
|
||||
elm_box_unpack(panel->content, panel->current->view);
|
||||
evas_object_hide(panel->current->view);
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_box_unpack(panel->content, panel->welcome);
|
||||
evas_object_hide(panel->welcome);
|
||||
}
|
||||
|
||||
panel->current = _edi_mainview_panel_item_for_view_get(panel, view);
|
||||
elm_box_pack_end(panel->content, view);
|
||||
evas_object_show(view);
|
||||
}
|
||||
|
||||
static void
|
||||
_content_load(Edi_Mainview_Item *item)
|
||||
{
|
||||
Edi_Content_Provider *provider;
|
||||
Evas_Object *child;
|
||||
|
||||
provider = edi_content_provider_for_id_get(item->editortype);
|
||||
if (!provider)
|
||||
{
|
||||
ERR("No content provider found for type %s", item->editortype);
|
||||
return;
|
||||
}
|
||||
child = provider->content_ui_add(item->container, item);
|
||||
|
||||
evas_object_size_hint_weight_set(child, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(child, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(item->container, child);
|
||||
evas_object_show(child);
|
||||
|
||||
item->loaded = EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_item_close(Edi_Mainview_Panel *panel, Edi_Mainview_Item *item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
edi_mainview_item_prev();
|
||||
evas_object_del(item->view);
|
||||
elm_box_unpack(panel->tabs, item->tab);
|
||||
evas_object_del(item->tab);
|
||||
panel->items = eina_list_remove(panel->items, item);
|
||||
|
||||
_edi_project_config_tab_remove(item->path);
|
||||
eina_stringshare_del(item->path);
|
||||
free(item);
|
||||
|
||||
if (eina_list_count(panel->items) == 0)
|
||||
_edi_mainview_panel_show(panel, panel->welcome);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_item_select(Edi_Mainview_Panel *panel, Edi_Mainview_Item *item)
|
||||
{
|
||||
Eina_List *list;
|
||||
Edi_Mainview_Item *it;
|
||||
Evas_Coord tabw, region_x = 0, w, total_w = 0;
|
||||
|
||||
if (item->win)
|
||||
{
|
||||
elm_win_raise(item->win);
|
||||
}
|
||||
else
|
||||
{
|
||||
EINA_LIST_FOREACH(panel->items, list, it)
|
||||
{
|
||||
elm_object_signal_emit(it->tab, "mouse,up,1", "base");
|
||||
evas_object_geometry_get(it->tab, NULL, NULL, &w, NULL);
|
||||
if (item == it) region_x = total_w;
|
||||
total_w += w;
|
||||
}
|
||||
|
||||
if (!item->loaded)
|
||||
_content_load(item);
|
||||
|
||||
_edi_mainview_panel_show(panel, item->view);
|
||||
elm_object_signal_emit(item->tab, "mouse,down,1", "base");
|
||||
|
||||
evas_object_geometry_get(item->tab, NULL, NULL, &tabw, NULL);
|
||||
elm_scroller_region_bring_in(panel->tabs, region_x, 0, tabw, 0);
|
||||
_edi_project_config->current_tab = edi_mainview_panel_item_current_tab_get(panel);
|
||||
_edi_project_config_save();
|
||||
}
|
||||
|
||||
ecore_event_add(EDI_EVENT_TAB_CHANGED, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_promote(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Edi_Mainview_Panel *panel;
|
||||
|
||||
panel = edi_mainview_panel_for_item_get((Edi_Mainview_Item *)data);
|
||||
edi_mainview_panel_focus(panel);
|
||||
edi_mainview_panel_item_select(panel, (Edi_Mainview_Item *)data);
|
||||
}
|
||||
|
||||
static void
|
||||
_closetab(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Edi_Mainview_Panel *panel;
|
||||
|
||||
panel = edi_mainview_panel_for_item_get((Edi_Mainview_Item *)data);
|
||||
edi_mainview_panel_item_close(panel, data);
|
||||
if (eina_list_count(panel->items)== 0)
|
||||
{
|
||||
edi_mainview_panel_remove(panel);
|
||||
}
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_edi_mainview_panel_content_create(Edi_Mainview_Item *item, Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *container;
|
||||
|
||||
container = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(container, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(container, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
||||
item->loaded = EINA_FALSE;
|
||||
item->container = container;
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_mainview_panel_item_tab_add(Edi_Mainview_Panel *panel, Edi_Path_Options *options, const char *mime)
|
||||
{
|
||||
Evas_Object *content, *tab;//, *icon;
|
||||
Edi_Mainview_Item *item;
|
||||
Edi_Editor *editor;
|
||||
|
||||
if (!panel) return;
|
||||
|
||||
int id = edi_mainview_panel_id(panel);
|
||||
|
||||
item = edi_mainview_item_add(options, mime, NULL, NULL);
|
||||
content = _edi_mainview_panel_content_create(item, panel->content);
|
||||
item->view = content;
|
||||
panel->items = eina_list_append(panel->items, item);
|
||||
_edi_mainview_panel_show(panel, content);
|
||||
|
||||
tab = elm_button_add(panel->tabs);
|
||||
evas_object_size_hint_weight_set(tab, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(tab, 0.0, EVAS_HINT_FILL);
|
||||
|
||||
elm_layout_theme_set(tab, "multibuttonentry", "btn", "default");
|
||||
elm_object_part_text_set(tab, "elm.btn.text", basename((char*)options->path));
|
||||
/*
|
||||
icon = elm_icon_add(tab);
|
||||
elm_icon_standard_set(icon, provider->icon);
|
||||
elm_object_part_content_set(tab, "icon", icon);
|
||||
*/
|
||||
elm_layout_signal_callback_add(tab, "mouse,clicked,1", "*", _promote, item);
|
||||
elm_layout_signal_callback_add(tab, "elm,deleted", "elm", _closetab, item);
|
||||
|
||||
elm_box_pack_end(panel->tabs, tab);
|
||||
evas_object_show(tab);
|
||||
elm_box_recalculate(panel->tabs);
|
||||
item->tab = tab;
|
||||
|
||||
if (!options->background)
|
||||
edi_mainview_panel_item_select(panel, item);
|
||||
|
||||
// Set focus on the newly opening window so that one can just start typing
|
||||
editor = (Edi_Editor *)evas_object_data_get(content, "editor");
|
||||
if (editor)
|
||||
elm_object_focus_set(editor->entry, EINA_TRUE);
|
||||
|
||||
if (options->line)
|
||||
{
|
||||
if (options->character > 1)
|
||||
edi_mainview_panel_goto_position(panel, options->line, options->character);
|
||||
else
|
||||
edi_mainview_panel_goto(panel, options->line);
|
||||
}
|
||||
|
||||
_edi_project_config_tab_add(options->path, mime?mime:options->type, EINA_FALSE, id);
|
||||
}
|
||||
|
||||
static Edi_Mainview_Item *
|
||||
_get_item_for_path(Edi_Mainview_Panel *panel, const char *path)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it;
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (it && !strcmp(it->path, path))
|
||||
return it;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_popup_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
evas_object_del((Evas_Object *) data);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_mainview_panel_mime_content_safe_popup(void)
|
||||
{
|
||||
Evas_Object *popup, *label, *button;
|
||||
|
||||
popup = elm_popup_add(_main_win);
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Unrecognized file type");
|
||||
label = elm_label_add(popup);
|
||||
elm_object_text_set(label, "To force open, select this file in the file browser, and use \"open as\" menu options.");
|
||||
evas_object_show(label);
|
||||
elm_object_content_set(popup, label);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "OK");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked", _edi_popup_cancel_cb, popup);
|
||||
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_close(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Mainview_Item *item;
|
||||
|
||||
item = edi_mainview_panel_item_current_get(panel);
|
||||
|
||||
edi_mainview_panel_item_close(panel, item);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_save(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
Elm_Code *code;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (!editor)
|
||||
return;
|
||||
|
||||
editor->modified = EINA_FALSE;
|
||||
|
||||
code = elm_code_widget_code_get(editor->entry);
|
||||
elm_code_file_save(code->file);
|
||||
ecore_event_add(EDI_EVENT_FILE_SAVED, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_undo(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (editor)
|
||||
elm_code_widget_undo(editor->entry);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
edi_mainview_panel_can_undo(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
if (!panel->current)
|
||||
return EINA_FALSE;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (!editor)
|
||||
return EINA_FALSE;
|
||||
|
||||
return elm_code_widget_can_undo_get(editor->entry);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_redo(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (editor)
|
||||
elm_code_widget_redo(editor->entry);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
edi_mainview_panel_can_redo(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
if (!panel->current)
|
||||
return EINA_FALSE;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (!editor)
|
||||
return EINA_FALSE;
|
||||
|
||||
return elm_code_widget_can_redo_get(editor->entry);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
edi_mainview_panel_modified(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
if (!panel->current)
|
||||
return EINA_FALSE;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
if (!editor)
|
||||
return EINA_FALSE;
|
||||
|
||||
return editor->modified;
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_cut(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (editor)
|
||||
elm_code_widget_selection_cut(editor->entry);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_copy(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (editor)
|
||||
elm_code_widget_selection_copy(editor->entry);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_paste(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (editor)
|
||||
elm_code_widget_selection_paste(editor->entry);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_search(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
|
||||
if (editor)
|
||||
edi_editor_search(editor);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_goto(Edi_Mainview_Panel *panel, unsigned int number)
|
||||
{
|
||||
edi_mainview_panel_goto_position(panel, number, 1);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_goto_position(Edi_Mainview_Panel *panel, unsigned int row, unsigned int col)
|
||||
{
|
||||
Edi_Editor *editor;
|
||||
|
||||
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||
if (!editor || row <= 0 || col <= 0)
|
||||
return;
|
||||
|
||||
elm_code_widget_cursor_position_set(editor->entry, row, col);
|
||||
elm_object_focus_set(editor->entry, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_mainview_panel_goto_popup_go_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
int number;
|
||||
|
||||
number = atoi(elm_entry_entry_get((Evas_Object *) data));
|
||||
edi_mainview_goto(number);
|
||||
|
||||
evas_object_del(_edi_mainview_goto_popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_mainview_panel_goto_popup_key_up_cb(void *data, Evas *e EINA_UNUSED,
|
||||
Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Edi_Mainview_Panel *panel = data;
|
||||
Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *)event_info;
|
||||
const char *str;
|
||||
|
||||
str = elm_object_text_get(obj);
|
||||
|
||||
if (strlen(str) && (!strcmp(ev->key, "KP_Enter") || !strcmp(ev->key, "Return")))
|
||||
_edi_mainview_panel_goto_popup_go_cb(panel, obj, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_goto_popup_show(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Evas_Object *popup, *box, *input, *button;
|
||||
|
||||
popup = elm_popup_add(_main_win);
|
||||
_edi_mainview_goto_popup = popup;
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Enter line number");
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
input = elm_entry_add(box);
|
||||
elm_entry_single_line_set(input, EINA_TRUE);
|
||||
elm_entry_scrollable_set(input, EINA_TRUE);
|
||||
evas_object_event_callback_add(input, EVAS_CALLBACK_KEY_UP, _edi_mainview_panel_goto_popup_key_up_cb, panel);
|
||||
evas_object_size_hint_weight_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(input);
|
||||
elm_box_pack_end(box, input);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "cancel");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_popup_cancel_cb, NULL);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "go");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_mainview_panel_goto_popup_go_cb, input);
|
||||
|
||||
evas_object_show(popup);
|
||||
elm_object_focus_set(input, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_mainview_panel_tab_stat_done(void *data, Eio_File *handler EINA_UNUSED, const Eina_Stat *stat)
|
||||
{
|
||||
Edi_Mainview_Panel *panel;
|
||||
Edi_Path_Options *options;
|
||||
Edi_Content_Provider *provider;
|
||||
const char *mime;
|
||||
|
||||
options = data;
|
||||
if (!S_ISREG(stat->mode))
|
||||
return;
|
||||
|
||||
mime = efreet_mime_type_get(options->path);
|
||||
provider = edi_content_provider_for_mime_get(mime);
|
||||
if (!provider)
|
||||
{
|
||||
_edi_mainview_panel_mime_content_safe_popup();
|
||||
return;
|
||||
}
|
||||
|
||||
options->type = provider->id;
|
||||
panel = edi_mainview_panel_current_get();
|
||||
_edi_mainview_panel_item_tab_add(panel, options, mime);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_open_path(Edi_Mainview_Panel *panel, const char *path)
|
||||
{
|
||||
Edi_Path_Options *options;
|
||||
|
||||
options = edi_path_options_create(path);
|
||||
edi_mainview_panel_open(panel, options);
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_open(Edi_Mainview_Panel *panel, Edi_Path_Options *options)
|
||||
{
|
||||
Edi_Mainview_Item *it;
|
||||
|
||||
edi_mainview_panel_focus(panel);
|
||||
|
||||
it = _get_item_for_path(panel, options->path);
|
||||
if (it)
|
||||
{
|
||||
edi_mainview_panel_item_select(panel, it);
|
||||
if (options->line)
|
||||
{
|
||||
if (options->character > 1)
|
||||
edi_mainview_goto_position(options->line, options->character);
|
||||
else
|
||||
edi_mainview_goto(options->line);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (options->type == NULL)
|
||||
{
|
||||
eio_file_direct_stat(options->path, _edi_mainview_panel_tab_stat_done, dummy, options);
|
||||
}
|
||||
else if (!edi_content_provider_for_id_get(options->type))
|
||||
{
|
||||
const char *mime = options->type;
|
||||
Edi_Content_Provider *provider = edi_content_provider_for_mime_get(mime);
|
||||
|
||||
if (provider)
|
||||
options->type = provider->id;
|
||||
else
|
||||
options->type = NULL;
|
||||
|
||||
_edi_mainview_panel_item_tab_add(panel, options, mime);
|
||||
}
|
||||
else
|
||||
{
|
||||
_edi_mainview_panel_item_tab_add(panel, options, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_close_all(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it;
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (it)
|
||||
edi_mainview_panel_item_close(panel, it);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_refresh_all(Edi_Mainview_Panel *panel)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it;
|
||||
char *path;
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (it)
|
||||
{
|
||||
path = strdup(it->path);
|
||||
edi_mainview_panel_item_close(panel, it);
|
||||
if (ecore_file_exists(path))
|
||||
edi_mainview_panel_open_path(panel, path);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
edi_mainview_panel_item_close_path(Edi_Mainview_Panel *panel, const char *path)
|
||||
{
|
||||
Eina_List *item;
|
||||
Edi_Mainview_Item *it;
|
||||
|
||||
EINA_LIST_FOREACH(panel->items, item, it)
|
||||
{
|
||||
if (it && !strcmp(it->path, path))
|
||||
{
|
||||
edi_mainview_panel_item_close(panel, it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_mainview_panel_next_clicked_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
int x, y, w, h;
|
||||
Evas_Object *scroller = data;
|
||||
|
||||
elm_scroller_region_get(scroller, &x, &y, &w, &h);
|
||||
x += w * 0.8;
|
||||
elm_scroller_region_bring_in(scroller, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_mainview_panel_prev_clicked_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
int x, y, w, h;
|
||||
Evas_Object *scroller = data;
|
||||
|
||||
elm_scroller_region_get(scroller, &x, &y, &w, &h);
|
||||
x -= w * 0.8;
|
||||
elm_scroller_region_bring_in(scroller, x, y, w, h);
|
||||
}
|
||||
|
||||
Edi_Mainview_Panel *
|
||||
edi_mainview_panel_add(Evas_Object *parent)
|
||||
{
|
||||
Edi_Mainview_Panel *panel;
|
||||
Evas_Object *box, *scroll, *txt, *nf, *tabs, *tab, *bg, *pad, *scr, *tb;
|
||||
Evas_Object *next, *prev, *ico_next, *ico_prev;
|
||||
_main_win = parent;
|
||||
|
||||
panel = calloc(1, sizeof(*panel));
|
||||
|
||||
box = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(box);
|
||||
elm_box_pack_end(parent, box);
|
||||
|
||||
tabs = elm_table_add(box);
|
||||
evas_object_size_hint_weight_set(tabs, EVAS_HINT_EXPAND, 0);
|
||||
evas_object_size_hint_align_set(tabs, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(tabs);
|
||||
elm_box_pack_end(box, tabs);
|
||||
|
||||
bg = elm_box_add(tabs);
|
||||
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(bg, 0.0, EVAS_HINT_FILL);
|
||||
evas_object_show(bg);
|
||||
elm_table_pack(tabs, bg, 0, 0, 1, 1);
|
||||
|
||||
scr = elm_scroller_add(parent);
|
||||
evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, 0.04);
|
||||
evas_object_size_hint_align_set(scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_min_set(scr, 0, 100 * elm_config_scale_get());
|
||||
elm_scroller_bounce_set(scr, EINA_FALSE, EINA_FALSE);
|
||||
elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
|
||||
elm_table_pack(tabs, scr, 0, 0, 1, 1);
|
||||
evas_object_show(scr);
|
||||
|
||||
prev = elm_button_add(tabs);
|
||||
evas_object_size_hint_weight_set(prev, 0, 0);
|
||||
evas_object_size_hint_align_set(prev, 0, EVAS_HINT_FILL);
|
||||
elm_table_pack(tabs, prev, 1, 0, 1, 1);
|
||||
evas_object_smart_callback_add(prev, "clicked",
|
||||
_edi_mainview_panel_prev_clicked_cb, scr);
|
||||
ico_prev = elm_icon_add(prev);
|
||||
elm_icon_standard_set(ico_prev, "go-previous");
|
||||
elm_object_part_content_set(prev, "icon", ico_prev);
|
||||
evas_object_show(prev);
|
||||
|
||||
next = elm_button_add(tabs);
|
||||
evas_object_size_hint_weight_set(next, 0, 0);
|
||||
evas_object_size_hint_align_set(next, 0, EVAS_HINT_FILL);
|
||||
elm_table_pack(tabs, next, 2, 0, 1, 1);
|
||||
evas_object_smart_callback_add(next, "clicked",
|
||||
_edi_mainview_panel_next_clicked_cb, scr);
|
||||
|
||||
ico_next = elm_icon_add(next);
|
||||
elm_icon_standard_set(ico_next, "go-next");
|
||||
elm_object_part_content_set(next, "icon", ico_next);
|
||||
evas_object_show(next);
|
||||
|
||||
tab = elm_button_add(tabs);
|
||||
evas_object_size_hint_weight_set(tab, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(tab, 0.0, EVAS_HINT_FILL);
|
||||
elm_layout_theme_set(tab, "multibuttonentry", "btn", "default");
|
||||
elm_object_part_text_set(tab, "elm.btn.text", "hg");
|
||||
elm_box_pack_end(bg, tab);
|
||||
|
||||
pad = elm_box_add(tabs);
|
||||
evas_object_size_hint_weight_set(pad, 0.0, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(pad, 0.0, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_min_set(pad, 0, 1.5 * elm_config_scale_get());
|
||||
elm_box_pack_end(bg, pad);
|
||||
|
||||
tb = elm_box_add(scr);
|
||||
evas_object_size_hint_weight_set(tb, 0.0, 0.0);
|
||||
evas_object_size_hint_align_set(tb, 0.0, EVAS_HINT_FILL);
|
||||
elm_box_horizontal_set(tb, EINA_TRUE);
|
||||
elm_object_content_set(scr, tb);
|
||||
evas_object_show(tb);
|
||||
panel->tabs = tb;
|
||||
panel->box = box;
|
||||
panel->tb = tb;
|
||||
|
||||
nf = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(box, nf);
|
||||
evas_object_show(nf);
|
||||
panel->content = nf;
|
||||
|
||||
scroll = elm_scroller_add(parent);
|
||||
evas_object_size_hint_weight_set(scroll, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(scroll, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(scroll);
|
||||
panel->scroll = scroll;
|
||||
|
||||
txt = elm_label_add(scroll);
|
||||
elm_object_text_set(txt, "<hilight>Welcome</hilight><br><br>Click on any file to edit.");
|
||||
evas_object_size_hint_weight_set(txt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(txt, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(txt);
|
||||
elm_object_content_set(scroll, txt);
|
||||
|
||||
panel->welcome = scroll;
|
||||
_edi_mainview_panel_show(panel, scroll);
|
||||
return panel;
|
||||
}
|
||||
|
|
@ -0,0 +1,290 @@
|
|||
#ifndef EDI_MAINVIEW_PANEL_H_
|
||||
# define EDI_MAINVIEW_PANEL_H_
|
||||
|
||||
#include <Elementary.h>
|
||||
#include <Evas.h>
|
||||
|
||||
#include "Edi.h"
|
||||
|
||||
#include "mainview/edi_mainview_item.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief These routines are used for managing content panels within the
|
||||
* main area of the Edi interface.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @struct _Edi_Mainview_Panel
|
||||
* A panel within mainview, holds many mainview items.
|
||||
*/
|
||||
typedef struct _Edi_Mainview_Panel
|
||||
{
|
||||
Eina_List *items;
|
||||
|
||||
Edi_Mainview_Item *current;
|
||||
Evas_Object *box, *scroll, *tabs, *content, *welcome, *tb;
|
||||
} Edi_Mainview_Panel;
|
||||
|
||||
/**
|
||||
* @brief Content management functions.
|
||||
* @defgroup Content
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* Opening and managing content within the view.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialise a new Edi main view panel inside the parent container.
|
||||
*
|
||||
* @param parent The mainview parent into which the panel will be loaded.
|
||||
* @return the panel that represents tha added mainview panel.
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
Edi_Mainview_Panel *edi_mainview_panel_add(Evas_Object *parent);
|
||||
|
||||
/**
|
||||
* Close mainview by path.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
* @praram path The path of file to close.
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_item_close_path(Edi_Mainview_Panel *panel, const char *path);
|
||||
|
||||
/**
|
||||
* Refresh all existing open files.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_refresh_all(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Close all existing open files.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_close_all(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Open the file at path for editing within this panel.
|
||||
* Supported types are "text" and "image".
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
* @param path The absolute path of the file to open.
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_open_path(Edi_Mainview_Panel *panel, const char *path);
|
||||
|
||||
/**
|
||||
* Open the file described in the provided options in this panel
|
||||
* - path and location etc.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
* @param path The path and options of the file to open.
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_open(Edi_Mainview_Panel *panel, Edi_Path_Options *options);
|
||||
|
||||
void edi_mainview_panel_item_close(Edi_Mainview_Panel *panel, Edi_Mainview_Item *item);
|
||||
|
||||
void edi_mainview_panel_item_select(Edi_Mainview_Panel *panel, Edi_Mainview_Item *item);
|
||||
|
||||
/**
|
||||
* Select the previous open tab.
|
||||
* Previous means the next tab left, if there is one.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Tabs
|
||||
*/
|
||||
void edi_mainview_panel_item_prev(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Select the next open tab.
|
||||
* Next means the next tab to the right, if there is one.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Tabs
|
||||
*/
|
||||
void edi_mainview_panel_item_next(Edi_Mainview_Panel *panel);
|
||||
|
||||
void edi_mainview_panel_tab_select(Edi_Mainview_Panel *panel, unsigned int id);
|
||||
|
||||
Eina_Bool edi_mainview_panel_item_contains(Edi_Mainview_Panel *panel, Edi_Mainview_Item *item);
|
||||
|
||||
Edi_Mainview_Item *edi_mainview_panel_item_current_get(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Save the current file.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_save(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Move the current tab to a new window.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_new_window(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Close the current file.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_close(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Close all open files.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_closeall(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Undo the most recent change in the current view.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_undo(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Return if editor has been modified
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
Eina_Bool edi_mainview_panel_modified(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* See whether the current view can undo a change.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
Eina_Bool edi_mainview_panel_can_undo(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Redo the most recent change in the current view.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_redo(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* See whether the current view can redo a change.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
Eina_Bool edi_mainview_panel_can_redo(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Cut the current selection into the clipboard.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_cut(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Copy the current selection into the clipboard.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_copy(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Paste the current clipboard contents at the current cursor position.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_paste(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Search the current view's contents.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_search(Edi_Mainview_Panel *panel);
|
||||
|
||||
/**
|
||||
* Go to a requested line in the panel's current view contents.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
* @param line the line number (1 based) to scroll to
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_goto(Edi_Mainview_Panel *panel, unsigned int line);
|
||||
|
||||
/**
|
||||
* Go to a requested line, column position in the panel's current view contents.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
* @param row the line number (1 based) to scroll to
|
||||
* @param col the column position (1 based) to scroll to
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_goto_position(Edi_Mainview_Panel *panel, unsigned int row, unsigned int col);
|
||||
|
||||
/**
|
||||
* Present a popup that will initiate a goto in the current panel view.
|
||||
*
|
||||
* @param panel the mainview panel context
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
void edi_mainview_panel_goto_popup_show();
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EDI_MAINVIEW_PANEL_H_ */
|
Loading…
Reference in New Issue