From f403c0d731ad82eedf8d65967af8061effdb1643 Mon Sep 17 00:00:00 2001 From: Stephen Houston Date: Thu, 30 Jun 2011 16:04:18 +0000 Subject: [PATCH] Add edje viewing capabilities. SVN revision: 60875 --- src/bin/ephoto.h | 3 ++- src/bin/ephoto_main.c | 43 ++++++++++++++++++++++++++++----- src/bin/ephoto_single_browser.c | 27 +++++++++++++++++---- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h index ac036dc..bd0662e 100644 --- a/src/bin/ephoto.h +++ b/src/bin/ephoto.h @@ -185,7 +185,8 @@ _ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info) (strcasecmp(ext, "png") == 0) || (strcasecmp(ext, "gif") == 0) || (strcasecmp(ext, "tif") == 0) || - (strcasecmp(ext, "svg") == 0)) + (strcasecmp(ext, "svg") == 0) || + (strcasecmp(ext, "edj") == 0)) return EINA_TRUE; } diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c index 2fa0068..6085935 100644 --- a/src/bin/ephoto_main.c +++ b/src/bin/ephoto_main.c @@ -401,8 +401,11 @@ _thumb_gen_size_changed_timer_cb(void *data) { Ethumb_Thumb_Format format; format = (long)evas_object_data_get(o, "ephoto_format"); - ethumb_client_format_set(client, format); - elm_thumb_reload(o); + if (format) + { + ethumb_client_format_set(client, format); + elm_thumb_reload(o); + } } end: @@ -441,10 +444,24 @@ Evas_Object * ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path) { Evas_Object *o; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - o = elm_thumb_add(parent); + if (path) + { + const char *ext = strrchr(path, '.'); + if (ext) + { + ext++; + if ((strcasecmp(ext, "edj") == 0)) + o = elm_icon_add(parent); + else + o = elm_thumb_add(parent); + } + else + o = elm_thumb_add(parent); + } + else + o = elm_thumb_add(parent); if (!o) return NULL; if (path) ephoto_thumb_path_set(o, path); @@ -458,6 +475,7 @@ void ephoto_thumb_path_set(Evas_Object *o, const char *path) { Ethumb_Thumb_Format format = ETHUMB_THUMB_FDO; + const char *group = NULL; const char *ext = strrchr(path, '.'); if (ext) { @@ -465,11 +483,24 @@ ephoto_thumb_path_set(Evas_Object *o, const char *path) if ((strcasecmp(ext, "jpg") == 0) || (strcasecmp(ext, "jpeg") == 0)) format = ETHUMB_THUMB_JPEG; /* faster! */ + else if ((strcasecmp(ext, "edj") == 0)) + { + if (edje_file_group_exists(path, "e,desktop,background")) + group = "e,desktop,background"; + else + { + Eina_List *g = edje_file_collection_list(path); + group = eina_list_data_get(g); + edje_file_collection_list_free(g); + } + elm_icon_file_set(o, path, group); + evas_object_data_set(o, "ephoto_format", NULL); + return; + } } - ethumb_client_format_set(elm_thumb_ethumb_client_get(), format); evas_object_data_set(o, "ephoto_format", (void*)(long)format); - elm_thumb_file_set(o, path, NULL); + elm_thumb_file_set(o, path, group); } Ephoto_Entry * diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c index f2fbb6c..1f9ea6e 100644 --- a/src/bin/ephoto_single_browser.c +++ b/src/bin/ephoto_single_browser.c @@ -92,13 +92,30 @@ _viewer_add(Evas_Object *parent, const char *path) else { Evas_Coord w, h; + const char *group = NULL; + const char *ext = strrchr(path, '.'); + if (ext) + { + ext++; + if ((strcasecmp(ext, "edj") == 0)) + { + if (edje_file_group_exists(path, "e,desktop,background")) + group = "e,desktop,background"; + else + { + Eina_List *g = edje_file_collection_list(path); + group = eina_list_data_get(g); + edje_file_collection_list_free(g); + } + } + } obj = v->scroller = elm_scroller_add(parent); EINA_SAFETY_ON_NULL_GOTO(obj, error); - v->image = evas_object_image_filled_add(evas_object_evas_get(parent)); - evas_object_image_file_set(v->image, path, NULL); + v->image = elm_image_add(parent); + elm_image_file_set(v->image, path, group); err = evas_object_image_load_error_get(v->image); if (err != EVAS_LOAD_ERROR_NONE) goto load_error; - evas_object_image_size_get(v->image, &w, &h); + elm_image_object_size_get(v->image, &w, &h); evas_object_size_hint_align_set(v->image, 0.5, 0.5); evas_object_size_hint_min_set(v->image, w, h); evas_object_size_hint_max_set(v->image, w, h); @@ -128,7 +145,7 @@ _viewer_zoom_apply(Ephoto_Viewer *v, double zoom) else { Evas_Coord w, h; - evas_object_image_size_get(v->image, &w, &h); + elm_image_object_size_get(v->image, &w, &h); w *= zoom; h *= zoom; evas_object_size_hint_min_set(v->image, w, h); @@ -150,7 +167,7 @@ _viewer_zoom_fit_apply(Ephoto_Viewer *v) else { evas_object_geometry_get(v->scroller, NULL, NULL, &cw, &ch); - evas_object_image_size_get(v->image, &iw, &ih); + elm_image_object_size_get(v->image, &iw, &ih); } if ((cw <= 0) || (ch <= 0)) return; /* object still not resized */