/* * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include "define.h" #include "grid.h" #include "datamgr.h" #define STR_TV "TV" #define STYLE_TV "style.tv" #define ITEM_TV_X (378 + 26) #define ITEM_TV_Y (294 + 26) static char *_text_get(void *data, Evas_Object *obj, const char *part) { struct datamgr *dmgr; char *name; if (!data) { _ERR("Data is NULL."); return NULL; } dmgr = get_channel_datamgr(); if (!dmgr || !dmgr->get_data) return NULL; name = dmgr->get_data(data, DATA_NAME); if (!name) return NULL; return name; } static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part) { struct datamgr *dmgr; Evas_Object *img; char *thumbnail; if (!data || !obj) { _ERR("Invalid argument."); return NULL; } dmgr = get_channel_datamgr(); if (!dmgr || !dmgr->get_data) return NULL; thumbnail = dmgr->get_data(data, DATA_THUMBNAIL); img = elm_image_add(obj); if (!img) { _ERR("elm_image_add failed."); return NULL; } elm_image_aspect_fixed_set(img, EINA_FALSE); evas_object_show(img); if (!strcmp(part, PART_THUMB_ICON) && thumbnail) elm_image_file_set(img, thumbnail, NULL); else if (!strcmp(part, PART_THUMB_DEFAULT_TV_ICON) && !thumbnail) elm_image_file_set(img, DEFAULT_TV_PNG, NULL); else img = NULL; return img; } static struct grid_class _gclass = { .item_style = STYLE_TV, .text_get = _text_get, .content_get = _content_get, .state_get = NULL, .del = NULL, }; static Eina_List *_create_item_list(void) { struct datamgr *dmgr; dmgr = get_channel_datamgr(); if (!dmgr || !dmgr->get_favorites) return NULL; return dmgr->get_favorites(ITEM_CHANNEL); } static void _destroy_item_list(Eina_List *list) { struct datamgr *dmgr; if (!list) return; dmgr = get_channel_datamgr(); if (!dmgr || !dmgr->free_favorites) return; dmgr->free_favorites(list); } static void _item_selected(Elm_Object_Item *it) { struct datamgr *dmgr; if (!it) { _ERR("Invalid argument."); return; } dmgr = get_channel_datamgr(); if (!dmgr || !dmgr->action) return; if (!dmgr->action(it)) _ERR("The item action failed."); } static struct grid_data _gdata = { .id = STR_TV, .item_size_x = ITEM_TV_X, .item_size_y = ITEM_TV_Y, .gclass = &_gclass, .create_item_list = _create_item_list, .destroy_item_list = _destroy_item_list, .item_selected = _item_selected, }; struct grid_data *get_tv_grid_data(void) { return &_gdata; }