summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-08-25 15:30:22 +0900
committerJehun Lim <jehun.lim@samsung.com>2015-08-25 16:32:36 +0900
commit9b868fbc021126fb22001f1fe3ac98c7b02d103b (patch)
tree6830d9a17eb5d82e30cfb6e3cccb54002c6b5187 /src/util
parentc37791a56c5b528eb01fb60775750d15d1e7adfe (diff)
downloadair_mediahub-9b868fbc021126fb22001f1fe3ac98c7b02d103b.tar.gz
air_mediahub-9b868fbc021126fb22001f1fe3ac98c7b02d103b.tar.bz2
air_mediahub-9b868fbc021126fb22001f1fe3ac98c7b02d103b.zip
base: find the item to be focused using media id
Change-Id: I849d019370453f9b64b5233d243eeaa69fd31abd Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/listmgr.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/src/util/listmgr.c b/src/util/listmgr.c
index 0f8b84b..a96e005 100644
--- a/src/util/listmgr.c
+++ b/src/util/listmgr.c
@@ -452,6 +452,29 @@ bool _focus_to_content(struct listmgr *lmgr, Evas_Object *base)
return true;
}
+Elm_Object_Item *_get_grid_item(Evas_Object *grid, const char *id)
+{
+ Elm_Object_Item *it;
+ app_media *am;
+ app_media_info *mi;
+
+ for (it = elm_gengrid_first_item_get(grid); it;
+ it = elm_gengrid_item_next_get(it)) {
+ am = elm_object_item_data_get(it);
+ if (!am)
+ continue;
+
+ mi = app_media_get_info(am);
+ if (!mi)
+ continue;
+
+ if (!strcmp(id, mi->media_id))
+ return it;
+ }
+
+ return NULL;
+}
+
void listmgr_set_focus_state(struct listmgr *lmgr, Eina_Bool state)
{
if (!lmgr) {
@@ -477,26 +500,26 @@ bool listmgr_focus_play_info(struct listmgr *lmgr)
return true;
}
-bool listmgr_focus_content_list(struct listmgr *lmgr, int index, bool update)
+bool listmgr_focus_content_list(struct listmgr *lmgr, const char *id)
{
Eina_List *item, *l;
Evas_Object *ly, *grid;
Elm_Object_Item *it;
- int count;
- int r;
- if (!update) {
- r = _focus_to_content(lmgr, lmgr->focused);
- if (!r)
- _ERR("failed to focus to content");
- return r;
+ if (!lmgr) {
+ _ERR("failed to get listmgr");
+ return false;
+ }
+
+ if (!id) {
+ _ERR("invalid argument");
+ return false;
}
item = elm_box_children_get(lmgr->box);
- if (lmgr->show_play_info)
- item = eina_list_next(item);
grid = NULL;
+ it = NULL;
EINA_LIST_FOREACH(item, l, ly) {
grid = elm_object_part_content_get(ly, PART_ITEM_CONTENT);
if (!grid) {
@@ -504,18 +527,11 @@ bool listmgr_focus_content_list(struct listmgr *lmgr, int index, bool update)
return false;
}
- count = elm_gengrid_items_count(grid);
-
- if (index < count)
+ it = _get_grid_item(grid, id);
+ if (it)
break;
-
- index -= count;
}
- it = elm_gengrid_first_item_get(grid);
- while (index--)
- it = elm_gengrid_item_next_get(it);
-
if (!it) {
_ERR("failed to get current grid item");
return false;