[MPlayer-cvslog] r35470 - in trunk/gui: interface.c interface.h util/list.c util/list.h win32/interface.c

ib subversion at mplayerhq.hu
Sun Nov 25 12:51:35 CET 2012


Author: ib
Date: Sun Nov 25 12:51:35 2012
New Revision: 35470

Log:
Move add_to_gui_playlist() to util/list.c.

It's not an interface related function, but a playlist utility one.

Additionally, add doxygen comments and change debug message.

As a result, the different implementation of add_to_gui_playlist() of
the Win32 GUI - the GUI uses code from util/list.c - can't have the same
name and thus will be renamed to import_file_into_gui() again, reverting
the r35467 and r35444 changes which were premature.

Modified:
   trunk/gui/interface.c
   trunk/gui/interface.h
   trunk/gui/util/list.c
   trunk/gui/util/list.h
   trunk/gui/win32/interface.c

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Sun Nov 25 12:37:52 2012	(r35469)
+++ trunk/gui/interface.c	Sun Nov 25 12:51:35 2012	(r35470)
@@ -834,38 +834,6 @@ int gui(int what, void *data)
     return True;
 }
 
-// This function adds/inserts one file into the gui playlist.
-int add_to_gui_playlist(const char *what, int how)
-{
-    char *filename, *pathname;
-    plItem *item;
-
-    if (!what || (how != PLAYLIST_ITEM_APPEND && how != PLAYLIST_ITEM_INSERT))
-        return 0;
-
-    filename = strdup(mp_basename(what));
-    pathname = strdup(what);
-
-    if (strlen(pathname) - strlen(filename) > 0)
-        pathname[strlen(pathname) - strlen(filename) - 1] = 0;                                            // we have some path, so remove / at end
-    else
-        pathname[strlen(pathname) - strlen(filename)] = 0;
-
-    item = calloc(1, sizeof(plItem));
-
-    if (!item)
-        return 0;
-
-    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] playtree, add: %s/%s\n", pathname, filename);
-
-    item->name = filename;
-    item->path = pathname;
-
-    listMgr(how, item);
-
-    return 1;
-}
-
 // This function imports the initial playtree (based on cmd-line files)
 // into the gui playlist by either:
 // - overwriting gui pl (enqueue=0)

Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h	Sun Nov 25 12:37:52 2012	(r35469)
+++ trunk/gui/interface.h	Sun Nov 25 12:51:35 2012	(r35470)
@@ -150,6 +150,4 @@ void mplayerLoadSubtitle(const char *nam
 void gmp_msg(int mod, int lev, const char *format, ...);
 //@}
 
-int add_to_gui_playlist(const char *what, int how);
-
 #endif /* MPLAYER_GUI_INTERFACE_H */

Modified: trunk/gui/util/list.c
==============================================================================
--- trunk/gui/util/list.c	Sun Nov 25 12:37:52 2012	(r35469)
+++ trunk/gui/util/list.c	Sun Nov 25 12:51:35 2012	(r35470)
@@ -27,6 +27,9 @@
 #include "list.h"
 #include "string.h"
 
+#include "mp_msg.h"
+#include "path.h"
+
 static plItem *plList;
 static plItem *plCurrent;
 
@@ -275,3 +278,42 @@ void listRepl(char ***list, const char *
     (*list)[i]     = strdup(replace);
     (*list)[i + 1] = NULL;
 }
+
+/**
+ * @brief Append or insert a file to the playlist.
+ *
+ * @param what file to be added
+ * @param how command (#PLAYLIST_ITEM_APPEND or #PLAYLIST_ITEM_INSERT) to be performed
+ *
+ * @return 1 (ok) or 0 (error)
+ */
+int add_to_gui_playlist(const char *what, int how)
+{
+    char *filename, *pathname;
+    plItem *item;
+
+    if (!what || (how != PLAYLIST_ITEM_APPEND && how != PLAYLIST_ITEM_INSERT))
+        return 0;
+
+    filename = strdup(mp_basename(what));
+    pathname = strdup(what);
+
+    if (strlen(pathname) - strlen(filename) > 0)
+        pathname[strlen(pathname) - strlen(filename) - 1] = 0;                                            // we have some path, so remove / at end
+    else
+        pathname[strlen(pathname) - strlen(filename)] = 0;
+
+    item = calloc(1, sizeof(plItem));
+
+    if (!item)
+        return 0;
+
+    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[list] adding %s/%s\n", pathname, filename);
+
+    item->name = filename;
+    item->path = pathname;
+
+    listMgr(how, item);
+
+    return 1;
+}

Modified: trunk/gui/util/list.h
==============================================================================
--- trunk/gui/util/list.h	Sun Nov 25 12:37:52 2012	(r35469)
+++ trunk/gui/util/list.h	Sun Nov 25 12:51:35 2012	(r35470)
@@ -55,4 +55,9 @@ void listRepl(char ***list, const char *
 void listSet(char ***list, const char *entry);
 //@}
 
+/// @name high-level list operations
+//@{
+int add_to_gui_playlist(const char *what, int how);
+//@}
+
 #endif /* MPLAYER_GUI_LIST_H */

Modified: trunk/gui/win32/interface.c
==============================================================================
--- trunk/gui/win32/interface.c	Sun Nov 25 12:37:52 2012	(r35469)
+++ trunk/gui/win32/interface.c	Sun Nov 25 12:51:35 2012	(r35470)
@@ -459,7 +459,7 @@ void uiSetFileName(char *dir, char *name
     filename = guiInfo.Filename;
 #ifdef __WINE__
     // When the GUI receives the files to be played in guiPlaylistInitialize()
-    // and guiPlaylistAdd(), it calls add_to_gui_playlist() where the call of
+    // and guiPlaylistAdd(), 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.
@@ -817,18 +817,18 @@ int gui(int what, void *data)
 }
 
 /* This function adds/inserts one file into the gui playlist */
-int add_to_gui_playlist(const char *what, int how)
+static int import_file_into_gui(char *pathname, int insert)
 {
     char filename[MAX_PATH];
     char *filepart = filename;
 
-    if (strstr(what, "://"))
+    if (strstr(pathname, "://"))
     {
-        mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", what);
-        mygui->playlist->add_track(mygui->playlist, what, NULL, NULL, 0);
+        mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname);
+        mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0);
         return 1;
     }
-    if (GetFullPathName(what, MAX_PATH, filename, &filepart))
+    if (GetFullPathName(pathname, MAX_PATH, filename, &filepart))
     {
         if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY))
         {
@@ -860,7 +860,7 @@ int guiPlaylistInitialize(play_tree_t *m
         {
             if (parse_filename(filename, my_playtree, config, 0))
                 result = 1;
-            else if (add_to_gui_playlist(filename, PLAYLIST_ITEM_APPEND)) /* Add it to end of list */
+            else if (import_file_into_gui(filename, 0)) /* Add it to end of list */
                 result = 1;
         }
     }
@@ -889,7 +889,7 @@ int guiPlaylistAdd(play_tree_t *my_playt
     if((my_pt_iter = pt_iter_create(&my_playtree, config)))
     {
         while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)
-            if (add_to_gui_playlist(filename, PLAYLIST_ITEM_INSERT)) /* insert it into the list and set plCurrent = new item */
+            if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */
                 result = 1;
         pt_iter_destroy(&my_pt_iter);
     }


More information about the MPlayer-cvslog mailing list