changeset 35510:06aa6dc71613

Combine guiPlaylistInitialize() and guiPlaylistAdd(). New guiPlaylist() handles both now according to the instruction passed to it.
author ib
date Wed, 05 Dec 2012 11:51:08 +0000
parents 01b3dd463acb
children 6616645f91ea
files gui/interface.c gui/interface.h gui/win32/interface.c mplayer.c
diffstat 4 files changed, 39 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/gui/interface.c	Wed Dec 05 08:35:23 2012 +0000
+++ b/gui/interface.c	Wed Dec 05 11:51:08 2012 +0000
@@ -853,14 +853,18 @@
     return True;
 }
 
+int guiPlaylist(int what, play_tree_t *my_playtree, m_config_t *config, int enqueue)
+{
+    play_tree_iter_t *my_pt_iter = NULL;
+    int added = False;
+    plItem *save;
+
+    switch (what) {
 // This function imports the initial playtree (based on cmd-line files)
 // into the gui playlist by either:
 // - overwriting gui pl (enqueue=0)
 // - appending it to gui pl (enqueue=1)
-int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue)
-{
-    play_tree_iter_t *my_pt_iter = NULL;
-    int added = False;
+    case GUI_PLAYLIST_INIT:
 
     if (!enqueue)
         listMgr(PLAYLIST_DELETE, 0);             // delete playlist before "appending"
@@ -881,19 +885,14 @@
     if (added)
         guiInfo.Track = 1;
 
-    return added;
-}
+        break;
 
 // This function imports and inserts an playtree, that is created "on the fly",
 // for example by parsing some MOV-Reference-File; or by loading an playlist
 // with "File Open". (The latter, actually, isn't allowed in MPlayer and thus
 // not working which is why this function won't get called for that reason.)
 // The file which contained the playlist is thereby replaced with it's contents.
-int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config)
-{
-    play_tree_iter_t *my_pt_iter = NULL;
-    int added = False;
-    plItem *save;
+    case GUI_PLAYLIST_ADD:
 
     save = (plItem *)listMgr(PLAYLIST_ITEM_GET_CURR, 0);    // save current item
 
@@ -916,6 +915,9 @@
 
     uiCurr();   // update filename
 
+        break;
+    }
+
     return added;
 }
 
--- a/gui/interface.h	Wed Dec 05 08:35:23 2012 +0000
+++ b/gui/interface.h	Wed Dec 05 11:51:08 2012 +0000
@@ -55,6 +55,12 @@
     GUI_SET_VIDEO
 };
 
+/// guiPlaylist() instructions
+enum {
+    GUI_PLAYLIST_INIT,
+    GUI_PLAYLIST_ADD
+};
+
 //@{
 /// Playing state
 #define GUI_STOP  0
@@ -140,8 +146,7 @@
 int gui(int what, void *data);
 void guiDone(void);
 void guiInit(void);
-int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config);
-int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue);
+int guiPlaylist(int what, play_tree_t *my_playtree, m_config_t *config, int enqueue);
 //@}
 
 /// @name GUI -> MPlayer
--- a/gui/win32/interface.c	Wed Dec 05 08:35:23 2012 +0000
+++ b/gui/win32/interface.c	Wed Dec 05 11:51:08 2012 +0000
@@ -182,7 +182,7 @@
     if(strstr(file, ".m3u") || strstr(file, ".pls"))
     {
         playtree = parse_playlist_file(file);
-        guiPlaylistAdd(playtree, mconfig);
+        guiPlaylist(GUI_PLAYLIST_ADD, playtree, mconfig, 0);
         return 1;
     }
     return 0;
@@ -457,8 +457,8 @@
 
     filename = guiInfo.Filename;
 #ifdef __WINE__
-    // When the GUI receives the files to be played in guiPlaylistInitialize()
-    // and guiPlaylistAdd(), it calls import_file_into_gui() where the call of
+    // When the GUI receives the files to be played in guiPlaylist(),
+    // it calls import_file_into_gui() where the call of
     // Wine's GetFullPathName() converts each file name into the Windows style
     // (C:\path\to\file), which needs to be reconverted for MPlayer, so that
     // it will find the filename in the Linux filesystem.
@@ -842,14 +842,17 @@
     return 0;
 }
 
+int guiPlaylist (int what, play_tree_t *my_playtree, m_config_t *config, int enqueue)
+{
+    play_tree_iter_t *my_pt_iter = NULL;
+    int added = FALSE;
+
+    switch (what)
+    {
 /*  This function imports the initial playtree (based on cmd-line files) into the gui playlist
     by either:
     - overwriting gui pl (enqueue=0) */
-
-int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue)
-{
-    play_tree_iter_t *my_pt_iter = NULL;
-    int added = FALSE;
+      case GUI_PLAYLIST_INIT:
 
     if(!mygui) guiInit();
 
@@ -873,17 +876,12 @@
 
     if (enqueue) filename = NULL;
 
-    return added;
-}
+          break;
 
 /* This function imports and inserts an playtree, that is created "on the fly", for example by
    parsing some MOV-Reference-File; or by loading an playlist with "File Open"
    The file which contained the playlist is thereby replaced with it's contents. */
-
-int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config)
-{
-    play_tree_iter_t *my_pt_iter = NULL;
-    int added = FALSE;
+        case GUI_PLAYLIST_ADD:
 
     if((my_pt_iter = pt_iter_create(&my_playtree, config)))
     {
@@ -892,6 +890,10 @@
                 added = TRUE;
         pt_iter_destroy(&my_pt_iter);
     }
+
+          break;
+    }
+
     return added;
 }
 
--- a/mplayer.c	Wed Dec 05 08:35:23 2012 +0000
+++ b/mplayer.c	Wed Dec 05 11:51:08 2012 +0000
@@ -1033,7 +1033,7 @@
 #ifdef CONFIG_GUI
     if (use_gui) {
         if (entry) {
-            guiPlaylistAdd(entry, mconfig);
+            guiPlaylist(GUI_PLAYLIST_ADD, entry, mconfig, 0);
             play_tree_free_list(entry, 1);
         }
     } else
@@ -2859,7 +2859,7 @@
             play_tree_add_bpf(mpctx->playtree, cwd);
         }
         // Import initital playtree into GUI.
-        guiPlaylistInitialize(mpctx->playtree, mconfig, enqueue);
+        guiPlaylist(GUI_PLAYLIST_INIT, mpctx->playtree, mconfig, enqueue);
     }
 #endif /* CONFIG_GUI */