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-12-01 14:54:17 -08:00
|
|
|
#include "edi_config.h"
|
2014-02-14 15:50:25 -08:00
|
|
|
#include "edi_filepanel.h"
|
2014-04-27 08:57:47 -07:00
|
|
|
#include "edi_logpanel.h"
|
|
|
|
#include "edi_consolepanel.h"
|
2014-09-13 08:48:16 -07:00
|
|
|
#include "mainview/edi_mainview.h"
|
2014-06-29 15:54:29 -07:00
|
|
|
#include "welcome/edi_welcome.h"
|
2014-02-12 12:56:20 -08:00
|
|
|
|
|
|
|
#include "edi_private.h"
|
|
|
|
|
2014-11-29 11:06:02 -08:00
|
|
|
typedef struct _Edi_Panel_Slide_Effect
|
|
|
|
{
|
|
|
|
double max;
|
|
|
|
Evas_Object *content;
|
|
|
|
|
|
|
|
Eina_Bool expand;
|
|
|
|
Eina_Bool left;
|
|
|
|
} Edi_Panel_Slide_Effect;
|
|
|
|
|
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-11-22 07:56:16 -08:00
|
|
|
static Evas_Object *_edi_leftpanes, *_edi_bottompanes;
|
|
|
|
static Evas_Object *_edi_logpanel, *_edi_consolepanel, *_edi_testpanel;
|
|
|
|
static Elm_Object_Item *_edi_logpanel_item, *_edi_consolepanel_item, *_edi_testpanel_item;
|
|
|
|
static Elm_Object_Item *_edi_selected_bottompanel;
|
|
|
|
static Evas_Object *_edi_filepanel, *_edi_filepanel_icon;
|
|
|
|
|
2015-01-15 14:56:08 -08:00
|
|
|
static Evas_Object *_edi_main_win, *_edi_new_popup, *_edi_goto_popup,*_edi_message_popup;
|
2014-12-21 15:32:14 -08:00
|
|
|
int _edi_log_dom = -1;
|
2014-03-14 06:43:34 -07:00
|
|
|
|
2015-01-15 14:56:08 -08:00
|
|
|
static void
|
|
|
|
_edi_on_close_message(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
evas_object_del(data);
|
|
|
|
evas_object_del(_edi_message_popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_message_open(const char *message)
|
|
|
|
{
|
|
|
|
Evas_Object *popup, *button;
|
|
|
|
|
|
|
|
popup = elm_popup_add(_edi_main_win);
|
|
|
|
_edi_message_popup = popup;
|
|
|
|
elm_object_part_text_set(popup, "title,text",
|
|
|
|
message);
|
|
|
|
|
|
|
|
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_on_close_message, NULL);
|
|
|
|
|
|
|
|
evas_object_show(popup);
|
|
|
|
}
|
|
|
|
|
2014-02-15 15:17:40 -08:00
|
|
|
static void
|
2014-03-13 11:31:24 -07:00
|
|
|
_edi_file_open_cb(const char *path, const char *type, Eina_Bool newwin)
|
2014-02-15 15:17:40 -08:00
|
|
|
{
|
2014-03-16 09:01:35 -07:00
|
|
|
Edi_Path_Options *options;
|
|
|
|
|
2015-01-15 14:56:08 -08:00
|
|
|
if (path == NULL)
|
|
|
|
{
|
|
|
|
_edi_message_open("Please choose a file from the list");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-16 09:01:35 -07:00
|
|
|
options = edi_path_options_create(path);
|
|
|
|
options->type = type;
|
|
|
|
|
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-03-13 11:31:24 -07:00
|
|
|
if (newwin)
|
2014-03-16 09:01:35 -07:00
|
|
|
edi_mainview_open_window(options);
|
2014-03-13 11:31:24 -07:00
|
|
|
else
|
2014-03-16 09:01:35 -07:00
|
|
|
edi_mainview_open(options);
|
2014-02-25 23:28:24 -08:00
|
|
|
}
|
|
|
|
|
2014-12-03 15:52:12 -08:00
|
|
|
static Evas_Object *
|
|
|
|
_edi_panel_tab_for_index(int index)
|
|
|
|
{
|
|
|
|
if (index == 1)
|
|
|
|
return _edi_consolepanel;
|
|
|
|
if (index == 2)
|
|
|
|
return _edi_testpanel;
|
|
|
|
|
|
|
|
return _edi_logpanel;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_panel_size_save(Eina_Bool left)
|
|
|
|
{
|
|
|
|
double size;
|
|
|
|
Eina_Bool open;
|
|
|
|
|
|
|
|
if (left)
|
|
|
|
size = elm_panes_content_left_size_get(_edi_leftpanes);
|
|
|
|
else
|
|
|
|
size = elm_panes_content_right_size_get(_edi_bottompanes);
|
|
|
|
open = (size != 0.0);
|
|
|
|
|
|
|
|
if (left)
|
|
|
|
{
|
|
|
|
_edi_cfg->gui.leftopen = open;
|
|
|
|
if (open)
|
|
|
|
_edi_cfg->gui.leftsize = size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_edi_cfg->gui.bottomopen = open;
|
|
|
|
if (open)
|
|
|
|
_edi_cfg->gui.bottomsize = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
_edi_config_save();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_panel_save_tab(int index)
|
|
|
|
{
|
|
|
|
_edi_cfg->gui.bottomtab = index;
|
|
|
|
_edi_config_save();
|
|
|
|
}
|
|
|
|
|
2014-11-29 11:06:02 -08:00
|
|
|
static void
|
|
|
|
_edi_slide_panel(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
|
|
|
|
{
|
|
|
|
Edi_Panel_Slide_Effect *slide;
|
|
|
|
Evas_Object *obj;
|
2014-11-29 18:45:49 -08:00
|
|
|
double position, weight;
|
2014-11-29 11:06:02 -08:00
|
|
|
const Eina_List *item;
|
|
|
|
const Eina_List *objs;
|
|
|
|
|
|
|
|
if (!effect) return;
|
|
|
|
slide = (Edi_Panel_Slide_Effect *)effect;
|
|
|
|
objs = elm_transit_objects_get(transit);
|
|
|
|
|
2014-11-29 18:45:49 -08:00
|
|
|
if (slide->left)
|
|
|
|
position = elm_panes_content_left_size_get(eina_list_nth(objs, 0));
|
|
|
|
else
|
|
|
|
position = elm_panes_content_right_size_get(eina_list_nth(objs, 0));
|
|
|
|
|
2014-11-29 11:06:02 -08:00
|
|
|
if (slide->expand)
|
|
|
|
weight = progress * slide->max;
|
|
|
|
else
|
2014-11-29 18:45:49 -08:00
|
|
|
weight = (1 - progress) * position;
|
2014-11-29 11:06:02 -08:00
|
|
|
|
|
|
|
if (slide->left)
|
|
|
|
EINA_LIST_FOREACH(objs, item, obj)
|
|
|
|
elm_panes_content_left_size_set(obj, weight);
|
|
|
|
else
|
|
|
|
EINA_LIST_FOREACH(objs, item, obj)
|
|
|
|
elm_panes_content_right_size_set(obj, weight);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_slide_panel_free(Elm_Transit_Effect *effect, Elm_Transit *transit EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Edi_Panel_Slide_Effect *slide;
|
|
|
|
|
|
|
|
slide = (Edi_Panel_Slide_Effect *) effect;
|
|
|
|
if (!slide->expand)
|
|
|
|
evas_object_hide(slide->content);
|
|
|
|
free(slide);
|
2014-12-03 15:52:12 -08:00
|
|
|
|
|
|
|
_edi_panel_size_save(slide->left);
|
2014-11-29 11:06:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_slide_panel_new(Evas_Object *panel, Evas_Object *content, double max,
|
|
|
|
Eina_Bool expand, Eina_Bool left)
|
|
|
|
{
|
|
|
|
Edi_Panel_Slide_Effect *slide;
|
|
|
|
Elm_Transit *trans;
|
|
|
|
|
|
|
|
slide = malloc(sizeof(Edi_Panel_Slide_Effect));
|
|
|
|
slide->max = max;
|
|
|
|
slide->content = content;
|
|
|
|
slide->expand = expand;
|
|
|
|
slide->left = left;
|
|
|
|
|
|
|
|
if (slide->expand)
|
|
|
|
evas_object_show(slide->content);
|
|
|
|
|
|
|
|
/* Adding Transit */
|
|
|
|
trans = elm_transit_add();
|
2014-11-29 18:45:49 -08:00
|
|
|
elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
|
2014-11-29 11:06:02 -08:00
|
|
|
elm_transit_object_add(trans, panel);
|
|
|
|
elm_transit_effect_add(trans, _edi_slide_panel, slide, _edi_slide_panel_free);
|
2014-11-29 18:45:49 -08:00
|
|
|
elm_transit_duration_set(trans, 0.33);
|
2014-11-29 11:06:02 -08:00
|
|
|
elm_transit_go(trans);
|
|
|
|
}
|
|
|
|
|
2014-03-14 06:43:34 -07:00
|
|
|
static void
|
2014-11-22 07:56:16 -08:00
|
|
|
_edi_toggle_file_panel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2014-03-14 06:43:34 -07:00
|
|
|
{
|
2014-11-22 07:56:16 -08:00
|
|
|
Evas_Object *panel;
|
|
|
|
double size;
|
|
|
|
|
|
|
|
panel = (Evas_Object *)data;
|
|
|
|
size = elm_panes_content_left_size_get(_edi_leftpanes);
|
|
|
|
|
|
|
|
if (size == 0.0)
|
|
|
|
{
|
|
|
|
elm_icon_standard_set(_edi_filepanel_icon, "stock_left");
|
2014-12-03 15:52:12 -08:00
|
|
|
_edi_slide_panel_new(_edi_leftpanes, panel, _edi_cfg->gui.leftsize, EINA_TRUE, EINA_TRUE);
|
2014-11-22 07:56:16 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elm_icon_standard_set(_edi_filepanel_icon, "stock_right");
|
2014-12-03 15:52:12 -08:00
|
|
|
_edi_slide_panel_new(_edi_leftpanes, panel, _edi_cfg->gui.leftsize, EINA_FALSE, EINA_TRUE);
|
2014-11-22 07:56:16 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_toggle_panel(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2014-12-03 15:52:12 -08:00
|
|
|
int index, c;
|
2014-11-22 07:56:16 -08:00
|
|
|
double size;
|
|
|
|
Elm_Object_Item *item;
|
|
|
|
Evas_Object *panel;
|
|
|
|
|
2014-12-03 15:52:12 -08:00
|
|
|
index = atoi((char *) data);
|
|
|
|
panel = _edi_panel_tab_for_index(index);
|
2014-11-22 07:56:16 -08:00
|
|
|
item = (Elm_Object_Item *) event_info;
|
2014-11-29 10:16:57 -08:00
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
if (obj)
|
|
|
|
elm_object_focus_set(obj, EINA_FALSE);
|
|
|
|
|
2014-12-03 15:52:12 -08:00
|
|
|
for (c = 0; c <= 2; c++)
|
|
|
|
if (c != index)
|
|
|
|
evas_object_hide(_edi_panel_tab_for_index(c));
|
2014-11-22 07:56:16 -08:00
|
|
|
|
|
|
|
if (item == _edi_selected_bottompanel)
|
|
|
|
{
|
|
|
|
elm_toolbar_item_icon_set(item, "stock_up");
|
|
|
|
|
2014-12-03 15:52:12 -08:00
|
|
|
_edi_slide_panel_new(_edi_bottompanes, panel, _edi_cfg->gui.bottomsize, EINA_FALSE, EINA_FALSE);
|
2014-11-22 07:56:16 -08:00
|
|
|
_edi_selected_bottompanel = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (_edi_selected_bottompanel)
|
|
|
|
elm_toolbar_item_icon_set(_edi_selected_bottompanel, "stock_up");
|
|
|
|
elm_toolbar_item_icon_set(item, "stock_down");
|
|
|
|
|
|
|
|
size = elm_panes_content_right_size_get(_edi_bottompanes);
|
|
|
|
if (size == 0.0)
|
2014-12-03 15:52:12 -08:00
|
|
|
_edi_slide_panel_new(_edi_bottompanes, panel, _edi_cfg->gui.bottomsize, EINA_TRUE, EINA_FALSE);
|
2014-11-29 11:06:02 -08:00
|
|
|
else
|
|
|
|
evas_object_show(panel);
|
2014-11-22 07:56:16 -08:00
|
|
|
|
|
|
|
_edi_selected_bottompanel = item;
|
|
|
|
}
|
2014-11-29 10:16:57 -08:00
|
|
|
elm_toolbar_item_selected_set(item, EINA_FALSE);
|
2014-12-03 15:52:12 -08:00
|
|
|
_edi_panel_save_tab(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_panel_dragged_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_edi_panel_size_save(data == _edi_filepanel);
|
2014-03-14 06:43:34 -07:00
|
|
|
}
|
|
|
|
|
2015-01-10 09:43:12 -08:00
|
|
|
void
|
2014-12-03 15:52:12 -08:00
|
|
|
edi_consolepanel_show()
|
2014-04-27 08:57:47 -07:00
|
|
|
{
|
2014-11-29 10:24:56 -08:00
|
|
|
if (_edi_selected_bottompanel != _edi_consolepanel_item)
|
|
|
|
elm_toolbar_item_selected_set(_edi_consolepanel_item, EINA_TRUE);
|
2014-04-27 08:57:47 -07:00
|
|
|
}
|
|
|
|
|
2015-01-10 09:43:12 -08:00
|
|
|
void
|
2014-12-03 15:52:12 -08:00
|
|
|
edi_testpanel_show()
|
2014-11-18 13:11:10 -08:00
|
|
|
{
|
2014-11-29 10:24:56 -08:00
|
|
|
if (_edi_selected_bottompanel != _edi_testpanel_item)
|
|
|
|
elm_toolbar_item_selected_set(_edi_testpanel_item, EINA_TRUE);
|
2014-11-18 13:11:10 -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-11-22 07:56:16 -08:00
|
|
|
Evas_Object *filepane, *logpane, *logpanels, *content_out, *content_in, *tb;
|
|
|
|
Evas_Object *icon, *button;
|
2014-02-12 15:02:09 -08:00
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
filepane = elm_panes_add(win);
|
|
|
|
evas_object_size_hint_weight_set(filepane, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2014-11-22 08:52:14 -08:00
|
|
|
evas_object_size_hint_align_set(filepane, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
logpane = elm_panes_add(win);
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_panes_horizontal_set(logpane, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(logpane, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2014-11-22 08:52:14 -08:00
|
|
|
evas_object_size_hint_align_set(logpane, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2014-02-12 15:02:09 -08:00
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
_edi_filepanel = elm_box_add(win);
|
|
|
|
_edi_logpanel = elm_box_add(win);
|
|
|
|
_edi_consolepanel = elm_box_add(win);
|
|
|
|
_edi_testpanel = elm_box_add(win);
|
2014-02-15 15:17:40 -08:00
|
|
|
|
2014-03-14 06:43:34 -07:00
|
|
|
// add main content
|
|
|
|
content_out = elm_box_add(win);
|
|
|
|
elm_box_horizontal_set(content_out, EINA_FALSE);
|
2014-11-22 08:52:14 -08:00
|
|
|
evas_object_size_hint_weight_set(content_out, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2014-03-14 06:43:34 -07:00
|
|
|
evas_object_size_hint_align_set(content_out, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
|
|
|
|
content_in = elm_box_add(content_out);
|
|
|
|
elm_box_horizontal_set(content_in, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(content_in, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(content_in, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
icon = elm_icon_add(content_in);
|
2014-12-03 15:52:12 -08:00
|
|
|
if (_edi_cfg->gui.leftopen)
|
|
|
|
elm_icon_standard_set(icon, "stock_left");
|
|
|
|
else
|
|
|
|
elm_icon_standard_set(icon, "stock_right");
|
2014-03-14 06:43:34 -07:00
|
|
|
button = elm_button_add(content_in);
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_object_part_content_set(button, "icon", icon);
|
|
|
|
elm_object_focus_allow_set(button, EINA_FALSE);
|
|
|
|
_edi_filepanel_icon = icon;
|
|
|
|
|
2014-03-14 06:43:34 -07:00
|
|
|
evas_object_smart_callback_add(button, "clicked",
|
2014-11-22 07:56:16 -08:00
|
|
|
_edi_toggle_file_panel, _edi_filepanel);
|
2014-03-14 06:43:34 -07:00
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_pack_end(content_in, button);
|
|
|
|
evas_object_show(button);
|
|
|
|
|
|
|
|
edi_mainview_add(content_in, win);
|
|
|
|
evas_object_show(content_in);
|
2014-11-22 08:52:14 -08:00
|
|
|
elm_object_part_content_set(filepane, "right", content_in);
|
|
|
|
elm_box_pack_end(content_out, filepane);
|
2014-03-14 06:43:34 -07:00
|
|
|
|
2014-11-22 08:52:14 -08:00
|
|
|
elm_object_part_content_set(logpane, "top", content_out);
|
|
|
|
evas_object_show(filepane);
|
2014-11-22 07:56:16 -08:00
|
|
|
_edi_leftpanes = filepane;
|
2014-02-12 15:02:09 -08:00
|
|
|
|
2014-02-25 20:32:12 -08:00
|
|
|
// add file list
|
2014-11-22 07:56:16 -08:00
|
|
|
evas_object_size_hint_weight_set(_edi_filepanel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2014-03-14 06:43:34 -07:00
|
|
|
evas_object_size_hint_align_set(_edi_filepanel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2014-12-03 15:52:12 -08:00
|
|
|
if (_edi_cfg->gui.leftopen)
|
|
|
|
elm_panes_content_left_size_set(filepane, _edi_cfg->gui.leftsize);
|
|
|
|
else
|
|
|
|
elm_panes_content_left_size_set(filepane, 0.0);
|
|
|
|
evas_object_smart_callback_add(filepane, "unpress", _edi_panel_dragged_cb, _edi_filepanel);
|
2014-03-14 02:41:09 -07:00
|
|
|
|
2014-03-14 06:43:34 -07:00
|
|
|
edi_filepanel_add(_edi_filepanel, win, path, _edi_file_open_cb);
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_object_part_content_set(filepane, "left", _edi_filepanel);
|
2014-03-14 06:43:34 -07:00
|
|
|
evas_object_show(_edi_filepanel);
|
2014-02-25 20:32:12 -08:00
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
// add lower panel buttons
|
2014-04-27 08:57:47 -07:00
|
|
|
tb = elm_toolbar_add(content_out);
|
|
|
|
evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_toolbar_homogeneous_set(tb, EINA_FALSE);
|
|
|
|
elm_toolbar_align_set(tb, 1.0);
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_toolbar_icon_size_set(tb, 14);
|
|
|
|
elm_object_style_set(tb, "item_horizontal");
|
|
|
|
elm_object_focus_allow_set(tb, EINA_FALSE);
|
2014-04-27 08:57:47 -07:00
|
|
|
elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_toolbar_select_mode_set(tb, ELM_OBJECT_SELECT_MODE_DEFAULT);
|
2014-04-27 08:57:47 -07:00
|
|
|
elm_box_pack_end(content_out, tb);
|
|
|
|
evas_object_show(tb);
|
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
_edi_logpanel_item = elm_toolbar_item_append(tb, "stock_up", "Logs",
|
2014-12-03 15:52:12 -08:00
|
|
|
_edi_toggle_panel, "0");
|
2014-11-22 07:56:16 -08:00
|
|
|
_edi_consolepanel_item = elm_toolbar_item_append(tb, "stock_up", "Console",
|
2014-12-03 15:52:12 -08:00
|
|
|
_edi_toggle_panel, "1");
|
2014-11-22 07:56:16 -08:00
|
|
|
_edi_testpanel_item = elm_toolbar_item_append(tb, "stock_up", "Tests",
|
2014-12-03 15:52:12 -08:00
|
|
|
_edi_toggle_panel, "2");
|
2014-04-27 08:57:47 -07:00
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
// add lower panel panes
|
|
|
|
logpanels = elm_table_add(logpane);
|
|
|
|
evas_object_size_hint_weight_set(_edi_logpanel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2014-03-14 06:43:34 -07:00
|
|
|
evas_object_size_hint_align_set(_edi_logpanel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2014-03-14 02:41:09 -07:00
|
|
|
|
2014-03-14 06:43:34 -07:00
|
|
|
edi_logpanel_add(_edi_logpanel);
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_table_pack(logpanels, _edi_logpanel, 0, 0, 1, 1);
|
2014-03-14 06:43:34 -07:00
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
evas_object_size_hint_weight_set(_edi_consolepanel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2014-04-27 08:57:47 -07:00
|
|
|
evas_object_size_hint_align_set(_edi_consolepanel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
|
|
|
|
edi_consolepanel_add(_edi_consolepanel);
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_table_pack(logpanels, _edi_consolepanel, 0, 0, 1, 1);
|
2014-04-27 08:57:47 -07:00
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
evas_object_size_hint_weight_set(_edi_testpanel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2014-11-18 13:11:10 -08:00
|
|
|
evas_object_size_hint_align_set(_edi_testpanel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
|
|
|
|
edi_testpanel_add(_edi_testpanel);
|
2014-11-22 07:56:16 -08:00
|
|
|
elm_table_pack(logpanels, _edi_testpanel, 0, 0, 1, 1);
|
|
|
|
elm_object_part_content_set(logpane, "bottom", logpanels);
|
2014-12-03 15:52:12 -08:00
|
|
|
if (_edi_cfg->gui.bottomopen)
|
|
|
|
{
|
|
|
|
elm_panes_content_right_size_set(logpane, _edi_cfg->gui.bottomsize);
|
|
|
|
if (_edi_cfg->gui.bottomtab == 1)
|
2014-12-08 13:03:26 -08:00
|
|
|
{
|
|
|
|
elm_toolbar_item_icon_set(_edi_consolepanel_item, "stock_down");
|
|
|
|
_edi_selected_bottompanel = _edi_consolepanel_item;
|
|
|
|
}
|
2014-12-03 15:52:12 -08:00
|
|
|
else if (_edi_cfg->gui.bottomtab == 2)
|
2014-12-08 13:03:26 -08:00
|
|
|
{
|
|
|
|
elm_toolbar_item_icon_set(_edi_testpanel_item, "stock_down");
|
|
|
|
_edi_selected_bottompanel = _edi_testpanel_item;
|
|
|
|
}
|
2014-12-03 15:52:12 -08:00
|
|
|
else
|
2014-12-08 13:03:26 -08:00
|
|
|
{
|
|
|
|
elm_toolbar_item_icon_set(_edi_logpanel_item, "stock_down");
|
|
|
|
_edi_selected_bottompanel = _edi_logpanel_item;
|
|
|
|
}
|
2014-12-03 15:52:12 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_panes_content_right_size_set(logpane, 0.0);
|
|
|
|
if (_edi_cfg->gui.bottomopen)
|
|
|
|
evas_object_show(_edi_panel_tab_for_index(_edi_cfg->gui.bottomtab));
|
|
|
|
evas_object_smart_callback_add(logpane, "unpress", _edi_panel_dragged_cb, NULL);
|
|
|
|
|
2014-11-22 07:56:16 -08:00
|
|
|
evas_object_show(logpane);
|
|
|
|
_edi_bottompanes = logpane;
|
|
|
|
|
|
|
|
return logpane;
|
2014-02-12 15:02:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-03-31 14:24:56 -07:00
|
|
|
_tb_new_create_cb(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2014-02-12 15:02:09 -08:00
|
|
|
{
|
2014-03-31 14:24:56 -07:00
|
|
|
const char *path, *name;
|
|
|
|
|
|
|
|
name = elm_entry_entry_get((Evas_Object *) data);
|
2014-04-27 09:36:20 -07:00
|
|
|
path = edi_project_file_path_get(name);
|
2014-03-31 14:24:56 -07:00
|
|
|
|
|
|
|
fclose(fopen(path, "w"));
|
2015-01-27 14:31:12 -08:00
|
|
|
edi_mainview_open_path(eina_stringshare_add(path));
|
2014-03-31 14:24:56 -07:00
|
|
|
|
|
|
|
evas_object_del(_edi_new_popup);
|
2014-04-27 13:01:42 -07:00
|
|
|
free((char*)path);
|
2014-03-31 14:24:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_new_cancel_cb(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
evas_object_del(_edi_new_popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_new_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *popup, *input, *button;
|
|
|
|
|
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
|
|
|
|
|
|
|
popup = elm_popup_add(_edi_main_win);
|
|
|
|
_edi_new_popup = popup;
|
|
|
|
elm_object_part_text_set(popup, "title,text",
|
|
|
|
"Enter new file name");
|
|
|
|
|
|
|
|
input = elm_entry_add(popup);
|
2014-03-15 06:12:34 -07:00
|
|
|
elm_entry_single_line_set(input, EINA_TRUE);
|
2014-03-31 14:24:56 -07:00
|
|
|
elm_object_content_set(popup, 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",
|
|
|
|
_tb_new_cancel_cb, NULL);
|
|
|
|
|
|
|
|
button = elm_button_add(popup);
|
|
|
|
elm_object_text_set(button, "create");
|
|
|
|
elm_object_part_content_set(popup, "button2", button);
|
|
|
|
evas_object_smart_callback_add(button, "clicked",
|
|
|
|
_tb_new_create_cb, input);
|
|
|
|
|
|
|
|
evas_object_show(popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_save_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
2014-02-16 09:09:55 -08:00
|
|
|
edi_mainview_save();
|
|
|
|
}
|
|
|
|
|
2014-03-13 11:31:24 -07:00
|
|
|
static void
|
2014-03-31 14:24:56 -07:00
|
|
|
_tb_open_window_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2014-03-13 11:31:24 -07:00
|
|
|
{
|
2014-03-31 14:24:56 -07:00
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
2014-03-13 11:31:24 -07:00
|
|
|
edi_mainview_new_window();
|
|
|
|
}
|
|
|
|
|
2014-02-16 09:09:55 -08:00
|
|
|
static void
|
2014-03-31 14:24:56 -07:00
|
|
|
_tb_close_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2014-02-16 09:09:55 -08:00
|
|
|
{
|
2014-03-31 14:24:56 -07:00
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
2014-02-16 09:09:55 -08:00
|
|
|
edi_mainview_close();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-03-31 14:24:56 -07:00
|
|
|
_tb_cut_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2014-02-16 09:09:55 -08:00
|
|
|
{
|
2014-03-31 14:24:56 -07:00
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
2014-02-16 09:09:55 -08:00
|
|
|
edi_mainview_cut();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-03-31 14:24:56 -07:00
|
|
|
_tb_copy_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2014-02-16 09:09:55 -08:00
|
|
|
{
|
2014-03-31 14:24:56 -07:00
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
2014-02-16 09:09:55 -08:00
|
|
|
edi_mainview_copy();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_paste_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2014-03-31 14:24:56 -07:00
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
2014-02-16 09:09:55 -08:00
|
|
|
edi_mainview_paste();
|
2014-02-12 15:02:09 -08:00
|
|
|
}
|
|
|
|
|
2014-04-30 15:06:16 -07:00
|
|
|
static void
|
|
|
|
_tb_search_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
|
|
|
edi_mainview_search();
|
|
|
|
}
|
|
|
|
|
2014-03-15 06:12:34 -07:00
|
|
|
static void
|
|
|
|
_tb_goto_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_goto_popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_goto_cancel_cb(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
evas_object_del(_edi_goto_popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_goto_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *popup, *input, *button;
|
|
|
|
|
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
|
|
|
|
|
|
|
popup = elm_popup_add(_edi_main_win);
|
|
|
|
_edi_goto_popup = popup;
|
|
|
|
elm_object_part_text_set(popup, "title,text",
|
|
|
|
"Enter line number");
|
|
|
|
|
|
|
|
input = elm_entry_add(popup);
|
|
|
|
elm_entry_single_line_set(input, EINA_TRUE);
|
|
|
|
elm_object_content_set(popup, 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",
|
|
|
|
_tb_goto_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",
|
|
|
|
_tb_goto_go_cb, input);
|
|
|
|
|
|
|
|
evas_object_show(popup);
|
|
|
|
}
|
|
|
|
|
2014-11-09 06:08:52 -08:00
|
|
|
static Eina_Bool
|
2014-11-18 13:37:58 -08:00
|
|
|
_edi_build_prep(Evas_Object *button, Eina_Bool test)
|
2014-04-27 08:57:47 -07:00
|
|
|
{
|
2014-11-09 06:08:52 -08:00
|
|
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(button), EINA_FALSE);
|
2014-04-27 08:57:47 -07:00
|
|
|
|
|
|
|
edi_consolepanel_clear();
|
2014-11-18 13:37:58 -08:00
|
|
|
if (test)
|
|
|
|
edi_testpanel_show();
|
|
|
|
else
|
|
|
|
edi_consolepanel_show();
|
2014-04-27 08:57:47 -07:00
|
|
|
|
2014-04-27 09:36:20 -07:00
|
|
|
if (!edi_builder_can_build())
|
|
|
|
{
|
|
|
|
edi_consolepanel_append_error_line("Cowardly refusing to build unknown project type.");
|
2014-11-09 06:08:52 -08:00
|
|
|
return EINA_FALSE;
|
2014-04-27 09:36:20 -07:00
|
|
|
}
|
2014-11-09 06:08:52 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_build_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2014-11-18 13:37:58 -08:00
|
|
|
if (_edi_build_prep(obj, EINA_FALSE))
|
2014-11-09 06:08:52 -08:00
|
|
|
edi_builder_build();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tb_test_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2014-11-18 13:37:58 -08:00
|
|
|
if (_edi_build_prep(obj, EINA_TRUE))
|
|
|
|
edi_builder_test();
|
2014-11-09 06:08:52 -08:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
static void
|
|
|
|
_tb_run_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2014-11-18 13:37:58 -08:00
|
|
|
if (_edi_build_prep(obj, EINA_FALSE))
|
2014-11-09 06:08:52 -08:00
|
|
|
edi_builder_run();
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_tb_clean_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2014-11-18 13:37:58 -08:00
|
|
|
if (_edi_build_prep(obj, EINA_FALSE))
|
2014-11-09 06:08:52 -08:00
|
|
|
edi_builder_clean();
|
2014-04-27 08:57:47 -07:00
|
|
|
}
|
|
|
|
|
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-03-31 14:24:56 -07:00
|
|
|
elm_toolbar_homogeneous_set(tb, EINA_FALSE);
|
2014-02-12 15:02:09 -08:00
|
|
|
elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
|
2014-03-31 14:24:56 -07:00
|
|
|
elm_toolbar_select_mode_set(tb, ELM_OBJECT_SELECT_MODE_NONE);
|
2014-02-16 09:09:55 -08:00
|
|
|
elm_toolbar_align_set(tb, 0.0);
|
2014-03-31 14:24:56 -07:00
|
|
|
elm_object_focus_allow_set(tb, EINA_FALSE);
|
2014-02-12 15:02:09 -08:00
|
|
|
evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
|
|
|
|
|
2014-03-31 14:24:56 -07:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "document-new", "New File", _tb_new_cb, NULL);
|
|
|
|
tb_it = elm_toolbar_item_append(tb, "document-save", "Save", _tb_save_cb, NULL);
|
|
|
|
tb_it = elm_toolbar_item_append(tb, "window-new", "New window", _tb_open_window_cb, NULL);
|
2014-03-13 09:34:05 -07:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "window-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-03-31 14:24:56 -07:00
|
|
|
|
2014-04-27 08:57:47 -07:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
|
|
|
|
elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
|
|
|
|
|
2015-01-18 09:36:12 -08:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "find", "Find & Replace", _tb_search_cb, NULL);
|
2014-03-15 06:12:34 -07:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "go-jump", "Goto Line", _tb_goto_cb, NULL);
|
2014-04-30 15:06:16 -07:00
|
|
|
|
|
|
|
tb_it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
|
|
|
|
elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
|
|
|
|
|
2014-04-27 08:57:47 -07:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "system-run", "Build", _tb_build_cb, NULL);
|
2014-11-09 06:08:52 -08:00
|
|
|
tb_it = elm_toolbar_item_append(tb, "emblem-default", "Test", _tb_test_cb, NULL);
|
|
|
|
// tb_it = elm_toolbar_item_append(tb, "player-play", "Run", _tb_run_cb, NULL);
|
|
|
|
tb_it = elm_toolbar_item_append(tb, "edit-clear", "Clean", _tb_clean_cb, NULL);
|
2014-04-27 08:57:47 -07:00
|
|
|
|
2014-02-12 15:02:09 -08:00
|
|
|
evas_object_show(tb);
|
|
|
|
return tb;
|
|
|
|
}
|
|
|
|
|
2014-02-16 11:54:06 -08:00
|
|
|
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-04-27 13:01:42 -07:00
|
|
|
dirname = basename((char*)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-06-29 15:54:29 -07:00
|
|
|
static void
|
|
|
|
_edi_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
edi_close();
|
|
|
|
}
|
|
|
|
|
2014-12-03 15:52:12 -08:00
|
|
|
static void
|
|
|
|
_edi_resize_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
|
|
|
w /= elm_config_scale_get();
|
|
|
|
h /= elm_config_scale_get();
|
|
|
|
|
|
|
|
_edi_cfg->gui.width = w + 1;
|
|
|
|
_edi_cfg->gui.height = h + 1;
|
|
|
|
_edi_config_save();
|
|
|
|
}
|
|
|
|
|
2015-01-10 09:43:12 -08:00
|
|
|
Evas_Object *
|
2014-11-12 15:43:18 -08:00
|
|
|
edi_open(const char *inputpath)
|
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;
|
2014-11-12 15:43:18 -08:00
|
|
|
char *path;
|
2014-02-16 11:54:06 -08:00
|
|
|
|
2014-11-12 15:43:18 -08:00
|
|
|
if (!edi_project_set(inputpath))
|
2014-10-22 14:41:23 -07:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Project path must be a directory\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-11-12 15:43:18 -08:00
|
|
|
path = realpath(inputpath, NULL);
|
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);
|
2014-04-27 13:01:42 -07:00
|
|
|
free((char*)winname);
|
2014-02-12 12:56:20 -08:00
|
|
|
if (!win) return NULL;
|
|
|
|
|
2014-03-31 14:24:56 -07:00
|
|
|
_edi_main_win = win;
|
2014-02-12 12:56:20 -08:00
|
|
|
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-12-03 15:52:12 -08:00
|
|
|
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _edi_resize_cb, 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-03-14 02:41:09 -07:00
|
|
|
content = edi_content_setup(vbx, 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-12-03 15:52:12 -08:00
|
|
|
evas_object_resize(win, _edi_cfg->gui.width * elm_config_scale_get(),
|
|
|
|
_edi_cfg->gui.height * elm_config_scale_get());
|
2014-02-12 12:56:20 -08:00
|
|
|
evas_object_show(win);
|
|
|
|
|
2014-12-01 14:54:17 -08:00
|
|
|
_edi_config_project_add(path);
|
|
|
|
|
2014-11-12 15:43:18 -08:00
|
|
|
free(path);
|
2014-02-12 12:56:20 -08:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
2015-01-10 09:43:12 -08:00
|
|
|
void
|
2014-06-29 15:54:29 -07:00
|
|
|
edi_close()
|
|
|
|
{
|
|
|
|
elm_exit();
|
|
|
|
}
|
|
|
|
|
2014-12-21 15:32:14 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_edi_log_init()
|
|
|
|
{
|
|
|
|
_edi_log_dom = eina_log_domain_register("edi", EINA_COLOR_GREEN);
|
|
|
|
if (_edi_log_dom < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Edi can not create its log domain.");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_log_shutdown()
|
|
|
|
{
|
|
|
|
eina_log_domain_unregister(_edi_log_dom);
|
|
|
|
_edi_log_dom = -1;
|
|
|
|
}
|
|
|
|
|
2014-02-12 12:56:20 -08:00
|
|
|
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
|
|
|
|
|
2014-12-01 14:54:17 -08:00
|
|
|
if (!_edi_config_init())
|
|
|
|
goto config_error;
|
|
|
|
|
2014-02-12 12:56:20 -08:00
|
|
|
edi_init();
|
2014-12-21 15:32:14 -08:00
|
|
|
if (!_edi_log_init())
|
|
|
|
goto end;
|
2014-02-12 12:56:20 -08:00
|
|
|
|
|
|
|
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-10-22 14:41:23 -07:00
|
|
|
project_path = argv[args];
|
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-06-29 15:54:29 -07:00
|
|
|
if (!project_path)
|
|
|
|
{
|
|
|
|
if (!edi_welcome_show())
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
else if (!(win = edi_open(project_path)))
|
2014-02-12 12:56:20 -08:00
|
|
|
goto end;
|
|
|
|
|
|
|
|
elm_run();
|
|
|
|
|
|
|
|
end:
|
2014-12-21 15:32:14 -08:00
|
|
|
_edi_log_shutdown();
|
2014-02-12 12:56:20 -08:00
|
|
|
elm_shutdown();
|
2014-12-01 14:54:17 -08:00
|
|
|
edi_shutdown();
|
|
|
|
|
|
|
|
config_error:
|
|
|
|
_edi_config_shutdown();
|
2014-02-12 12:56:20 -08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ELM_MAIN()
|