From 239515ca7c5dfbe35a6f461cdbbb4231282a84ec Mon Sep 17 00:00:00 2001 From: Stephen okra Houston Date: Mon, 15 Aug 2016 08:44:29 -0500 Subject: [PATCH] Revert "Ephoto: Add sorting by image similarity." This reverts commit 1f49a495cb39bf41eccd5614233e8dbd32d688e0. --- src/bin/ephoto.h | 8 +-- src/bin/ephoto_main.c | 29 +------- src/bin/ephoto_thumb_browser.c | 124 +++++++++++++++++++-------------- 3 files changed, 76 insertions(+), 85 deletions(-) diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index bcbc91c..9bc1fe2 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -55,7 +55,7 @@ Evas_Object *ephoto_window_add(const char *path); void ephoto_title_set(Ephoto *ephoto, const char *title); void ephoto_thumb_size_set(Ephoto *ephoto, int size); Evas_Object *ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, - Ephoto_Entry *entry); + const char *path); void ephoto_thumb_path_set(Evas_Object *obj, const char *path); void ephoto_directory_set(Ephoto *ephoto, const char *path, Elm_Object_Item *expanded, Eina_Bool dirs_only, Eina_Bool thumbs_only); @@ -107,7 +107,6 @@ void ephoto_thumb_browser_slideshow(Evas_Object *obj); void ephoto_thumb_browser_paste(Ephoto *ephoto, Elm_Object_Item *item); void ephoto_thumb_browser_clear(Ephoto *ephoto); void ephoto_thumb_browser_dirs_only_set(Ephoto *ephoto, Eina_Bool dirs_only); -void ephoto_thumb_browser_resort(Ephoto *ephoto, Ephoto_Entry *entry); /* smart callbacks called: "selected" - an item in the thumb browser is * selected. The selected Ephoto_Entry is passed as event_info argument. */ @@ -203,8 +202,7 @@ enum _Ephoto_Sort EPHOTO_SORT_ALPHABETICAL_ASCENDING, EPHOTO_SORT_ALPHABETICAL_DESCENDING, EPHOTO_SORT_MODTIME_ASCENDING, - EPHOTO_SORT_MODTIME_DESCENDING, - EPHOTO_SORT_SIMILARITY + EPHOTO_SORT_MODTIME_DESCENDING }; enum _Ephoto_Ipc_Domain @@ -310,7 +308,6 @@ struct _Ephoto_Entry const char *path; const char *basename; const char *label; - char *sort_id; double size; Ephoto *ephoto; Eio_Monitor *monitor; @@ -322,7 +319,6 @@ struct _Ephoto_Entry Eina_Bool is_link; Eina_Bool no_delete; Evas_Object *genlist; - Evas_Object *thumb; }; struct _Ephoto_Event_Entry_Create diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index 91d2acb..50c212e 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -991,18 +991,6 @@ ephoto_thumb_size_set(Ephoto *ephoto, int size) ecore_timer_add(0.1, _thumb_gen_size_changed_timer_cb, ephoto); } -static void -_thumb_gen(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Ephoto_Entry *entry = data; - const char *id = e_thumb_sort_id_get(entry->thumb); - - if (id) - entry->sort_id = strdup(id); - e_thumb_icon_end(entry->thumb); - ephoto_thumb_browser_insert(entry->ephoto, entry); -} - static void _thumb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) @@ -1014,10 +1002,9 @@ _thumb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, } Evas_Object * -ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, Ephoto_Entry *entry) +ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path) { Evas_Object *o; - const char *path = entry->path; if (path) { @@ -1035,10 +1022,7 @@ ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, Ephoto_Entry *entry) o = e_thumb_icon_add(parent); e_thumb_icon_file_set(o, path, NULL); e_thumb_icon_size_set(o, ephoto->thumb_gen_size, - ephoto->thumb_gen_size); - evas_object_smart_callback_add(o, "e_thumb_gen", - _thumb_gen, entry); - entry->thumb = o; + ephoto->thumb_gen_size); e_thumb_icon_begin(o); } } @@ -1048,17 +1032,11 @@ ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, Ephoto_Entry *entry) e_thumb_icon_file_set(o, path, NULL); e_thumb_icon_size_set(o, ephoto->thumb_gen_size, ephoto->thumb_gen_size); - evas_object_smart_callback_add(o, "e_thumb_gen", - _thumb_gen, entry); - entry->thumb = o; e_thumb_icon_begin(o); } } else - { - o = e_thumb_icon_add(parent); - entry->thumb = o; - } + o = e_thumb_icon_add(parent); if (!o) return NULL; @@ -1159,7 +1137,6 @@ ephoto_entry_free(Ephoto *ephoto, Ephoto_Entry *entry) node); } } - free(entry->sort_id); eina_stringshare_del(entry->path); eina_stringshare_del(entry->label); if (entry->monitor) diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c index 7ae6d85..4894870 100644 --- a/src/bin/ephoto_thumb_browser.c +++ b/src/bin/ephoto_thumb_browser.c @@ -273,15 +273,20 @@ _thumb_item_text_get(void *data, Evas_Object *obj EINA_UNUSED, } static Evas_Object * -_thumb_file_icon_get(void *data, Evas_Object *obj EINA_UNUSED, +_thumb_file_icon_get(void *data, Evas_Object *obj, const char *part) { Ephoto_Entry *e = data; - Evas_Object *thumb = e->thumb; + Evas_Object *thumb = NULL; if (strcmp(part, "elm.swallow.icon")) return NULL; + if (e) + { + thumb = ephoto_thumb_add(e->ephoto, obj, e->path); + evas_object_show(thumb); + } return thumb; } @@ -368,24 +373,6 @@ _entry_cmp_grid_mod_desc(const void *pa, const void *pb) } } -static int -_entry_cmp_grid_similarity(const void *pa, const void *pb) -{ - const Ephoto_Entry *a, *b; - char *ida, *idb; - - a = elm_object_item_data_get(pa); - b = elm_object_item_data_get(pb); - - ida = a->sort_id; - idb = b->sort_id; - - if (!ida || !idb) - return 0; - - return strcmp(ida, idb); -} - static void _sort_alpha_asc(void *data, Evas_Object *obj, void *event_data EINA_UNUSED) @@ -458,24 +445,6 @@ _sort_mod_desc(void *data, Evas_Object *obj EINA_UNUSED, NULL, tb->dirs_only, tb->thumbs_only); } -static void -_sort_similarity(void *data, Evas_Object *obj EINA_UNUSED, - void *eent_data EINA_UNUSED) -{ - Ephoto_Thumb_Browser *tb = data; - Evas_Object *ic; - - tb->sort = EPHOTO_SORT_SIMILARITY; - tb->thumbs_only = 1; - tb->dirs_only = 0; - ic = elm_icon_add(obj); - elm_icon_standard_set(ic, "view-sort-ascending"); - elm_object_part_content_set(obj, "icon", ic); - evas_object_show(ic); - ephoto_directory_set(tb->ephoto, tb->ephoto->config->directory, - NULL, tb->dirs_only, tb->thumbs_only); -} - static void _zoom_in(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) @@ -1058,7 +1027,9 @@ _ephoto_thumb_search_go(void *data, Evas_Object *obj EINA_UNUSED, elm_box_unpack(tb->gridbox, tb->original_grid); evas_object_hide(tb->original_grid); + elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/ephoto.edj"); tb->grid = elm_gengrid_add(tb->gridbox); + elm_object_style_set(tb->grid, "noclip"); evas_object_size_hint_weight_set(tb->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(tb->grid, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -1088,18 +1059,46 @@ _ephoto_thumb_search_go(void *data, Evas_Object *obj EINA_UNUSED, tb->totsize = 0; EINA_LIST_FOREACH(results, l, o) { + const Elm_Gengrid_Item_Class *ic = NULL; Ephoto_Entry *entry = NULL, *e = NULL; - Evas_Object *thumb; + ic = &_ephoto_thumb_file_class; entry = elm_object_item_data_get(o); e = ephoto_entry_new(tb->ephoto, entry->path, entry->label, EINA_FILE_REG); - - thumb = ephoto_thumb_add(tb->ephoto, tb->grid, e); - evas_object_show(thumb); - tb->searchentries = eina_list_append(tb->searchentries, e); + if (tb->sort == EPHOTO_SORT_ALPHABETICAL_ASCENDING) + e->item = + elm_gengrid_item_sorted_insert(tb->grid, ic, e, + _entry_cmp_grid_alpha_asc, NULL, NULL); + else if (tb->sort == EPHOTO_SORT_ALPHABETICAL_DESCENDING) + e->item = + elm_gengrid_item_sorted_insert(tb->grid, ic, e, + _entry_cmp_grid_alpha_desc, NULL, NULL); + else if (tb->sort == EPHOTO_SORT_MODTIME_ASCENDING) + e->item = + elm_gengrid_item_sorted_insert(tb->grid, ic, e, + _entry_cmp_grid_mod_asc, NULL, NULL); + else if (tb->sort == EPHOTO_SORT_MODTIME_DESCENDING) + e->item = + elm_gengrid_item_sorted_insert(tb->grid, ic, e, + _entry_cmp_grid_mod_desc, NULL, NULL); + if (e->item) + { + Eina_File *f; + elm_object_item_data_set(e->item, e); + tb->totimages++; + f = eina_file_open(e->path, EINA_FALSE); + tb->totsize += (double) eina_file_size_get(f); + eina_file_close(f); + tb->searchentries = eina_list_append(tb->searchentries, e); + } + else + { + ephoto_entry_free(tb->ephoto, e); + } } tb->entries = tb->searchentries; + ephoto_thumb_browser_update_info_label(tb->ephoto); eina_list_free(results); } else @@ -1235,7 +1234,9 @@ _ephoto_thumb_view_add(Ephoto_Thumb_Browser *tb) EVAS_HINT_FILL); evas_object_show(tb->gridbox); + elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/themes/ephoto.edj"); tb->grid = elm_gengrid_add(tb->gridbox); + elm_object_style_set(tb->grid, "noclip"); evas_object_size_hint_weight_set(tb->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(tb->grid, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -1296,10 +1297,33 @@ _todo_items_process(void *data) return EINA_TRUE; else if (!entry->is_dir && !entry->item) { - Evas_Object *thumb; + const Elm_Gengrid_Item_Class *ic; - thumb = ephoto_thumb_add(entry->ephoto, tb->grid, entry); - evas_object_show(thumb); + ic = &_ephoto_thumb_file_class; + if (tb->sort == EPHOTO_SORT_ALPHABETICAL_ASCENDING) + entry->item = + elm_gengrid_item_sorted_insert(tb->grid, ic, entry, + _entry_cmp_grid_alpha_asc, NULL, NULL); + else if (tb->sort == EPHOTO_SORT_ALPHABETICAL_DESCENDING) + entry->item = + elm_gengrid_item_sorted_insert(tb->grid, ic, entry, + _entry_cmp_grid_alpha_desc, NULL, NULL); + else if (tb->sort == EPHOTO_SORT_MODTIME_ASCENDING) + entry->item = + elm_gengrid_item_sorted_insert(tb->grid, ic, entry, + _entry_cmp_grid_mod_asc, NULL, NULL); + else if (tb->sort == EPHOTO_SORT_MODTIME_DESCENDING) + entry->item = + elm_gengrid_item_sorted_insert(tb->grid, ic, entry, + _entry_cmp_grid_mod_desc, NULL, NULL); + if (entry->item) + { + elm_object_item_data_set(entry->item, entry); + } + else + { + ephoto_entry_free(tb->ephoto, entry); + } } tb->animator.processed++; } @@ -1704,8 +1728,8 @@ _ephoto_main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, free(tb); } -/*Ephoto Thumb Browser Public Functions*/ +/*Ephoto Thumb Browser Public Functions*/ void ephoto_thumb_browser_dirs_only_set(Ephoto *ephoto, Eina_Bool dirs_only) { @@ -1788,10 +1812,6 @@ ephoto_thumb_browser_insert(Ephoto *ephoto, Ephoto_Entry *entry) entry->item = elm_gengrid_item_sorted_insert(tb->grid, ic, entry, _entry_cmp_grid_mod_desc, NULL, NULL); - else if (tb->sort == EPHOTO_SORT_SIMILARITY) - entry->item = - elm_gengrid_item_sorted_insert(tb->grid, ic, entry, - _entry_cmp_grid_similarity, NULL, NULL); if (entry->item) { elm_object_item_data_set(entry->item, entry); @@ -1917,8 +1937,6 @@ ephoto_thumb_browser_show_controls(Ephoto *ephoto) "view-sort-ascending", ELM_ICON_STANDARD, _sort_mod_asc, tb); elm_hoversel_item_add(hover, _("Modification Time Descending"), "view-sort-descending", ELM_ICON_STANDARD, _sort_mod_desc, tb); - elm_hoversel_item_add(hover, _("Image Similarity"), - "view-sort-ascending", ELM_ICON_STANDARD, _sort_similarity, tb); elm_object_text_set(hover, _("Sort")); ic = elm_icon_add(hover); evas_object_size_hint_min_set(ic, 20*elm_config_scale_get(),