static void _get_song_count(char *str, int size, Eina_List *list);
static void _get_album_count(char *str, int size, Eina_List *list);
+static void _album_selected(void *data);
+
+struct _list_info {
+ Eina_List *list;
+ const char *title;
+};
+
struct _view_info {
const char *grid_style;
int grid_item_x;
char *(*get_grid_text)(void *data, Evas_Object *obj, const char *part);
Evas_Object *(*get_grid_content)(void *data, Evas_Object *obj,
const char *part);
-
void (*get_content_info)(char *str, int size, Eina_List *list);
+
+ void (*selected)(void *data);
+ bool detail_update;
};
static struct _view_info view_info[E_DETAIL_MAX] = {
.get_grid_text = _grid_text_get,
.get_grid_content = _grid_content_get,
.get_content_info = _get_movie_count,
+ .detail_update = EINA_FALSE,
},
[E_DETAIL_MUSIC_ALBUM] = {
.grid_style = STYLE_MUSIC_SONG_DETAIL,
.get_grid_text = _grid_text_get,
.get_grid_content = _grid_content_get,
.get_content_info = _get_song_count,
+ .detail_update = EINA_FALSE,
},
[E_DETAIL_MUSIC_ARTIST] = {
.grid_style = STYLE_MUSIC_ALBUM,
.get_grid_text = _album_text_get,
.get_grid_content = _album_content_get,
.get_content_info = _get_album_count,
+ .selected = _album_selected,
+ .detail_update = EINA_TRUE,
},
};
Elm_Object_Item *focused_it;
Eina_List *media_list;
+ Eina_List *view_list;
+
+ struct datamgr *dmgr;
int view_type;
+ int depth;
struct _view_info *vinfo;
};
+static void _update_view(struct _priv *priv)
+{
+ struct _list_info *linfo;
+ struct view_update_data vdata;
+
+ linfo = eina_list_data_get(priv->view_list);
+ priv->view_list = eina_list_remove(priv->view_list, linfo);
+
+ vdata.list = linfo->list;
+ vdata.index = E_DETAIL_MUSIC_ARTIST;
+ vdata.id = linfo->title;
+
+ viewmgr_update_view(VIEW_DETAIL, UPDATE_CONTENT, &vdata);
+ viewmgr_push_view(VIEW_DETAIL);
+
+ priv->depth--;
+
+ free(linfo);
+}
+
+static void _pop_view(void)
+{
+ viewmgr_update_view(VIEW_BASE, UPDATE_BACK, NULL);
+ viewmgr_pop_view();
+}
+
static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
Evas_Event_Key_Down *ev)
{
- if (!ev) {
+ struct _priv *priv;
+
+ if (!data || !ev) {
_ERR("invalid argument");
return;
}
+ priv = data;
+
if (!strcmp(ev->keyname, KEY_BACK) ||
!strcmp(ev->keyname, KEY_ESC)) {
- viewmgr_update_view(VIEW_BASE, UPDATE_BACK, NULL);
- viewmgr_pop_view();
+ if (priv->depth > 0)
+ _update_view(priv);
+ else
+ _pop_view();
}
}
priv->focused_it = it;
}
-static void _selected(void *data)
+static void _media_selected(void *data)
{
struct _priv *priv;
struct view_update_data vdata;
}
}
+static void _album_selected(void *data)
+{
+ struct _priv *priv;
+ struct view_update_data vdata;
+ struct _list_info *linfo;
+ struct datamgr *dmgr;
+ struct album_info *ai;
+
+ if (!data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ dmgr = priv->dmgr;
+
+ ai = elm_object_item_data_get(priv->focused_it);
+ if (!ai) {
+ _ERR("failed to get album info");
+ return;
+ }
+
+ linfo = calloc(1, sizeof(*linfo));
+ if (!linfo) {
+ _ERR("failed to allocate list info");
+ return;
+ }
+
+ linfo->list = priv->media_list;
+ linfo->title = ai->artist;
+
+ priv->view_list = eina_list_append(priv->view_list, linfo);
+
+ vdata.list = dmgr->ops->get_list(dmgr->handle,
+ E_LIST_ALBUM_MEDIA, &ai->id);
+ vdata.index = E_DETAIL_MUSIC_ALBUM;
+ vdata.id = ai->name;
+
+ viewmgr_update_view(VIEW_DETAIL, UPDATE_CONTENT, &vdata);
+ viewmgr_push_view(VIEW_DETAIL);
+
+ priv->depth++;
+}
+
static void _selected_cb(int id, void *data, Evas_Object *obj,
Elm_Object_Item *it)
{
struct _priv *priv;
+ void (*_selected)(void *data);
if (!data || !it)
return;
priv = data;
+ if (priv->vinfo->detail_update)
+ _selected = priv->vinfo->selected;
+ else
+ _selected = _media_selected;
+
ecore_job_add(_selected, priv);
}
Elm_Object_Item *it;
void *data;
+ elm_object_focus_set(priv->grid, EINA_FALSE);
elm_gengrid_clear(priv->grid);
elm_gengrid_item_size_set(priv->grid,
{
struct _priv *priv;
Evas_Object *base;
+ struct datamgr *dmgr;
if (!win) {
_ERR("failed to get win object");
EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, base);
+ dmgr = datamgr_create(E_DATA_ALBUM, MUSIC_MEDIA_COND, E_SOURCE_ALL);
+ if (!dmgr) {
+ _ERR("failed to create datamgr");
+ free(priv);
+ return NULL;
+ }
+
priv->win = win;
priv->base = base;
+ priv->dmgr = dmgr;
if (!_draw_thumbnail_area(priv)) {
_ERR("failed to draw items");
+ datamgr_destroy(dmgr);
free(priv);
return NULL;
}
priv = view_data;
+ datamgr_destroy(priv->dmgr);
+
evas_object_del(priv->base);
free(priv);