jackdanielz pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=7042c0a979fd49423bfb5c26e736ad5c27956e45

commit 7042c0a979fd49423bfb5c26e736ad5c27956e45
Author: Daniel Zaoui <daniel.za...@samsung.com>
Date:   Thu Nov 26 11:55:28 2015 +0200

    Objtree: prevent item realization if parent is not realized
    
    The problem is that the object item is always created, event if the
    parent is not expanded.
    We only need to realize the parents when a selection is done and not
    every time an object is created.
---
 src/bin/gui/objtree.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/bin/gui/objtree.c b/src/bin/gui/objtree.c
index 2d708d8..c49a93f 100644
--- a/src/bin/gui/objtree.c
+++ b/src/bin/gui/objtree.c
@@ -77,7 +77,7 @@ _find_last_item_child(Elm_Object_Item *parent)
 }
 
 static Elm_Object_Item *
-_item_realize(Eid *eid)
+_item_realize(Eid *eid, Eina_Bool realize_parents)
 {
    if (eid_is_dummy(eid) || !eid_exists(eid)) return NULL;
    Gui_Widget *wdg = wdg_get(eid);
@@ -86,14 +86,19 @@ _item_realize(Eid *eid)
    if (item) return item;
 
    Gui_Widget *parent = (Gui_Widget *)wdg_parent_get(wdg);
-   if (parent)
+   if (realize_parents && parent)
      {
-        parent_item = _item_realize(wdg_eid_get(parent));
+        parent_item = _item_realize(wdg_eid_get(parent), realize_parents);
         if (parent_item) elm_genlist_item_expanded_set(parent_item, EINA_TRUE);
      }
+   if (parent)
+     {
+        parent_item = wdg_data_get(parent, DATA_ITEM);
+        if (!parent_item) return NULL;
+     }
 
    item = wdg_data_get(wdg, DATA_ITEM);
-   if (!item && (!parent || parent_item))
+   if (!item)
      {
         const Gui_Widget *prev_wdg = wdg;
         Eid *prev_id = eid;
@@ -151,7 +156,7 @@ _expanded_cb(void *data EINA_UNUSED, Evas_Object *o 
EINA_UNUSED, void *event_inf
    EINA_LIST_FOREACH(wdg_children_list_get(wdg), itr, wid)
      {
         if (!_filter || strstr(eid_name_get(wid), _filter))
-           _item_realize(wid);
+           _item_realize(wid, EINA_FALSE);
      }
 }
 
@@ -219,7 +224,7 @@ _build()
         EINA_LIST_FOREACH(gui_context_wdg_list_get(_active_ctx), itr, eid)
           {
              if (strstr(eid_name_get(eid), _filter))
-                _item_realize(eid);
+                _item_realize(eid, EINA_TRUE);
           }
      }
    else
@@ -229,7 +234,7 @@ _build()
         EINA_LIST_FOREACH(gui_context_main_widgets_get(_active_ctx), itr, eid)
           {
              if (eid_is_dummy(eid) || !eid_exists(eid)) continue;
-             _item_realize(eid);
+             _item_realize(eid, EINA_FALSE);
           }
      }
 }
@@ -290,7 +295,7 @@ objtree_item_selected_set(const Gui_Widget *wdg)
    Elm_Object_Item *item = NULL;
    if (!wdg) return;
    _filter = NULL;
-   item = _item_realize(wdg_eid_get(wdg));
+   item = _item_realize(wdg_eid_get(wdg), EINA_TRUE);
    if (!item) return;
    elm_genlist_item_bring_in(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
    elm_genlist_item_selected_set(item, EINA_TRUE);
@@ -304,11 +309,14 @@ objtree_item_add(const Gui_Widget *wdg)
    if (eid_is_dummy(eid) || !eid_exists(eid)) return;
    const Gui_Widget *parent = wdg_parent_get(wdg);
    Elm_Object_Item *parent_item = parent ? wdg_data_get(parent, DATA_ITEM) : 
NULL;
-   if (!parent || parent_item)
+   if (!parent || (parent_item && elm_genlist_item_expanded_get(parent_item)))
      {
         if (parent_item && elm_genlist_item_type_get(parent_item) != 
ELM_GENLIST_ITEM_TREE)
-           objtree_item_remove(parent);
-        _item_realize(wdg_eid_get(wdg));
+          {
+             objtree_item_remove(parent);
+             objtree_item_add(parent);
+          }
+        _item_realize(wdg_eid_get(wdg), EINA_FALSE);
      }
 }
 

-- 


Reply via email to