hermet pushed a commit to branch master. http://git.enlightenment.org/tools/enventor.git/commit/?id=7d24fc8a3cc9588517bf0ee962157b22c713e557
commit 7d24fc8a3cc9588517bf0ee962157b22c713e557 Author: Kateryna Fesyna <k.fes...@samsung.com> Date: Thu Aug 7 21:59:51 2014 +0900 [EDC-Editor] Make template of parts to use unique names on insertion Summary: To create templates with unique name the counter of created parts is added to the Configure Data. The line with the name of the part is placed in separate template because it is the same for each part template. Reviewers: Hermet Projects: #enventor Differential Revision: https://phab.enlightenment.org/D1278 --- src/bin/edc_editor.c | 23 +++++++++++++++++++++++ src/include/template_code.h | 8 ++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/bin/edc_editor.c b/src/bin/edc_editor.c index 1228169..10bc611 100644 --- a/src/bin/edc_editor.c +++ b/src/bin/edc_editor.c @@ -8,6 +8,12 @@ const int SYNTAX_COLOR_SPARE_LINES = 42; const double SYNTAX_COLOR_DEFAULT_TIME = 0.25; const double SYNTAX_COLOR_SHORT_TIME = 0.025; +static const char ALPHA_STRING[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + +static const char ALPHA_STRING_LEN = 52; + typedef struct syntax_color_thread_data_s { edit_data *ed; @@ -463,6 +469,14 @@ edit_cur_indent_depth_get(edit_data *ed) return indent_space_get(syntax_indent_data_get(ed->sh), ed->en_edit); } +static void +part_name_string_generate(char *part_name_line) +{ + char *pos = strstr(part_name_line, QUOT); + while (*(++pos) != QUOT_C) + *pos = ALPHA_STRING[rand() % ALPHA_STRING_LEN]; +} + void edit_template_part_insert(edit_data *ed, Edje_Part_Type type) { @@ -525,6 +539,14 @@ edit_template_part_insert(edit_data *ed, Edje_Part_Type type) break; } + char *part_name_line = strdup(TEMPLATE_PART_NAME_FORMAT); + part_name_string_generate(part_name_line); + + elm_entry_entry_insert(ed->en_edit, p); + elm_entry_entry_insert(ed->en_edit, part_name_line); + edit_line_increase(ed, 1); + free(part_name_line); + int i; for (i = 0; i < (line_cnt - 1); i++) { @@ -982,6 +1004,7 @@ scroller_vbar_unpress_cb(void *data, Evas_Object *obj EINA_UNUSED, edit_data * edit_init(Evas_Object *parent) { + srand(time(NULL)); parser_data *pd = parser_init(); syntax_helper *sh = syntax_init(); diff --git a/src/include/template_code.h b/src/include/template_code.h index 5c7e452..77338a1 100644 --- a/src/include/template_code.h +++ b/src/include/template_code.h @@ -32,12 +32,13 @@ const char *TEMPLATE_GROUP[TEMPLATE_GROUP_LINE_CNT] = "}" }; +const char * TEMPLATE_PART_NAME_FORMAT = + "part { name: \"PartName\";<br/>"; #define TEMPLATE_PART_IMAGE_LINE_CNT 15 const char *TEMPLATE_PART_IMAGE[TEMPLATE_PART_IMAGE_LINE_CNT] = { - "part { name: \"XXX\";<br/>", " type: IMAGE;<br/>", " scale: 1;<br/>", " mouse_events: 1;<br/>", @@ -58,7 +59,6 @@ const char *TEMPLATE_PART_IMAGE[TEMPLATE_PART_IMAGE_LINE_CNT] = const char *TEMPLATE_PART_RECT[TEMPLATE_PART_RECT_LINE_CNT] = { - "part { name: \"XXX\";<br/>", " type: RECT;<br/>", " scale: 1;<br/>", " mouse_events: 1;<br/>", @@ -78,7 +78,6 @@ const char *TEMPLATE_PART_RECT[TEMPLATE_PART_RECT_LINE_CNT] = const char *TEMPLATE_PART_SWALLOW[TEMPLATE_PART_SWALLOW_LINE_CNT] = { - "part { name: \"XXX\";<br/>", " type: SWALLOW;<br/>", " scale: 1;<br/>", " mouse_events: 1;<br/>", @@ -97,7 +96,6 @@ const char *TEMPLATE_PART_SWALLOW[TEMPLATE_PART_SWALLOW_LINE_CNT] = const char *TEMPLATE_PART_SPACER[TEMPLATE_PART_SPACER_LINE_CNT] = { - "part { name: \"XXX\";<br/>", " type: SPACER;<br/>", " scale: 1;<br/>", " description { state: \"default\" 0.0;<br/>", @@ -114,7 +112,6 @@ const char *TEMPLATE_PART_SPACER[TEMPLATE_PART_SPACER_LINE_CNT] = const char *TEMPLATE_PART_TEXT[TEMPLATE_PART_TEXT_LINE_CNT] = { - "part { name: \"XXX\";<br/>", " type: TEXT;<br/>", " scale: 1;<br/>", " mouse_events: 1;<br/>", @@ -144,7 +141,6 @@ const char *TEMPLATE_PART_TEXT[TEMPLATE_PART_TEXT_LINE_CNT] = const char *TEMPLATE_PART_TEXTBLOCK[TEMPLATE_PART_TEXTBLOCK_LINE_CNT] = { - "part { name: \"XXX\";<br/>", " type: TEXTBLOCK;<br/>", " description { state: \"default\" 0.0;<br/>", " rel1 { relative: 0.0 0.0; offset: 0 0; /*to: \"XXX\";*/ }<br/>", --