From cdb21f616a6ce0a5d8b49e600bdeb7be490e00ad Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Wed, 22 Aug 2012 20:01:40 +0000 Subject: [PATCH] ephoto: fix walking on single browser Use same compare function to create the list and search on it. Keep the one that was prioritizing directories. SVN revision: 75560 --- src/bin/ephoto.h | 1 + src/bin/ephoto_main.c | 6 +++--- src/bin/ephoto_single_browser.c | 32 +++++++++----------------------- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index a184384..3555fe7 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -159,6 +159,7 @@ void ephoto_entry_free(Ephoto_Entry *entry); void ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data); void ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data); void ephoto_entries_free(Ephoto *ephoto); +int ephoto_entries_cmp(const void *pa, const void *pb); extern int __log_domain; #define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__) diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index 9b7fdcc..b375eae 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -261,8 +261,8 @@ ephoto_title_set(Ephoto *ephoto, const char *title) elm_win_title_set(ephoto->win, buf); } -static int -_entry_cmp(const void *pa, const void *pb) +int +ephoto_entries_cmp(const void *pa, const void *pb) { const Ephoto_Entry *a = pa, *b = pb; if (a->is_dir == b->is_dir) @@ -291,7 +291,7 @@ _ephoto_populate_main(void *data, Eio_File *handler __UNUSED__, const Eina_File_ { int near_cmp; Eina_List *near_node = eina_list_search_sorted_near_list - (ephoto->entries, _entry_cmp, e, &near_cmp); + (ephoto->entries, ephoto_entries_cmp, e, &near_cmp); if (near_cmp < 0) ephoto->entries = eina_list_append_relative_list diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c index a17db78..53b6a9c 100644 --- a/src/bin/ephoto_single_browser.c +++ b/src/bin/ephoto_single_browser.c @@ -559,18 +559,6 @@ _zoom_fit_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) _zoom_fit(sb); } -static int -_entry_cmp(const void *pa, const void *pb) -{ - const Ephoto_Entry *a = pa; - const char *path = pb; - - if (path == a->path) - return 0; - else - return strcoll(a->path, path); -} - static void _next_entry(Ephoto_Single_Browser *sb) { @@ -578,14 +566,11 @@ _next_entry(Ephoto_Single_Browser *sb) Eina_List *node; EINA_SAFETY_ON_NULL_RETURN(sb->entry); - node = eina_list_search_sorted_list(sb->ephoto->entries, _entry_cmp, sb->entry->path); + node = eina_list_search_sorted_list(sb->ephoto->entries, ephoto_entries_cmp, + sb->entry); if (!node) return; - while ((node = node->next)) - { - entry = node->data; - if (!entry->is_dir) - break; - } + if ((node = node->next)) + entry = node->data; if (!entry) entry = _first_entry_find(sb); if (entry) @@ -602,13 +587,14 @@ _prev_entry(Ephoto_Single_Browser *sb) Ephoto_Entry *entry = NULL; EINA_SAFETY_ON_NULL_RETURN(sb->entry); - node = eina_list_search_sorted_list(sb->ephoto->entries, _entry_cmp, sb->entry->path); + node = eina_list_search_sorted_list(sb->ephoto->entries, ephoto_entries_cmp, + sb->entry); if (!node) return; - while ((node = node->prev)) + if ((node = node->prev)) { entry = node->data; - if (!entry->is_dir) - break; + if (entry->is_dir) + entry = NULL; } if (!entry) entry = _last_entry_find(sb);