2014-02-12 12:56:20 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* NOTE: Respecting header order is important for portability.
|
|
|
|
* Always put system first, then EFL, then your public header,
|
|
|
|
* and finally your private one. */
|
|
|
|
|
|
|
|
#include <Ecore_Getopt.h>
|
|
|
|
#include <Elementary.h>
|
2014-02-14 15:50:25 -08:00
|
|
|
#include <Eio.h>
|
2014-02-12 12:56:20 -08:00
|
|
|
|
|
|
|
#include "gettext.h"
|
|
|
|
|
|
|
|
#include "Edi.h"
|
2014-02-14 15:50:25 -08:00
|
|
|
#include "edi_filepanel.h"
|
2014-02-15 15:17:40 -08:00
|
|
|
#include "edi_mainview.h"
|
2014-02-12 12:56:20 -08:00
|
|
|
|
|
|
|
#include "edi_private.h"
|
|
|
|
|
2014-02-12 12:58:43 -08:00
|
|
|
#define COPYRIGHT "Copyright © 2014 Andy Williams <andy@andyilliams.me> and various contributors (see AUTHORS)."
|
2014-02-12 12:56:20 -08:00
|
|
|
|
2014-02-16 11:54:06 -08:00
|
|
|
static Evas_Object *edi_win_setup(const char *path);
|
|
|
|
|
2014-02-12 12:56:20 -08:00
|
|
|
static void
|
2014-02-16 11:54:06 -08:00
|
|
|
_edi_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2014-02-12 12:56:20 -08:00
|
|
|
{
|
|
|
|
elm_exit();
|
|
|
|
}
|
|
|
|
|
2014-02-15 15:17:40 -08:00
|
|
|
static void
|
2014-02-26 00:17:44 -08:00
|
|
|
_edi_file_open_cb(const char *path, const char *type)
|
2014-02-15 15:17:40 -08:00
|
|
|
{
|
2014-02-26 00:17:44 -08:00
|
|
|
if (type == NULL)
|
|
|
|
INF("Opening %s", path);
|
|
|
|
else
|
|
|
|
INF("Opening %s as %s", path, type);
|
2014-02-15 15:17:40 -08:00
|
|
|
|
2014-02-26 00:17:44 -08:00
|
|
|
edi_mainview_open_path(path, type);
|
2014-02-25 23:28:24 -08:00
|
|
|
}
|
|
|
|
|
2014-02-12 15:02:09 -08:00
|
|
|
static Evas_Object *
|
2014-02-16 11:54:06 -08:00
|
|
|
edi_content_setup(Evas_Object *win, const char *path)
|
2014-02-12 15:02:09 -08:00
|
|
|
{
|
2014-02-25 20:32:12 -08:00
|
|
|
Evas_Object *panes, *panes_h, *panel;
|
2014-02-12 15:02:09 -08:00
|
|
|
|
|
|
|
panes = elm_panes_add(win);
|
|
|
|
evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
|
|
|
|
// add panes
|
|
|
|
panes_h = elm_panes_add(win);
|
|
|
|
elm_panes_horizontal_set(panes_h, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(panes_h, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(panes_h, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(panes_h);
|
|
|
|
elm_panes_content_right_size_set(panes_h, 0.15);
|
|
|
|
elm_object_part_content_set(panes, "right", panes_h);
|
|
|
|
|
2014-02-25 20:32:12 -08:00
|
|
|
// add lower panel
|
|
|
|
panel = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(panel);
|
|
|
|
edi_logpanel_add(panel);
|
|
|
|
|
|
|
|
elm_object_part_content_set(panes_h, "bottom", panel);
|
|
|
|
|
2014-02-12 15:02:09 -08:00
|
|
|
// add main content
|
2014-02-15 15:17:40 -08:00
|
|
|
panel = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(panel);
|
|
|
|
edi_mainview_add(panel);
|
|
|
|
|
|
|
|
elm_object_part_content_set(panes_h, "top", panel);
|
2014-02-12 15:02:09 -08:00
|
|
|
|
2014-02-25 20:32:12 -08:00
|
|
|
// add file list
|
|
|
|
panel = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(panel);
|
2014-02-26 00:17:44 -08:00
|
|
|
edi_filepanel_add(panel, win, path, _edi_file_open_cb);
|
2014-02-25 20:32:12 -08:00
|
|
|
|
|
|
|
elm_object_part_content_set(panes, "left", panel);
|
|
|
|
elm_panes_content_left_size_set(panes, 0.2);
|
|
|
|
|
2014-02-12 15:02:09 -08:00
|
|
|
|
|
|
|
evas_object_show(panes);
|
|
|
|
return panes;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-02-16 09:09:55 -08:00
|
|
|
_tb_save_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2014-02-12 15:02:09 -08:00
|
|
|
{
|
2014-02-16 09:09:55 -08:00
|
|
|
edi_mainview_save();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_close_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edi_mainview_close();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_cut_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edi_mainview_cut();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_copy_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edi_mainview_copy();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_paste_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edi_mainview_paste();
|
2014-02-12 15:02:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
edi_toolbar_setup(Evas_Object *win)
|
|
|
|
{
|
2014-02-16 09:09:55 -08:00
|
|
|
Evas_Object *tb;
|
|
|
|
Elm_Object_Item *tb_it;
|
2014-02-12 15:02:09 -08:00
|
|
|
|
|
|
|
tb = elm_toolbar_add(win);
|
2014-02-16 09:09:55 -08:00
|
|
|
elm_toolbar_homogeneous_set(tb, EINA_TRUE);
|
2014-02-12 15:02:09 -08:00
|
|
|
elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
|
2014-02-16 09:09:55 -08:00
|
|
|
elm_toolbar_align_set(tb, 0.0);
|
2014-02-12 15:02:09 -08:00
|
|
|
evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
|
|
|
|
|
2014-02-16 09:09:55 -08:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "save", "Save", _tb_save_cb, NULL);
|
|
|
|
tb_it = elm_toolbar_item_append(tb, "close", "Close", _tb_close_cb, NULL);
|
2014-02-12 15:02:09 -08:00
|
|
|
|
2014-02-16 09:09:55 -08:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
|
|
|
|
elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
|
2014-02-12 15:02:09 -08:00
|
|
|
|
2014-02-16 09:09:55 -08:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "edit-cut", "Cut", _tb_cut_cb, NULL);
|
|
|
|
tb_it = elm_toolbar_item_append(tb, "edit-copy", "Copy", _tb_copy_cb, NULL);
|
|
|
|
tb_it = elm_toolbar_item_append(tb, "edit-paste", "Paste", _tb_paste_cb, NULL);
|
2014-02-12 15:02:09 -08:00
|
|
|
|
|
|
|
evas_object_show(tb);
|
|
|
|
return tb;
|
|
|
|
}
|
|
|
|
|
2014-02-16 11:54:06 -08:00
|
|
|
static void
|
|
|
|
_edi_project_chosen_cb(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
const char *selected;
|
|
|
|
|
|
|
|
evas_object_del(data);
|
|
|
|
|
|
|
|
selected = event_info;
|
|
|
|
if (selected)
|
|
|
|
edi_win_setup(selected);
|
|
|
|
else
|
|
|
|
elm_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_edi_project_choose()
|
|
|
|
{
|
|
|
|
Evas_Object *win, *fs;
|
|
|
|
|
|
|
|
elm_need_ethumb();
|
|
|
|
elm_need_efreet();
|
|
|
|
|
|
|
|
win = elm_win_util_standard_add("projectselector", "Choose a Project Folder");
|
|
|
|
if (!win) return NULL;
|
|
|
|
|
|
|
|
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
|
|
|
evas_object_smart_callback_add(win, "delete,request", _edi_exit, NULL);
|
|
|
|
|
|
|
|
fs = elm_fileselector_add(win);
|
|
|
|
evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_smart_callback_add(fs, "done", _edi_project_chosen_cb, win);
|
|
|
|
elm_win_resize_object_add(win, fs);
|
|
|
|
evas_object_show(fs);
|
|
|
|
|
|
|
|
elm_fileselector_expandable_set(fs, EINA_TRUE);
|
|
|
|
elm_fileselector_folder_only_set(fs, EINA_TRUE);
|
|
|
|
elm_fileselector_path_set(fs, getenv("HOME"));
|
2014-02-19 11:24:50 -08:00
|
|
|
elm_fileselector_sort_method_set(fs, ELM_FILESELECTOR_SORT_BY_FILENAME_ASC);
|
2014-02-16 11:54:06 -08:00
|
|
|
|
|
|
|
evas_object_resize(win, 380, 260);
|
|
|
|
evas_object_show(win);
|
|
|
|
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_edi_win_title_get(const char *path)
|
|
|
|
{
|
2014-02-19 11:24:50 -08:00
|
|
|
char *winname, *dirname;
|
2014-02-16 11:54:06 -08:00
|
|
|
|
2014-02-19 11:24:50 -08:00
|
|
|
dirname = basename(path);
|
2014-02-16 11:54:06 -08:00
|
|
|
winname = malloc((8 + strlen(dirname)) * sizeof(char));
|
|
|
|
snprintf(winname, 8 + strlen(dirname), "Edi :: %s", dirname);
|
|
|
|
|
|
|
|
return winname;
|
|
|
|
}
|
|
|
|
|
2014-02-12 12:56:20 -08:00
|
|
|
static Evas_Object *
|
2014-02-16 11:54:06 -08:00
|
|
|
edi_win_setup(const char *path)
|
2014-02-12 12:56:20 -08:00
|
|
|
{
|
2014-02-12 15:20:29 -08:00
|
|
|
Evas_Object *win, *vbx, *content, *tb;
|
2014-02-16 11:54:06 -08:00
|
|
|
const char *winname;
|
|
|
|
|
|
|
|
if (!path) return _edi_project_choose();
|
2014-02-12 12:56:20 -08:00
|
|
|
|
2014-02-16 11:54:06 -08:00
|
|
|
elm_need_ethumb();
|
|
|
|
elm_need_efreet();
|
|
|
|
|
|
|
|
winname = _edi_win_title_get(path);
|
|
|
|
win = elm_win_util_standard_add("main", winname);
|
|
|
|
free(winname);
|
2014-02-12 12:56:20 -08:00
|
|
|
if (!win) return NULL;
|
|
|
|
|
|
|
|
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
2014-02-16 11:54:06 -08:00
|
|
|
evas_object_smart_callback_add(win, "delete,request", _edi_exit, NULL);
|
2014-02-12 12:56:20 -08:00
|
|
|
|
2014-02-12 15:20:29 -08:00
|
|
|
vbx = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(vbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(win, vbx);
|
|
|
|
evas_object_show(vbx);
|
2014-02-12 12:56:20 -08:00
|
|
|
|
2014-02-12 15:02:09 -08:00
|
|
|
tb = edi_toolbar_setup(win);
|
2014-02-12 15:20:29 -08:00
|
|
|
elm_box_pack_end(vbx, tb);
|
|
|
|
|
2014-02-16 11:54:06 -08:00
|
|
|
content = edi_content_setup(win, path);
|
2014-02-12 15:20:29 -08:00
|
|
|
evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(content, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_pack_end(vbx, content);
|
2014-02-12 12:56:20 -08:00
|
|
|
|
2014-02-25 20:32:12 -08:00
|
|
|
ERR("Loaded project at %s", path);
|
2014-02-16 11:54:06 -08:00
|
|
|
evas_object_resize(win, 560, 420);
|
2014-02-12 12:56:20 -08:00
|
|
|
evas_object_show(win);
|
|
|
|
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Ecore_Getopt optdesc = {
|
|
|
|
"edi",
|
2014-02-16 11:54:06 -08:00
|
|
|
"%prog [options] [project-dir]",
|
2014-02-12 12:56:20 -08:00
|
|
|
PACKAGE_VERSION,
|
|
|
|
COPYRIGHT,
|
|
|
|
"BSD with advertisement clause",
|
2014-02-12 15:02:09 -08:00
|
|
|
"The EFL IDE",
|
2014-02-16 11:54:06 -08:00
|
|
|
EINA_TRUE,
|
2014-02-12 12:56:20 -08:00
|
|
|
{
|
|
|
|
ECORE_GETOPT_LICENSE('L', "license"),
|
|
|
|
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
|
|
|
|
ECORE_GETOPT_VERSION('V', "version"),
|
|
|
|
ECORE_GETOPT_HELP('h', "help"),
|
|
|
|
ECORE_GETOPT_SENTINEL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
EAPI_MAIN int
|
|
|
|
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *win;
|
|
|
|
int args;
|
|
|
|
Eina_Bool quit_option = EINA_FALSE;
|
2014-02-16 11:54:06 -08:00
|
|
|
const char *project_path = NULL;
|
2014-02-12 12:56:20 -08:00
|
|
|
|
|
|
|
Ecore_Getopt_Value values[] = {
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
#if ENABLE_NLS
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
edi_init();
|
|
|
|
|
|
|
|
args = ecore_getopt_parse(&optdesc, values, argc, argv);
|
|
|
|
if (args < 0)
|
|
|
|
{
|
2014-02-15 16:31:10 -08:00
|
|
|
EINA_LOG_CRIT("Could not parse arguments.");
|
|
|
|
goto end;
|
2014-02-12 12:56:20 -08:00
|
|
|
}
|
|
|
|
else if (quit_option)
|
|
|
|
{
|
2014-02-15 16:31:10 -08:00
|
|
|
goto end;
|
2014-02-12 12:56:20 -08:00
|
|
|
}
|
|
|
|
|
2014-02-16 11:54:06 -08:00
|
|
|
if (args < argc)
|
|
|
|
{
|
2014-02-19 11:24:50 -08:00
|
|
|
project_path = realpath(argv[args], NULL);
|
2014-02-16 11:54:06 -08:00
|
|
|
}
|
|
|
|
|
2014-02-12 12:56:20 -08:00
|
|
|
elm_app_info_set(elm_main, "edi", "images/edi.png");
|
|
|
|
|
2014-02-16 11:54:06 -08:00
|
|
|
if (!(win = edi_win_setup(project_path)))
|
2014-02-12 12:56:20 -08:00
|
|
|
goto end;
|
|
|
|
|
|
|
|
edi_library_call();
|
|
|
|
|
|
|
|
elm_run();
|
|
|
|
|
|
|
|
end:
|
|
|
|
edi_shutdown();
|
|
|
|
elm_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ELM_MAIN()
|