diff options
author | jinwoo.shin <jw0227.shin@samsung.com> | 2015-08-20 10:28:00 +0900 |
---|---|---|
committer | jinwoo.shin <jw0227.shin@samsung.com> | 2015-08-20 10:28:00 +0900 |
commit | 5b4769622778385a51156a4a83c440f88afe8b5a (patch) | |
tree | 95c84def0199cb0a8fa87e0e2bc28bcb3e6c2db2 /src | |
parent | f6111f55f144e4d251cd130c15d3bc153b0bcb83 (diff) | |
download | air_livetv-5b4769622778385a51156a4a83c440f88afe8b5a.tar.gz air_livetv-5b4769622778385a51156a4a83c440f88afe8b5a.tar.bz2 air_livetv-5b4769622778385a51156a4a83c440f88afe8b5a.zip |
Relocate draw channel info function
Change-Id: I8190210922a73660e9326c2e637071d3beccc804
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/layout_channelinfo.c | 3 | ||||
-rw-r--r-- | src/layout_channelinfo_list.c | 6 | ||||
-rw-r--r-- | src/layout_channelinfo_search.c | 2 | ||||
-rw-r--r-- | src/util.c | 155 | ||||
-rw-r--r-- | src/view_channelinfo.c | 157 |
5 files changed, 160 insertions, 163 deletions
diff --git a/src/layout_channelinfo.c b/src/layout_channelinfo.c index 2771b12..3d9dec9 100644 --- a/src/layout_channelinfo.c +++ b/src/layout_channelinfo.c @@ -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) diff --git a/src/layout_channelinfo_list.c b/src/layout_channelinfo_list.c index 89d71ff..6cb64de 100644 --- a/src/layout_channelinfo_list.c +++ b/src/layout_channelinfo_list.c @@ -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); } diff --git a/src/layout_channelinfo_search.c b/src/layout_channelinfo_search.c index 0382a6f..3849fdf 100644 --- a/src/layout_channelinfo_search.c +++ b/src/layout_channelinfo_search.c @@ -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, @@ -16,9 +16,12 @@ #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(¤t_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); +} diff --git a/src/view_channelinfo.c b/src/view_channelinfo.c index 818e06d..e720d43 100644 --- a/src/view_channelinfo.c +++ b/src/view_channelinfo.c @@ -28,14 +28,8 @@ #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(¤t_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; |