jaehwan pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=0035f313733b0d209e7e6c1a472bfeb0209311cb

commit 0035f313733b0d209e7e6c1a472bfeb0209311cb
Author: Jaehwan Kim <[email protected]>
Date:   Mon May 16 17:35:10 2016 +0900

    main: add the style option in widget option.
    
    When eflete is executed by command, it can use like
    eflete -w button:default,anchor ~/default.edj
---
 src/bin/common/widget_list.c     | 49 +++++++++++++++++++++++++++++++++++++++
 src/bin/common/widget_list.h     |  1 +
 src/bin/main.c                   |  2 +-
 src/bin/ui/tab_home_import_edj.c | 50 +++++++++++++++++++++++++++++++++++-----
 4 files changed, 95 insertions(+), 7 deletions(-)

diff --git a/src/bin/common/widget_list.c b/src/bin/common/widget_list.c
index de8a8e8..d405907 100644
--- a/src/bin/common/widget_list.c
+++ b/src/bin/common/widget_list.c
@@ -242,3 +242,52 @@ item_style_name_check(const Eina_Stringshare *group_name, 
const char *style_name
 
    return !strcmp(style_name, style);
 }
+
+const char *
+option_widget_name_get(const char *str, Eina_List **style_list)
+{
+   int len = strlen(str);
+   char widget[32], style[256];
+   Eina_List *list = NULL;
+   int i, first = 0;
+   Eina_Bool is_style = EINA_FALSE;
+
+   for (i = 0; i < len; i++)
+     {
+        if (str[i] == ':')
+          {
+             is_style = EINA_TRUE;
+             widget[i] = '\0';
+             first = i + 1;
+             continue;
+          }
+
+        if (!is_style)
+          {
+             widget[i] = str[i];
+          }
+        else
+          {
+             if (str[i] == ',')
+               {
+                  style[i - first] = '\0';
+                  list = eina_list_append(list, strdup(style));
+                  first = i + 1;
+                  continue;
+               }
+               style[i - first] = str[i];
+          }
+     }
+
+   if (!is_style)
+      widget[i] = '\0';
+   else
+     {
+        style[i - first] = '\0';
+        list = eina_list_append(list, strdup(style));
+     }
+
+   *style_list = list;
+
+   return strdup(widget);
+}
diff --git a/src/bin/common/widget_list.h b/src/bin/common/widget_list.h
index b7db873..35683a4 100644
--- a/src/bin/common/widget_list.h
+++ b/src/bin/common/widget_list.h
@@ -40,5 +40,6 @@ const char *style_name_get(const Eina_Stringshare 
*group_name);
 const char *item_style_name_get(const Eina_Stringshare *group_name, Eina_List 
*style_list);
 Eina_Bool style_name_check(const Eina_Stringshare *group_name, const char 
*style_name);
 Eina_Bool item_style_name_check(const Eina_Stringshare *group_name, const char 
*style_name, Eina_List *style_list);
+const char *option_widget_name_get(const char *str, Eina_List **style_list);
 
 #endif /* WIDGET_LIST_H */
diff --git a/src/bin/main.c b/src/bin/main.c
index b32149b..07109c7 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -65,7 +65,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", 
"WIDGET_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", 
"WIDGET_NAME[:STYLE_NAME, ...]", 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 0099369..7c6abb7 100644
--- a/src/bin/ui/tab_home_import_edj.c
+++ b/src/bin/ui/tab_home_import_edj.c
@@ -645,11 +645,13 @@ _delayed_popup(void *data)
 void
 _tab_import_edj_data_set(const char *name, const char *path, const char *edj, 
const Eina_List *widgets)
 {
-   const Eina_List *l, *wl;
-   const char *str;
+   const Eina_List *l, *wl, *wll, *wlll, *wllll;
+   Eina_List *style_list = NULL;
+   const char *str, *widget_name, *style_name;
    Eina_Strbuf *buf = eina_strbuf_new();
    Eina_Bool first_not_found = true;
-   Tree_Item_Data *widget = NULL;
+   Tree_Item_Data *widget = NULL, *style = NULL;
+   End_Item_Data *item_style = NULL;
 
    assert(tab_edj.layout != NULL);
 
@@ -663,17 +665,53 @@ _tab_import_edj_data_set(const char *name, const char 
*path, const char *edj, co
 
    EINA_LIST_FOREACH(widgets, l, str)
      {
+        widget_name = option_widget_name_get(str, &style_list);
+
         EINA_LIST_FOREACH(widget_list, wl, widget)
           {
-             if (!strcasecmp(str, widget->name))
+             if (!strcasecmp(widget_name, widget->name))
                {
-                  widget->check = true;
+                  if (!style_list)
+                    {
+                       EINA_LIST_FOREACH(widget->list, wll, style)
+                         {
+                            EINA_LIST_FOREACH(style->list, wlll, item_style)
+                              {
+                                 item_style->check = true;
+                              }
+                            style->check = true;
+                         }
+                       widget->check = true;
+                    }
+                  else
+                    {
+                       EINA_LIST_FOREACH(style_list, wlll, style_name)
+                         {
+                            EINA_LIST_FOREACH(widget->list, wll, style)
+                              {
+                                 if (!strcasecmp(style_name, style->name))
+                                   {
+                                      EINA_LIST_FOREACH(style->list, wllll, 
item_style)
+                                        {
+                                           item_style->check = true;
+                                        }
+                                      style->check = true;
+                                      break;
+                                   }
+                              }
+                            if (!style)
+                              {
+                                 eina_strbuf_append_printf(buf, 
first_not_found ? "%s(%s)" : ", %s(%s)", widget_name, style_name);
+                                 first_not_found = false;
+                              }
+                         }
+                    }
                   break;
                }
           }
         if (!widget)
           {
-             eina_strbuf_append_printf(buf, first_not_found ? "%s" : ", %s", 
str);
+             eina_strbuf_append_printf(buf, first_not_found ? "%s" : ", %s", 
widget_name);
              first_not_found = false;
           }
      }

-- 


Reply via email to