initial upload for tizen 2.0 beta
[apps/home/gallery.git] / ug / ug-gallery-efl / src / ge-thumb.c
1 /*
2  *  ug-gallery-efl
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Sangjin Han <sjhan.han@samsung.com>,
7  *                      Jiansong Jin <jiansong.jin@samsung.com>,
8  *                      Jonghyuk Lee <jhyuk47.lee@samsung.com>,
9  *                      Chaolong Lin <chaolong.lin@samsung.com>,
10  *                      Yongjun Zhao <yj123.zhao@samsung.com>
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  *
24  */
25
26 #include "ge-debug.h"
27 #include "ge-util.h"
28 #include "ge-drm.h"
29 #include "ge-strings.h"
30 #ifdef _USE_ROTATE_BG_GE
31 #include "ge-rotate-bg.h"
32 #include "ge-exif.h"
33 #endif
34
35 #define GE_PHOTOFRAME_STYLE_VIDEO_BOOKMARK "default_layout_video_bookmark"
36 #define GE_PHOTOFRAME_STYLE_VIDEO_FAVOR "default_layout_video_favor"
37 #define GE_PHOTOFRAME_STYLE_VIDEO "default_layout_video"
38 #define GE_PHOTOFRAME_STYLE_FAVOR "default_layout_favor"
39 #define GE_PHOTOFRAME_STYLE_DEFAULT "default_layout"
40
41 #define GE_CLASS_GENGRID "gengrid"
42 #define GE_GRP_PHOTOFRAME "photoframe"
43 #define GE_GRID_TEXT "elm.text"
44
45 Evas_Object *_ge_thumb_show_part_icon_image(Evas_Object *obj, char *path,
46                                             unsigned int orient,
47                                             bool is_expired_drm, int item_size)
48 {
49         GE_CHECK_NULL(obj);
50
51         Evas_Object *layout = elm_layout_add(obj);
52         GE_CHECK_NULL(layout);
53
54 #ifdef _USE_ROTATE_BG_GE
55         Evas_Object *bg = _ge_rotate_bg_add(layout);
56 #else
57         Evas_Object *bg = elm_bg_add(layout);
58 #endif
59         if (bg == NULL) {
60                 evas_object_del(layout);
61                 return NULL;
62         }
63
64 #ifdef _USE_ROTATE_BG_GE
65         _ge_rotate_bg_set_file(bg, path, item_size, item_size);
66         _ge_rotate_bg_rotate_image(bg, orient);
67 #else
68         elm_bg_file_set(bg, path, NULL);
69         elm_bg_load_size_set(bg, item_size, item_size);
70         evas_object_size_hint_max_set(bg, item_size, item_size);
71         evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
72         evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
73         evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
74 #endif
75
76         // TODO: Need to check the expired drm icon file...
77         /* Expired drm icon */
78         if (is_expired_drm) {
79                 elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME,
80                                      GE_PHOTOFRAME_STYLE_FAVOR);
81                 elm_object_part_content_set(layout, "elm.swallow.icon", bg);
82
83                 Evas_Object *icon = elm_icon_add(layout);
84                 elm_icon_file_set(icon, GE_LOCK_ICON, NULL);
85                 evas_object_show(icon);
86                 elm_object_part_content_set(layout, "elm.swallow.favoricon",
87                                             icon);
88         } else {
89                 elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME,
90                                      GE_PHOTOFRAME_STYLE_DEFAULT);
91                 elm_object_part_content_set(layout, "elm.swallow.icon", bg);
92         }
93
94         evas_object_show(layout);
95         return layout;
96 }
97
98 Evas_Object *_ge_thumb_show_part_icon_video(Evas_Object *obj, char *path,
99                                             unsigned int v_dur, int bk_len,
100                                             bool is_expired_drm,
101                                             int item_size)
102 {
103         GE_CHECK_NULL(obj);
104
105         Evas_Object *layout = elm_layout_add(obj);
106         GE_CHECK_NULL(layout);
107
108 #ifdef _USE_ROTATE_BG_GE
109         Evas_Object *bg = _ge_rotate_bg_add(layout);
110 #else
111         Evas_Object *bg = elm_bg_add(layout);
112 #endif
113         if (bg == NULL) {
114                 evas_object_del(layout);
115                 return NULL;
116         }
117
118 #ifdef _USE_ROTATE_BG_GE
119         _ge_rotate_bg_set_file(bg, path, item_size, item_size);
120         _ge_rotate_bg_rotate_image(bg, GE_ORIENTATION_ROT_0);
121 #else
122         elm_bg_file_set(bg, path, NULL);
123         elm_bg_load_size_set(bg, item_size, item_size);
124         evas_object_size_hint_max_set(bg, item_size, item_size);
125         evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
126         evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
127         evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
128 #endif
129
130         if (bk_len)
131                 elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME,
132                                      GE_PHOTOFRAME_STYLE_VIDEO_BOOKMARK);
133         else if (is_expired_drm)
134                 elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME,
135                                      GE_PHOTOFRAME_STYLE_VIDEO_FAVOR);
136         else
137                 elm_layout_theme_set(layout, GE_CLASS_GENGRID, GE_GRP_PHOTOFRAME,
138                                      GE_PHOTOFRAME_STYLE_VIDEO);
139         elm_object_part_content_set(layout, "elm.swallow.icon", bg);
140
141         // TODO: Need to check the expired drm icon file...
142         /* Expired drm icon */
143         if (is_expired_drm) {
144                 Evas_Object *icon = elm_icon_add(layout);
145                 elm_icon_file_set(icon, GE_LOCK_ICON, NULL);
146                 evas_object_show(icon);
147                 elm_object_part_content_set(layout, "elm.swallow.favoricon",
148                                             icon);
149         /* Set favourites icon */
150         }
151
152         if (bk_len) {
153                 Evas_Object *icon = elm_icon_add(layout);
154                 elm_icon_file_set(icon, GE_THUMB_BOOKMARK, NULL);
155                 evas_object_show(icon);
156                 elm_object_part_content_set(layout, "elm.swallow.bookmarkicon",
157                                             icon);
158         }
159
160         char *dur_str = _ge_get_duration_string(v_dur);
161         GE_CHECK_NULL(dur_str);
162         elm_object_part_text_set(layout, GE_GRID_TEXT, dur_str);
163         free(dur_str);
164
165         evas_object_show(layout);
166         return layout;
167 }
168