Gallery grid: Fixed text for showing duration of video 15/44215/2
authorHyojung Jo <hj903.jo@samsung.com>
Mon, 20 Jul 2015 02:52:51 +0000 (11:52 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Mon, 20 Jul 2015 05:30:39 +0000 (14:30 +0900)
Change-Id: I3660af612b48f7a5f3ba8622ba408b989b9ce0c6
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/define.h
res/images/ic_thumbnail_picture.png [new file with mode: 0644]
res/widgets/gengrid_gallery.edc
src/data/media.c
src/grid/grid_gallery.c

index 4c9ebf1..cb91d3d 100644 (file)
@@ -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 (file)
index 0000000..04d17f6
Binary files /dev/null and b/res/images/ic_thumbnail_picture.png differ
index 4ab0723..d4727c4 100644 (file)
@@ -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 {
index e35e6d1..27568f9 100644 (file)
@@ -225,6 +225,9 @@ int get_media_duration(app_media *am)
                return -1;
        }
 
+       if (!minfo->video)
+               return -1;
+
        return minfo->video->duration;
 }
 
index c39c69e..275e808 100644 (file)
@@ -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);