2013-07-20 01:51:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
struct menu_s
|
|
|
|
{
|
|
|
|
Evas_Object *win;
|
|
|
|
Evas_Object *menu_layout;
|
|
|
|
Evas_Object *setting_layout;
|
|
|
|
Evas_Object *warning_layout;
|
|
|
|
Evas_Object *fileselector_layout;
|
2013-08-30 09:40:15 -07:00
|
|
|
Evas_Object *about_layout;
|
2013-07-20 01:51:56 -07:00
|
|
|
Evas_Object *img_path_entry;
|
|
|
|
Evas_Object *snd_path_entry;
|
2013-08-27 10:26:13 -07:00
|
|
|
Evas_Object *fnt_path_entry;
|
2013-08-27 21:22:46 -07:00
|
|
|
Evas_Object *data_path_entry;
|
2013-08-21 10:04:24 -07:00
|
|
|
Evas_Object *slider_font;
|
2014-01-27 22:22:26 -08:00
|
|
|
Evas_Object *slider_view;
|
2013-07-20 01:51:56 -07:00
|
|
|
Evas_Object *toggle_stats;
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *toggle_linenum;
|
2013-07-20 01:51:56 -07:00
|
|
|
Evas_Object *toggle_highlight;
|
2013-08-20 09:22:44 -07:00
|
|
|
Evas_Object *toggle_swallow;
|
2013-08-20 09:19:09 -07:00
|
|
|
Evas_Object *toggle_indent;
|
2013-07-20 01:51:56 -07:00
|
|
|
Evas_Object *ctxpopup;
|
|
|
|
|
2013-12-12 04:54:39 -08:00
|
|
|
const char *last_accessed_path;
|
|
|
|
|
2014-01-29 04:56:29 -08:00
|
|
|
int open_depth;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
edit_data *ed;
|
|
|
|
};
|
|
|
|
|
2014-01-29 08:15:33 -08:00
|
|
|
static menu_data *g_md = NULL;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-07-22 09:58:47 -07:00
|
|
|
static void warning_no_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED);
|
|
|
|
static void new_save_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED);
|
|
|
|
static void edc_reload(menu_data *md, const char *edc_path);
|
|
|
|
static void edc_file_save(menu_data *md);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
static void
|
2014-01-29 08:15:33 -08:00
|
|
|
fileselector_close()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_data *md = g_md;
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_signal_emit(md->fileselector_layout, "elm,state,dismiss", "");
|
|
|
|
}
|
|
|
|
|
2013-07-20 23:56:44 -07:00
|
|
|
static void
|
2014-01-29 08:15:33 -08:00
|
|
|
about_close()
|
2013-07-20 23:56:44 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_data *md = g_md;
|
2013-08-30 09:40:15 -07:00
|
|
|
elm_object_signal_emit(md->about_layout, "elm,state,dismiss", "");
|
2013-07-20 23:56:44 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
2014-01-29 08:15:33 -08:00
|
|
|
setting_close()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_data *md = g_md;
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_signal_emit(md->setting_layout, "elm,state,dismiss", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-29 08:15:33 -08:00
|
|
|
warning_close()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_data *md = g_md;
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_signal_emit(md->warning_layout, "elm,state,dismiss", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_close()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_data *md = g_md;
|
2014-01-29 04:56:29 -08:00
|
|
|
if (!md->menu_layout) return;
|
|
|
|
elm_object_signal_emit(md->menu_layout, "elm,state,dismiss", "");
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fileselector_dismiss_done(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
evas_object_del(md->fileselector_layout);
|
|
|
|
md->fileselector_layout = NULL;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth--;
|
2013-07-20 01:51:56 -07:00
|
|
|
if (md->menu_layout)
|
|
|
|
{
|
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_FALSE);
|
|
|
|
elm_object_focus_set(md->menu_layout, EINA_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
setting_dismiss_done(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
2013-07-21 00:10:00 -07:00
|
|
|
evas_object_del(md->setting_layout);
|
|
|
|
md->setting_layout = NULL;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth--;
|
2013-08-25 10:17:57 -07:00
|
|
|
if (!md->menu_layout) return;
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_FALSE);
|
|
|
|
elm_object_focus_set(md->menu_layout, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
2013-07-20 23:56:44 -07:00
|
|
|
static void
|
2013-08-30 09:40:15 -07:00
|
|
|
about_dismiss_done(void *data, Evas_Object *obj EINA_UNUSED,
|
2013-07-20 23:56:44 -07:00
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
2013-08-30 09:40:15 -07:00
|
|
|
evas_object_del(md->about_layout);
|
|
|
|
md->about_layout = NULL;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth--;
|
2013-08-25 10:17:57 -07:00
|
|
|
if (!md->menu_layout) return;
|
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_FALSE);
|
|
|
|
elm_object_focus_set(md->menu_layout, EINA_TRUE);
|
2013-07-20 23:56:44 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
|
|
|
menu_dismiss_done(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
evas_object_del(md->menu_layout);
|
|
|
|
md->menu_layout = NULL;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth--;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
warning_dismiss_done(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
evas_object_del(md->warning_layout);
|
|
|
|
md->warning_layout = NULL;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth--;
|
2013-08-25 10:17:57 -07:00
|
|
|
if (!md->menu_layout) return;
|
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_FALSE);
|
|
|
|
elm_object_focus_set(md->menu_layout, EINA_TRUE);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
warning_layout_create(menu_data *md, Evas_Smart_Cb yes_cb,
|
|
|
|
Evas_Smart_Cb save_cb)
|
|
|
|
{
|
2013-08-06 08:37:35 -07:00
|
|
|
if (md->warning_layout) return;
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
//Layout
|
|
|
|
Evas_Object *layout = elm_layout_add(md->win);
|
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "warning_layout");
|
|
|
|
elm_object_signal_callback_add(layout, "elm,state,dismiss,done", "",
|
|
|
|
warning_dismiss_done, md);
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(md->win, layout);
|
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
Evas_Object *btn;
|
|
|
|
|
|
|
|
//Save Button
|
|
|
|
btn = elm_button_add(layout);
|
|
|
|
elm_object_text_set(btn, "Save");
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", save_cb, md);
|
|
|
|
evas_object_show(btn);
|
|
|
|
elm_object_focus_set(btn, EINA_TRUE);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.save", btn);
|
|
|
|
|
|
|
|
//No Button
|
|
|
|
btn = elm_button_add(layout);
|
|
|
|
elm_object_text_set(btn, "No");
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", warning_no_btn_cb, md);
|
|
|
|
evas_object_show(btn);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.no", btn);
|
|
|
|
|
|
|
|
//Yes Button
|
|
|
|
btn = elm_button_add(layout);
|
|
|
|
elm_object_text_set(btn, "Yes");
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", yes_cb, md);
|
|
|
|
evas_object_show(btn);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.yes", btn);
|
|
|
|
|
|
|
|
if (md->menu_layout)
|
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_TRUE);
|
|
|
|
|
|
|
|
md->warning_layout = layout;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth++;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
setting_apply_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
2014-01-29 09:45:10 -08:00
|
|
|
|
|
|
|
config_edc_img_path_set(elm_object_text_get(md->img_path_entry));
|
|
|
|
config_edc_snd_path_set(elm_object_text_get(md->snd_path_entry));
|
|
|
|
config_edc_fnt_path_set(elm_object_text_get(md->fnt_path_entry));
|
|
|
|
config_edc_data_path_set(elm_object_text_get(md->data_path_entry));
|
|
|
|
config_font_size_set((float) elm_slider_value_get(md->slider_font));
|
|
|
|
config_view_scale_set(elm_slider_value_get(md->slider_view));
|
|
|
|
config_stats_bar_set(elm_check_state_get(md->toggle_stats));
|
|
|
|
config_linenumber_set(elm_check_state_get(md->toggle_linenum));
|
|
|
|
config_part_highlight_set(elm_check_state_get(md->toggle_highlight));
|
|
|
|
config_dummy_swallow_set(elm_check_state_get(md->toggle_swallow));
|
|
|
|
config_auto_indent_set(elm_check_state_get(md->toggle_indent));
|
|
|
|
|
|
|
|
config_apply();
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
setting_close(md);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
img_path_entry_update(Evas_Object *entry, Eina_List *edc_img_paths)
|
|
|
|
{
|
|
|
|
elm_entry_entry_set(entry, NULL);
|
|
|
|
|
|
|
|
Eina_List *l;
|
|
|
|
char *edc_img_path;
|
|
|
|
EINA_LIST_FOREACH(edc_img_paths, l, edc_img_path)
|
|
|
|
{
|
|
|
|
elm_entry_entry_append(entry, edc_img_path);
|
|
|
|
elm_entry_entry_append(entry, ";");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-27 10:26:13 -07:00
|
|
|
static void
|
|
|
|
fnt_path_entry_update(Evas_Object *entry, Eina_List *edc_fnt_paths)
|
|
|
|
{
|
|
|
|
elm_entry_entry_set(entry, NULL);
|
|
|
|
|
|
|
|
Eina_List *l;
|
|
|
|
char *edc_fnt_path;
|
|
|
|
EINA_LIST_FOREACH(edc_fnt_paths, l, edc_fnt_path)
|
|
|
|
{
|
|
|
|
elm_entry_entry_append(entry, edc_fnt_path);
|
|
|
|
elm_entry_entry_append(entry, ";");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-27 21:22:46 -07:00
|
|
|
static void
|
|
|
|
data_path_entry_update(Evas_Object *entry, Eina_List *edc_data_paths)
|
|
|
|
{
|
|
|
|
elm_entry_entry_set(entry, NULL);
|
|
|
|
|
|
|
|
Eina_List *l;
|
|
|
|
char *edc_data_path;
|
|
|
|
EINA_LIST_FOREACH(edc_data_paths, l, edc_data_path)
|
|
|
|
{
|
|
|
|
elm_entry_entry_append(entry, edc_data_path);
|
|
|
|
elm_entry_entry_append(entry, ";");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
|
|
|
snd_path_entry_update(Evas_Object *entry, Eina_List *edc_snd_paths)
|
|
|
|
{
|
|
|
|
elm_entry_entry_set(entry, NULL);
|
|
|
|
|
|
|
|
Eina_List *l;
|
|
|
|
char *edc_snd_path;
|
|
|
|
EINA_LIST_FOREACH(edc_snd_paths, l, edc_snd_path)
|
|
|
|
{
|
|
|
|
elm_entry_entry_append(entry, edc_snd_path);
|
|
|
|
elm_entry_entry_append(entry, ";");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 07:15:00 -07:00
|
|
|
static void
|
|
|
|
setting_cancel_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
setting_close(md);
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
|
|
|
setting_reset_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
|
|
|
|
img_path_entry_update(md->img_path_entry,
|
2014-01-29 09:45:10 -08:00
|
|
|
(Eina_List *)config_edc_img_path_list_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
snd_path_entry_update(md->snd_path_entry,
|
2014-01-29 09:45:10 -08:00
|
|
|
(Eina_List *)config_edc_snd_path_list_get());
|
2013-08-27 10:26:13 -07:00
|
|
|
fnt_path_entry_update(md->fnt_path_entry,
|
2014-01-29 09:45:10 -08:00
|
|
|
(Eina_List *)config_edc_fnt_path_list_get());
|
2013-08-27 21:22:46 -07:00
|
|
|
data_path_entry_update(md->data_path_entry,
|
2014-01-29 09:45:10 -08:00
|
|
|
(Eina_List *)config_edc_data_path_list_get());
|
2013-08-27 10:26:13 -07:00
|
|
|
|
2014-01-29 09:45:10 -08:00
|
|
|
elm_slider_value_set(md->slider_font, (double) config_font_size_get());
|
|
|
|
elm_slider_value_set(md->slider_view, (double) config_view_scale_get());
|
2013-08-24 10:41:53 -07:00
|
|
|
|
2014-01-29 09:45:10 -08:00
|
|
|
elm_check_state_set(md->toggle_stats, config_stats_bar_get());
|
|
|
|
elm_check_state_set(md->toggle_linenum, config_linenumber_get());
|
|
|
|
elm_check_state_set(md->toggle_highlight, config_part_highlight_get());
|
|
|
|
elm_check_state_set(md->toggle_swallow, config_dummy_swallow_get());
|
|
|
|
elm_check_state_set(md->toggle_indent, config_auto_indent_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2014-01-29 09:05:51 -08:00
|
|
|
static Evas_Object *
|
|
|
|
entry_create(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *entry = elm_entry_add(parent);
|
|
|
|
elm_object_style_set(entry, elm_app_name_get());
|
|
|
|
elm_entry_single_line_set(entry, EINA_TRUE);
|
|
|
|
elm_entry_scrollable_set(entry, EINA_TRUE);
|
|
|
|
evas_object_show(entry);
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
toggle_create(Evas_Object *parent, const char *text, Eina_Bool state)
|
|
|
|
{
|
|
|
|
Evas_Object *toggle = elm_check_add(parent);
|
|
|
|
elm_object_style_set(toggle, "toggle");
|
|
|
|
elm_check_state_set(toggle, state);
|
|
|
|
evas_object_size_hint_weight_set(toggle, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(toggle, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_text_set(toggle, text);
|
|
|
|
evas_object_show(toggle);
|
|
|
|
|
|
|
|
return toggle;
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
|
|
|
setting_open(menu_data *md)
|
|
|
|
{
|
|
|
|
//Layout
|
|
|
|
Evas_Object *layout = elm_layout_add(md->win);
|
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "setting_layout");
|
|
|
|
elm_object_signal_callback_add(layout, "elm,state,dismiss,done", "",
|
|
|
|
setting_dismiss_done, md);
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(md->win, layout);
|
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
//Image Path Entry
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *img_path_entry = entry_create(layout);
|
2013-07-20 01:51:56 -07:00
|
|
|
img_path_entry_update(img_path_entry,
|
2014-01-29 09:45:10 -08:00
|
|
|
(Eina_List *)config_edc_img_path_list_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_focus_set(img_path_entry, EINA_TRUE);
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.img_path_entry",
|
|
|
|
img_path_entry);
|
|
|
|
|
|
|
|
//Sound Path Entry
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *snd_path_entry = entry_create(layout);
|
2013-07-20 01:51:56 -07:00
|
|
|
snd_path_entry_update(snd_path_entry,
|
2014-01-29 09:45:10 -08:00
|
|
|
(Eina_List *)config_edc_snd_path_list_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.snd_path_entry",
|
|
|
|
snd_path_entry);
|
2013-08-27 10:26:13 -07:00
|
|
|
//Font Path Entry
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *fnt_path_entry = entry_create(layout);
|
2013-08-27 10:26:13 -07:00
|
|
|
fnt_path_entry_update(fnt_path_entry,
|
2014-01-29 09:45:10 -08:00
|
|
|
(Eina_List *)config_edc_fnt_path_list_get());
|
2013-08-27 10:26:13 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.fnt_path_entry",
|
|
|
|
fnt_path_entry);
|
2013-08-27 21:22:46 -07:00
|
|
|
|
|
|
|
//Data Path Entry
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *data_path_entry = entry_create(layout);
|
2013-08-27 21:22:46 -07:00
|
|
|
data_path_entry_update(data_path_entry,
|
2014-01-29 09:45:10 -08:00
|
|
|
(Eina_List *)config_edc_data_path_list_get());
|
2013-08-27 21:22:46 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.data_path_entry",
|
|
|
|
data_path_entry);
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
//Preference
|
2013-07-20 03:56:33 -07:00
|
|
|
Evas_Object *scroller = elm_scroller_add(layout);
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.preference", scroller);
|
|
|
|
evas_object_show(scroller);
|
|
|
|
|
|
|
|
Evas_Object *box = elm_box_add(scroller);
|
|
|
|
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);
|
2013-07-20 01:51:56 -07:00
|
|
|
evas_object_show(box);
|
|
|
|
|
2013-07-20 03:56:33 -07:00
|
|
|
elm_object_content_set(scroller, box);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-01-27 22:22:26 -08:00
|
|
|
Evas_Object *label, *box2;
|
|
|
|
|
2013-08-21 10:04:24 -07:00
|
|
|
//Font Size
|
2014-01-27 22:22:26 -08:00
|
|
|
box2 = elm_box_add(box);
|
2013-08-21 10:04:24 -07:00
|
|
|
elm_box_horizontal_set(box2, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(box2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(box2, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(box2);
|
|
|
|
|
|
|
|
elm_box_pack_end(box, box2);
|
|
|
|
|
|
|
|
//Font Size (Label)
|
2014-01-27 22:22:26 -08:00
|
|
|
label = elm_label_add(box2);
|
2013-08-21 10:04:24 -07:00
|
|
|
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(label, 0, EVAS_HINT_FILL);
|
|
|
|
|
|
|
|
elm_object_text_set(label, "Font Size");
|
|
|
|
evas_object_show(label);
|
|
|
|
|
|
|
|
elm_box_pack_end(box2, label);
|
|
|
|
|
|
|
|
//Font Size (Slider)
|
2014-01-27 22:22:26 -08:00
|
|
|
Evas_Object *slider_font = elm_slider_add(box2);
|
|
|
|
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(slider_font, 1, EVAS_HINT_FILL);
|
|
|
|
elm_slider_span_size_set(slider_font, 400);
|
|
|
|
elm_slider_indicator_show_set(slider_font, EINA_FALSE);
|
|
|
|
elm_slider_unit_format_set(slider_font, "%1.1fx");
|
|
|
|
elm_slider_min_max_set(slider_font, MIN_FONT_SIZE, MAX_FONT_SIZE);
|
2014-01-29 09:45:10 -08:00
|
|
|
elm_slider_value_set(slider_font, (double) config_font_size_get());
|
2014-01-27 22:22:26 -08:00
|
|
|
evas_object_show(slider_font);
|
|
|
|
|
|
|
|
elm_box_pack_end(box2, slider_font);
|
|
|
|
|
|
|
|
//View Scale
|
|
|
|
box2 = elm_box_add(box);
|
|
|
|
elm_box_horizontal_set(box2, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(box2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(box2, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(box2);
|
|
|
|
|
|
|
|
elm_box_pack_end(box, box2);
|
|
|
|
|
|
|
|
//View Scale (Label)
|
|
|
|
label = elm_label_add(box2);
|
|
|
|
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(label, 0, EVAS_HINT_FILL);
|
|
|
|
|
|
|
|
elm_object_text_set(label, "View Scale");
|
|
|
|
evas_object_show(label);
|
|
|
|
|
|
|
|
elm_box_pack_end(box2, label);
|
|
|
|
|
|
|
|
//View Scale (Slider)
|
|
|
|
Evas_Object *slider_view = elm_slider_add(box2);
|
2013-08-21 10:04:24 -07:00
|
|
|
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2014-01-27 22:22:26 -08:00
|
|
|
evas_object_size_hint_align_set(slider_view, 1, EVAS_HINT_FILL);
|
|
|
|
elm_slider_span_size_set(slider_view, 394);
|
|
|
|
elm_slider_indicator_show_set(slider_view, EINA_FALSE);
|
|
|
|
elm_slider_unit_format_set(slider_view, "%1.2fx");
|
|
|
|
elm_slider_min_max_set(slider_view, MIN_VIEW_SCALE, MAX_VIEW_SCALE);
|
2014-01-29 09:45:10 -08:00
|
|
|
elm_slider_value_set(slider_view, (double) config_view_scale_get());
|
2014-01-27 22:22:26 -08:00
|
|
|
evas_object_show(slider_view);
|
2013-08-21 10:04:24 -07:00
|
|
|
|
2014-01-27 22:22:26 -08:00
|
|
|
elm_box_pack_end(box2, slider_view);
|
2013-08-21 10:04:24 -07:00
|
|
|
|
2013-08-28 21:25:49 -07:00
|
|
|
//Toggle (File Tab)
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *toggle_filetab = toggle_create(box, "File Tab", EINA_FALSE);
|
|
|
|
elm_object_disabled_set(toggle_filetab, EINA_TRUE);
|
|
|
|
elm_box_pack_end(box, toggle_filetab);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//Toggle (Status bar)
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *toggle_stats = toggle_create(box, "Status Bar",
|
2014-01-29 09:45:10 -08:00
|
|
|
config_stats_bar_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_box_pack_end(box, toggle_stats);
|
|
|
|
|
|
|
|
//Toggle (Line Number)
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *toggle_linenum = toggle_create(box, "Line Number",
|
2014-01-29 09:45:10 -08:00
|
|
|
config_linenumber_get());
|
2014-01-29 09:05:51 -08:00
|
|
|
elm_box_pack_end(box, toggle_linenum);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//Toggle (Part Highlighting)
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *toggle_highlight = toggle_create(box, "Part Highlighting",
|
2014-01-29 09:45:10 -08:00
|
|
|
config_part_highlight_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_box_pack_end(box, toggle_highlight);
|
|
|
|
|
2013-07-20 03:56:33 -07:00
|
|
|
//Toggle (Dummy Swallow)
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *toggle_swallow = toggle_create(box, "Dummy Swallow",
|
2014-01-29 09:45:10 -08:00
|
|
|
config_dummy_swallow_get());
|
2013-08-20 09:22:44 -07:00
|
|
|
elm_box_pack_end(box, toggle_swallow);
|
2013-07-20 03:56:33 -07:00
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
//Toggle (Auto Indentation)
|
2014-01-29 09:05:51 -08:00
|
|
|
Evas_Object *toggle_indent = toggle_create(box, "Auto Indentation",
|
2014-01-29 09:45:10 -08:00
|
|
|
config_auto_indent_get());
|
2013-08-20 09:19:09 -07:00
|
|
|
elm_box_pack_end(box, toggle_indent);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
Evas_Object *btn;
|
|
|
|
|
|
|
|
//Apply Button
|
|
|
|
btn = elm_button_add(layout);
|
|
|
|
elm_object_text_set(btn, "Apply");
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", setting_apply_btn_cb, md);
|
|
|
|
evas_object_show(btn);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.apply_btn", btn);
|
|
|
|
|
2013-08-28 07:15:00 -07:00
|
|
|
//Reset Button
|
2013-07-20 01:51:56 -07:00
|
|
|
btn = elm_button_add(layout);
|
|
|
|
elm_object_text_set(btn, "Reset");
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", setting_reset_btn_cb, md);
|
|
|
|
evas_object_show(btn);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.reset_btn", btn);
|
|
|
|
|
2013-08-28 07:15:00 -07:00
|
|
|
//Cancel Button
|
|
|
|
btn = elm_button_add(layout);
|
|
|
|
elm_object_text_set(btn, "Cancel");
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", setting_cancel_btn_cb, md);
|
|
|
|
evas_object_show(btn);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.cancel_btn", btn);
|
|
|
|
|
2013-08-25 10:17:57 -07:00
|
|
|
if (md->menu_layout)
|
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_TRUE);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
md->setting_layout = layout;
|
|
|
|
md->img_path_entry = img_path_entry;
|
|
|
|
md->snd_path_entry = snd_path_entry;
|
2013-08-27 10:26:13 -07:00
|
|
|
md->fnt_path_entry = fnt_path_entry;
|
2013-08-27 21:22:46 -07:00
|
|
|
md->data_path_entry = data_path_entry;
|
2014-01-27 22:22:26 -08:00
|
|
|
md->slider_font = slider_font;
|
|
|
|
md->slider_view = slider_view;
|
2013-07-20 01:51:56 -07:00
|
|
|
md->toggle_stats = toggle_stats;
|
2014-01-29 09:05:51 -08:00
|
|
|
md->toggle_linenum = toggle_linenum;
|
2013-07-20 01:51:56 -07:00
|
|
|
md->toggle_highlight = toggle_highlight;
|
2013-08-20 09:22:44 -07:00
|
|
|
md->toggle_swallow = toggle_swallow;
|
2013-08-20 09:19:09 -07:00
|
|
|
md->toggle_indent = toggle_indent;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth++;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 22:38:08 -07:00
|
|
|
static void
|
2013-08-30 09:40:15 -07:00
|
|
|
about_open(menu_data *md)
|
2013-07-20 22:38:08 -07:00
|
|
|
{
|
|
|
|
//Layout
|
|
|
|
Evas_Object *layout = elm_layout_add(md->win);
|
2013-08-30 09:40:15 -07:00
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "about_layout");
|
2013-07-20 22:38:08 -07:00
|
|
|
elm_object_signal_callback_add(layout, "elm,state,dismiss,done", "",
|
2013-08-30 09:40:15 -07:00
|
|
|
about_dismiss_done, md);
|
2013-07-20 22:38:08 -07:00
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(md->win, layout);
|
|
|
|
evas_object_show(layout);
|
2013-07-20 23:56:44 -07:00
|
|
|
|
|
|
|
//Entry
|
|
|
|
Evas_Object *entry = elm_entry_add(layout);
|
2013-08-30 09:40:15 -07:00
|
|
|
elm_object_style_set(entry, "about");
|
2013-07-20 23:56:44 -07:00
|
|
|
elm_entry_scrollable_set(entry, EINA_TRUE);
|
|
|
|
elm_entry_line_wrap_set(entry, EINA_TRUE);
|
2013-07-21 00:10:00 -07:00
|
|
|
elm_entry_editable_set(entry, EINA_FALSE);
|
2013-07-20 23:56:44 -07:00
|
|
|
evas_object_show(entry);
|
|
|
|
|
2013-07-21 00:10:00 -07:00
|
|
|
elm_object_focus_set(entry, EINA_TRUE);
|
|
|
|
|
2013-07-20 23:56:44 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.entry", entry);
|
|
|
|
|
|
|
|
elm_entry_entry_append(entry, "<color=#ffffff><font_size=12>");
|
|
|
|
|
|
|
|
//Read README
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf), "%s/docs/README", elm_app_data_dir_get());
|
|
|
|
|
|
|
|
Eina_File *file = eina_file_open(buf, EINA_FALSE);
|
|
|
|
if (!file) goto err;
|
|
|
|
|
|
|
|
Eina_Iterator *itr = eina_file_map_lines(file);
|
|
|
|
if (!itr) goto err;
|
|
|
|
|
|
|
|
Eina_Strbuf *strbuf = eina_strbuf_new();
|
|
|
|
if (!strbuf) goto err;
|
|
|
|
|
|
|
|
Eina_File_Line *line;
|
|
|
|
int line_num = 0;
|
|
|
|
|
|
|
|
EINA_ITERATOR_FOREACH(itr, line)
|
|
|
|
{
|
2013-08-24 10:41:53 -07:00
|
|
|
//Append edc ccde
|
2013-07-20 23:56:44 -07:00
|
|
|
if (line_num > 0)
|
|
|
|
{
|
2013-09-19 06:38:16 -07:00
|
|
|
if (!eina_strbuf_append(strbuf, EOL)) goto err;
|
2013-07-20 23:56:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!eina_strbuf_append_length(strbuf, line->start, line->length))
|
|
|
|
goto err;
|
|
|
|
line_num++;
|
|
|
|
}
|
|
|
|
elm_entry_entry_append(entry, eina_strbuf_string_get(strbuf));
|
|
|
|
elm_entry_entry_append(entry, "</font_size></color>");
|
|
|
|
|
|
|
|
if (md->menu_layout)
|
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_TRUE);
|
|
|
|
|
2013-08-30 09:40:15 -07:00
|
|
|
md->about_layout = layout;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth++;
|
2013-07-20 23:56:44 -07:00
|
|
|
|
|
|
|
err:
|
|
|
|
if (strbuf) eina_strbuf_free(strbuf);
|
|
|
|
if (itr) eina_iterator_free(itr);
|
|
|
|
if (file) eina_file_close(file);
|
2013-07-20 22:38:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-08-30 09:40:15 -07:00
|
|
|
about_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
2013-07-20 22:38:08 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
2013-08-30 09:40:15 -07:00
|
|
|
about_open(md);
|
2013-07-20 22:38:08 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
|
|
|
setting_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
setting_open(md);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
new_yes_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
|
|
|
|
edc_reload(md, PROTO_EDC_PATH);
|
|
|
|
warning_close(md);
|
2014-01-29 04:56:29 -08:00
|
|
|
menu_close(md);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
exit_yes_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
elm_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
exit_save_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
edit_save(md->ed);
|
|
|
|
elm_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
exit_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_exit();
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2013-07-20 22:38:08 -07:00
|
|
|
btn_create(Evas_Object *parent, const char *label, Evas_Smart_Cb cb, void *data)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
Evas_Object *layout, *btn;
|
|
|
|
|
|
|
|
layout = elm_layout_add(parent);
|
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "button_layout");
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
btn = elm_button_add(layout);
|
|
|
|
evas_object_smart_callback_add(btn, "clicked", cb, data);
|
|
|
|
elm_object_text_set(btn, label);
|
|
|
|
evas_object_show(btn);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.btn", btn);
|
|
|
|
|
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
btn_effect_timer_cb(void *data)
|
|
|
|
{
|
|
|
|
Evas_Object *btn = data;
|
|
|
|
elm_object_signal_emit(btn, "elm,action,btn,zoom", "");
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
edc_reload(menu_data *md, const char *edc_path)
|
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_path_set(edc_path);
|
2013-07-20 01:51:56 -07:00
|
|
|
edit_new(md->ed);
|
2013-09-19 05:42:42 -07:00
|
|
|
edj_mgr_reload_need_set(edj_mgr_get(), EINA_TRUE);
|
2014-01-29 09:45:10 -08:00
|
|
|
config_apply();
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
warning_no_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
warning_close(md);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
new_save_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
|
|
|
|
edit_save(md->ed);
|
|
|
|
edc_reload(md, PROTO_EDC_PATH);
|
|
|
|
warning_close(md);
|
2014-01-29 04:56:29 -08:00
|
|
|
menu_close(md);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
new_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
2013-08-25 10:26:45 -07:00
|
|
|
menu_edc_new(md);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
save_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
2013-08-04 09:28:47 -07:00
|
|
|
edc_file_save(md);
|
2013-07-22 09:58:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-12-12 04:54:39 -08:00
|
|
|
fileselector_save_done_cb(void *data, Evas_Object *obj, void *event_info)
|
2013-07-22 09:58:47 -07:00
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
const char *selected = event_info;
|
|
|
|
|
2013-12-12 10:04:57 -08:00
|
|
|
eina_stringshare_refplace(&(md->last_accessed_path),
|
2013-12-12 09:30:44 -08:00
|
|
|
elm_fileselector_path_get(obj));
|
2013-12-12 04:54:39 -08:00
|
|
|
|
2013-08-04 09:28:47 -07:00
|
|
|
if (!selected)
|
2013-07-22 09:58:47 -07:00
|
|
|
{
|
|
|
|
fileselector_close(md);
|
2013-08-04 09:28:47 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Filter to read only edc extension file.
|
|
|
|
char *ext = strrchr(selected, '.');
|
|
|
|
if (!ext || strcmp(ext, ".edc"))
|
|
|
|
{
|
|
|
|
elm_object_part_text_set(md->fileselector_layout,
|
|
|
|
"elm.text.msg",
|
|
|
|
"Support only .edc file.");
|
|
|
|
elm_object_signal_emit(md->fileselector_layout,
|
|
|
|
"elm,action,msg,show", "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Directory?
|
|
|
|
if (ecore_file_is_dir(selected))
|
|
|
|
{
|
|
|
|
elm_object_part_text_set(md->fileselector_layout,
|
|
|
|
"elm.text.msg", "Choose a file to save.");
|
|
|
|
elm_object_signal_emit(md->fileselector_layout,
|
|
|
|
"elm,action,msg,show", "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Update the edc file and try to save.
|
2014-01-29 09:45:10 -08:00
|
|
|
if (strcmp(config_edc_path_get(), selected))
|
2013-08-04 09:28:47 -07:00
|
|
|
edit_changed_set(md->ed, EINA_TRUE);
|
|
|
|
|
2014-01-29 09:45:10 -08:00
|
|
|
config_edc_path_set(selected);
|
2013-08-04 09:28:47 -07:00
|
|
|
|
|
|
|
if (!edit_save(md->ed))
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
snprintf(buf, sizeof(buf), "Failed to load: %s.", selected);
|
|
|
|
elm_object_part_text_set(md->fileselector_layout,
|
|
|
|
"elm.text.msg", buf);
|
|
|
|
elm_object_signal_emit(md->fileselector_layout,
|
|
|
|
"elm,action,msg,show", "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-19 05:42:42 -07:00
|
|
|
edj_mgr_reload_need_set(edj_mgr_get(), EINA_TRUE);
|
2014-01-29 09:45:10 -08:00
|
|
|
config_apply();
|
2013-08-04 09:28:47 -07:00
|
|
|
|
|
|
|
fileselector_close(md);
|
2014-01-29 04:56:29 -08:00
|
|
|
menu_close(md);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-07-29 09:16:58 -07:00
|
|
|
static void
|
|
|
|
fileselector_save_selected_cb(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
fileselector_save_done_cb(data, obj, event_info);
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
2013-12-12 04:54:39 -08:00
|
|
|
fileselector_load_done_cb(void *data, Evas_Object *obj, void *event_info)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
const char *selected = event_info;
|
|
|
|
|
2013-12-12 10:04:57 -08:00
|
|
|
eina_stringshare_refplace(&(md->last_accessed_path),
|
|
|
|
elm_fileselector_path_get(obj));
|
2013-12-12 04:54:39 -08:00
|
|
|
|
2013-07-29 09:16:58 -07:00
|
|
|
if (!selected)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
fileselector_close(md);
|
2013-07-29 09:16:58 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-04 09:28:47 -07:00
|
|
|
//Filter to read only edc extension file.
|
|
|
|
char *ext = strrchr(selected, '.');
|
|
|
|
if (!ext || strcmp(ext, ".edc"))
|
2013-07-29 09:16:58 -07:00
|
|
|
{
|
|
|
|
elm_object_part_text_set(md->fileselector_layout,
|
2013-08-04 09:28:47 -07:00
|
|
|
"elm.text.msg",
|
|
|
|
"Support only .edc file.");
|
2013-07-29 09:16:58 -07:00
|
|
|
elm_object_signal_emit(md->fileselector_layout,
|
|
|
|
"elm,action,msg,show", "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-04 09:28:47 -07:00
|
|
|
//Directory?
|
|
|
|
if (ecore_file_is_dir(selected))
|
2013-07-29 09:16:58 -07:00
|
|
|
{
|
|
|
|
elm_object_part_text_set(md->fileselector_layout,
|
2013-08-04 09:28:47 -07:00
|
|
|
"elm.text.msg", "Choose a file to load.");
|
2013-07-29 09:16:58 -07:00
|
|
|
elm_object_signal_emit(md->fileselector_layout,
|
|
|
|
"elm,action,msg,show", "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-04 09:28:47 -07:00
|
|
|
//Show a message if it failed to load the file.
|
2013-07-29 09:16:58 -07:00
|
|
|
if (!ecore_file_can_read(selected))
|
|
|
|
{
|
2013-08-04 09:28:47 -07:00
|
|
|
char buf[PATH_MAX];
|
2013-07-29 09:16:58 -07:00
|
|
|
const char *filename = ecore_file_file_get(selected);
|
|
|
|
snprintf(buf, sizeof(buf), "Failed to load: %s.", filename);
|
|
|
|
elm_object_part_text_set(md->fileselector_layout,
|
|
|
|
"elm.text.msg", buf);
|
|
|
|
elm_object_signal_emit(md->fileselector_layout,
|
|
|
|
"elm,action,msg,show", "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
edc_reload(md, selected);
|
|
|
|
fileselector_close(md);
|
2014-01-29 04:56:29 -08:00
|
|
|
menu_close(md);
|
2013-07-29 09:16:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fileselector_load_selected_cb(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
fileselector_load_done_cb(data, obj, event_info);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-07-22 09:58:47 -07:00
|
|
|
static void
|
|
|
|
edc_file_save(menu_data *md)
|
|
|
|
{
|
|
|
|
//Layout
|
|
|
|
Evas_Object *layout = elm_layout_add(md->win);
|
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "fileselector_layout");
|
2013-08-21 09:43:52 -07:00
|
|
|
elm_object_part_text_set(layout, "elm.text.title", "Save");
|
2013-07-22 09:58:47 -07:00
|
|
|
elm_object_signal_callback_add(layout, "elm,state,dismiss,done", "",
|
|
|
|
fileselector_dismiss_done, md);
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(md->win, layout);
|
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
Evas_Object *fs = elm_fileselector_add(layout);
|
|
|
|
elm_object_part_text_set(fs, "ok", "Save");
|
2013-08-28 07:15:00 -07:00
|
|
|
elm_object_part_text_set(fs, "cancel", "Close");
|
2013-12-12 04:54:39 -08:00
|
|
|
elm_fileselector_path_set(fs, md->last_accessed_path ? md->last_accessed_path : getenv("HOME"));
|
2013-07-22 09:58:47 -07:00
|
|
|
elm_fileselector_expandable_set(fs, EINA_FALSE);
|
|
|
|
elm_fileselector_is_save_set(fs, EINA_TRUE);
|
|
|
|
evas_object_smart_callback_add(fs, "done", fileselector_save_done_cb, md);
|
2013-07-29 09:16:58 -07:00
|
|
|
evas_object_smart_callback_add(fs, "selected", fileselector_save_selected_cb,
|
|
|
|
md);
|
2013-07-22 09:58:47 -07:00
|
|
|
evas_object_show(fs);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.fileselector", fs);
|
|
|
|
|
|
|
|
if (md->menu_layout)
|
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_TRUE);
|
|
|
|
elm_object_focus_set(fs, EINA_TRUE);
|
|
|
|
|
|
|
|
md->fileselector_layout = layout;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth++;
|
2013-07-22 09:58:47 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
|
|
|
edc_file_load(menu_data *md)
|
|
|
|
{
|
|
|
|
//Layout
|
|
|
|
Evas_Object *layout = elm_layout_add(md->win);
|
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "fileselector_layout");
|
2013-08-21 09:43:52 -07:00
|
|
|
elm_object_part_text_set(layout, "elm.text.title", "Load");
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_signal_callback_add(layout, "elm,state,dismiss,done", "",
|
|
|
|
fileselector_dismiss_done, md);
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(md->win, layout);
|
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
Evas_Object *fs = elm_fileselector_add(layout);
|
2013-12-12 04:54:39 -08:00
|
|
|
elm_fileselector_path_set(fs, md->last_accessed_path ? md->last_accessed_path : getenv("HOME"));
|
2013-07-22 09:58:47 -07:00
|
|
|
elm_object_part_text_set(fs, "ok", "Load");
|
2013-08-28 07:15:00 -07:00
|
|
|
elm_object_part_text_set(fs, "cancel", "Close");
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_fileselector_expandable_set(fs, EINA_FALSE);
|
2013-07-22 09:58:47 -07:00
|
|
|
elm_fileselector_is_save_set(fs, EINA_TRUE);
|
|
|
|
evas_object_smart_callback_add(fs, "done", fileselector_load_done_cb, md);
|
2013-07-29 09:16:58 -07:00
|
|
|
evas_object_smart_callback_add(fs, "selected", fileselector_load_selected_cb,
|
|
|
|
md);
|
2013-07-20 01:51:56 -07:00
|
|
|
evas_object_show(fs);
|
|
|
|
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.fileselector", fs);
|
|
|
|
|
|
|
|
if (md->menu_layout)
|
|
|
|
elm_object_disabled_set(md->menu_layout, EINA_TRUE);
|
|
|
|
elm_object_focus_set(fs, EINA_TRUE);
|
|
|
|
|
|
|
|
md->fileselector_layout = layout;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth++;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
load_yes_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
edc_file_load(md);
|
|
|
|
warning_close(md);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
load_save_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
edit_save(md->ed);
|
|
|
|
edc_file_load(md);
|
|
|
|
warning_close(md);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-29 08:15:33 -08:00
|
|
|
load_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
2013-07-20 01:51:56 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_edc_load();
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
menu_open(menu_data *md)
|
|
|
|
{
|
|
|
|
//Layout
|
|
|
|
Evas_Object *layout = elm_layout_add(md->win);
|
|
|
|
elm_layout_file_set(layout, EDJE_PATH, "menu_layout");
|
|
|
|
elm_object_signal_callback_add(layout, "elm,state,dismiss,done", "",
|
|
|
|
menu_dismiss_done, md);
|
|
|
|
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(md->win, layout);
|
|
|
|
evas_object_show(layout);
|
|
|
|
|
|
|
|
//Button
|
|
|
|
Evas_Object *btn;
|
|
|
|
|
|
|
|
//Button(New)
|
2013-07-20 22:38:08 -07:00
|
|
|
btn = btn_create(layout, "New", new_btn_cb, md);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_focus_set(btn, EINA_TRUE);
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.new_btn", btn);
|
|
|
|
ecore_timer_add(0, btn_effect_timer_cb, btn);
|
|
|
|
|
|
|
|
//Button(Save)
|
2013-07-20 22:38:08 -07:00
|
|
|
btn = btn_create(layout, "Save", save_btn_cb, md);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.save_btn", btn);
|
|
|
|
ecore_timer_add(0.03, btn_effect_timer_cb, btn);
|
|
|
|
|
|
|
|
//Button(Load)
|
2013-07-20 22:38:08 -07:00
|
|
|
btn = btn_create(layout, "Load", load_btn_cb, md);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.load_btn", btn);
|
|
|
|
ecore_timer_add(0.06, btn_effect_timer_cb, btn);
|
|
|
|
|
|
|
|
//Button(Setting)
|
2013-07-20 22:38:08 -07:00
|
|
|
btn = btn_create(layout, "Setting", setting_btn_cb, md);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.setting_btn", btn);
|
|
|
|
ecore_timer_add(0.09, btn_effect_timer_cb, btn);
|
|
|
|
|
2013-08-30 09:40:15 -07:00
|
|
|
//Button(About)
|
|
|
|
btn = btn_create(layout, "About", about_btn_cb, md);
|
|
|
|
elm_object_part_content_set(layout, "elm.swallow.about_btn", btn);
|
2013-07-20 01:51:56 -07:00
|
|
|
ecore_timer_add(0.12, btn_effect_timer_cb, btn);
|
|
|
|
|
|
|
|
//Button(Exit)
|
2013-07-20 22:38:08 -07:00
|
|
|
btn = btn_create(layout, "Exit", exit_btn_cb, md);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_object_part_content_set(layout, "elm.swallow.exit_btn", btn);
|
|
|
|
ecore_timer_add(0.15, btn_effect_timer_cb, btn);
|
|
|
|
|
|
|
|
md->menu_layout = layout;
|
2014-01-29 04:56:29 -08:00
|
|
|
md->open_depth++;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2014-01-29 08:46:02 -08:00
|
|
|
static void
|
|
|
|
ctxpopup_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
menu_data *md = data;
|
|
|
|
md->ctxpopup = NULL;
|
|
|
|
}
|
|
|
|
|
2014-01-29 08:19:29 -08:00
|
|
|
void
|
2014-01-29 09:45:10 -08:00
|
|
|
menu_init(Evas_Object *win, edit_data *ed)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
menu_data *md = calloc(1, sizeof(menu_data));
|
2014-01-29 09:48:26 -08:00
|
|
|
g_md = md;
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
md->win = win;
|
|
|
|
md->ed = ed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_term()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_data *md = g_md;
|
2013-07-20 01:51:56 -07:00
|
|
|
if (!md) return;
|
|
|
|
free(md);
|
|
|
|
}
|
|
|
|
|
2014-01-29 08:46:02 -08:00
|
|
|
void
|
|
|
|
menu_about()
|
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
about_open(md);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
menu_setting()
|
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
setting_open(md);
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
menu_edc_new()
|
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
if (edit_changed_get(md->ed))
|
|
|
|
{
|
|
|
|
warning_layout_create(md, new_yes_btn_cb, new_save_btn_cb);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
edc_reload(md, PROTO_EDC_PATH);
|
|
|
|
menu_close(md);
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
menu_edc_save()
|
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
edc_file_save(md);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
menu_edc_load()
|
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
if (edit_changed_get(md->ed))
|
|
|
|
warning_layout_create(md, load_yes_btn_cb, load_save_btn_cb);
|
|
|
|
else
|
|
|
|
edc_file_load(md);
|
|
|
|
}
|
|
|
|
|
2014-01-29 04:56:29 -08:00
|
|
|
void
|
2013-08-24 10:41:53 -07:00
|
|
|
menu_toggle()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
|
2014-01-29 04:56:29 -08:00
|
|
|
if (md->setting_layout)
|
2013-07-21 00:10:00 -07:00
|
|
|
{
|
2014-01-29 04:56:29 -08:00
|
|
|
setting_close(md);
|
|
|
|
return;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
if (md->warning_layout)
|
|
|
|
{
|
|
|
|
warning_close(md);
|
2014-01-29 04:56:29 -08:00
|
|
|
return;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
2014-01-29 04:56:29 -08:00
|
|
|
if (md->fileselector_layout)
|
|
|
|
{
|
|
|
|
fileselector_close(md);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (md->about_layout)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 04:56:29 -08:00
|
|
|
about_close(md);
|
|
|
|
return;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
2014-01-29 04:56:29 -08:00
|
|
|
if (md->ctxpopup)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 04:56:29 -08:00
|
|
|
elm_ctxpopup_dismiss(md->ctxpopup);
|
|
|
|
return;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
2014-01-29 04:56:29 -08:00
|
|
|
|
|
|
|
//Main Menu
|
|
|
|
if (md->open_depth) menu_close(md);
|
|
|
|
else menu_open(md);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
2013-09-09 08:58:33 -07:00
|
|
|
void
|
|
|
|
menu_ctxpopup_unregister(Evas_Object *ctxpopup)
|
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
evas_object_event_callback_del(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb);
|
|
|
|
if (ctxpopup == md->ctxpopup) md->ctxpopup = NULL;
|
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
void
|
|
|
|
menu_ctxpopup_register(Evas_Object *ctxpopup)
|
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
md->ctxpopup = ctxpopup;
|
|
|
|
if (!ctxpopup) return;
|
|
|
|
evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb,
|
|
|
|
md);
|
|
|
|
}
|
2014-01-29 04:56:29 -08:00
|
|
|
|
|
|
|
int
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_open_depth()
|
2014-01-29 04:56:29 -08:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_data *md = g_md;
|
2014-01-29 04:56:29 -08:00
|
|
|
return md->open_depth;
|
|
|
|
}
|
2014-01-29 08:46:02 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
menu_exit()
|
|
|
|
{
|
|
|
|
menu_data *md = g_md;
|
|
|
|
if (edit_changed_get(md->ed))
|
|
|
|
warning_layout_create(md, exit_yes_btn_cb, exit_save_btn_cb);
|
|
|
|
else
|
|
|
|
elm_exit();
|
|
|
|
}
|