From 98a9eca6c57e11ce0bdb91edbd13d3ff409a46c9 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Wed, 12 Nov 2014 16:44:19 +0900 Subject: [PATCH] live_edit: Fix T1785 to restore live edit Summary: Fix T1785 to restore live edit @fix Reviewers: Hermet Maniphest Tasks: T1785 Differential Revision: https://phab.enlightenment.org/D1650 --- src/bin/live_edit.c | 28 ++++++++++++---------------- src/bin/main.c | 21 +++++++++------------ src/bin/tools.c | 7 +++---- src/lib/Enventor_Legacy.h | 5 +++++ src/lib/enventor_object.eo | 12 ++++++++++++ src/lib/enventor_private.h | 10 ++-------- src/lib/enventor_smart.c | 22 ++++++++++++++++------ src/lib/template.c | 25 +++++++++++++++---------- 8 files changed, 74 insertions(+), 56 deletions(-) diff --git a/src/bin/live_edit.c b/src/bin/live_edit.c index 21967b7..1e76935 100644 --- a/src/bin/live_edit.c +++ b/src/bin/live_edit.c @@ -7,7 +7,7 @@ #include #include #include "common.h" -#if 0 + typedef struct menu_data_s { const char *name; @@ -199,16 +199,15 @@ key_down_cb(void *data, int type EINA_UNUSED, void *ev) if (!strcmp(event->key, "Return")) { -#if 0 - template_part_insert(ld->ed, - MENU_ITEMS[ld->cur_part_data->type].type, - TEMPLATE_INSERT_LIVE_EDIT, - ld->cur_part_data->rel1_x, - ld->cur_part_data->rel1_y, - ld->cur_part_data->rel2_x, - ld->cur_part_data->rel2_y, - view_group_name_get(VIEW_DATA)); -#endif + enventor_object_template_part_insert(ld->enventor, + MENU_ITEMS[ld->cur_part_data->type].type, + ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT, + ld->cur_part_data->rel1_x, + ld->cur_part_data->rel1_y, + ld->cur_part_data->rel2_x, + ld->cur_part_data->rel2_y, + NULL, 0); + enventor_object_save(ld->enventor, config_edc_path_get()); } else if (strcmp(event->key, "Delete")) return EINA_TRUE; @@ -308,9 +307,9 @@ live_edit_toggle(void) { live_data *ld = g_ld; Eina_Bool on = !config_live_edit_get(); - Evas_Object *event_obj = view_obj_get(VIEW_DATA); + Evas_Object *event_obj = enventor_object_live_view_get(ld->enventor); if (!event_obj) return; -#if 0 + if (on) { evas_object_event_callback_add(event_obj, EVAS_CALLBACK_MOUSE_UP, @@ -328,7 +327,6 @@ live_edit_toggle(void) else stats_info_msg_update("Live View Edit Mode Disabled."); config_live_edit_set(on); -#endif } void @@ -373,5 +371,3 @@ live_edit_term() free(ld); g_ld = NULL; } - -#endif diff --git a/src/bin/main.c b/src/bin/main.c index dc8b363..eadc21e 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -57,14 +57,14 @@ static Eina_Bool template_insert_patch(app_data *ad, const char *key) { Edje_Part_Type part_type; -#if 0 + if (config_live_edit_get()) { stats_info_msg_update("Insertion of template code is disabled " "while in Live Edit mode"); return ECORE_CALLBACK_DONE; } -#endif + if (!strcmp(key, "a") || !strcmp(key, "A")) part_type = EDJE_PART_TYPE_TABLE; else if (!strcmp(key, "b") || !strcmp(key, "B")) @@ -93,9 +93,10 @@ template_insert_patch(app_data *ad, const char *key) part_type = EDJE_PART_TYPE_NONE; char syntax[12]; - if (enventor_object_template_part_insert(ad->enventor, part_type, REL1_X, - REL1_Y, REL2_X, REL2_Y, syntax, - sizeof(syntax))) + if (enventor_object_template_part_insert(ad->enventor, part_type, + ENVENTOR_TEMPLATE_INSERT_DEFAULT, + REL1_X, REL1_Y, REL2_X, REL2_Y, + syntax, sizeof(syntax))) { char msg[64]; snprintf(msg, sizeof(msg), "Template code inserted, (%s)", syntax); @@ -535,16 +536,15 @@ dummy_swallow_toggle(app_data *ad) static void default_template_insert(app_data *ad) { -#if 0 if (config_live_edit_get()) { stats_info_msg_update("Insertion of template code is disabled " "while in Live Edit mode"); return; } -#endif + char syntax[12]; - if (enventor_object_template_insert(ad->enventor, syntax, sizeof(syntax))) + if (enventor_object_template_insert(ad->enventor, ENVENTOR_TEMPLATE_INSERT_DEFAULT, syntax, sizeof(syntax))) { char msg[64]; snprintf(msg, sizeof(msg), "Template code inserted, (%s)", syntax); @@ -643,9 +643,7 @@ ctrl_func(app_data *ad, const char *key) //Live Edit if (!strcmp(key, "e") || !strcmp(key, "E")) { -#if 0 live_edit_toggle(); -#endif return ECORE_CALLBACK_DONE; } @@ -799,6 +797,7 @@ init(app_data *ad, int argc, char **argv) enventor_setup(ad); file_mgr_init(ad->enventor); tools_set(ad->enventor); + live_edit_init(ad->enventor); base_gui_show(); @@ -816,9 +815,7 @@ static void term(app_data *ad EINA_UNUSED) { menu_term(); -#if 0 live_edit_term(); -#endif stats_term(); base_gui_term(); file_mgr_term(); diff --git a/src/bin/tools.c b/src/bin/tools.c index 3f3227b..fe615dc 100644 --- a/src/bin/tools.c +++ b/src/bin/tools.c @@ -87,13 +87,12 @@ console_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, { base_console_toggle(); } -#if 0 + static void live_edit_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) { live_edit_toggle(); } -#endif static Evas_Object * tools_btn_create(Evas_Object *parent, const char *icon, const char *label, @@ -146,12 +145,12 @@ tools_create(Evas_Object *parent, Evas_Object *enventor) evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL); elm_box_pack_end(box, btn); -/* + btn = tools_btn_create(box, "live_edit", "LiveEdit", live_edit_cb, NULL); evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL); elm_box_pack_end(box, btn); -*/ + sp = elm_separator_add(box); evas_object_show(sp); elm_box_pack_end(box, sp); diff --git a/src/lib/Enventor_Legacy.h b/src/lib/Enventor_Legacy.h index 16c52f9..d572433 100644 --- a/src/lib/Enventor_Legacy.h +++ b/src/lib/Enventor_Legacy.h @@ -27,6 +27,11 @@ typedef struct Eina_Bool self_changed : 1; } Enventor_EDC_Modified; +typedef enum { + ENVENTOR_TEMPLATE_INSERT_DEFAULT, + ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT +} Enventor_Template_Insert_Type; + EAPI int enventor_init(int argc, char **argv); EAPI int enventor_shutdown(void); EAPI Evas_Object *enventor_object_add(Evas_Object *parent); diff --git a/src/lib/enventor_object.eo b/src/lib/enventor_object.eo index ea877cb..5335aa9 100644 --- a/src/lib/enventor_object.eo +++ b/src/lib/enventor_object.eo @@ -358,6 +358,7 @@ class Enventor.Object (Elm_Widget, Efl.File) { @ingroup Enventor */ return: Eina_Bool; params { + @in Enventor_Template_Insert_Type insert_type; /*@ ... */ @in char *syntax; /*@ ... */ @in size_t n; } @@ -372,6 +373,7 @@ class Enventor.Object (Elm_Widget, Efl.File) { return: Eina_Bool; params { @in Edje_Part_Type type; /*@ ... */ + @in Enventor_Template_Insert_Type insert_type; /*@ ... */ @in float rel1_x; /*@ ... */ @in float rel1_y; /*@ ... */ @in float rel2_x; /*@ ... */ @@ -395,6 +397,16 @@ class Enventor.Object (Elm_Widget, Efl.File) { @see @ingroup Enventor */ } + disabled_set { + /*@ + @brief + @warning + @see + @ingroup Enventor */ + params { + @in Eina_Bool disabled; /*@ ... */ + } + } } implements { class.constructor; diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h index e5c7edf..42b23b3 100644 --- a/src/lib/enventor_private.h +++ b/src/lib/enventor_private.h @@ -57,12 +57,6 @@ struct attr_value_s Eina_Bool program : 1; }; -typedef enum { - TEMPLATE_INSERT_DEFAULT, - TEMPLATE_INSERT_LIVE_EDIT -} Template_Insert_Type; - - /* auto_comp */ void autocomp_init(void); void autocomp_term(void); @@ -178,8 +172,8 @@ void view_string_list_free(Eina_List *list); /* template */ -Eina_Bool template_part_insert(edit_data *ed, Edje_Part_Type part_type, Template_Insert_Type insert_type, float rel1_x, float rel1_y, float rel2_x, float rel2_y, const Eina_Stringshare *group_name, char *syntax, size_t n); -Eina_Bool template_insert(edit_data *ed, Template_Insert_Type insert_type, char *syntax, size_t n); +Eina_Bool template_part_insert(edit_data *ed, Edje_Part_Type part_type, Enventor_Template_Insert_Type insert_type, float rel1_x, float rel1_y, float rel2_x, float rel2_y, const Eina_Stringshare *group_name, char *syntax, size_t n); +Eina_Bool template_insert(edit_data *ed, Enventor_Template_Insert_Type insert_type, char *syntax, size_t n); /* ctxpopup */ diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c index 3541c20..b26b188 100644 --- a/src/lib/enventor_smart.c +++ b/src/lib/enventor_smart.c @@ -496,20 +496,30 @@ _enventor_object_live_view_get(Eo *obj EINA_UNUSED, EOLIAN static Eina_Bool _enventor_object_template_insert(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd, + Enventor_Template_Insert_Type insert_type, char *syntax, size_t n) { - return template_insert(pd->ed, TEMPLATE_INSERT_DEFAULT, syntax, n); + return template_insert(pd->ed, insert_type, syntax, n); } EOLIAN static Eina_Bool _enventor_object_template_part_insert(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd, - Edje_Part_Type part, float rel1_x, - float rel1_y, float rel2_x, float rel2_y, - char *syntax, size_t n) + Edje_Part_Type part, + Enventor_Template_Insert_Type insert_type, + float rel1_x, float rel1_y, float rel2_x, + float rel2_y, char *syntax, size_t n) { - return template_part_insert(pd->ed, part, TEMPLATE_INSERT_DEFAULT, rel1_x, - rel1_y, rel2_x, rel2_y, NULL, syntax, n); + return template_part_insert(pd->ed, part, insert_type, rel1_x, rel1_y, rel2_x, + rel2_y, NULL, syntax, n); +} + +EOLIAN static void +_enventor_object_disabled_set(Eo *obj EINA_UNUSED, + Enventor_Object_Data *pd, + Eina_Bool disabled) +{ + edit_disabled_set(pd->ed, disabled); } diff --git a/src/lib/template.c b/src/lib/template.c index d9977c9..a12daa8 100644 --- a/src/lib/template.c +++ b/src/lib/template.c @@ -37,7 +37,7 @@ image_description_add(edit_data *ed) if (images_block) { elm_entry_cursor_pos_set(edit_entry, cursor_pos); - template_insert(ed, TEMPLATE_INSERT_LIVE_EDIT, NULL, 0); + template_insert(ed, ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT, NULL, 0); } else { @@ -89,12 +89,12 @@ textblock_style_add(edit_data *ed, const char *style_name) static int template_part_insert_cursor_pos_set(edit_data *ed, - Template_Insert_Type insert_type, + Enventor_Template_Insert_Type insert_type, const Eina_Stringshare *group_name) { int cursor_pos = -1; Evas_Object *edit_entry = edit_entry_get(ed); - if (insert_type == TEMPLATE_INSERT_LIVE_EDIT) + if (insert_type == ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT) { cursor_pos = parser_end_of_parts_block_pos_get(edit_entry, group_name); if (cursor_pos != -1) @@ -114,11 +114,15 @@ template_part_insert_cursor_pos_set(edit_data *ed, Eina_Bool template_part_insert(edit_data *ed, Edje_Part_Type part_type, - Template_Insert_Type insert_type, float rel1_x, + Enventor_Template_Insert_Type insert_type, float rel1_x, float rel1_y, float rel2_x, float rel2_y, const Eina_Stringshare *group_name, char *syntax, size_t n) { Evas_Object *edit_entry = edit_entry_get(ed); + + if (insert_type == ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT) + group_name = view_group_name_get(VIEW_DATA); + int cursor_pos = template_part_insert_cursor_pos_set(ed, insert_type, group_name); if (cursor_pos == -1) return EINA_FALSE; @@ -221,14 +225,14 @@ template_part_insert(edit_data *ed, Edje_Part_Type part_type, } //add new line only in live edit mode - if (insert_type == TEMPLATE_INSERT_LIVE_EDIT) + if (insert_type == ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT) elm_entry_entry_insert(edit_entry, "
"); /* Increase (part name + body + relatives + tail) line. But line increase count should be -1 in entry template insertion because the cursor position would be taken one line additionally. */ int line_inc = 1 + line_cnt + 2 + TEMPLATE_PART_TALE_LINE_CNT; - if (insert_type == TEMPLATE_INSERT_DEFAULT) line_inc--; + if (insert_type == ENVENTOR_TEMPLATE_INSERT_DEFAULT) line_inc--; edit_line_increase(ed, line_inc); int cursor_pos2 = elm_entry_cursor_pos_get(edit_entry); @@ -236,7 +240,7 @@ template_part_insert(edit_data *ed, Edje_Part_Type part_type, elm_entry_cursor_pos_set(edit_entry, cursor_pos); - if (insert_type == TEMPLATE_INSERT_LIVE_EDIT) + if (insert_type == ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT) { if (part_type == EDJE_PART_TYPE_IMAGE) image_description_add(ed); @@ -250,7 +254,8 @@ template_part_insert(edit_data *ed, Edje_Part_Type part_type, } Eina_Bool -template_insert(edit_data *ed, Template_Insert_Type insert_type, char *syntax, size_t n) +template_insert(edit_data *ed, Enventor_Template_Insert_Type insert_type, + char *syntax, size_t n) { Evas_Object *entry = edit_entry_get(ed); Eina_Stringshare *paragh = edit_cur_paragh_get(ed); @@ -260,7 +265,7 @@ template_insert(edit_data *ed, Template_Insert_Type insert_type, char *syntax, s if (!strcmp(paragh, "parts")) { ret = template_part_insert(ed, EDJE_PART_TYPE_IMAGE, - TEMPLATE_INSERT_DEFAULT, + ENVENTOR_TEMPLATE_INSERT_DEFAULT, REL1_X, REL1_Y, REL2_X, REL2_Y, NULL, syntax, n); goto end; @@ -317,7 +322,7 @@ template_insert(edit_data *ed, Template_Insert_Type insert_type, char *syntax, s /* Line increase count should be -1 in entry template insertion because the cursor position would be taken one line additionally. */ - if (insert_type == TEMPLATE_INSERT_DEFAULT) line_cnt--; + if (insert_type == ENVENTOR_TEMPLATE_INSERT_DEFAULT) line_cnt--; edit_line_increase(ed, line_cnt); int cursor_pos2 = elm_entry_cursor_pos_get(entry);