Relocate draw channel info function 83/46383/1
authorjinwoo.shin <jw0227.shin@samsung.com>
Thu, 20 Aug 2015 01:28:00 +0000 (10:28 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Thu, 20 Aug 2015 01:28:00 +0000 (10:28 +0900)
Change-Id: I8190210922a73660e9326c2e637071d3beccc804
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
include/util.h
include/view.h
src/layout_channelinfo.c
src/layout_channelinfo_list.c
src/layout_channelinfo_search.c
src/util.c
src/view_channelinfo.c

index 045d39e..1e29db5 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <stdbool.h>
+#include "tv.h"
 
 #ifndef __UTIL_H__
 #define __UTIL_H__
@@ -26,5 +27,7 @@ Evas_Object *util_add_icon(Evas_Object *parent, const char *file,
                const char *part);
 Evas_Object *util_add_button(Evas_Object *parent, const char *part,
                const char *text, const char *style);
+void util_draw_channel_info(Evas_Object *obj,
+               const struct tv_channel_info *channel_info);
 
 #endif
index 5fbf8d4..bc299cb 100644 (file)
@@ -27,6 +27,11 @@ enum _update_type {
        UPDATE_TYPE_NOSIGNAL,
 };
 
+enum _update_op {
+       START_HIDE_TIMER,
+       STOP_HIDE_TIMER
+};
+
 void draw_channel_info(Evas_Object *obj, const struct tv_channel_info *channel_info);
 
 view_class *view_channelnumber_get_vclass(void);
index 2771b12..3d9dec9 100644 (file)
@@ -23,6 +23,7 @@
 #include "define.h"
 #include "tv.h"
 #include "view.h"
+#include "util.h"
 
 struct _priv {
        Evas_Object *base;
@@ -46,7 +47,7 @@ static void _update_channel_info(struct _priv *priv)
                return;
        }
 
-       draw_channel_info(priv->layout, priv->channel_info);
+       util_draw_channel_info(priv->layout, priv->channel_info);
 }
 
 static bool _create(layoutmgr *lmgr, void *data)
index 89d71ff..6cb64de 100644 (file)
@@ -101,7 +101,7 @@ static void _update_channel_info(struct _priv *priv)
                }
        }
 
-       draw_channel_info(priv->current_channel, current);
+       util_draw_channel_info(priv->current_channel, current);
 
        channel_list = tv_channel_get_list();
        if (!channel_list) {
@@ -132,10 +132,10 @@ static void _update_channel_info(struct _priv *priv)
        }
 
        if (prev)
-               draw_channel_info(priv->prev_channel, prev);
+               util_draw_channel_info(priv->prev_channel, prev);
 
        if (next)
-               draw_channel_info(priv->next_channel, next);
+               util_draw_channel_info(priv->next_channel, next);
 
        tv_channel_del_list(channel_list);
 }
index 0382a6f..3849fdf 100644 (file)
@@ -135,7 +135,7 @@ static void _load_channel_list(struct _priv *priv, Eina_List *channel_list)
                if (!ly)
                        continue;
                elm_object_focus_allow_set(ly, EINA_TRUE);
