+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef _AIR_MEDIAHUB_GRIDMGR_H__
-#define _AIR_MEDIAHUB_GRIDMGR_H__
-
-#include <stdbool.h>
-
-struct gridmgr;
-
-struct grid_class {
- const char *grid_style;
-
- char *(*text_get)(void *data, Evas_Object *obj, const char *part);
- Evas_Object *(*content_get)(void *data, Evas_Object *obj,
- const char *part);
- /* It will be added later */
-};
-
-struct gridmgr *gridmgr_create(void);
-bool gridmgr_destroy(struct gridmgr *gmgr);
-bool gridmgr_add_grid(struct gridmgr *gmgr, const char *grid_id,
- Evas_Object *grid, struct grid_class *gclass);
-bool gridmgr_update_grid(struct gridmgr *gmgr, const char *grid_id, Eina_List *item_list);
-
-#endif /* _AIR_MEDIAHUB_GRIDMGR_H__ */
+++ /dev/null
-/*
- * 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 <Elementary.h>
-#include <app_debug.h>
-
-#include "define.h"
-#include "util/gridmgr.h"
-
-struct gridmgr {
- Eina_List *list;
-};
-
-struct grid_item {
- const char *id;
- Evas_Object *grid;
- struct grid_class *gclass;
-};
-
-struct grid_item *_get_item_from_id(struct gridmgr *gmgr, const char *id)
-{
- Eina_List *l;
- struct grid_item *gitem;
-
- if (!gmgr || !id)
- return NULL;
-
- gitem = NULL;
- EINA_LIST_FOREACH(gmgr->list, l, gitem) {
- if (!strcmp(gitem->id, id))
- break;
- }
-
- return gitem;
-}
-
-Elm_Gengrid_Item_Class *_get_item_class(struct grid_class *gclass)
-{
- Elm_Gengrid_Item_Class *ic;
-
- if (!gclass)
- return NULL;
-
- ic = elm_gengrid_item_class_new();
- if (!ic) {
- _ERR("failed to create item class");
- return NULL;
- }
-
- ic->func.text_get = gclass->text_get;
- ic->func.content_get = gclass->content_get;
-
- ic->item_style = gclass->grid_style;
-
- return ic;
-}
-
-struct gridmgr *gridmgr_create(void)
-{
- struct gridmgr *gmgr;
-
- gmgr = calloc(1, sizeof(*gmgr));
- if (!gmgr) {
- _ERR("failed to create gridmgr");
- return NULL;
- }
-
- return gmgr;
-}
-
-bool gridmgr_destroy(struct gridmgr *gmgr)
-{
- struct grid_item *gitem;
-
- if (!gmgr) {
- _ERR("failed to get gridmgr");
- return false;
- }
-
- EINA_LIST_FREE(gmgr->list, gitem)
- free(gitem);
-
- free(gmgr);
- gmgr = NULL;
-
- return true;
-}
-
-bool gridmgr_add_grid(struct gridmgr *gmgr, const char *grid_id,
- Evas_Object *grid, struct grid_class *gclass)
-{
- struct grid_item *gitem;
-
- if (!gmgr) {
- _ERR("failed to get gridmgr");
- return false;
- }
-
- if (!gclass || !gclass->text_get || !gclass->content_get) {
- _ERR("failed to get grid class");
- return false;
- }
-
- gitem = calloc(1, sizeof(*gitem));
- if (!gitem) {
- _ERR("failed to create gengrid item");
- return false;
- }
-
- gitem->id = grid_id;
- gitem->grid = grid;
- gitem->gclass = gclass;
-
- gmgr->list = eina_list_append(gmgr->list, gitem);
-
- return true;
-}
-
-bool gridmgr_update_grid(struct gridmgr *gmgr, const char *grid_id,
- Eina_List *item_list)
-{
- Eina_List *l;
- Elm_Object_Item *it;
- Elm_Gengrid_Item_Class *ic;
- struct grid_item *gitem;
- void *data;
-
- if (!gmgr) {
- _ERR("failed to get gridmgr");
- return false;
- }
-
- gitem = _get_item_from_id(gmgr, grid_id);
- if (!gitem) {
- _ERR("%s doesn't exist", grid_id);
- return false;
- }
-
- elm_gengrid_clear(gitem->grid);
-
- ic = _get_item_class(gitem->gclass);
- if (!ic) {
- _ERR("failed to get item class");
- return false;
- }
-
- EINA_LIST_FOREACH(item_list, l, data) {
- it = elm_gengrid_item_append(gitem->grid, ic, data, NULL, NULL);
-
- elm_object_item_data_set(it, data);
- }
-
- elm_gengrid_item_class_free(ic);
-
- return true;
-}