summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjinwoo.shin <jw0227.shin@samsung.com>2015-09-03 14:16:07 +0900
committerjinwoo.shin <jw0227.shin@samsung.com>2015-09-03 14:16:07 +0900
commitcf24548ef200fedb5909f94766c01c726f3a4690 (patch)
treea9bb0f70f8b2880b0484fcda2b8256219c9ffb34 /src
parenta1d208163b57dff2d31124d5df22449a4bc3bf14 (diff)
downloadair_livetv-cf24548ef200fedb5909f94766c01c726f3a4690.tar.gz
air_livetv-cf24548ef200fedb5909f94766c01c726f3a4690.tar.bz2
air_livetv-cf24548ef200fedb5909f94766c01c726f3a4690.zip
Change-Id: I12d012f4d832fdc37fd27f2d22aa5886cf6e8d3c Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/view_action_menu.c114
1 files changed, 100 insertions, 14 deletions
diff --git a/src/view_action_menu.c b/src/view_action_menu.c
index 4f36cf0..a73131b 100644
--- a/src/view_action_menu.c
+++ b/src/view_action_menu.c
@@ -41,6 +41,7 @@ enum _button_id {
BUTTON_LIVETV,
BUTTON_FAV,
BUTTON_LOCK,
+ BUTTON_CHANNEL,
};
enum _button_state {
@@ -138,8 +139,61 @@ static int _lock_state(void)
return r;
}
+static void _channel_clicked(void)
+{
+ const struct tv_channel_info *channel_info;
+ int r;
+
+ channel_info = tv_channel_get_info();
+ if (!channel_info) {
+ _ERR("failed to get channel info");
+ return;
+ }
+
+ if (channel_info->remembered)
+ r = tv_channel_del_channel(channel_info->service_id);
+ else
+ r = tv_channel_add_channel(channel_info->service_id);
+
+ if (r < 0)
+ _ERR("failed to set channel");
+ else {
+ if (channel_info->remembered)
+ viewmgr_update_view(VIEW_ACTION_MENU,
+ UPDATE_TYPE_SHOW_TOAST,
+ STR_REMOVE_CHANNEL_TOAST);
+ else
+ viewmgr_update_view(VIEW_ACTION_MENU,
+ UPDATE_TYPE_SHOW_TOAST,
+ STR_ADD_CHANNEL_TOAST);
+ }
+
+ tv_channel_del_info(channel_info);
+
+ viewmgr_hide_view(VIEW_ACTION_MENU);
+}
+
+static int _channel_state(void)
+{
+ const struct tv_channel_info *channel_info;
+ int r;
+
+ channel_info = tv_channel_get_info();
+ if (!channel_info) {
+ _ERR("failed to get channel info");
+ return STATE_INVALID;
+ }
+
+ r = channel_info->remembered ? STATE_TOGGLE : STATE_UNTOGGLE;
+
+ tv_channel_del_info(channel_info);
+
+ return r;
+}
+
struct _button {
int id;
+ const char *style;
struct _button_data data[2];
void (*clicked)(void);
@@ -149,12 +203,13 @@ struct _button {
static struct _button buttons[] = {
{
.id = BUTTON_FAV,
+ .style = STYLE_ACTION_MENU_BTN,
.data[UNTOGGLE] = {
.text = STR_BUTTON_FAVORITE,
- .normal = IMAGE_FAV_NOR,
- .focused = IMAGE_FAV_FOC,
- .selected = IMAGE_FAV_SEL,
- .disabled = IMAGE_FAV_DIS
+ .normal = IMAGE_UNFAV_NOR,
+ .focused = IMAGE_UNFAV_FOC,
+ .selected = IMAGE_UNFAV_SEL,
+ .disabled = IMAGE_UNFAV_DIS
},
.data[TOGGLE] = {
.text = STR_BUTTON_FAVORITE,
@@ -168,24 +223,45 @@ static struct _button buttons[] = {
},
{
.id = BUTTON_LOCK,
+ .style = STYLE_ACTION_MENU_BTN,
.data[UNTOGGLE] = {
.text = STR_BUTTON_LOCK,
- .normal = IMAGE_LOCK_NOR,
- .focused = IMAGE_LOCK_FOC,
- .selected = IMAGE_LOCK_SEL,
- .disabled = IMAGE_LOCK_DIS
- },
- .data[TOGGLE] = {
- .text = STR_BUTTON_UNLOCK,
.normal = IMAGE_UNLOCK_NOR,
.focused = IMAGE_UNLOCK_FOC,
.selected = IMAGE_UNLOCK_SEL,
.disabled = IMAGE_UNLOCK_DIS
},
+ .data[TOGGLE] = {
+ .text = STR_BUTTON_UNLOCK,
+ .normal = IMAGE_LOCK_NOR,
+ .focused = IMAGE_LOCK_FOC,
+ .selected = IMAGE_LOCK_SEL,
+ .disabled = IMAGE_LOCK_DIS
+ },
.clicked = _lock_clicked,
.state = _lock_state
},
{
+ .id = BUTTON_CHANNEL,
+ .style = STYLE_ACTION_MENU_BTN,
+ .data[UNTOGGLE] = {
+ .text = STR_BUTTON_ADD_CHANNEL,
+ .normal = IMAGE_REMOVE_CH_NOR,
+ .focused = IMAGE_REMOVE_CH_FOC,
+ .selected = IMAGE_REMOVE_CH_SEL,
+ .disabled = IMAGE_REMOVE_CH_DIS
+ },
+ .data[TOGGLE] = {
+ .text = STR_BUTTON_REMOVE_CHANNEL,
+ .normal = IMAGE_ADD_CH_NOR,
+ .focused = IMAGE_ADD_CH_FOC,
+ .selected = IMAGE_ADD_CH_SEL,
+ .disabled = IMAGE_ADD_CH_DIS
+ },
+ .clicked = _channel_clicked,
+ .state = _channel_state
+ },
+ {
.id = BUTTON_INVALID
}
};
@@ -355,6 +431,17 @@ static void _update_favorite(struct _priv *priv)
tv_channel_del_list(channel_list);
}
+static void _update_menu(struct _priv *priv)
+{
+ int i;
+
+ i = 0;
+ while (buttons[i].id != BUTTON_INVALID && i < BUTTON_MAX) {
+ _update_button_state(priv->menu_btn[i], &buttons[i]);
+ i++;
+ }
+}
+
static bool _draw_channel_info(struct _priv *priv)
{
Evas_Object *layout;
@@ -406,7 +493,7 @@ static bool _draw_menu_area(struct _priv *priv)
while (buttons[i].id != BUTTON_INVALID && i < BUTTON_MAX) {
btn = util_add_button(priv->base, NULL,
buttons[i].data[UNTOGGLE].text,
- STYLE_ACTION_MENU_BTN);
+ buttons[i].style);
if (!btn) {
_ERR("Add button failed.");
evas_object_del(table);
@@ -434,8 +521,6 @@ static bool _draw_menu_area(struct _priv *priv)
inputmgr_add_callback(btn, buttons[i].id,
&button_handler, &buttons[i]);
- _update_button_state(btn, &buttons[i]);
-
col = i % ITEMS_IN_ROW;
row = i / ITEMS_IN_ROW;
elm_table_pack(table, btn, col, row, 1, 1);
@@ -565,6 +650,7 @@ static void _show(void *data)
priv = data;
_update_channel_info(priv);
+ _update_menu(priv);
_update_favorite(priv);
evas_object_show(priv->base);