hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=50a7b468ef5ae48b0dc9ef027f970903d1f751ed

commit 50a7b468ef5ae48b0dc9ef027f970903d1f751ed
Author: Hermet Park <her...@hermet.pe.kr>
Date:   Fri Feb 26 22:22:29 2016 +0900

    edc_navigator: 2nd patch for base navigation behavior.
    
    not completed.
---
 data/themes/default/layout_common.edc |   2 +-
 src/bin/Makefile.am                   |   3 +-
 src/bin/base_gui.c                    |  19 +++
 src/bin/edc_navigator.c               | 267 ++++++++++++++++++++++++++++++++++
 src/bin/main.c                        |   2 +
 src/include/base_gui.h                |   3 +
 src/include/edc_navigator.h           |   4 +
 src/lib/enventor_object.eo            |   9 ++
 src/lib/enventor_smart.c              |  15 ++
 9 files changed, 322 insertions(+), 2 deletions(-)

diff --git a/data/themes/default/layout_common.edc 
b/data/themes/default/layout_common.edc
index dc511e8..dc9255b 100644
--- a/data/themes/default/layout_common.edc
+++ b/data/themes/default/layout_common.edc
@@ -2720,7 +2720,7 @@ group { name: "main_layout";
          }
          desc { "visible";
             inherit: "default";
-            min: 150 0;
+            min: 200 0;
          }
       }
    }
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 9f520fd..57cecd5 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -28,7 +28,8 @@ enventor_SOURCES = \
        globals.c \
        live_edit.c \
        console.c \
-       file_mgr.c
+       file_mgr.c \
+       edc_navigator.c
 
 enventor_LDADD = \
        $(top_builddir)/src/lib/libenventor.la \
diff --git a/src/bin/base_gui.c b/src/bin/base_gui.c
index 817efc1..05b9e4c 100644
--- a/src/bin/base_gui.c
+++ b/src/bin/base_gui.c
@@ -197,11 +197,25 @@ base_gui_term(void)
    base_data *bd = g_bd;
    assert(bd);
 
+   edc_navigator_term();
    panes_term();
+
    free(bd);
 }
 
 void
