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.
20 #include <AppCommon.h>
24 #include "DirectoryInfo.h"
25 #include "GengridItemClass.h"
27 const char *typestr[] = {
36 void CGengridItemClass::sm_SetTypeimage(Evas_Object *img, int type)
45 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
46 FBR_IMAGE_NORMAL_VIDEO);
49 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
50 FBR_IMAGE_NORMAL_MUSIC);
53 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
54 FBR_IMAGE_NORMAL_OTHER);
58 elm_image_file_set(img, buf, NULL);
61 Evas_Object *CGengridItemClass::sm_GetIcon(Evas_Object *obj, CExtNameInfo *pInfo)
70 icon = elm_icon_add(obj);
75 elm_icon_thumb_set(icon, path, NULL);
76 elm_image_aspect_fixed_set(icon, EINA_FALSE);
81 Evas_Object *CGengridItemClass::sm_AddThumbnail(Evas_Object *obj, CExtNameInfo *pInfo)
92 path = pInfo->ThumbnailPath();
93 _DBG("path: %x", path);
95 if (!path && type == E_GRP_PHOTO) {
96 img = sm_GetIcon(obj, pInfo);
100 img = elm_image_add(obj);
103 evas_object_show(img);
106 elm_image_file_set(img, path, "NULL");
107 elm_image_aspect_fixed_set(img, EINA_FALSE);
113 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
117 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
118 FBR_IMAGE_DEFAULT_VIDEO);
121 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
122 FBR_IMAGE_DEFAULT_MUSIC);
125 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
126 FBR_IMAGE_DEFAULT_OTHER);
129 elm_image_no_scale_set(img, EINA_TRUE);
130 elm_image_aspect_fixed_set(img, EINA_TRUE);
131 elm_image_file_set(img, buf, NULL);
136 char *CGengridItemClass::sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
141 SItemInfo *itinfo = (SItemInfo *)data;
142 CExtNameInfo *pInfo = itinfo->pInfo;
145 char buf[MAX_LENGTH];
149 if (!strcmp(part, "elm.text")) {
154 else if (!strcmp(part, "elm.text1")) {
155 type = pInfo->Type();
156 if (type == E_GRP_FOLDER) {
157 CDirectoryInfo* pDirInfo = (CDirectoryInfo*)pInfo;
158 count = pDirInfo->Count();
159 snprintf(buf, sizeof(buf), "%d", count);
163 return strdup(typestr[type]);
169 Evas_Object *CGengridItemClass::sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
180 itinfo = (SItemInfo *)data;
181 pInfo = itinfo->pInfo;
183 if (!strcmp(part, "elm.swallow.icon")) {
184 img = sm_AddThumbnail(obj, pInfo);
187 else if (!strcmp(part, "elm.swallow.icon1")) {
188 type = pInfo->Type();
189 if (type == E_GRP_FOLDER || type == E_GRP_PHOTO)
192 path = pInfo->ThumbnailPath();
196 img = elm_image_add(obj);
200 sm_SetTypeimage(img, type);
201 elm_image_no_scale_set(img, EINA_TRUE);
202 evas_object_show(img);
209 void CGengridItemClass::sm_CbRemove(void *data, Evas_Object *obj)
214 bool CGengridItemClass::Create(void)
219 m_pItemClass = elm_gengrid_item_class_new();
224 m_pItemClass->item_style = FBR_STYLE_MEDIA_GRID;
225 m_pItemClass->func.text_get = sm_CbTextGet;
226 m_pItemClass->func.content_get = sm_CbContentGet;
227 m_pItemClass->func.state_get = NULL;
228 m_pItemClass->func.del = sm_CbRemove;
233 void CGengridItemClass::Destroy(void)
238 elm_gengrid_item_class_free(m_pItemClass);
242 Elm_Gengrid_Item_Class* CGengridItemClass::Handle(void)