Delete current media from playlist

Summary:
So you have unorganized files, or pseudo-organized files, and you dump them into rage. A song or video comes up that you don't want to bother with, so you want to hit delete to not play it.

This will be more useful later with a "loop all" feature, but I implemented it now because I often bump into this situation.

Reviewers: etrunko, raster

Projects: #rage

Differential Revision: https://phab.enlightenment.org/D1486

* also fix mem leak in not freeing vid struct content
This commit is contained in:
Carsten Haitzler 2014-11-29 10:47:12 +09:00
parent ae23214e0e
commit 05608eec3a
3 changed files with 40 additions and 0 deletions

View File

@ -130,6 +130,10 @@ key_handle(Evas_Object *win, Evas_Event_Key_Down *ev)
if (win_video_have_next(win)) win_video_last(win);
else win_video_next(win);
}
else if (!strcmp(ev->key, "Delete"))
{
win_video_delete(win);
}
else if ((!strcmp(ev->keyname, "m")) ||
(!strcmp(ev->key, "XF86AudioMute")))
{

View File

@ -250,6 +250,41 @@ win_video_last(Evas_Object *win)
win_list_sel_update(win);
}
void
win_video_delete(Evas_Object *win)
{
Inf *inf = evas_object_data_get(win, "inf");
Eina_List *l, *l_next;
Winvid_Entry *vid;
int direction = NULL; // -1 prev, 1 next
if (!inf->file_list) return;
// If we're able to delete something, do it,
// and decide on next/prev
if (win_video_have_next(win) || win_video_have_prev(win))
{
EINA_LIST_FOREACH_SAFE(inf->file_list, l, l_next, vid)
{
if (l == inf->file_cur)
{
if (vid->file) eina_stringshare_del(vid->file);
if (vid->sub) eina_stringshare_del(vid->sub);
free(vid);
inf->file_list = eina_list_remove_list(inf->file_list, l);
direction = (l_next == NULL ? -1 : 1);
break;
}
}
}
// Move to a direction and update playlist, which is confused
if (direction == -1) win_do_prev(win);
else if (direction == 1) win_do_next(win);
win_list_content_update(win);
}
Eina_Bool
win_video_have_next(Evas_Object *win)
{

View File

@ -37,6 +37,7 @@ void win_video_next(Evas_Object *win);
void win_video_prev(Evas_Object *win);
void win_video_first(Evas_Object *win);
void win_video_last(Evas_Object *win);
void win_video_delete(Evas_Object *win);
Eina_Bool win_video_have_next(Evas_Object *win);
Eina_Bool win_video_have_prev(Evas_Object *win);
Evas_Object *win_add(void);