From d9bf2659b790141abd3472e50b2b442a716e63cf Mon Sep 17 00:00:00 2001 From: Hyojung Jo Date: Mon, 20 Jul 2015 11:52:51 +0900 Subject: [PATCH] Gallery grid: Fixed text for showing duration of video Change-Id: I3660af612b48f7a5f3ba8622ba408b989b9ce0c6 Signed-off-by: Hyojung Jo --- include/define.h | 1 + res/images/ic_thumbnail_picture.png | Bin 0 -> 1811 bytes res/widgets/gengrid_gallery.edc | 2 +- src/data/media.c | 3 +++ src/grid/grid_gallery.c | 42 ++++++++++++++++++++---------------- 5 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 res/images/ic_thumbnail_picture.png diff --git a/include/define.h b/include/define.h index 4c9ebf1..cb91d3d 100644 --- a/include/define.h +++ b/include/define.h @@ -71,6 +71,7 @@ /* Image */ #define PLAY_ICON_PNG "ic_thumbnail_play.png" +#define DEFAULT_IMAGE_PNG IMGDIR"/ic_thumbnail_picture.png" /* Path */ #define PATH_PLAY_ICON_PNG IMGDIR"/ic_thumbnail_play.png" diff --git a/res/images/ic_thumbnail_picture.png b/res/images/ic_thumbnail_picture.png new file mode 100644 index 0000000000000000000000000000000000000000..04d17f64f3efe29b43bbf289eeb101c06fd0f00c GIT binary patch literal 1811 zcmbVNX;2eq7!H?Egi+( zLel58fGx&*<2LPV=G^2v`*pCto2 z4WFFDlF?-*5mKy6DZ`M=GI^G|tVGS#kdqRD1RIYaFd(=Juo?75Gtb5+PxA7JwR4+B z1}07L5^a76gHD0D}%PXmnyg6p+bdK|BT zH%wE+%YY?QzKAzIxfsVyJQ~evwNkC|R20+FKrWZ-vY$_8Cq|#{ygEOy5YcrmK{2Rt= zt<71bCWMxOm{AL+CeEWM$^|BB_hv^hufsAq$zn*t<$_`f41!`7N5mF!K?oMc zGbEyTnCZewjb>bBR3k3GI>PT1mh(m|PlO>V9L2IwRPR!Nq8P}Ll#a>}o0o6h78dBBd;fQb3Qb-u|#aWxa0s%{B|!m)z7?BmV#YrS=C z3$K3ot&&1r9{KnKJh)L!L|Ao^HH((?cE|-B-qZYR zk0#cXcwBbuHL|^%?MQmy-aD4rBl5f>C*4*DkDs+0#1~EvpU?`PJiFkt%{wA=mV#8b2S?K88ak8}EiI1i(+_wyR=1nQW7{tE*A=5FEu*;;?Kju2emHbkWGEpe zbwHMoR)*dlUfm8wHZRSyJnCLB-nB7euo1kouRJvj8FZwj-wjvJ*e!^CR8=2!Z)JJ- zmYLVmGS6IX*h7sqFYSUtXFfeQ((0A(*Z;MCeZ;4u=~0&PzybOF8%?Vjw~knDH_UAd ziSth_SXIeBW~uI||Iw$cw_)p5_DFtDqF+VrDZa|5o#~P0eR@3eV{R2>Pbz$#+WPyU z2T}dUyB80fYy`CGXI=Rw@2tTAp~CC#{ehgaQ~JG?$Lj4vJ19fy_r2`%{c{U@loO%M z<@?s{ert)>;hoIJ0V{8;S0z6%YNG`U0&ukjl{Xvl389~*XjICNyT!wIk}+fA0o@C Aod5s; literal 0 HcmV?d00001 diff --git a/res/widgets/gengrid_gallery.edc b/res/widgets/gengrid_gallery.edc index 4ab0723..d4727c4 100644 --- a/res/widgets/gengrid_gallery.edc +++ b/res/widgets/gengrid_gallery.edc @@ -17,7 +17,7 @@ group { name, "elm/gengrid/item/style.gallery/default"; data.item, "focus_highlight" "on"; - data.item, "text" "part.thumb.text"; + data.item, "texts" "part.thumb.text"; data.item, "contents" "part.thumb.icon part.thumb.play.icon"; parts { part { diff --git a/src/data/media.c b/src/data/media.c index e35e6d1..27568f9 100644 --- a/src/data/media.c +++ b/src/data/media.c @@ -225,6 +225,9 @@ int get_media_duration(app_media *am) return -1; } + if (!minfo->video) + return -1; + return minfo->video->duration; } diff --git a/src/grid/grid_gallery.c b/src/grid/grid_gallery.c index c39c69e..275e808 100644 --- a/src/grid/grid_gallery.c +++ b/src/grid/grid_gallery.c @@ -32,6 +32,8 @@ static char *_text_get(void *data, Evas_Object *obj, const char *part) { app_media *am; + int duration, h, m, s, sec; + char str[SIZE_STR]; if (!data) { _ERR("Data is NULL."); @@ -39,14 +41,29 @@ static char *_text_get(void *data, Evas_Object *obj, const char *part) } am = data; - return strdup(get_media_name(am)); + if (get_media_type(am) != MEDIA_CONTENT_TYPE_VIDEO) + return NULL; + + duration = get_media_duration(am); + + sec = duration / 1000; + h = sec / 3600; + m = (sec % 3600) / 60; + s = sec % 60; + + if (h) + snprintf(str, sizeof(str), "%d:%02d:%02d", h, m, s); + else + snprintf(str, sizeof(str), "%d:%02d", m, s); + + return strdup(str); } static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part) { app_media *am; - Evas_Object *icon, *img; - char *thumbnail; + Evas_Object *img; + char *img_path; if (!data || !obj) { _ERR("Invalid argument."); @@ -55,20 +72,9 @@ static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part) am = data; if (!strcmp(part, PART_THUMB_ICON)) { - thumbnail = get_media_thumbnail(am); - - if (!thumbnail) { - icon = elm_icon_add(obj); - if (!icon) { - _ERR("elm_icon_add failed."); - return NULL; - } - - elm_icon_thumb_set(icon, get_media_path(am), NULL); - elm_image_aspect_fixed_set(icon, EINA_FALSE); - - return icon; - } + img_path = get_media_thumbnail(am); + if (!img_path) + img_path = DEFAULT_IMAGE_PNG; img = elm_image_add(obj); if (!img) { @@ -76,7 +82,7 @@ static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part) return NULL; } - elm_image_file_set(img, thumbnail, NULL); + elm_image_file_set(img, img_path, NULL); elm_image_aspect_fixed_set(img, EINA_FALSE); evas_object_show(img); -- 2.7.4