summaryrefslogtreecommitdiff
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-29 11:47:05 -0400
committerMike Blumenkrantz <zmike@samsung.com>2020-04-29 11:47:05 -0400
commitf21df93595f18f803ee50095084bd695421b304a (patch)
tree2e04c8a13cfe705c3f74a59096cb5d1ca9f0d565 /src/lib/elementary
parent37e94d635bee2c713b5cdc077bdfe24e2ac1900a (diff)
elm_fileselector: support expandable items
Summary: the fileselector can store exactly 1 model and monitor that for changes, which works normally just well. However, when we expand a items, another model comes into play, which is not monitored, and no additional reference is taken. Which means, _process_last will simply delete it, and elements that did not come into play at the _populate call are never displayed. With this commit, we check that we do not have a parent item, and explictly wait for the model to publish all its items, before we call _process_last. Additionally, that showed that the tracking of the list/grid item is ultimatly buggy, as there is no assertion that the parent model is really the parent directoy. Hence we need to hand pass the parent item here, as a fallback option to set the correct parent item. fixes T8689 Reviewers: zmike Reviewed By: zmike Subscribers: zmike, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8689 Differential Revision: https://phab.enlightenment.org/D11765
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/elc_fileselector.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/lib/elementary/elc_fileselector.c b/src/lib/elementary/elc_fileselector.c
index eb107b14c6..01d4586b0e 100644
--- a/src/lib/elementary/elc_fileselector.c
+++ b/src/lib/elementary/elc_fileselector.c
@@ -880,7 +880,7 @@ _listing_request_cleanup(Listing_Request *lreq)
880} 880}
881 881
882static void 882static void
883_process_model(Elm_Fileselector_Data *sd, Efl_Model *child) 883_process_model(Elm_Fileselector_Data *sd, Efl_Model *child, Elm_Object_Item *fallback_parent_item)
884{ 884{
885 Elm_Fileselector_Item_Data *it_data; 885 Elm_Fileselector_Item_Data *it_data;
886 Elm_Object_Item *item, *it_parent; 886 Elm_Object_Item *item, *it_parent;
@@ -927,6 +927,8 @@ _process_model(Elm_Fileselector_Data *sd, Efl_Model *child)
927 it_data->is_dir = dir; 927 it_data->is_dir = dir;
928 928
929 it_parent = efl_key_data_get(parent, ".item.data"); 929 it_parent = efl_key_data_get(parent, ".item.data");
930 if (!it_parent)
931 it_parent = fallback_parent_item;
930 932
931 if (dir) 933 if (dir)
932 { 934 {
@@ -981,7 +983,9 @@ _process_children_cb(Eo *model EINA_UNUSED, void *data, const Eina_Value v)
981 if (!lreq->valid) goto end; 983 if (!lreq->valid) goto end;
982 984
983 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child) 985 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
984 _process_model(lreq->sd, child); 986 {
987 _process_model(lreq->sd, child, lreq->parent_it);
988 }
985 989
986 lreq->item_total = len; 990 lreq->item_total = len;
987 991
@@ -1004,6 +1008,29 @@ _process_children_error(Eo *model EINA_UNUSED, void *data, Eina_Error error)
1004} 1008}
1005 1009
1006static void 1010static void
1011_count_changed_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1012{
1013 Listing_Request *lreq = data;
1014 Eina_Future *future;
1015
1016 efl_event_callback_del(lreq->model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed_cb, lreq);
1017
1018 if (efl_model_children_count_get(lreq->model))
1019 {
1020 future = efl_model_children_slice_get(lreq->model, 0, efl_model_children_count_get(lreq->model));
1021 future = efl_future_then(lreq->obj, future);
1022 efl_future_then(lreq->model, future,
1023 .success = _process_children_cb,
1024 .error = _process_children_error,
1025 .data = lreq);
1026 }
1027 else
1028 {
1029 _process_last(lreq);
1030 }
1031}
1032
1033static void
1007_populate(Evas_Object *obj, 1034_populate(Evas_Object *obj,
1008 Efl_Model *model, 1035 Efl_Model *model,
1009 Elm_Object_Item *parent_it, 1036 Elm_Object_Item *parent_it,
@@ -1087,7 +1114,10 @@ _populate(Evas_Object *obj,
1087 } 1114 }
1088 else 1115 else
1089 { 1116 {
1090 _process_last(lreq); 1117 if (parent_it)
1118 efl_event_callback_add(lreq->model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed_cb, lreq);
1119 else
1120 _process_last(lreq);
1091 } 1121 }
1092} 1122}
1093 1123
@@ -1624,7 +1654,7 @@ _resource_created_then(Eo *model EINA_UNUSED, void *data, const Eina_Value v)
1624 ELM_FILESELECTOR_DATA_GET(fs, sd); 1654 ELM_FILESELECTOR_DATA_GET(fs, sd);
1625 1655
1626 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child) 1656 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
1627 _process_model(sd, child); 1657 _process_model(sd, child, NULL); //this function will always just work for the root model of the fileselector
1628 1658
1629 return v; 1659 return v;
1630} 1660}