Ephoto/Images: Sort images so they are in alphabetical order. This seems to be a good solution as it doesn't seem to slow down Ephoto much at all.

SVN revision: 57520
This commit is contained in:
titan 2011-03-04 21:50:07 +00:00 committed by titan
parent 9ac8cb0be1
commit 004acaf9f8
3 changed files with 66 additions and 5 deletions

View File

@ -312,6 +312,22 @@ 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)
{
const Ephoto_Entry *a = pa, *b = pb;
int ret, s;
s = strcmp(a->basename, b->basename);
if (s > 0)
ret = 1;
else if (s < 0)
ret = -1;
else
ret = 0;
return ret;
}
static void
_ephoto_populate_main(void *data, Eio_File *handler __UNUSED__, const Eina_File_Direct_Info *info)
{
@ -321,7 +337,7 @@ _ephoto_populate_main(void *data, Eio_File *handler __UNUSED__, const Eina_File_
e = ephoto_entry_new(ephoto, info->path, info->path + info->name_start);
ephoto->entries = eina_list_append(ephoto->entries, e);
ephoto->entries = eina_list_sorted_insert(ephoto->entries, _entry_cmp, e);
ev = calloc(1, sizeof(Ephoto_Event_Entry_Create));
ev->entry = e;

View File

@ -122,13 +122,15 @@ _viewer_add(Evas_Object *parent, const char *path)
if (err != EVAS_LOAD_ERROR_NONE) goto load_error;
evas_object_image_size_get(v->image, &w, &h);
evas_object_size_hint_align_set(v->image, 0.5, 0.5);
evas_object_size_hint_weight_set(v->image, 1.0, 1.0);
evas_object_size_hint_min_set(v->image, w, h);
evas_object_size_hint_max_set(v->image, w, h);
evas_object_resize(v->image, w, h);
evas_object_show(v->image);
elm_scroller_content_set(obj, v->image);
}
elm_scroller_custom_widget_base_theme_set(obj, "photocam", "default");
}
evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_data_set(obj, "viewer", v);

View File

@ -92,6 +92,22 @@ static const Elm_Gengrid_Item_Class _ephoto_thumb_file_class = {
}
};
static int
_entry_cmp(const void *pa, const void *pb)
{
const Ephoto_Entry *a = pa, *b = pb;
int ret, s;
s = strcmp(a->basename, b->basename);
if (s > 0)
ret = 1;
else if (s < 0)
ret = -1;
else
ret = 0;
return ret;
}
static void
_entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e)
{
@ -99,9 +115,36 @@ _entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e)
ic = &_ephoto_thumb_file_class;
e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
tb->grid_items = eina_list_append(tb->grid_items, e->item);
if (!tb->grid_items)
{
e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
tb->grid_items = eina_list_append(tb->grid_items, e);
}
else
{
int near_cmp;
Ephoto_Entry *near_entry;
Elm_Gengrid_Item *near_item;
Eina_List *near_node = eina_list_search_sorted_near_list
(tb->grid_items, _entry_cmp, e, &near_cmp);
near_entry = near_node->data;
near_item = near_entry->item;
if (near_cmp < 0)
{
e->item = elm_gengrid_item_insert_after
(tb->grid, ic, e, near_item, NULL, NULL);
tb->grid_items = eina_list_append_relative_list
(tb->grid_items, e, near_node);
}
else
{
e->item = elm_gengrid_item_insert_before
(tb->grid, ic, e, near_item, NULL, NULL);
tb->grid_items = eina_list_prepend_relative_list
(tb->grid_items, e, near_node);
}
}
if (e->item)
elm_gengrid_item_data_set(e->item, e);
else