changeset 1553:f4ece39e4252 trunk

[svn] - saving now uses PlaylistContainer class. Because there is no PlaylistContainer implementations yet, saving is presently broken.
author nenolod
date Thu, 10 Aug 2006 18:49:44 -0700
parents aaca4aab4670
children 51c1bf500d3f
files ChangeLog audacious/playlist.c audacious/playlist.h audacious/playlist_container.h audacious/ui_playlist.c
diffstat 5 files changed, 28 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Aug 10 18:40:52 2006 -0700
+++ b/ChangeLog	Thu Aug 10 18:49:44 2006 -0700
@@ -1,3 +1,13 @@
+2006-08-11 01:40:52 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [2018]
+  - further integration
+  
+
+  Changes:        Modified:
+  +10 -0          trunk/audacious/playlist_container.c  
+  +2 -2           trunk/audacious/playlist_container.h  
+
+
 2006-08-11 01:39:05 +0000  William Pitcock <nenolod@nenolod.net>
   revision [2016]
   - fix
--- a/audacious/playlist.c	Thu Aug 10 18:40:52 2006 -0700
+++ b/audacious/playlist.c	Thu Aug 10 18:49:44 2006 -0700
@@ -63,11 +63,6 @@
 PlaylistEntry *playlist_position;
 G_LOCK_DEFINE(playlist);
 
-/* NOTE: match the order listed in PlaylistFormat enum */
-static const gchar *playlist_format_suffixes[] = { 
-    ".m3u", ".pls", NULL 
-};
-
 static GList *playlist = NULL;
 static GList *shuffle_list = NULL;
 static GList *queued_list = NULL;
@@ -126,12 +121,6 @@
 static void playlist_save_m3u(FILE * file);
 static void playlist_save_pls(FILE * file);
 
-static PlaylistSaveFunc playlist_save_func_table[] = {
-    playlist_save_m3u,
-    playlist_save_pls
-};
-
-
 static guint playlist_load_ins(const gchar * filename, gint pos);
 
 static void playlist_load_ins_file(const gchar * filename,
@@ -1325,21 +1314,23 @@
 }
 
 gboolean
-playlist_save(const gchar * filename,
-              PlaylistFormat format)
+playlist_save(const gchar * filename)
 {
-    FILE *file;
+    PlaylistContainer *plc = NULL;
+    gchar *ext;
 
     g_return_val_if_fail(filename != NULL, FALSE);
 
+    ext = strrchr(filename, '.') + 1;
+
     playlist_set_current_name(filename);
 
-    if ((file = fopen(filename, "w")) == NULL)
+    if ((plc = playlist_container_find(ext)) == NULL)
         return FALSE;
 
-    playlist_save_func_table[format](file);
-    
-    return (fclose(file) == 0);
+    plc->plc_write(filename, 0);
+
+    return TRUE;
 }
 
 gboolean
--- a/audacious/playlist.h	Thu Aug 10 18:40:52 2006 -0700
+++ b/audacious/playlist.h	Thu Aug 10 18:49:44 2006 -0700
@@ -103,7 +103,7 @@
 gchar *playlist_get_info_text(void);
 gint playlist_get_current_length(void);
 
-gboolean playlist_save(const gchar * filename, PlaylistFormat format);
+gboolean playlist_save(const gchar * filename);
 gboolean playlist_load(const gchar * filename);
 
 GList *playlist_get(void);
--- a/audacious/playlist_container.h	Thu Aug 10 18:40:52 2006 -0700
+++ b/audacious/playlist_container.h	Thu Aug 10 18:49:44 2006 -0700
@@ -36,6 +36,6 @@
 extern void playlist_container_unregister(PlaylistContainer *plc);
 extern void playlist_container_read(char *filename, gint pos);
 extern void playlist_container_write(char *filename, gint pos);
-
+extern PlaylistContainer *playlist_container_find(char *ext);
 
 #endif
--- a/audacious/ui_playlist.c	Thu Aug 10 18:40:52 2006 -0700
+++ b/audacious/ui_playlist.c	Thu Aug 10 18:49:44 2006 -0700
@@ -48,6 +48,7 @@
 #include "mainwin.h"
 #include "playback.h"
 #include "playlist.h"
+#include "playlist_container.h"
 #include "util.h"
 
 #include "pixmaps.h"
@@ -871,10 +872,11 @@
 static void
 playlistwin_save_playlist(const gchar * filename)
 {
-    PlaylistFormat format;
+    PlaylistContainer *plc;
+    gchar *ext = strrchr(filename, '.') + 1;
 
-    format = playlist_format_get_from_name(filename);
-    if (format == PLAYLIST_FORMAT_UNKNOWN) {
+    plc = playlist_container_find(ext);
+    if (plc == NULL) {
         show_playlist_save_format_error(GTK_WINDOW(playlistwin), filename);
         return;
     }
@@ -885,7 +887,7 @@
         if (!show_playlist_overwrite_prompt(GTK_WINDOW(playlistwin), filename))
             return;
 
-    if (!playlist_save(filename, format))
+    if (!playlist_save(filename))
         show_playlist_save_error(GTK_WINDOW(playlistwin), filename);
 }
 
@@ -1938,7 +1940,7 @@
         playlistwin_select_playlist_to_save(playlist_get_current_name());
         break;
     case PLIST_DEFAULTSAVE:
-        playlist_save(bmp_paths[BMP_PATH_PLAYLIST_FILE], FALSE);
+        playlist_save(bmp_paths[BMP_PATH_PLAYLIST_FILE]);
         break;
     case PLIST_SAVE_AS:
         playlistwin_select_playlist_to_save(playlist_get_current_name());