raster pushed a commit to branch master.

http://git.enlightenment.org/apps/rage.git/commit/?id=873ed3c4b612c637e17eb282a9d8ec9cec3e66a7

commit 873ed3c4b612c637e17eb282a9d8ec9cec3e66a7
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Sat Nov 29 10:47:40 2014 +0900

    Keybind c to clear playlist
    
    Summary:
    It's somewhat annoying to keep restarting rage in order to manipulate the 
playlist. Having a keybind for clearing it
    goes a long way for usability.
    
    Test Plan: Add files. Hit c. Add more files. Skip around in the playlist. 
Clear. Add.
    
    Reviewers: etrunko, raster
    
    Projects: #rage
    
    Differential Revision: https://phab.enlightenment.org/D1484
    
    * fix mem leak of vid content
---
 src/bin/key.c    |  7 +++++++
 src/bin/winvid.c | 29 +++++++++++++++++++++++++++++
 src/bin/winvid.h |  1 +
 3 files changed, 37 insertions(+)

diff --git a/src/bin/key.c b/src/bin/key.c
index 7079c86..997ec81 100644
--- a/src/bin/key.c
+++ b/src/bin/key.c
@@ -110,6 +110,13 @@ key_handle(Evas_Object *win, Evas_Event_Key_Down *ev)
         video_stop(inf->vid);
         elm_layout_signal_emit(inf->lay, "action,stop", "rage");
      }
+   else if (!strcmp(ev->keyname, "c"))
+     {
+        printf("(c)lear!\n");
+        video_stop(inf->vid);
+        elm_layout_signal_emit(inf->lay, "action,stop", "rage");
+        win_video_free(win);
+     }
    else if ((!strcmp(ev->key, "Prior")) ||
             (!strcmp(ev->key, "XF86AudioPrev")))
      {
diff --git a/src/bin/winvid.c b/src/bin/winvid.c
index e30a776..aa97b32 100644
--- a/src/bin/winvid.c
+++ b/src/bin/winvid.c
@@ -240,6 +240,35 @@ win_video_insert(Evas_Object *win, const char *file)
 }
 
 void
+win_video_free(Evas_Object *win)
+{
+   Winvid_Entry *vid;
+   Inf *inf = evas_object_data_get(win, "inf");
+   if (!inf->file_list)
+     {
+        printf("AAAAIEEEEEE, no file_list\n");
+        return;
+     }
+
+   EINA_LIST_FREE(inf->file_list, vid)
+     {
+        printf("[%p] Free %s\n", vid, vid->file);
+        if (vid->file) eina_stringshare_del(vid->file);
+        if (vid->sub) eina_stringshare_del(vid->sub);
+        free(vid);
+     }
+
+   // Clean up inf state and reinit window
+   // to not confuse rage
+   inf->file_cur = NULL;
+   inf->vid = NULL;
+   win_video_init(win);
+
+   // Refresh to get rid of playlist icons/preview videos
+   win_list_content_update(win);
+}
+
+void
 win_video_goto(Evas_Object *win, Eina_List *l)
 {
    Inf *inf = evas_object_data_get(win, "inf");
diff --git a/src/bin/winvid.h b/src/bin/winvid.h
index 9e0a804..f7f6e42 100644
--- a/src/bin/winvid.h
+++ b/src/bin/winvid.h
@@ -10,6 +10,7 @@ typedef struct _Winvid_Entry
 void win_video_init(Evas_Object *win);
 void win_video_file_list_set(Evas_Object *win, Eina_List *list);
 void win_video_insert(Evas_Object *win, const char *file);
+void win_video_free(Evas_Object *win);
 void win_video_goto(Evas_Object *win, Eina_List *l);
 
 #endif

-- 


Reply via email to