+base_edc_navigator_parts_reload(void)
+{
+   edc_navigator_parts_reload();
+}
+
+void
+base_edc_navigator_group_reload(void)
+{
+   edc_navigator_group_reload();
+}
+
+void
 base_console_reset(void)
 {
    base_data *bd = g_bd;
@@ -265,6 +279,11 @@ base_gui_init(void)
    if (config_console_get())
      panes_editors_full_view(EINA_TRUE);
 
+   //EDC Navigator
+   Evas_Object *edc_navigator = edc_navigator_init(layout);
+   elm_object_part_content_set(layout, "elm.swallow.edc_navigator",
+                               edc_navigator);
+
    bd->win = win;
    bd->layout = layout;
    bd->console = console;
diff --git a/src/bin/edc_navigator.c b/src/bin/edc_navigator.c
new file mode 100644
index 0000000..c269e57
--- /dev/null
+++ b/src/bin/edc_navigator.c
@@ -0,0 +1,267 @@
+#include "common.h"
+
+typedef struct edc_navigator_s
+{
+   Evas_Object *genlist;
+
+   Eina_List *group_items;                 //group object item
+   Eina_List *part_items;                  //part object item
+   Eina_List *state_items;                 //state object item
+
+   Eina_List *group_list;                  //group name list
+   Eina_List *part_list;                   //part name list
+   Eina_List *state_list;                  //state name list
+
+   Elm_Genlist_Item_Class *group_itc;
+   Elm_Genlist_Item_Class *part_itc;
+   Elm_Genlist_Item_Class *state_itc;
+} navi_data;
+
+static navi_data *g_nd = NULL;
+
+/*****************************************************************************/
+/* Internal method implementation                                            */
+/*****************************************************************************/
+static void
+gl_state_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void 
*event_info)
+{
+   Elm_Object_Item *it = event_info;
+   //TODO: Search Current State
+}
+
+static void
+states_reload(navi_data *nd, Elm_Object_Item *part_it)
+{
+   const char *part = elm_object_item_text_get(part_it);
+   if (!part) return;
+
+   Eina_List *l;
+   Elm_Object_Item *it;
+
+   //Remove Previous Parts
+   EINA_LIST_FREE(nd->state_items, it)
+     elm_object_item_del(it);
+
+   //Append States
+   Evas_Object *enventor = base_enventor_get();
+   edje_edit_string_list_free(nd->state_list);
+   nd->state_list = enventor_object_part_states_list_get(enventor, part);
+   char *name;
+
+   EINA_LIST_FOREACH(nd->state_list, l, name)
+     {
+        it = elm_genlist_item_append(nd->genlist,
+                                     nd->state_itc,         /* item class */
+                                     name,                  /* item data */
+                                     part_it,               /* parent */
+                                     ELM_GENLIST_ITEM_NONE, /* item type */
+                                     gl_state_selected_cb,  /* select cb */
+                                     nd);                   /* select cb data 
*/
+        nd->state_items = eina_list_append(nd->state_items, it);
+     }
+}
+
+static char *
+gl_text_get_cb(void *data, Evas_Object *obj EINA_UNUSED,
+               const char *part EINA_UNUSED)
+{
+   const char *text = data;
+   return strdup(text);
+}
+
+static Evas_Object *
+gl_content_get_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                  const char *part EINA_UNUSED)
+{
+   return NULL;
+}
+
+static void
+gl_del_cb(void *data, Evas_Object *obj EINA_UNUSED)
+{
+
+}
+
+static void
+gl_group_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void 
*event_info)
+{
+   Elm_Object_Item *it = event_info;
+
+   //TODO: Search Current Group
+}
+
+static void
+gl_part_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+   navi_data *nd = data;
+   Elm_Object_Item *it = event_info;
+   //TODO: Search Current Part
+
+   //TODO: Add States List
+   states_reload(nd, it);
+}
+
+/*****************************************************************************/
+/* Externally accessible calls                                               */
+/*****************************************************************************/
+
+void
+edc_navigator_parts_reload(void)
+{
+   if (!config_edc_navigator_get()) return;
+
+   navi_data *nd = g_nd;
+   if (!nd) return;
+
+   Eina_List *l;
+   Elm_Object_Item *it;
+
+   //Remove Previous Parts
+   EINA_LIST_FREE(nd->part_items, it)
+      elm_object_item_del(it);
+
+   //Find a current group item
+   const char *cur_group = stats_group_name_get();
+   if (!cur_group) return;
+
+   Elm_Object_Item *group_item = NULL;
+
+   EINA_LIST_FOREACH(nd->group_items, l, it)
+     {
+        group_item = it;
+        const char *group_name = elm_object_item_text_get(it);
+        if (!group_name) continue;
+
+        if (!strcmp(group_name, cur_group) &&
+            strlen(group_name) == strlen(cur_group))
+          {
+             group_item = it;
+             break;
+          }
+     }
+
+   if (!group_item) return;
+
+   //Append Parts
+   Evas_Object *enventor = base_enventor_get();
+   edje_edit_string_list_free(nd->part_list);
+   nd->part_list = enventor_object_parts_list_get(enventor);
+   char *name;
+
+   EINA_LIST_FOREACH(nd->part_list, l, name)
+     {
+        it = elm_genlist_item_append(nd->genlist,
+                                     nd->part_itc,          /* item class */
+                                     name,                  /* item data */
+                                     group_item,            /* parent */
+                                     ELM_GENLIST_ITEM_NONE, /* item type */
+                                     gl_part_selected_cb,   /* select cb */
+                                     nd);                   /* select cb data 
*/
+        nd->part_items = eina_list_append(nd->part_items, it);
+     }
+}
+
+void
+edc_navigator_group_reload(void)
+{
+   if (!config_edc_navigator_get()) return;
+
+   navi_data *nd = g_nd;
+   if (!nd) return;
+
+   //Reset Navigator resource
+   nd->group_items = eina_list_free(nd->group_items);
+   elm_genlist_clear(nd->genlist);
+   edje_file_collection_list_free(nd->group_list);
+   nd->group_list = edje_file_collection_list(config_output_path_get());
+
+   Eina_List *l;
+   char *name;
+   Elm_Object_Item *it;
+   const char *cur_group = stats_group_name_get();
+
+   //Update Group
+   EINA_LIST_REVERSE_FOREACH(nd->group_list, l, name)
+     {
+        it = elm_genlist_item_append(nd->genlist,
+                                     nd->group_itc,         /* item class */
+                                     name,                  /* item data */
+                                     NULL,                  /* parent */
+                                     ELM_GENLIST_ITEM_NONE, /* item type */
+                                     gl_group_selected_cb,  /* select cb */
+                                     nd);                   /* select cb data 
*/
+
+        nd->group_items = eina_list_append(nd->group_items, it);
+
+        //Update Parts only if current group
+        if (cur_group && !strcmp(name, cur_group) &&
+            (strlen(name) == strlen(cur_group)))
+           edc_navigator_parts_reload();
+     }
+}
+
+Evas_Object *
+edc_navigator_init(Evas_Object *parent)
+{
+   navi_data *nd = calloc(1, sizeof(navi_data));
+   if (!nd)
+     {
+        EINA_LOG_ERR("Failed to allocate Memory!");
+        return NULL;
+     }
+   g_nd = nd;
+
+   Evas_Object *genlist = elm_genlist_add(parent);
+
+   //Group Item Class
+   Elm_Genlist_Item_Class *itc;
+
+   itc = elm_genlist_item_class_new();
+   itc->item_style = "default";
+   itc->func.text_get = gl_text_get_cb;
+   itc->func.content_get = gl_content_get_cb;
+   itc->func.del = gl_del_cb;
+
+   nd->group_itc = itc;
+
+   //Part Item Class
+   itc = elm_genlist_item_class_new();
+   itc->item_style = "default";
+   itc->func.text_get = gl_text_get_cb;
+   itc->func.content_get = gl_content_get_cb;
+   itc->func.del = gl_del_cb;
+
+   nd->part_itc = itc;
+
+   //State Item Class
+   itc = elm_genlist_item_class_new();
+   itc->item_style = "default";
+   itc->func.text_get = gl_text_get_cb;
+   itc->func.content_get = gl_content_get_cb;
+   itc->func.del = gl_del_cb;
+
+   nd->state_itc = itc;
+
+   nd->genlist = genlist;
+
+   return genlist;
+}
+
+void
+edc_navigator_term(void)
+{
+   navi_data *nd = g_nd;
+   if (!nd) return;
+
+   eina_list_free(nd->state_items);
+   eina_list_free(nd->part_items);
+   eina_list_free(nd->group_items);
+   edje_file_collection_list_free(nd->group_list);
+   edje_edit_string_list_free(nd->part_list);
+   edje_edit_string_list_free(nd->state_list);
+   elm_genlist_item_class_free(nd->group_itc);
+   elm_genlist_item_class_free(nd->part_itc);
+   elm_genlist_item_class_free(nd->state_itc);
+   free(nd);
+   g_nd = NULL;
+}
diff --git a/src/bin/main.c b/src/bin/main.c
index 6b991e4..9ffed8f 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -402,6 +402,7 @@ enventor_cursor_group_changed_cb(void *data EINA_UNUSED,
 {
    const char *group_name = event_info;
    stats_edc_group_update(group_name);
+   base_edc_navigator_parts_reload();
 }
 
 static void
@@ -430,6 +431,7 @@ enventor_live_view_loaded_cb(void *data EINA_UNUSED, 
Evas_Object *obj,
    Evas_Coord w, h;
    config_view_size_get(&w, &h);
    enventor_object_live_view_size_set(obj, w, h);
+   base_edc_navigator_group_reload();
 }
 
 static void
diff --git a/src/include/base_gui.h b/src/include/base_gui.h
index 12f861c..90457a8 100644
--- a/src/include/base_gui.h
+++ b/src/include/base_gui.h
@@ -1,4 +1,5 @@
 #include "panes.h"
+#include "edc_navigator.h"
 
 Eina_Bool base_gui_init(void);
 void base_gui_show(void);
@@ -22,3 +23,5 @@ void base_console_reset(void);
 void base_error_msg_set(const char *msg);
 void base_console_full_view(void);
 void base_edc_navigator_toggle(Eina_Bool toggle);
+void base_edc_navigator_group_reload(void);
+void base_edc_navigator_parts_reload(void);
diff --git a/src/include/edc_navigator.h b/src/include/edc_navigator.h
new file mode 100644
index 0000000..fa886c3
--- /dev/null
+++ b/src/include/edc_navigator.h
@@ -0,0 +1,4 @@
+Evas_Object *edc_navigator_init(Evas_Object *parent);
+void edc_navigator_term(void);
+void edc_navigator_group_reload(void);
+void edc_navigator_parts_reload(void);
diff --git a/src/lib/enventor_object.eo b/src/lib/enventor_object.eo
index e56796a..30a2c71 100644
--- a/src/lib/enventor_object.eo
+++ b/src/lib/enventor_object.eo
@@ -113,6 +113,15 @@ class Enventor.Object (Elm.Widget, Efl.File) {
             @in type: Enventor_Path_Type;
          }
       }
+      part_states_list_get {
+         return: Eina_List *;
+         params {
+            @in type: const(char) *;
+         }
+      }
+      parts_list_get {
+         return: Eina_List *;
+      }
       max_line_get {
          return: int;
       }
diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c
index eb195e1..6e391df 100644
--- a/src/lib/enventor_smart.c
+++ b/src/lib/enventor_smart.c
@@ -315,6 +315,21 @@ err:
    return EINA_FALSE;
 }
 
+EOLIAN static Eina_List *
+_enventor_object_part_states_list_get(Eo *obj EINA_UNUSED,
+                                      Enventor_Object_Data *pd EINA_UNUSED,
+                                      const char *part)
+{
+   return view_part_states_list_get(VIEW_DATA, part);
+}
+
+EOLIAN static Eina_List *
+_enventor_object_parts_list_get(Eo *obj EINA_UNUSED,
+                                Enventor_Object_Data *pd EINA_UNUSED)
+{
+   return view_parts_list_get(VIEW_DATA);
+}
+
 EOLIAN static void
 _enventor_object_linenumber_set(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd,
                                 Eina_Bool linenumber)

-- 


Reply via email to