raster pushed a commit to branch master.

http://git.enlightenment.org/apps/rage.git/commit/?id=05608eec3a7634b712576409f487d84f48de1b4a

commit 05608eec3a7634b712576409f487d84f48de1b4a
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Sat Nov 29 10:47:12 2014 +0900

    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
---
 src/bin/key.c |  4 ++++
 src/bin/win.c | 35 +++++++++++++++++++++++++++++++++++
 src/bin/win.h |  1 +
 3 files changed, 40 insertions(+)

diff --git a/src/bin/key.c b/src/bin/key.c
index d18730a..7079c86 100644
--- a/src/bin/key.c
+++ b/src/bin/key.c
@@ -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")))
      {
diff --git a/src/bin/win.c b/src/bin/win.c
index 1dc4f07..9904ef4 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -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)
 {
diff --git a/src/bin/win.h b/src/bin/win.h
index 8c96245..23e4f16 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -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);

-- 


Reply via email to