action_menu: add selected callback for favorite item 33/46433/1
authorJehun Lim <jehun.lim@samsung.com>
Thu, 20 Aug 2015 07:11:15 +0000 (16:11 +0900)
committerJehun Lim <jehun.lim@samsung.com>
Thu, 20 Aug 2015 07:50:53 +0000 (16:50 +0900)
Change-Id: Ie4139cb1d150cab130228e9f271094c12aa655ed
Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
src/view/action_menu.c

index 7dec094..b2241fd 100644 (file)
@@ -54,9 +54,13 @@ struct _priv {
 
        Evas_Object *tv_btn;
        Evas_Object *menu_btn[NUM_MENU_BTN];
+
        Evas_Object *grid;
+       Elm_Object_Item *selected_it;
 
        Eina_List *favorite_list;
+
+       int content_type;
 };
 
 struct _menu_info {
@@ -157,9 +161,70 @@ static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
        }
 }
 
+static void _grid_selected(void *data)
+{
+       app_media *am;
+       struct view_update_data vdata;
+       struct _priv *priv;
+
+       if (!data) {
+               _ERR("invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       am = elm_object_item_data_get(priv->selected_it);
+       if (!am) {
+               _ERR("failed to get app media");
+               return;
+       }
+
+       vdata.list = priv->favorite_list;
+       vdata.index = util_get_media_index(vdata.list, am);
+
+       viewmgr_hide_view(VIEW_ACTION_MENU);
+
+       switch (priv->content_type) {
+       case E_CONTENT_MOVIE:
+       case E_CONTENT_GALLERY:
+               viewmgr_update_view(VIEW_VIEWER, UPDATE_CONTENT, &vdata);
+               viewmgr_push_view(VIEW_VIEWER);
+               break;
+       case E_CONTENT_MUSIC:
+               viewmgr_update_view(VIEW_MPLAYER, UPDATE_CONTENT, &vdata);
+               viewmgr_push_view(VIEW_MPLAYER);
+               break;
+       default:
+               break;
+       }
+}
+
+static void _selected_cb(int id, void *data, Evas_Object *obj,
+                       Elm_Object_Item *it)
+{
+       struct _priv *priv;
+
+       if (!data || !it)
+               return;
+
+       priv = data;
+
+       switch (id) {
+       case ACTION_FAVORITE_GRID:
+               priv->selected_it = it;
+               ecore_job_add(_grid_selected, priv);
+
+               break;
+       default:
+               break;
+       }
+}
+
 static input_handler _handler = {
        .key_down = _key_down_cb,
-       .mouse_move = _mouse_move_cb
+       .mouse_move = _mouse_move_cb,
+       .selected = _selected_cb
 };
 
 static char *_grid_text_get(void *data, Evas_Object *obj, const char *part)
@@ -473,16 +538,19 @@ static bool _draw_favorite_area(struct _priv *priv)
        return true;
 }
 
-static void _update_favorite_area(struct _priv *priv, int type)
+static void _update_favorite_area(struct _priv *priv)
 {
 
        Elm_Gengrid_Item_Class *ic;
        Elm_Object_Item *it;
        Eina_List *favorite_l, *l;
        app_media *am;
+       int type;
 
        elm_gengrid_clear(priv->grid);
 
+       type = priv->content_type;
+
        elm_gengrid_item_size_set(priv->grid,
                        elm_config_scale_get() * content_info[type].grid_x,
                        elm_config_scale_get() * content_info[type].grid_y);
@@ -526,7 +594,6 @@ static bool _update_items(struct _priv *priv, struct view_update_data *vdata)
 {
        app_media *am;
        app_media_info *mi;
-       int type;
 
        am = eina_list_nth(vdata->list, vdata->index);
        if (!am) {
@@ -540,9 +607,9 @@ static bool _update_items(struct _priv *priv, struct view_update_data *vdata)
                return false;
        }
 
-       type = _get_content_type(mi);
+       priv->content_type = _get_content_type(mi);
 
-       _update_favorite_area(priv, type);
+       _update_favorite_area(priv);
 
        return true;
 }