From f438e6e62badde9137151b7bc70decd95d6b4d0f Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Wed, 6 Jun 2018 14:04:09 +0100 Subject: [PATCH] filepanel: on tab focus improve visibility. This patch selects the next best match. Making it easier to follow the file in use (especially duplicate names). On expand (next best), it will automatically select the actual path. Visual and usability improvement. Thanks Brokenshackles for suggestion. --- src/bin/edi_filepanel.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/bin/edi_filepanel.c b/src/bin/edi_filepanel.c index 6848986..33b2408 100644 --- a/src/bin/edi_filepanel.c +++ b/src/bin/edi_filepanel.c @@ -1084,6 +1084,35 @@ _edi_filepanel_select_check(void *data EINA_UNUSED) return ECORE_CALLBACK_RENEW; } +static void +_edi_filepanel_select_next_best_path(const char *path) +{ + Elm_Object_Item *item; + char *end, *try = strdup(path); + + while (1) + { + if (!strcmp(try, edi_project_get())) + break; + + end = strrchr(try, '/'); + if (!end) + break; + else + *end = '\0'; + + item = _file_listing_item_find(try); + if (item) + { + elm_genlist_item_selected_set(item, EINA_TRUE); + elm_genlist_item_bring_in(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); + break; + } + } + + free(try); +} + void edi_filepanel_select_path(const char *path) { @@ -1091,12 +1120,16 @@ edi_filepanel_select_path(const char *path) item = _file_listing_item_find(path); if (!item) - return; + { + _edi_filepanel_select_next_best_path(path); + return; + } if (elm_genlist_item_selected_get(item)) return; elm_genlist_item_selected_set(item, EINA_TRUE); + elm_genlist_item_bring_in(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); } void