-               draw_channel_info(ly, channel_info);
+               util_draw_channel_info(ly, channel_info);
                elm_box_pack_end(priv->box, ly);
 
                inputmgr_add_callback(ly, 0, &channel_handler,
index b9b3f72..fbf1a59 100644 (file)
 
 #include <Elementary.h>
 #include <app_debug.h>
+#include <viewmgr.h>
 
-#include "util.h"
 #include "define.h"
+#include "view.h"
+
+#define BUF_MAX 128
 
 Evas_Object *util_add_layout(Evas_Object *parent, const char *group)
 {
@@ -154,3 +157,153 @@ Evas_Object *util_add_button(Evas_Object *parent, const char *part,
        return btn;
 }
 
+static int _get_program_time(char *buf, int buf_len, time_t start_time,
+               time_t end_time)
+{
+       struct tm tm;
+       int r;
+
+       if (start_time >= end_time) {
+               _ERR("invalid time");
+               return -1;
+       }
+
+       localtime_r(&start_time, &tm);
+       r = strftime(buf, buf_len, "%I:%M %P -", &tm);
+       if (r <= 0)
+               return -1;
+
+       localtime_r(&end_time, &tm);
+       r = strftime(buf + r, buf_len - r, " %I:%M %P", &tm);
+       if (r <= 0)
+               return -1;
+
+       return 0;
+}
+
+static void _set_icon_box(Evas_Object *obj,
+               const struct tv_channel_info *channel_info)
+{
+       elm_object_signal_emit(obj, SIGNAL_RESET, SOURCE_PROGRAM);
+
+       if (channel_info->locked)
+               elm_object_signal_emit(obj, SIGNAL_LOCKED, SOURCE_PROGRAM);
+       if (channel_info->favorite)
+               elm_object_signal_emit(obj, SIGNAL_FAVORITE, SOURCE_PROGRAM);
+}
+
+static void _load_channel_text(Evas_Object *obj,
+               const struct tv_channel_info *channel_info)
+{
+       char buf[BUF_MAX];
+
+       if (channel_info->channel_minor > 0 &&
+                       channel_info->channel_minor < MINOR_MAX)
+               snprintf(buf, sizeof(buf), "%lu-%lu %s",
+                               channel_info->channel_major,
+                               channel_info->channel_minor,
+                               channel_info->channel_name);
+       else
+               snprintf(buf, sizeof(buf), "%lu %s",
+                               channel_info->channel_major,
+                               channel_info->channel_name);
+
+       elm_object_part_text_set(obj,
+                       PART_CHANNELINFO_CHANNEL, buf);
+
+       elm_object_part_text_set(obj,
+                       PART_CHANNELINFO_TITLE,
+                       STR_NOTITLE);
+       elm_object_part_text_set(obj,
+                       PART_CHANNELINFO_TIME,
+                       STR_NOTIME);
+}
+
+static void _load_program_info(Evas_Object *obj,
+               const struct tv_program_info *prog)
+{
+       char buf[BUF_MAX];
+       int r, service_id;
+
+       service_id = (int) evas_object_data_get(obj, KEY_SVCID);
+       if (service_id != prog->service_id)
+               return;
+
+       if (prog->start_time && prog->end_time) {
+               r = _get_program_time(buf, sizeof(buf),
+                               prog->start_time,
+                               prog->end_time);
+               if (!r)
+                       elm_object_part_text_set(obj,
+                                       PART_CHANNELINFO_TIME, buf);
+       }
+
+       if (strlen(prog->prog_title) > 0)
+               elm_object_part_text_set(obj,
+                               PART_CHANNELINFO_TITLE, prog->prog_title);
+}
+
+static void _tv_program_cb(Eina_List *prog_list, void *data)
+{
+       Evas_Object *obj;
+       struct tv_program_info *prog = NULL;
+
+       if (!data) {
+               _ERR("failed to get data");
+               return;
+       }
+
+       obj = data;
+
+       prog = (struct tv_program_info *) eina_list_nth(prog_list, 0);
+       if (prog)
+               _load_program_info(obj, prog);
+       else
+               _ERR("failed to get tv_program_info");
+
+       viewmgr_update_view(VIEW_CHANNELINFO,
+                       UPDATE_TYPE_TIMER, START_HIDE_TIMER);
+}
+
+void util_draw_channel_info(Evas_Object *obj,
+               const struct tv_channel_info *channel_info)
+{
+       struct tv_program_request *prog_req;
+       int r;
+       int current_service;
+
+       if (!obj || !channel_info) {
+               _ERR("Invalid argument");
+
+               return;
+       }
+
+       r = tv_get_current_service_id(&current_service);
+       if (r < 0)
+               current_service = -1;
+
+       viewmgr_update_view(VIEW_CHANNELINFO,
+                       UPDATE_TYPE_TIMER, (void *)STOP_HIDE_TIMER);
+
+       _load_channel_text(obj, channel_info);
+       _set_icon_box(obj, channel_info);
+       evas_object_data_set(obj, KEY_SVCID, (void *)channel_info->service_id);
+
+       prog_req = calloc(1, sizeof(*prog_req));
+       prog_req->tv_program_cb = _tv_program_cb;
+       prog_req->user_data = obj;
+
+       r = tv_epg_get_cache_program(channel_info->service_id,
+                       prog_req);
+
+       if (channel_info->service_id == current_service) {
+               prog_req = calloc(1, sizeof(*prog_req));
+               prog_req->tv_program_cb = _tv_program_cb;
+               prog_req->user_data = obj;
+               r = tv_epg_get_program(channel_info->service_id, prog_req);
+       }
+
+       if (r < 0)
+               viewmgr_update_view(VIEW_CHANNELINFO,
+                               UPDATE_TYPE_TIMER, START_HIDE_TIMER);
+}
index 818e06d..e720d43 100644 (file)
 #include "layout_channelinfo_search.h"
 
 #define HIDE_DUR 10.0
-#define BUF_MAX 128
 #define STATUS_BOX_PADDING 10
 
-enum _update_op {
-       START_HIDE_TIMER,
-       STOP_HIDE_TIMER
-};
-
 struct _priv {
        Evas_Object *base;
        Ecore_Timer *hide_timer;
@@ -103,30 +97,6 @@ static input_handler key_handler = {
        .mouse_move = _mouse_move_cb,
 };
 
-static int _get_program_time(char *buf, int buf_len, time_t start_time,
-               time_t end_time)
-{
-       struct tm tm;
-       int r;
-
-       if (start_time >= end_time) {
-               _ERR("invalid time");
-               return -1;
-       }
-
-       localtime_r(&start_time, &tm);
-       r = strftime(buf, buf_len, "%I:%M %P -", &tm);
-       if (r <= 0)
-               return -1;
-
-       localtime_r(&end_time, &tm);
-       r = strftime(buf + r, buf_len - r, " %I:%M %P", &tm);
-       if (r <= 0)
-               return -1;
-
-       return 0;
-}
-
 static Eina_Bool _hide_timer(void *data)
 {
        struct _priv *priv;
@@ -159,133 +129,6 @@ static void _stop_hide_timer(struct _priv *priv)
        }
 }
 
-static void _set_icon_box(Evas_Object *obj,
-               const struct tv_channel_info *channel_info)
-{
-       elm_object_signal_emit(obj, SIGNAL_RESET, SOURCE_PROGRAM);
-
-       if (channel_info->locked)
-               elm_object_signal_emit(obj, SIGNAL_LOCKED, SOURCE_PROGRAM);
-       if (channel_info->favorite)
-               elm_object_signal_emit(obj, SIGNAL_FAVORITE, SOURCE_PROGRAM);
-}
-
-static void _load_channel_text(Evas_Object *obj,
-               const struct tv_channel_info *channel_info)
-{
-       char buf[BUF_MAX];
-
-       if (channel_info->channel_minor > 0 &&
-                       channel_info->channel_minor < MINOR_MAX)
-               snprintf(buf, sizeof(buf), "%lu-%lu %s",
-                               channel_info->channel_major,
-                               channel_info->channel_minor,
-                               channel_info->channel_name);
-       else
-               snprintf(buf, sizeof(buf), "%lu %s",
-                               channel_info->channel_major,
-                               channel_info->channel_name);
-
-       elm_object_part_text_set(obj,
-                       PART_CHANNELINFO_CHANNEL, buf);
-
-       elm_object_part_text_set(obj,
-                       PART_CHANNELINFO_TITLE,
-                       STR_NOTITLE);
-       elm_object_part_text_set(obj,
-                       PART_CHANNELINFO_TIME,
-                       STR_NOTIME);
-}
-
-static void _load_program_info(Evas_Object *obj,
-               const struct tv_program_info *prog)
-{
-       char buf[BUF_MAX];
-       int r, service_id;
-
-       service_id = (int) evas_object_data_get(obj, KEY_SVCID);
-       if (service_id != prog->service_id)
-               return;
-
-       if (prog->start_time && prog->end_time) {
-               r = _get_program_time(buf, sizeof(buf),
-                               prog->start_time,
-                               prog->end_time);
-               if (!r)
-                       elm_object_part_text_set(obj,
-                                       PART_CHANNELINFO_TIME, buf);
-       }
-
-       if (strlen(prog->prog_title) > 0)
-               elm_object_part_text_set(obj,
-                               PART_CHANNELINFO_TITLE, prog->prog_title);
-}
-
-static void _tv_program_cb(Eina_List *prog_list, void *data)
-{
-       Evas_Object *obj;
-       struct tv_program_info *prog = NULL;
-
-       if (!data) {
-               _ERR("failed to get data");
-               return;
-       }
-
-       obj = data;
-
-       prog = (struct tv_program_info *) eina_list_nth(prog_list, 0);
-       if (prog)
-               _load_program_info(obj, prog);
-       else
-               _ERR("failed to get tv_program_info");
-
-       viewmgr_update_view(VIEW_CHANNELINFO,
-                       UPDATE_TYPE_TIMER, START_HIDE_TIMER);
-}
-
-void draw_channel_info(Evas_Object *obj,
-               const struct tv_channel_info *channel_info)
-{
-       struct tv_program_request *prog_req;
-       int r;
-       int current_service;
-
-       if (!obj || !channel_info) {
-               _ERR("Invalid argument");
-
-               return;
-       }
-
-       r = tv_get_current_service_id(&current_service);
-       if (r < 0)
-               current_service = -1;
-
-       viewmgr_update_view(VIEW_CHANNELINFO,
-                       UPDATE_TYPE_TIMER, (void *)STOP_HIDE_TIMER);
-
-       _load_channel_text(obj, channel_info);
-       _set_icon_box(obj, channel_info);
-       evas_object_data_set(obj, KEY_SVCID, (void *)channel_info->service_id);
-
-       prog_req = calloc(1, sizeof(*prog_req));
-       prog_req->tv_program_cb = _tv_program_cb;
-       prog_req->user_data = obj;
-
-       r = tv_epg_get_cache_program(channel_info->service_id,
-                       prog_req);
-
-       if (channel_info->service_id == current_service) {
-               prog_req = calloc(1, sizeof(*prog_req));
-               prog_req->tv_program_cb = _tv_program_cb;
-               prog_req->user_data = obj;
-               r = tv_epg_get_program(channel_info->service_id, prog_req);
-       }
-
-       if (r < 0)
-               viewmgr_update_view(VIEW_CHANNELINFO,
-                               UPDATE_TYPE_TIMER, START_HIDE_TIMER);
-}
-
 static Evas_Object *_create(Evas_Object *win, void *data)
 {
        struct _priv *priv;