--- /dev/null
+/*
+ * Copyright (c) 2014 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 <layoutmgr.h>
+#include <inputmgr.h>
+#include <viewmgr.h>
+#include <app_debug.h>
+
+#include "define.h"
+#include "util.h"
+#include "tv.h"
+#include "view_channelinfo.h"
+
+#define DIVIDER_WIDTH 536
+#define DIVIDER_HEIGHT 1
+#define DIVIDER_COLOR_R 0
+#define DIVIDER_COLOR_G 0
+#define DIVIDER_COLOR_B 0
+#define DIVIDER_COLOR_A (255 * 0.1)
+
+struct _priv {
+ Evas_Object *base;
+ Evas_Object *scroll;
+ Evas_Object *box;
+
+ layoutmgr *lmgr;
+ Eina_List *channel_list;
+};
+
+static void _load_channel_list(struct _priv *priv, Eina_List *channel_list)
+{
+ Evas_Object *ly, *divider;
+ Evas *e;
+ Eina_List *l;
+ const struct tv_channel_info *channel_info;
+ int r;
+ int current_service;
+
+ r = tv_get_current_service_id(¤t_service);
+ if (r < 0)
+ current_service = -1;
+
+ e = evas_object_evas_get(priv->base);
+
+ divider = evas_object_rectangle_add(e);
+ evas_object_color_set(divider, DIVIDER_COLOR_R,
+ DIVIDER_COLOR_G, DIVIDER_COLOR_B, DIVIDER_COLOR_A);
+ evas_object_size_hint_min_set(divider,
+ DIVIDER_WIDTH, DIVIDER_HEIGHT);
+ evas_object_show(divider);
+
+ elm_box_clear(priv->box);
+
+ EINA_LIST_FOREACH(channel_list, l, channel_info) {
+ if (!channel_info->remembered)
+ continue;
+
+ ly = util_add_layout(priv->box, GRP_CHANNELINFO);
+ if (!ly)
+ continue;
+ elm_object_focus_allow_set(ly, EINA_TRUE);
+ draw_channel_info(ly, channel_info);
+
+ elm_box_pack_end(priv->box, ly);
+
+ if (eina_list_next(l))
+ elm_box_pack_end(priv->box, divider);
+ }
+}
+
+static void _update_channel_list(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("failed to get priv");
+ return;
+ }
+
+ if (priv->channel_list)
+ tv_channel_del_list(priv->channel_list);
+
+ priv->channel_list = tv_channel_get_list();
+ if (!priv->channel_list) {
+ _ERR("failed to get channel list");
+ return;
+ }
+
+ _load_channel_list(priv, priv->channel_list);
+}
+
+static bool _create(layoutmgr *lmgr, void *data)
+{
+ struct _priv *priv;
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ _ERR("failed to allocate priv");
+ return false;
+ }
+
+ priv->base = layoutmgr_get_base(lmgr);
+
+ priv->scroll = elm_scroller_add(priv->base);
+ if (!priv->scroll) {
+ _ERR("failed to create scroll");
+ goto error;
+ }
+ evas_object_size_hint_weight_set(priv->scroll,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ priv->box = util_add_box(priv->scroll, false);
+ if (!priv->box) {
+ _ERR("failed to create box");
+ goto error;
+ }
+ elm_box_align_set(priv->box, 0.0, 0.5);
+ elm_box_padding_set(priv->box, 0, DIVIDER_HEIGHT);
+ evas_object_color_set(priv->box, DIVIDER_COLOR_R,
+ DIVIDER_COLOR_G, DIVIDER_COLOR_B, DIVIDER_COLOR_A);
+
+ priv->lmgr = lmgr;
+
+ layoutmgr_set_layout_data(lmgr, LAYOUT_CHANNELINFO_SEARCH, priv);
+
+ return true;
+
+error:
+ evas_object_del(priv->scroll);
+ evas_object_del(priv->box);
+ free(priv);
+
+ return false;
+}
+
+static void _destroy(void *layout_data)
+{
+ struct _priv *priv;
+
+ if (!layout_data)
+ return;
+
+ priv = layout_data;
+
+ if (priv->channel_list)
+ tv_channel_del_list(priv->channel_list);
+
+ evas_object_del(priv->scroll);
+ free(priv);
+}
+
+static void _show(void *layout_data)
+{
+ struct _priv *priv;
+
+ if (!layout_data)
+ return;
+
+ priv = layout_data;
+
+ _update_channel_list(priv);
+
+ elm_object_content_set(priv->base, priv->scroll);
+ evas_object_show(priv->scroll);
+}
+
+static void _hide(void *layout_data)
+{
+ struct _priv *priv;
+
+ if (!layout_data)
+ return;
+
+ priv = layout_data;
+
+ elm_object_content_unset(priv->base);
+ evas_object_hide(priv->scroll);
+}
+
+static void _update(void *layout_data, int update_type, void *data)
+{
+}
+
+static layout_class lclass = {
+ .layout_id = LAYOUT_CHANNELINFO_SEARCH,
+ .create = _create,
+ .show = _show,
+ .hide = _hide,
+ .destroy = _destroy,
+ .update = _update,
+};
+
+layout_class *layout_channelinfo_search_get_lclass(void)
+{
+ return &lclass;
+}
#include "tv.h"
#include "layout_channelinfo.h"
#include "layout_channelinfo_list.h"
+#include "layout_channelinfo_search.h"
#define HIDE_DUR 10.0
#define BUF_MAX 128
layoutmgr_add_layout(priv->lmgr, layout_channelinfo_get_lclass(), NULL);
layoutmgr_add_layout(priv->lmgr,
layout_channelinfo_list_get_lclass(), NULL);
+ layoutmgr_add_layout(priv->lmgr,
+ layout_channelinfo_search_get_lclass(), NULL);
viewmgr_set_view_data(VIEW_CHANNELINFO, priv);
layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO);
layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO_LIST);
+ layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO_SEARCH);
layoutmgr_destroy(priv->lmgr);
evas_object_del(priv->base);