From 2006861f920d9255d430603389262043b55ceb28 Mon Sep 17 00:00:00 2001 From: Dave Andreoli Date: Fri, 13 Apr 2018 20:37:36 +0200 Subject: [PATCH] Genlist: restore old behaviour of item next/prev in group items Commit fd82c2521 has changed the behaviour of item_next/prev_get() in case of genlist with group items (not tree). The lagacy behaviour was to tread normal items and group items in a flat way, like if group items was on the same level of the children normal items. As the commit already implement bug compatibility, seems to me the case to restore also this case. Note that this changes only apply to legacy genlist (I think). Let me know if this broke something for you...as touching genlist code is always an "I hope this is right" operation. --- src/lib/elementary/elm_genlist.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c index 97bf2d8..08e5d86 100644 --- a/src/lib/elementary/elm_genlist.c +++ b/src/lib/elementary/elm_genlist.c @@ -7192,6 +7192,12 @@ _elm_genlist_next_item_get_insane(Elm_Genlist_Data *sd, Elm_Gen_Item *it) if (sd->filter && !_item_filtered_get(it2)) continue; + // Insanity does not apply for group items + // (group and normal items was treated in a flat way) + if (it->item->type == ELM_GENLIST_ITEM_GROUP || + it2->item->type == ELM_GENLIST_ITEM_GROUP) + return EO_OBJ(it2); + // 1. Return next sibling in list, if any if (it->parent == it2->parent) return EO_OBJ(it2); @@ -7215,7 +7221,7 @@ _elm_genlist_next_item_get_insane(Elm_Genlist_Data *sd, Elm_Gen_Item *it) return EO_OBJ(it->parent); } /* if item is already last item, return its parent if a parent exists */ - if (it->parent) + if (it->parent && it->parent->item->type != ELM_GENLIST_ITEM_GROUP) return EO_OBJ(it->parent); return EO_OBJ(it2); } @@ -7235,6 +7241,16 @@ _elm_genlist_prev_item_get_insane(Elm_Genlist_Data *sd, Elm_Gen_Item *it) return EO_OBJ(it2); } + // Insanity does not apply for group items + // (group and normal items was treated in a flat way) + if (it->item->type == ELM_GENLIST_ITEM_GROUP) + { + for (it2 = ELM_GEN_ITEM_PREV(it); it2; it2 = ELM_GEN_ITEM_PREV(it2)) + if (!sd->filter || _item_filtered_get(it2)) + break; + return EO_OBJ(it2); + } + parent = it->parent; if (!parent) { @@ -7254,7 +7270,7 @@ _elm_genlist_prev_item_get_insane(Elm_Genlist_Data *sd, Elm_Gen_Item *it) } it2 = ELM_GEN_ITEM_PREV(it); - if (it2 == parent) + if (it2 == parent && it2->item->type != ELM_GENLIST_ITEM_GROUP) return _elm_genlist_prev_item_get_insane(sd, it2); return EO_OBJ(it2); -- 2.7.4