--- /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_SETTINGS_LISTMGR_H__
+#define __AIR_SETTINGS_LISTMGR_H__
+
+struct listmgr;
+
+struct listmgr *listmgr_create(Evas_Object *parent);
+bool listmgr_destroy(struct listmgr *listmgr);
+
+bool listmgr_add_list(struct listmgr *listmgr, const char *list_id,
+ struct data_class *dclass, struct grid_class *gclass);
+bool listmgr_remove_list(struct listmgr *listmgr, const char *list_id);
+
+bool listmgr_update_list(struct listmgr *listmgr, const char *list_id,
+ void (*update_done_cb)(void *data), void *user_data);
+bool listmgr_show_list(struct listmgr *listmgr, const char *list_id,
+ const char *part);
+bool listmgr_hide_list(struct listmgr *listmgr, const char *list_id,
+ const char *part);
+
+#endif /* __AIR_SETTINGS_LISTMGR_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 <gridmgr.h>
+#include <app_debug.h>
+
+#include "datamgr.h"
+#include "utils.h"
+#include "define.h"
+
+struct listmgr {
+ Evas_Object *parent;
+ Eina_List *list;
+};
+
+struct list_item {
+ char *list_id;
+ struct datamgr *dmgr;
+ struct gridmgr *gmgr;
+ Evas_Object *grid;
+};
+
+struct listmgr *listmgr_create(Evas_Object *parent)
+{
+ struct listmgr *listmgr;
+
+ if (!parent) {
+ _ERR("Invalid argument.");
+ return NULL;
+ }
+
+ listmgr = calloc(1, sizeof(*listmgr));
+ if (!listmgr) {
+ _ERR("Calloc failed.");
+ return NULL;
+ }
+
+ listmgr->parent = parent;
+
+ return listmgr;
+}
+
+bool listmgr_destroy(struct listmgr *listmgr)
+{
+ struct list_item *litem;
+
+ if (!listmgr) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ EINA_LIST_FREE(listmgr->list, litem) {
+ gridmgr_destroy(litem->gmgr);
+ datamgr_destroy(litem->dmgr);
+ free(litem->list_id);
+ free(litem);
+ }
+
+ free(listmgr);
+ listmgr = NULL;
+
+ return true;
+}
+
+static struct list_item *_get_list_item(struct listmgr *listmgr,
+ const char *list_id)
+{
+ Eina_List *l;
+ struct list_item *litem;
+
+ EINA_LIST_FOREACH(listmgr->list, l, litem) {
+ if (!litem)
+ continue;
+
+ if (!strcmp(litem->list_id, list_id))
+ return litem;
+ }
+
+ return NULL;
+}
+
+static bool _add_grid(struct list_item *litem, Evas_Object *parent,
+ struct grid_class *gclass)
+{
+ struct gridmgr *gmgr;
+ Evas_Object *grid;
+
+ gmgr = gridmgr_create();
+ if (!gmgr) {
+ _ERR("Gridmgr create failed.");
+ return false;
+ }
+
+ grid = utils_add_gengrid(parent, EINA_TRUE,
+ SIZE_LIST_ITEM_X, SIZE_LIST_ITEM_Y);
+ if (!grid) {
+ _ERR("Add gengrid failed.");
+ gridmgr_destroy(gmgr);
+ return false;
+ }
+
+ if (!gridmgr_add_grid(gmgr, litem->list_id, grid, gclass)) {
+ _ERR("Gridmgr add grid failed.");
+ evas_object_del(grid);
+ gridmgr_destroy(gmgr);
+ return false;
+ }
+
+ litem->gmgr = gmgr;
+ litem->grid = grid;
+
+ return true;
+}
+
+bool listmgr_add_list(struct listmgr *listmgr, const char *list_id,
+ struct data_class *dclass, struct grid_class *gclass)
+{
+ struct list_item *litem;
+
+ if (!listmgr || !list_id || !dclass || !gclass) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ litem = _get_list_item(listmgr, list_id);
+ if (litem) {
+ _ERR("LIST ID [%s] already exists.", list_id);
+ return false;
+ }
+
+ litem = calloc(1, sizeof(*litem));
+ if (!litem) {
+ _ERR("Calloc failed.");
+ return false;
+ }
+
+ litem->list_id = strdup(list_id);
+
+ litem->dmgr = datamgr_create(dclass);
+ if (!litem->dmgr) {
+ _ERR("Datamgr create failed.");
+ free(litem);
+ return false;
+ }
+
+ if (!_add_grid(litem, listmgr->parent, gclass)) {
+ _ERR("Add grid failed.");
+ datamgr_destroy(litem->dmgr);
+ free(litem);
+ return false;
+ }
+
+ listmgr->list = eina_list_append(listmgr->list, litem);
+
+ return true;
+}
+
+bool listmgr_remove_list(struct listmgr *listmgr, const char *list_id)
+{
+ struct list_item *litem;
+
+ if (!listmgr || !list_id) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ litem = _get_list_item(listmgr, list_id);
+ if (!litem) {
+ _ERR("List %s does not exist.", list_id);
+ return false;
+ }
+
+ gridmgr_destroy(litem->gmgr);
+ datamgr_destroy(litem->dmgr);
+
+ free(litem->list_id);
+
+ listmgr->list = eina_list_remove(listmgr->list, litem);
+
+ return true;
+}
+
+bool listmgr_update_list(struct listmgr *listmgr, const char *list_id,
+ void (*update_done_cb)(void *data), void *user_data)
+{
+ struct list_item *litem;
+
+ if (!listmgr || !list_id || !update_done_cb) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ litem = _get_list_item(listmgr, list_id);
+ if (!litem) {
+ _ERR("List %s does not exist.", list_id);
+ return false;
+ }
+
+ if (!datamgr_update(litem->dmgr, update_done_cb, user_data)) {
+ _ERR("Datamgr update failed.");
+ return false;
+ }
+
+ return true;
+}
+
+bool listmgr_show_list(struct listmgr *listmgr, const char *list_id,
+ const char *part)
+{
+ struct list_item *litem;
+
+ if (!listmgr || !list_id || !part) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ litem = _get_list_item(listmgr, list_id);
+ if (!litem) {
+ _ERR("List %s does not exist.", list_id);
+ return false;
+ }
+
+ if (!gridmgr_append_list(litem->gmgr, list_id, litem->dmgr->list)) {
+ _ERR("Gridmgr append list failed.");
+ return false;
+ }
+
+ elm_object_part_content_set(listmgr->parent, part, litem->grid);
+ evas_object_show(litem->grid);
+
+ return true;
+}
+
+bool listmgr_hide_list(struct listmgr *listmgr, const char *list_id,
+ const char *part)
+{
+ struct list_item *litem;
+
+ if (!listmgr || !list_id || !part) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ litem = _get_list_item(listmgr, list_id);
+ if (!litem) {
+ _ERR("List %s does not exist.", list_id);
+ return false;
+ }
+
+ elm_object_part_content_unset(listmgr->parent, part);
+ evas_object_hide(litem->grid);
+
+ return true;
+}
return ctxpopup;
}
+
+
+Evas_Object *utils_add_gengrid(Evas_Object *parent, Eina_Bool horizontal,
+ int width, int height)
+{
+ Evas_Object *grid;
+
+ if (!parent) {
+ _ERR("Invalid argument.");
+ return NULL;
+ }
+
+ grid = elm_gengrid_add(parent);
+ if (!grid) {
+ _ERR("elm_gengrid_add failed.");
+ return NULL;
+ }
+
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ elm_gengrid_multi_select_set(grid, EINA_FALSE);
+ elm_gengrid_horizontal_set(grid, horizontal);
+ elm_gengrid_align_set(grid, 0.0, 0.0);
+ elm_gengrid_select_mode_set(grid, ELM_OBJECT_SELECT_MODE_ALWAYS);
+ elm_gengrid_item_size_set(grid,
+ elm_config_scale_get() * width,
+ elm_config_scale_get() * height);
+ elm_scroller_policy_set(grid, ELM_SCROLLER_POLICY_OFF,
+ ELM_SCROLLER_POLICY_OFF);
+
+ return grid;
+}