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
This commit is contained in:
Bruno Dilly 2012-08-22 20:01:40 +00:00
parent 1d12801c6f
commit cdb21f616a
3 changed files with 13 additions and 26 deletions

View File

@ -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__)

View File

@ -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

View File

@ -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);