jaehwan pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=24774dc71fe9d2cbf07724b2720e4b3f644bf533
commit 24774dc71fe9d2cbf07724b2720e4b3f644bf533 Author: Jaehwan Kim <jae.hwan....@samsung.com> Date: Tue Sep 27 15:34:52 2016 +0900 import_edj: add specific item loading option. It can make to load specific item style of widget by command. @feature --- src/bin/common/widget_list.c | 146 ++++++++++++++++++++++++++++++++++++++- src/bin/common/widget_list.h | 4 +- src/bin/main.c | 2 +- src/bin/ui/tab_home_import_edj.c | 90 +++++++++++++++++++----- 4 files changed, 221 insertions(+), 21 deletions(-) diff --git a/src/bin/common/widget_list.c b/src/bin/common/widget_list.c index b84c45b..2d6f3d4 100644 --- a/src/bin/common/widget_list.c +++ b/src/bin/common/widget_list.c @@ -41,7 +41,6 @@ static const char *exception[] = "elm/colorselector/image/colorbar_1/", "elm/colorselector/image/colorbar_2/", "elm/colorselector/image/colorbar_3/", - "elm/gengrid/item/default/", "elm/entry/handler/start/", "elm/entry/handler/end/", "elm/entry/emoticon/wtf/", @@ -120,7 +119,8 @@ style_name_get(const Eina_Stringshare *group_name) } class[i - first] = '\0'; - if (!strcmp(widget, "genlist") && strcmp(class, "base")) return NULL; + if ((!strcmp(widget, "genlist") || !strcmp(widget, "gengrid")) && + strcmp(class, "base")) return NULL; first = i + 1; for (i = first; i < len; i++) @@ -134,6 +134,61 @@ style_name_get(const Eina_Stringshare *group_name) } Eina_Stringshare * +item_style_name_get(const Eina_Stringshare *group_name, Eina_Stringshare *style_name) +{ + int len = strlen(group_name); + int first, i; + Eina_List *l; + Eina_Stringshare *style_item; + char widget[32], class[32], style[256]; + const char *str; + + if (group_name[0] != 'e') return NULL; + if (group_name[1] != 'l') return NULL; + if (group_name[2] != 'm') return NULL; + if (group_name[3] != '/') return NULL; + + for (i = 4; i < len; i++) + { + if (group_name[i] == '/') break; + } + + first = 4; + for (i = first; i < len; i++) + { + if (group_name[i] == '/') break; + widget[i - first] = group_name[i]; + } + widget[i - first] = '\0'; + + first = i + 1; + for (i = first; i < len; i++) + { + if (group_name[i] == '/') break; + class[i - first] = group_name[i]; + } + class[i - first] = '\0'; + + if ((strcmp(widget, "genlist") && strcmp(widget, "gengrid")) || + !strcmp(class, "base")) return NULL; + + first = i + 1; + for (i = first; i < len; i++) + { + style[i - first] = group_name[i]; + } + style[i - first] = '\0'; + + str = string_rstr(style, style_name); + if (str) + { + style[strlen(style) - strlen(str) - 1] = '\0'; + } + + return eina_stringshare_add(style); +} + +Eina_Stringshare * option_widget_name_get(const char *str, Eina_List **style_list) { int len = strlen(str); @@ -188,7 +243,92 @@ option_widget_name_get(const char *str, Eina_List **style_list) } Eina_Stringshare * -option_style_name_get(const char *str, Eina_List **cp_style_list) +option_style_name_get(const char *str, Eina_List **item_style_list, Eina_List **cp_style_list) +{ + int len = strlen(str); + char style[32], cp_style[256], item_style[256]; + Eina_List *list = NULL; + int i, first = 0; + Eina_Bool is_cp_style = EINA_FALSE; + Eina_Bool is_item_style = EINA_FALSE; + + *item_style_list = NULL; + *cp_style_list = NULL; + + for (i = 0; i < len; i++) + { + if (str[i] == '{') + { + is_item_style = EINA_TRUE; + style[i] = '\0'; + first = i + 1; + continue; + } + else if (str[i] == '}') + break; + + if (!is_item_style) + { + if (str[i] == '[') + { + is_cp_style = EINA_TRUE; + style[i] = '\0'; + first = i + 1; + continue; + } + else if (str[i] == ']') + { + cp_style[i - first] = '\0'; + *cp_style_list = eina_list_append(*cp_style_list, eina_stringshare_add(cp_style)); + if (i + 1 < len && str[i + 1] != '{') break; + } + } + + if (!is_item_style) + { + if (!is_cp_style) + { + style[i] = str[i]; + } + else + { + if (str[i] == ',') + { + cp_style[i - first] = '\0'; + *cp_style_list = eina_list_append(*cp_style_list, eina_stringshare_add(cp_style)); + first = i + 1; + continue; + } + cp_style[i - first] = str[i]; + } + } + else + { + if (str[i] == ',') + { + item_style[i - first] = '\0'; + *item_style_list = eina_list_append(*item_style_list, eina_stringshare_add(item_style)); + first = i + 1; + continue; + } + item_style[i - first] = str[i]; + } + } + + if (!is_item_style && !is_cp_style) + style[i] = '\0'; + + if (is_item_style) + { + item_style[i - first] = '\0'; + *item_style_list = eina_list_append(*item_style_list, eina_stringshare_add(item_style)); + } + + return eina_stringshare_add(style); +} + +Eina_Stringshare * +option_item_style_name_get(const char *str, Eina_List **cp_style_list) { int len = strlen(str); char style[32], cp_style[256]; diff --git a/src/bin/common/widget_list.h b/src/bin/common/widget_list.h index 944bfea..b5ebcc1 100644 --- a/src/bin/common/widget_list.h +++ b/src/bin/common/widget_list.h @@ -38,8 +38,10 @@ typedef struct _End_Item_Data End_Item_Data; Eina_Stringshare *widget_name_get(const Eina_Stringshare *group_name); Eina_Stringshare *style_name_get(const Eina_Stringshare *group_name); +Eina_Stringshare *item_style_name_get(const Eina_Stringshare *group_name, Eina_Stringshare *style_name); Eina_Stringshare *option_widget_name_get(const char *str, Eina_List **style_list); -Eina_Stringshare *option_style_name_get(const char *str, Eina_List **cp_style_list); +Eina_Stringshare *option_style_name_get(const char *str, Eina_List **item_style_list, Eina_List **cp_style_list); +Eina_Stringshare *option_item_style_name_get(const char *str, Eina_List **cp_style_list); Eina_List *widget_prefix_list_get(Eina_List *collections, const char *widget_name, const char *style_name); /* diff --git a/src/bin/main.c b/src/bin/main.c index fb522f9..79762ef 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -69,7 +69,7 @@ static const Ecore_Getopt options = { ECORE_GETOPT_APPEND_METAVAR('s', "sd", "Add sound directory for edc compilation", "DIR_NAME", ECORE_GETOPT_TYPE_STR), ECORE_GETOPT_APPEND_METAVAR('f', "fd", "Add font directory for edc compilation", "DIR_NAME", ECORE_GETOPT_TYPE_STR), ECORE_GETOPT_APPEND_METAVAR('d', "dd", "Add data directory for edc compilation", "DIR_NAME", ECORE_GETOPT_TYPE_STR), - ECORE_GETOPT_APPEND_METAVAR('w', "widget", "Add widget to new project or import edj-file. Add its styles if the style names are added. Copy its styles if the copy style names are added", "WIDGET:STYLE[COPY_STYLE,..],..", ECORE_GETOPT_TYPE_STR), + ECORE_GETOPT_APPEND_METAVAR('w', "widget", "Add widget to new project or import edj-file. Add its styles if the style names are added. Copy its styles if the copy style names are added. **rule = WIDGET:STYLE[COPY_STYLE,..]{ITEM_STYLE,..[COPY_ITEM_STYLE,..]},..", "(Follow the below rule)", ECORE_GETOPT_TYPE_STR), ECORE_GETOPT_STORE_TRUE('r', "reopen", "reopen last project"), ECORE_GETOPT_VERSION ('v', "version"), ECORE_GETOPT_COPYRIGHT('c', "copyright"), diff --git a/src/bin/ui/tab_home_import_edj.c b/src/bin/ui/tab_home_import_edj.c index 3e22055..68b29ff 100644 --- a/src/bin/ui/tab_home_import_edj.c +++ b/src/bin/ui/tab_home_import_edj.c @@ -624,11 +624,37 @@ _delayed_popup(void *data) static void _genlist_style_selected_set(Node *item, Eina_List *styles, Eina_Bool selected) { - Eina_List *l, *l1, *cp_style_list; + Eina_List *l, *l1, *item_style_list, *cp_style_list, *cp_item_style_list; Node *node; - Eina_Stringshare *name, *name1, *sname, *style_name, *tmp; + Eina_Stringshare *name, *name1, *name2, *name3, *sname, *iname, *style_name, *item_style_name, *tmp; char cp_style[256]; int len; +#define GROUP_APPEND() \ + do \ + { \ + item->check = selected; \ + tab_edj.widget_list = eina_list_append(tab_edj.widget_list, item->name); \ + } while (0); + +#define GROUP_STYLE_COPY(LEN, COPY_STYLE) \ + do \ + { \ + len = strlen(item->name) - (LEN); \ + strncpy(cp_style, item->name, len - 1); \ + cp_style[len - 1] = '\0'; \ + tmp = eina_stringshare_printf("cp***%s***%s/%s", item->name, cp_style, COPY_STYLE); \ + tab_edj.widget_list = eina_list_append(tab_edj.widget_list, tmp); \ + } while (0); + +#define GROUP_ITEM_STYLE_COPY(LEN, COPY_STYLE, COPY_ITEM_STYLE) \ + do \ + { \ + len = strlen(item->name) - (LEN); \ + strncpy(cp_style, item->name, len - 1); \ + cp_style[len - 1] = '\0'; \ + tmp = eina_stringshare_printf("cp***%s***%s/%s/%s", item->name, cp_style, COPY_ITEM_STYLE, COPY_STYLE); \ + tab_edj.widget_list = eina_list_append(tab_edj.widget_list, tmp); \ + } while (0); assert (item != NULL); @@ -645,26 +671,59 @@ _genlist_style_selected_set(Node *item, Eina_List *styles, Eina_Bool selected) { EINA_LIST_FOREACH(styles, l, name) { - style_name = option_style_name_get(name, &cp_style_list); + style_name = option_style_name_get(name, &item_style_list, &cp_style_list); sname = style_name_get(item->name); - if (!strcmp(sname, style_name)) + iname = item_style_name_get(item->name, style_name); + if (sname) { - if (!cp_style_list) + if (!strcmp(sname, style_name)) { - item->check = selected; - tab_edj.widget_list = eina_list_append(tab_edj.widget_list, item->name); + if (!cp_style_list) + GROUP_APPEND() + else + EINA_LIST_FOREACH(cp_style_list, l1, name1) + GROUP_STYLE_COPY(strlen(style_name), name1) } - else + } + else if (iname) + { + if (item_style_list) { - EINA_LIST_FOREACH(cp_style_list, l1, name1) + EINA_LIST_FOREACH(item_style_list, l1, name1) { - len = strlen(item->name) - strlen(sname); - strncpy(cp_style, item->name, len - 1); - cp_style[len - 1] = '\0'; - tmp = eina_stringshare_printf("cp***%s***%s/%s", item->name, cp_style, name1); - tab_edj.widget_list = eina_list_append(tab_edj.widget_list, tmp); + item_style_name = option_item_style_name_get(name1, &cp_item_style_list); + if (!strcmp(iname, item_style_name)) + { + if (!cp_item_style_list) + { + if (!cp_style_list) + GROUP_APPEND() + else + EINA_LIST_FOREACH(cp_style_list, l1, name2) + GROUP_STYLE_COPY(strlen(style_name), name2) + } + else + { + EINA_LIST_FOREACH(cp_item_style_list, l1, name2) + { + if (!cp_style_list) + GROUP_ITEM_STYLE_COPY(strlen(style_name) + strlen(item_style_name) + 1, style_name, name2) + else + EINA_LIST_FOREACH(cp_style_list, l1, name3) + GROUP_ITEM_STYLE_COPY(strlen(style_name) + strlen(item_style_name) + 1, name3, name2) + } + } + } } } + else + { + if (!cp_style_list) + GROUP_APPEND() + else + EINA_LIST_FOREACH(cp_style_list, l1, name1) + GROUP_STYLE_COPY(strlen(style_name), name1) + } } eina_stringshare_del(style_name); EINA_LIST_STRINGSHARE_FREE(cp_style_list); @@ -673,8 +732,7 @@ _genlist_style_selected_set(Node *item, Eina_List *styles, Eina_Bool selected) else { /* if list of style empty need to select all available widget styles */ - item->check = selected; - tab_edj.widget_list = eina_list_append(tab_edj.widget_list, item->name); + GROUP_APPEND() } } } --