From 51f36d538b2f61e927fecea6e8fe5bef4112bbdf Mon Sep 17 00:00:00 2001 From: titan Date: Tue, 30 Nov 2010 02:33:22 +0000 Subject: [PATCH] Revert my changes while I work on a new way of doing things. This will make a certain few people happy for the time being until the new way is revealed... then things will get interesting. SVN revision: 55077 --- src/bin/ephoto_directory_thumb.c | 2 +- src/bin/ephoto_thumb_browser.c | 107 ++++++++++++++++++++++++++----- 2 files changed, 92 insertions(+), 17 deletions(-) diff --git a/src/bin/ephoto_directory_thumb.c b/src/bin/ephoto_directory_thumb.c index 5b309f2..eeda248 100644 --- a/src/bin/ephoto_directory_thumb.c +++ b/src/bin/ephoto_directory_thumb.c @@ -105,6 +105,7 @@ _populate_main(void *data, Eio_File *handler __UNUSED__, const Eina_File_Direct_ obj = dt->objs->data; file = eina_stringshare_add(info->path); + DBG("populate thumbnail %p with path '%s'", obj, file); dt->objs = eina_list_remove_list(dt->objs, dt->objs); @@ -135,7 +136,6 @@ ephoto_directory_thumb_add(Evas_Object *parent, Ephoto_Entry *entry) } obj = ephoto_thumb_add(entry->ephoto, parent, NULL); - evas_object_size_hint_max_set(obj, 32, 32); EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); if (!dt) diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c index 74fd79a..457807a 100644 --- a/src/bin/ephoto_thumb_browser.c +++ b/src/bin/ephoto_thumb_browser.c @@ -27,7 +27,6 @@ struct _Ephoto_Thumb_Browser Elm_Toolbar_Item *zoom_out; Elm_Toolbar_Item *view_flow; Elm_Toolbar_Item *slideshow; - Elm_Toolbar_Item *parent; } action; struct { Ecore_Animator *todo_items; @@ -66,6 +65,49 @@ _ephoto_thumb_item_label_get(void *data, Evas_Object *obj __UNUSED__, const char return strdup(e->label); } +static Evas_Object * +_ephoto_thumb_dir_icon_get(void *data, Evas_Object *obj, const char *part) +{ + Ephoto_Entry *e = data; + const char *f; + int n; + + if (strncmp(part, "elm.swallow.icon.", sizeof("elm.swallow.icon.") - 1) != 0) + return NULL; + + n = atoi(part + sizeof("elm.swallow.icon.") - 1); + if (n < 1) + return NULL; + n--; + + f = eina_list_nth(e->dir_files, n); + if (f) + return ephoto_thumb_add(e->ephoto, obj, f); + + if (e->dir_files_checked) + return NULL; + + return ephoto_directory_thumb_add(obj, e); +} + +static Eina_Bool +_ephoto_thumb_dir_state_get(void *data, Evas_Object *obj __UNUSED__, const char *part) +{ + Ephoto_Entry *e = data; + int n; + + if (strcmp(part, "have_files") == 0) + return !!e->dir_files; + + if (strncmp(part, "have_file.", sizeof("have_file.") - 1) != 0) + return EINA_FALSE; + + n = atoi(part + sizeof("have_file.") - 1); + if (n < 1) + return EINA_FALSE; + return n <= (int)eina_list_count(e->dir_files); +} + static Evas_Object * _ephoto_thumb_file_icon_get(void *data, Evas_Object *obj, const char *part __UNUSED__) { @@ -84,6 +126,26 @@ _ephoto_thumb_item_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__) */ } +static const Elm_Gengrid_Item_Class _ephoto_thumb_dir_class = { + "album-preview", + { + _ephoto_thumb_item_label_get, + _ephoto_thumb_dir_icon_get, + _ephoto_thumb_dir_state_get, + _ephoto_thumb_item_del + } +}; + +static const Elm_Gengrid_Item_Class _ephoto_thumb_up_class = { + "up", + { + _ephoto_thumb_item_label_get, + NULL, + NULL, + _ephoto_thumb_item_del + } +}; + static const Elm_Gengrid_Item_Class _ephoto_thumb_file_class = { "thumb", { @@ -124,7 +186,7 @@ _entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e) if (near_node) near_item = near_node->data; - if (e->is_dir) return; + if (e->is_dir) ic = &_ephoto_thumb_dir_class; else ic = &_ephoto_thumb_file_class; if (!near_item) @@ -160,6 +222,29 @@ _entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e) } } +static void +_up_item_add_if_required(Ephoto_Thumb_Browser *tb) +{ + Ephoto_Entry *entry; + char *parent_dir; + + if ((elm_gengrid_first_item_get(tb->grid)) || + (strcmp(tb->ephoto->config->directory, "/") == 0)) + return; + + parent_dir = ecore_file_dir_get(tb->ephoto->config->directory); + if (!parent_dir) return; + + entry = ephoto_entry_new(tb->ephoto, parent_dir, PARENT_DIR); + free(parent_dir); + EINA_SAFETY_ON_NULL_RETURN(entry); + entry->is_up = EINA_TRUE; + entry->is_dir = EINA_TRUE; + entry->item = elm_gengrid_item_append + (tb->grid, &_ephoto_thumb_up_class, entry, NULL, NULL); + /* does not go into entries as it is always the first - no sort! */ +} + static Eina_Bool _todo_items_process(void *data) { @@ -170,6 +255,8 @@ _todo_items_process(void *data) if ((tb->ls) && (eina_list_count(tb->todo_items) < TODO_ITEM_MIN_BATCH)) return EINA_TRUE; + _up_item_add_if_required(tb); + tb->animator.todo_items = NULL; EINA_LIST_FREE(tb->todo_items, entry) @@ -278,18 +365,6 @@ _slideshow(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) evas_object_smart_callback_call(tb->layout, "slideshow", entry); } -static void -_parent_directory(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) -{ - Ephoto_Thumb_Browser *tb = data; - const char *parent_dir; - - elm_toolbar_item_selected_set(tb->action.parent, EINA_FALSE); - parent_dir = ecore_file_dir_get(tb->ephoto->config->directory); - if (!parent_dir) return; - ephoto_directory_set(tb->ephoto, parent_dir); -} - static void _key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) { @@ -391,6 +466,8 @@ _ephoto_thumb_populate_end(void *data, int type __UNUSED__, void *event __UNUSED return ECORE_CALLBACK_PASS_ON; } + if (!tb->animator.todo_items) _up_item_add_if_required(tb); + edje_object_signal_emit(tb->edje, "populate,stop", "ephoto"); return ECORE_CALLBACK_PASS_ON; @@ -458,8 +535,6 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent) elm_toolbar_mode_shrink_set(tb->toolbar, ELM_TOOLBAR_SHRINK_MENU); elm_toolbar_menu_parent_set(tb->toolbar, parent); - tb->action.parent = _toolbar_item_add - (tb, "stock_up", "Parent", 150, _parent_directory); tb->action.slideshow = _toolbar_item_add (tb, "media-playback-start", "Slideshow", 100, _slideshow); tb->action.zoom_in = _toolbar_item_add