[TSAM-7819] Location gengrid item disappear bugfix 19/89119/4
authorBartlomiej Uliasz <b.uliasz@samsung.com>
Thu, 22 Sep 2016 08:29:52 +0000 (10:29 +0200)
committerBartlomiej Uliasz <b.uliasz@samsung.com>
Thu, 22 Sep 2016 11:08:27 +0000 (13:08 +0200)
Change-Id: I228e97b8bec5dad2024366da991aef4fdb99065b
Signed-off-by: Bartlomiej Uliasz <b.uliasz@samsung.com>
res/widget/gengrid_default.edc
src/common/listmgr.c
src/grid/grid_location.c
src/view/system/view_location.c

index 01bc01f..62c3458 100644 (file)
@@ -330,10 +330,9 @@ group {
                        signal, "elm,state,unfocused";
                        source, SRC_ELM;
                        script {
-                               new state;
-
-                               state = get_int(check_state);
-                               if (state == STATE_CHECKED)
+                               new is_checked;
+                               is_checked = get_int(check_state);
+                               if (is_checked == STATE_CHECKED)
                                        set_state(PART:"part.check.icon", "unfocused.checked", 0.0);
                                else
                                        set_state(PART:"part.check.icon", "unfocused.unchecked", 0.0);
@@ -349,7 +348,12 @@ group {
                        source, SRC_ELM;
                        script {
                                set_int(check_state, STATE_CHECKED);
-                               set_state(PART:"part.check.icon", "unfocused.checked", 0.0);
+                               new focus_state;
+                               focus_state = get_int(is_focused);
+                               if (focus_state == STATE_NORMAL)
+                                       set_state(PART:"part.check.icon", "unfocused.checked", 0.0);
+                               else
+                                       set_state(PART:"part.check.icon", "focused.checked", 0.0);
                        }
                }
 
index e11ccff..7e978e5 100644 (file)
@@ -32,7 +32,7 @@ struct listmgr {
 struct list_info {
        char *list_id;
        struct gridmgr *gmgr;
-       Evas_Object *grid;
+       Elm_Gengrid *grid;
        void (*selected_cb)(Elm_Object_Item *it, void *data);
        void *cb_data;
 };
@@ -371,19 +371,7 @@ bool listmgr_update_grid(struct listmgr *listmgr, const char *list_id)
                return false;
        }
 
-       list = elm_gengrid_realized_items_get(linfo->grid);
-       if (!list) {
-               _DBG("No realized items yet. No need to update.");
-               return true;
-       }
-
-       EINA_LIST_FOREACH(list, l, it) {
-               if (!it)
-                       continue;
-
-               elm_gengrid_item_update(it);
-       }
-
+       elm_gengrid_realized_items_update(linfo->grid);
        return true;
 }
 
index 021d8cc..fc6e304 100644 (file)
@@ -46,12 +46,10 @@ static char *_text_get(void *data, Evas_Object *obj, const char *part)
 static Eina_Bool _state_get(void *data, Evas_Object *obj, const char *part)
 {
        struct country_info_s *country_info = NULL;
-
        if (!data) {
                _ERR("Get data failed.");
                return EINA_FALSE;
        }
-
        country_info = data;
 
        return country_info->enabled;
index ea470fd..0143f2d 100644 (file)
@@ -65,7 +65,8 @@ static void _country_selected_cb(Elm_Object_Item *it, void *data)
 {
        SETTING_TRACE_BEGIN;
 
-       struct country_info_s *country_info = NULL;
+       struct country_info_s *new_country_info = NULL;
+       struct country_info_s *previous_country_info = NULL;
        struct _priv *priv = data;
 
        if (!it || !priv) {
@@ -73,33 +74,43 @@ static void _country_selected_cb(Elm_Object_Item *it, void *data)
                return;
        }
 
-       country_info = (struct country_info_s*)elm_object_item_data_get(it);
-       if (!country_info) {
+       new_country_info = (struct country_info_s*)elm_object_item_data_get(it);
+       if (!new_country_info) {
                _ERR("Get data failed.");
                return;
        }
 
-       if (country_info->enabled) {
-               _DBG("Already selected country: %s", country_info->long_name);
-               return;
-       } else {
-               _DBG("Selecting country: %s", country_info->long_name);
-               country_info->enabled = EINA_TRUE;
+       if (!new_country_info->enabled) {
+               _DBG("Selecting country: %s", new_country_info->long_name);
+               new_country_info->enabled = EINA_TRUE;
+               elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
                if (priv->selected_country_item) {
-                       country_info = (struct country_info_s*)elm_object_item_data_get(priv->selected_country_item);
-                       country_info->enabled = EINA_FALSE;
-                       _DBG("- deselecting: %s", country_info->long_name);
+                       /* even though grid multi_select is disabled there is
+                        * some bug, which makes text disappear, so we must
+                        * unselect previous item manually
+                        */
+                       elm_gengrid_item_selected_set(priv->selected_country_item, EINA_FALSE);
+                       previous_country_info = (struct country_info_s*)elm_object_item_data_get(
+                                       priv->selected_country_item);
+                       _DBG("- deselecting: %s", previous_country_info->long_name);
+                       previous_country_info->enabled = EINA_FALSE;
                }
+       } else {
+               _DBG("Country already selected: %s", new_country_info->long_name);
+               return;
        }
 
        priv->selected_country_item = it;
 
        if (!listmgr_update_grid(priv->list_mgr, LOCATION_LIST_ID))
                _ERR("Listmgr update list failed.");
+
+       SETTING_TRACE_END;
 }
 
 static void _show_country_list(struct _priv *priv)
 {
+       SETTING_TRACE_BEGIN;
        char *lang = NULL;
 
        if (!priv->list_mgr) {
@@ -123,6 +134,7 @@ static void _show_country_list(struct _priv *priv)
                return;
        }
        _country_selected_cb(priv->configured_country, priv);
+       SETTING_TRACE_END;
 }
 
 static void _btn_clicked_cb(int id, void *data, Evas_Object *obj)
@@ -244,15 +256,17 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-       if (!listmgr_add_list(priv->list_mgr, LOCATION_LIST_ID, get_location_grid_class(),
-                               _country_selected_cb, priv)) {
+       if (!listmgr_add_list(priv->list_mgr, LOCATION_LIST_ID,
+                       get_location_grid_class(),
+                       _country_selected_cb, priv)) {
                _ERR("Add location list failed.");
                listmgr_destroy(priv->list_mgr);
                evas_object_del(priv->base);
                free(priv);
                return NULL;
        }
-       listmgr_add_inner_grid_cb(priv->list_mgr, LOCATION_LIST_ID, &_grid_input_handler, NULL);
+       listmgr_add_inner_grid_cb(priv->list_mgr, LOCATION_LIST_ID,
+                       &_grid_input_handler, NULL);
 
        if (!viewmgr_set_view_data(VIEW_LOCATION, priv)) {
                _ERR("Set view data failed.");
@@ -262,8 +276,6 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-//     data_location_fill_list_data(priv->list_mgr, &priv->configured_country, NULL);
-
        _draw_menu_area(priv);
 
        return priv->base;
@@ -294,16 +306,16 @@ static void _hide(void *data)
                return;
        }
 
-       if (!listmgr_hide_grid(priv->list_mgr, LOCATION_LIST_ID, PART_LOCATION_MENU)) {
+       if (!listmgr_hide_grid(priv->list_mgr, LOCATION_LIST_ID,
+                       PART_LOCATION_MENU))
                _ERR("Listmgr hide list failed.");
-       }
+
        evas_object_hide(priv->base);
 }
 
 static void _destroy(void *data)
 {
        SETTING_TRACE_BEGIN;
-
        struct _priv *priv = data;
 
        if (!priv) {