From 6926304983f4c7e7c898b2ba29cbe3d28b087f25 Mon Sep 17 00:00:00 2001 From: titan Date: Fri, 2 Jul 2010 21:35:51 +0000 Subject: [PATCH] Use elm_layout for the images. Use a hash to keep a match of files and their corresponding thumb_path. SVN revision: 50005 --- data/themes/default/ephoto.edc | 40 +++------------------- src/bin/ephoto.h | 3 +- src/bin/ephoto_main.c | 15 ++++++++- src/bin/ephoto_thumb_browser.c | 61 ++++++++++++---------------------- 4 files changed, 42 insertions(+), 77 deletions(-) diff --git a/data/themes/default/ephoto.edc b/data/themes/default/ephoto.edc index 96294e7..a437271 100644 --- a/data/themes/default/ephoto.edc +++ b/data/themes/default/ephoto.edc @@ -11,26 +11,9 @@ collections } group { - name: "/ephoto/thumb/shadow"; - min: 198 136; + name: "/ephoto/thumb"; parts { - part - { - name: "ephoto.swallow.content"; - type: SWALLOW; - mouse_events: 1; - description - { - state: "default" 0.0; - min: 1 1; - max: 176 117; - visible: 1; - rel1.relative: 0.0 0.0; - rel2.relative: 1.0 1.0; - color: 255 255 255 255; - } - } part { name: "background"; @@ -39,24 +22,11 @@ collections description { state: "default" 0.0; - min: 198 136; - rel1.to: "ephoto.swallow.content"; - rel1.offset: 4 2; - rel2.to: "ephoto.swallow.content"; - rel2.offset: -5 3; color: 255 255 255 255; image.normal: "thumb_shadow.png"; image.border: 12 12 7 13; } } - } - } - group - { - name: "/ephoto/thumb/image"; - min: 176 117; - parts - { part { name: "clipper"; @@ -66,8 +36,10 @@ collections { state: "default" 0.0; visible: 1; - min: 1 1; - max: 176 117; + rel1.to: "background"; + rel1.offset: 12 7; + rel2.to: "background"; + rel2.offset: -13 -14; color: 255 255 255 255; } } @@ -81,8 +53,6 @@ collections { state: "default" 0.0; visible: 1; - min: 1 1; - max: 176 117; rel1.to: "clipper"; rel1.relative: 0.0 0.0; rel2.to: "clipper"; diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index ec33be2..9e5b71e 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -51,7 +51,8 @@ struct _Ephoto Evas_Object *thumb_browser; Evas_Object *thumb_slider; Evas_Object *toolbar; - Eina_List *images; + Eina_Hash *thumbs_images; + Eina_List *images; }; typedef struct _Ephoto Ephoto; extern Ephoto *em; diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index 960ac42..e072dd5 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -5,11 +5,13 @@ Ephoto *em; /*Inline Callbacks*/ static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info); +static void _ephoto_free_hash(void *data); /*Create the main ephoto window*/ void ephoto_create_main_window(void) { em = calloc(1, sizeof(Ephoto)); + em->thumbs_images = eina_hash_string_superfast_new(_ephoto_free_hash); /*Setup the main window*/ em->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC); @@ -46,9 +48,20 @@ static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event evas_object_del(em->box); evas_object_del(em->bg); evas_object_del(em->win); - if (em->images); + if (em->thumbs_images) + eina_hash_free(em->thumbs_images); + if (em->images) eina_list_free(em->images); free(em); elm_exit(); } +/*Free the eina hash*/ +static void _ephoto_free_hash(void *data) +{ + char *item; + + item = data; + free(item); +} + diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c index 288a54d..dc31624 100644 --- a/src/bin/ephoto_thumb_browser.c +++ b/src/bin/ephoto_thumb_browser.c @@ -240,17 +240,10 @@ _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id, const char *thumb_path, const char *thumb_key, Eina_Bool success) { - Evas_Object *o; - - o = ephoto_thumb_add(); - evas_object_image_size_set(o, 176, 117); - ephoto_thumb_fill_inside_set(o, 0); - ephoto_thumb_file_set(o, thumb_path, 176, 117); - evas_object_data_set(o, "file", strdup(file)); - if (success) { - elm_gengrid_item_append(em->thumb_browser, &eg, o, NULL, NULL); + eina_hash_add(em->thumbs_images, strdup(file), strdup(thumb_path)); + elm_gengrid_item_append(em->thumb_browser, &eg, file, NULL, NULL); } } @@ -258,12 +251,11 @@ _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id, static char * _ephoto_get_label(const void *data, Evas_Object *obj, const char *part) { - Evas_Object *o; - char *file, *bname; + char *file; + const char *bname; - o = (Evas_Object *)data; + file = (char *)data; - file = evas_object_data_get(o, "file"); bname = basename(file); return strdup(bname); @@ -273,37 +265,26 @@ _ephoto_get_label(const void *data, Evas_Object *obj, const char *part) static Evas_Object * _ephoto_get_icon(const void *data, Evas_Object *obj, const char *part) { - Evas_Object *edje, *thumb, *o; - - o = (Evas_Object *)data; + char *file, *path; + Evas_Object *thumb, *o; + file = (char *)data; + path = (char *)eina_hash_find(em->thumbs_images, file); + if (!strcmp(part, "elm.swallow.icon")) { - thumb = edje_object_add(evas_object_evas_get(em->thumb_browser)); - edje_object_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", - "/ephoto/thumb/shadow"); + thumb = elm_layout_add(em->win); + elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", + "/ephoto/thumb"); + evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(thumb); - evas_object_resize(thumb, 198, 136); - evas_object_size_hint_aspect_set(thumb, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - evas_object_size_hint_align_set(thumb, 0.5, 0.5); - evas_object_size_hint_fill_set(thumb, 1.0, 1.0); - evas_object_size_hint_min_set(thumb, 198, 136); - evas_object_size_hint_max_set(thumb, 198, 136); - - edje = edje_object_add(evas_object_evas_get(em->thumb_browser)); - edje_object_file_set(edje, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", - "/ephoto/thumb/image"); - evas_object_show(edje); - - edje_object_part_swallow(edje, "ephoto.swallow.content", o); - edje_object_part_swallow(thumb, "ephoto.swallow.content", edje); - - evas_object_resize(o, 176, 117); - evas_object_size_hint_min_set(o, 176, 117); - evas_object_size_hint_max_set(o, 176, 117); - evas_object_resize(edje, 176, 117); - evas_object_size_hint_min_set(edje, 176, 117); - evas_object_size_hint_max_set(edje, 176, 117); + + o = ephoto_thumb_add(); + evas_object_image_size_set(o, 176, 117); + ephoto_thumb_fill_inside_set(o, 0); + ephoto_thumb_file_set(o, path, 176, 117); + + elm_layout_content_set(thumb, "ephoto.swallow.content", o); return thumb; }