[MPlayer-cvslog] r35444 - in trunk/gui: interface.c interface.h ui/gtk/fileselect.c ui/gtk/url.c win32/interface.c

ib subversion at mplayerhq.hu
Thu Nov 22 14:57:41 CET 2012


Author: ib
Date: Thu Nov 22 14:57:40 2012
New Revision: 35444

Log:
Rename import_file_into_gui() add_to_gui_playlist().

This seems to be a more appropriate name.

Additionally, use self-explanatory enum constants instead of numeric
ones, change the parameter names and a declaration to const, check the
parameters and print the debug message only if the item will really be
added.

(For the sake of consistency, adjust the Win32 code as well.)

Modified:
   trunk/gui/interface.c
   trunk/gui/interface.h
   trunk/gui/ui/gtk/fileselect.c
   trunk/gui/ui/gtk/url.c
   trunk/gui/win32/interface.c

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Thu Nov 22 14:13:29 2012	(r35443)
+++ trunk/gui/interface.c	Thu Nov 22 14:57:40 2012	(r35444)
@@ -835,33 +835,33 @@ int gui(int what, void *data)
 }
 
 // This function adds/inserts one file into the gui playlist.
-int import_file_into_gui(char *temp, int insert)
+int add_to_gui_playlist(const char *what, int how)
 {
     char *filename, *pathname;
     plItem *item;
 
-    filename = strdup(mp_basename(temp));
-    pathname = strdup(temp);
+    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;
 
-    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] playtree, add: %s/%s\n", pathname, filename);
-
     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;
 
-    if (insert)
-        listMgr(PLAYLIST_ITEM_INSERT, item);           // inserts the item after current, and makes current=item
-    else
-        listMgr(PLAYLIST_ITEM_APPEND, item);
+    listMgr(how, item);
 
     return 1;
 }
@@ -881,7 +881,7 @@ int guiPlaylistInitialize(play_tree_t *m
     if ((my_pt_iter = pt_iter_create(&my_playtree, config))) {
         while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)
             /* add it to end of list */
-            if (import_file_into_gui(filename, 0))
+            if (add_to_gui_playlist(filename, PLAYLIST_ITEM_APPEND))
                 result = 1;
     }
 
@@ -910,7 +910,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)
             /* insert it into the list and set plCurrent=new item */
-            if (import_file_into_gui(filename, 1))
+            if (add_to_gui_playlist(filename, PLAYLIST_ITEM_INSERT))
                 result = 1;
 
         pt_iter_destroy(&my_pt_iter);

Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h	Thu Nov 22 14:13:29 2012	(r35443)
+++ trunk/gui/interface.h	Thu Nov 22 14:57:40 2012	(r35444)
@@ -150,6 +150,6 @@ void mplayerLoadSubtitle(const char *nam
 void gmp_msg(int mod, int lev, const char *format, ...);
 //@}
 
-int import_file_into_gui(char *temp, int insert);
+int add_to_gui_playlist(const char *what, int how);
 
 #endif /* MPLAYER_GUI_INTERFACE_H */

Modified: trunk/gui/ui/gtk/fileselect.c
==============================================================================
--- trunk/gui/ui/gtk/fileselect.c	Thu Nov 22 14:13:29 2012	(r35443)
+++ trunk/gui/ui/gtk/fileselect.c	Thu Nov 22 14:57:40 2012	(r35444)
@@ -32,6 +32,7 @@
 
 #include "gui/app.h"
 #include "gui/interface.h"
+#include "gui/util/list.h"
 #include "gui/util/mem.h"
 #include "gui/util/string.h"
 #include "help_mp.h"
@@ -510,7 +511,7 @@ static void fs_Ok_released( GtkButton * 
           selected = g_strconcat(fsSelectedDirectory, "/", fsSelectedFile, NULL);
           if (selected)
           {
-            import_file_into_gui(selected, 0);
+            add_to_gui_playlist(selected, PLAYLIST_ITEM_APPEND);
             g_free(selected);
           }
           guiInfo.NewPlay=GUI_FILE_NEW; sub_fps=0;

Modified: trunk/gui/ui/gtk/url.c
==============================================================================
--- trunk/gui/ui/gtk/url.c	Thu Nov 22 14:13:29 2012	(r35443)
+++ trunk/gui/ui/gtk/url.c	Thu Nov 22 14:57:40 2012	(r35444)
@@ -103,7 +103,7 @@ static void on_Button_pressed( GtkButton
      listMgr( URLLIST_ITEM_ADD,item );
 
      uiSetFileName( NULL,str,STREAMTYPE_STREAM ); guiInfo.NewPlay=GUI_FILE_NEW;
-     import_file_into_gui(str, 0);
+     add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND);
      uiEventHandling( evPlay,0 );
     }
   }

Modified: trunk/gui/win32/interface.c
==============================================================================
--- trunk/gui/win32/interface.c	Thu Nov 22 14:13:29 2012	(r35443)
+++ trunk/gui/win32/interface.c	Thu Nov 22 14:57:40 2012	(r35444)
@@ -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 import_file_into_gui() where the call of
+    // and guiPlaylistAdd(), it calls add_to_gui_playlist() 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 */
-static int import_file_into_gui(char *pathname, int insert)
+static int add_to_gui_playlist(const char *what, int how)
 {
     char filename[MAX_PATH];
     char *filepart = filename;
 
-    if (strstr(pathname, "://"))
+    if (strstr(what, "://"))
     {
-        mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname);
-        mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0);
+        mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", what);
+        mygui->playlist->add_track(mygui->playlist, what, NULL, NULL, 0);
         return 1;
     }
-    if (GetFullPathName(pathname, MAX_PATH, filename, &filepart))
+    if (GetFullPathName(what, 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 (import_file_into_gui(filename, 0)) /* Add it to end of list */
+            else if (add_to_gui_playlist(filename, PLAYLIST_ITEM_APPEND)) /* 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 (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */
+            if (add_to_gui_playlist(filename, PLAYLIST_ITEM_INSERT)) /* 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