From 4071d67710ca86f2eda2cb795d87589d78e835c4 Mon Sep 17 00:00:00 2001 From: Abhishek Sansanwal Date: Tue, 6 Jun 2017 09:53:56 +0530 Subject: [PATCH] Align wireless button text with wired text when no ap connected Signed-off-by: Abhishek Sansanwal Change-Id: I022b79de1b48e3f192eb425fb3053014a8ffc7af --- include/common/menumgr.h | 10 ++++++++++ src/common/menumgr.c | 11 +++++++++++ src/layout/layout_network.c | 14 ++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/include/common/menumgr.h b/include/common/menumgr.h index db65603..191da7c 100644 --- a/include/common/menumgr.h +++ b/include/common/menumgr.h @@ -60,6 +60,16 @@ struct menumgr *menumgr_create(Evas_Object *table, Evas_Object *tab_menu_btn, void menumgr_destroy(struct menumgr *m); /** +* @brief Changes the style of a button and sets status function. +* +* @param[in] m Menu manager pointer. +* @param[in] status Status function pointer. +* @param[in] id Index of the button. +* @param[in] style Style to be set on the button. +*/ +void menumgr_style_set(struct menumgr *m, char *(*status)(void *data, int id), int id, const char *style); + +/** * @brief Updates a Menu manager. * * @param[in] m Menu manager pointer. diff --git a/src/common/menumgr.c b/src/common/menumgr.c index 47de08a..a311c92 100755 --- a/src/common/menumgr.c +++ b/src/common/menumgr.c @@ -130,6 +130,17 @@ static input_handler _handler = { .focused = _focused }; +void menumgr_style_set(struct menumgr *m, char *(*status)(void *data, int id), int id, const char *style) +{ + if (!m) { + _ERR("Invalid parameter."); + return; + } + + m->info[id]->status = status; + elm_object_style_set(m->btn[id], style); +} + void menumgr_update(struct menumgr *m) { int i; diff --git a/src/layout/layout_network.c b/src/layout/layout_network.c index eee1b3b..d865769 100644 --- a/src/layout/layout_network.c +++ b/src/layout/layout_network.c @@ -1844,6 +1844,18 @@ err: return false; } +static void update_style(struct _priv *priv) +{ + char *str = NULL; + str = _get_connected_ap(priv, TYPE_WIRELESS); + if (!str) { + menumgr_style_set(priv->menu, NULL, TYPE_WIRELESS, STYLE_NORMAL_BTN); + } else { + menumgr_style_set(priv->menu, _get_connected_ap, TYPE_WIRELESS, STYLE_STATUS_BTN); + free(str); + } +} + static void _show(void *layout_data) { struct _priv *priv; @@ -1863,6 +1875,7 @@ static void _show(void *layout_data) // if (priv->cur_type == TYPE_WIRELESS) // _retry_wireless_network(priv); } + update_style(priv); menumgr_update(priv->menu); } @@ -1932,6 +1945,7 @@ static void _update(void *layout_data, int update_type, void *data) elm_object_disabled_set(priv->ly, EINA_FALSE); break; case UPDATE_CONTENT: + update_style(priv); menumgr_update(priv->menu); break; default: -- 2.7.4