Commit b478c952 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Handle back button on audio sub-views

Used to close playlists popup launched within a sub view.
parent 06dadef1
...@@ -140,6 +140,7 @@ typedef struct list_view ...@@ -140,6 +140,7 @@ typedef struct list_view
void (*pf_set_item)(list_view_item* p_list_item, void* p_item); void (*pf_set_item)(list_view_item* p_list_item, void* p_item);
Evas_Object* (*pf_get_widget)(list_sys* p_sys); Evas_Object* (*pf_get_widget)(list_sys* p_sys);
Evas_Object* (*pf_get_list)(list_sys* p_list_sys); Evas_Object* (*pf_get_list)(list_sys* p_list_sys);
bool (*pf_view_event_back)(list_sys* p_sys);
} list_view; } list_view;
#endif /* INTERFACE_H_ */ #endif /* INTERFACE_H_ */
...@@ -56,6 +56,7 @@ audio_list_album_item_selected(void *data, Evas_Object *obj /*EINA_UNUSED*/, voi ...@@ -56,6 +56,7 @@ audio_list_album_item_selected(void *data, Evas_Object *obj /*EINA_UNUSED*/, voi
Evas_Object* p_new_list = p_songs_view->pf_get_widget(p_songs_view->p_sys); Evas_Object* p_new_list = p_songs_view->pf_get_widget(p_songs_view->p_sys);
Elm_Object_Item *it = elm_naviframe_item_push(p_view_item->p_list_sys->p_parent, "", NULL, NULL, p_new_list, NULL); Elm_Object_Item *it = elm_naviframe_item_push(p_view_item->p_list_sys->p_parent, "", NULL, NULL, p_new_list, NULL);
elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE); elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
elm_object_item_data_set(it, p_songs_view);
} }
static void static void
......
...@@ -58,6 +58,7 @@ audio_list_artist_item_selected(void *data, Evas_Object *obj /*EINA_UNUSED*/, vo ...@@ -58,6 +58,7 @@ audio_list_artist_item_selected(void *data, Evas_Object *obj /*EINA_UNUSED*/, vo
Evas_Object* p_new_list = p_view->pf_get_widget(p_view->p_sys); Evas_Object* p_new_list = p_view->pf_get_widget(p_view->p_sys);
Elm_Object_Item *it = elm_naviframe_item_push(p_view_item->p_list_sys->p_parent, "", NULL, NULL, p_new_list, NULL); Elm_Object_Item *it = elm_naviframe_item_push(p_view_item->p_list_sys->p_parent, "", NULL, NULL, p_new_list, NULL);
elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE); elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
elm_object_item_data_set(it, p_view);
} }
static void static void
......
...@@ -122,6 +122,7 @@ audio_list_genres_item_selected(void *data, Evas_Object *obj, void *event_info) ...@@ -122,6 +122,7 @@ audio_list_genres_item_selected(void *data, Evas_Object *obj, void *event_info)
Evas_Object* p_new_list = p_view->pf_get_widget(p_view->p_sys); Evas_Object* p_new_list = p_view->pf_get_widget(p_view->p_sys);
Elm_Object_Item *it = elm_naviframe_item_push(p_view_item->p_list_sys->p_parent, "", NULL, NULL, p_new_list, NULL); Elm_Object_Item *it = elm_naviframe_item_push(p_view_item->p_list_sys->p_parent, "", NULL, NULL, p_new_list, NULL);
elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE); elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
elm_object_item_data_set(it, p_view);
} }
......
...@@ -129,6 +129,7 @@ audio_list_playlists_item_selected(void *data, Evas_Object *obj, void *event_inf ...@@ -129,6 +129,7 @@ audio_list_playlists_item_selected(void *data, Evas_Object *obj, void *event_inf
Evas_Object* p_new_list = p_view->pf_get_widget(p_view->p_sys); Evas_Object* p_new_list = p_view->pf_get_widget(p_view->p_sys);
Elm_Object_Item *it = elm_naviframe_item_push(p_view_item->p_list_sys->p_parent, "", NULL, NULL, p_new_list, NULL); Elm_Object_Item *it = elm_naviframe_item_push(p_view_item->p_list_sys->p_parent, "", NULL, NULL, p_new_list, NULL);
elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE); elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
elm_object_item_data_set(it, p_view);
} }
static list_view_item* static list_view_item*
......
...@@ -161,6 +161,24 @@ genlist_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) ...@@ -161,6 +161,24 @@ genlist_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
intf_start_audio_player(ali->p_list->p_intf, array, pos); intf_start_audio_player(ali->p_list->p_intf, array, pos);
} }
bool
audio_list_song_back_callback(list_sys *p_sys)
{
if (p_sys->current_popup != NULL)
{
evas_object_del(p_sys->current_popup);
p_sys->current_popup = NULL;
return true;
}
if (playlists_is_popup_open(p_sys->p_playlists))
{
playlists_popup_destroy(p_sys->p_playlists);
p_sys->p_playlists = NULL;
return true;
}
return false;
}
void void
audio_list_song_playlists_longpress_add_callback(void *data, Evas_Object *obj, void *event_info) audio_list_song_playlists_longpress_add_callback(void *data, Evas_Object *obj, void *event_info)
{ {
...@@ -320,6 +338,7 @@ audio_list_song_view_create(interface* p_intf, Evas_Object* p_parent, list_view_ ...@@ -320,6 +338,7 @@ audio_list_song_view_create(interface* p_intf, Evas_Object* p_parent, list_view_
p_view->pf_get_item = &audio_list_song_item_get_media_item; p_view->pf_get_item = &audio_list_song_item_get_media_item;
p_view->pf_set_item = &audio_list_song_item_set_media_item; p_view->pf_set_item = &audio_list_song_item_set_media_item;
p_view->pf_del = &audio_list_song_view_delete; p_view->pf_del = &audio_list_song_view_delete;
p_view->pf_view_event_back = &audio_list_song_back_callback;
application* p_app = intf_get_application( p_intf ); application* p_app = intf_get_application( p_intf );
p_sys->p_ctrl = audio_controller_create(p_app, p_view); p_sys->p_ctrl = audio_controller_create(p_app, p_view);
......
...@@ -90,6 +90,7 @@ create_audio_list_type(view_sys *p_view_sys, audio_view_type type ) ...@@ -90,6 +90,7 @@ create_audio_list_type(view_sys *p_view_sys, audio_view_type type )
Evas_Object* p_list = p_view->pf_get_widget(p_view->p_sys); Evas_Object* p_list = p_view->pf_get_widget(p_view->p_sys);
Elm_Object_Item *it = elm_naviframe_item_push(p_view_sys->nf_toolbar, "", NULL, NULL, p_list, NULL); Elm_Object_Item *it = elm_naviframe_item_push(p_view_sys->nf_toolbar, "", NULL, NULL, p_list, NULL);
elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE); elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
elm_object_item_data_set(it, p_view);
evas_object_show(p_list); evas_object_show(p_list);
return p_view; return p_view;
...@@ -207,17 +208,29 @@ audio_view_callback(view_sys *p_view_sys, interface_view_event event) ...@@ -207,17 +208,29 @@ audio_view_callback(view_sys *p_view_sys, interface_view_event event)
return true; return true;
} }
case INTERFACE_VIEW_EVENT_BACK: case INTERFACE_VIEW_EVENT_BACK:
{
/* Hide overflow menu */
if (p_view_sys->p_overflow_menu) { if (p_view_sys->p_overflow_menu) {
evas_object_del(p_view_sys->p_overflow_menu); evas_object_del(p_view_sys->p_overflow_menu);
p_view_sys->p_overflow_menu = NULL; p_view_sys->p_overflow_menu = NULL;
return true; return true;
} }
/* Handle back button for sub views */
Elm_Object_Item *it = elm_naviframe_top_item_get(p_view_sys->nf_toolbar);
list_view* p_view = (list_view *)elm_object_item_data_get(it);
if (p_view && p_view->pf_view_event_back)
if (p_view->pf_view_event_back(p_view->p_sys) == true)
return true;
/* Pop view */
if (naviframe_count(p_view_sys->nf_toolbar) > 1) if (naviframe_count(p_view_sys->nf_toolbar) > 1)
{ {
elm_naviframe_item_pop(p_view_sys->nf_toolbar); elm_naviframe_item_pop(p_view_sys->nf_toolbar);
return true; return true;
} }
return false; return false;
}
default: default:
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment