2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
25 #include <media_content.h>
26 #include "ExtNameInfo.h"
27 #include "DirectoryInfo.h"
28 #include "GengridItemClass.h"
30 const char *typestr[] = {
39 void CGengridItemClass::sm_SetTypeimage(Evas_Object *img, int type)
48 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
49 FBR_IMAGE_NORMAL_VIDEO);
52 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
53 FBR_IMAGE_NORMAL_MUSIC);
56 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
57 FBR_IMAGE_NORMAL_OTHER);
61 elm_image_file_set(img, buf, NULL);
64 Evas_Object *CGengridItemClass::sm_GetIcon(Evas_Object *obj, CExtNameInfo *pInfo)
73 icon = elm_icon_add(obj);
78 elm_icon_thumb_set(icon, path, NULL);
79 elm_image_aspect_fixed_set(icon, EINA_FALSE);
84 Evas_Object *CGengridItemClass::sm_AddThumbnail(Evas_Object *obj, CExtNameInfo *pInfo)
95 path = pInfo->ThumbnailPath();
96 _DBG("path: %x", path);
98 if (!path && type == E_GRP_PHOTO) {
99 img = sm_GetIcon(obj, pInfo);
103 img = elm_image_add(obj);
106 evas_object_show(img);
109 elm_image_file_set(img, path, "NULL");
110 elm_image_aspect_fixed_set(img, EINA_FALSE);
116 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
120 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
121 FBR_IMAGE_DEFAULT_VIDEO);
124 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
125 FBR_IMAGE_DEFAULT_MUSIC);
128 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
129 FBR_IMAGE_DEFAULT_OTHER);
132 elm_image_no_scale_set(img, EINA_TRUE);
133 elm_image_aspect_fixed_set(img, EINA_TRUE);
134 elm_image_file_set(img, buf, NULL);
139 char *CGengridItemClass::sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
144 SItemInfo *itinfo = (SItemInfo *)data;
145 CExtNameInfo *pInfo = itinfo->pInfo;
148 char buf[MAX_LENGTH];
152 if (!strcmp(part, "elm.text")) {
157 else if (!strcmp(part, "elm.text1")) {
158 type = pInfo->Type();
159 if (type == E_GRP_FOLDER) {
160 CDirectoryInfo* pDirInfo = (CDirectoryInfo*)pInfo;
161 count = pDirInfo->Count();
162 snprintf(buf, sizeof(buf), "%d", count);
166 return strdup(typestr[type]);
172 Evas_Object *CGengridItemClass::sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
183 itinfo = (SItemInfo *)data;
184 pInfo = itinfo->pInfo;
186 if (!strcmp(part, "elm.swallow.icon")) {
187 img = sm_AddThumbnail(obj, pInfo);
190 else if (!strcmp(part, "elm.swallow.icon1")) {
191 type = pInfo->Type();
192 if (type == E_GRP_FOLDER || type == E_GRP_PHOTO)
195 path = pInfo->ThumbnailPath();
199 img = elm_image_add(obj);
203 sm_SetTypeimage(img, type);
204 elm_image_no_scale_set(img, EINA_TRUE);
205 evas_object_show(img);
212 void CGengridItemClass::sm_CbRemove(void *data, Evas_Object *obj)
217 bool CGengridItemClass::Create(void)
222 m_pItemClass = elm_gengrid_item_class_new();
227 m_pItemClass->item_style = FBR_STYLE_MEDIA_GRID;
228 m_pItemClass->func.text_get = sm_CbTextGet;
229 m_pItemClass->func.content_get = sm_CbContentGet;
230 m_pItemClass->func.state_get = NULL;
231 m_pItemClass->func.del = sm_CbRemove;
236 void CGengridItemClass::Destroy(void)
241 elm_gengrid_item_class_free(m_pItemClass);
245 Elm_Gengrid_Item_Class* CGengridItemClass::Handle(void)