changeset 3337:99f34db2c3fc trunk

- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist. - modify playlist_load_ins() to return number of new entries.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Sun, 12 Aug 2007 21:21:46 +0900
parents 904c58081f0a
children 07ed916b7176
files src/audacious/playlist.c
diffstat 1 files changed, 15 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/playlist.c	Sat Aug 11 22:17:13 2007 -0700
+++ b/src/audacious/playlist.c	Sun Aug 12 21:21:46 2007 +0900
@@ -921,7 +921,10 @@
 guint
 playlist_add_url(Playlist * playlist, const gchar * url)
 {
-    return playlist_ins_url(playlist, url, -1);
+    guint entries;
+    entries = playlist_ins_url(playlist, url, -1);
+//    printf("playlist_add_url: entries = %d\n", entries);
+    return entries;
 }
 
 guint
@@ -967,19 +970,17 @@
                     gint pos)
 {
     gchar *tmp;
-    gint i = 1, entries = 0;
-    gboolean first = TRUE;
-    guint firstpos = 0;
-    gboolean success = FALSE;
+    gint entries = 0;
     gchar *decoded = NULL;
 
     g_return_val_if_fail(playlist != NULL, 0);
     g_return_val_if_fail(string != NULL, 0);
 
-    playlistwin_update_list(playlist);
+//    playlistwin_update_list(playlist); // is this necessary? --yaz
 
     while (*string) {
         GList *node;
+        guint i = 0;
         tmp = strchr(string, '\n');
         if (tmp) {
             if (*(tmp - 1) == '\r')
@@ -996,8 +997,7 @@
             if (is_playlist_name(decoded)) {
                 i = playlist_load_ins(playlist, decoded, pos);
             }
-            else {
-                success = playlist_ins(playlist, decoded, pos);
+            else if (playlist_ins(playlist, decoded, pos)) {
                 i = 1;
             }
         }
@@ -1010,11 +1010,6 @@
 
         entries += i;
 
-        if (first) {
-            first = FALSE;
-            firstpos = pos;
-        }
-
         if (pos >= 0)
             pos += i;
         if (!tmp)
@@ -1603,14 +1598,14 @@
 gboolean
 playlist_load(Playlist * playlist, const gchar * filename)
 {
-    gboolean ret = FALSE;
+    guint ret = 0;
     g_return_val_if_fail(playlist != NULL, FALSE);
 
     playlist->loading_playlist = TRUE;
     ret = playlist_load_ins(playlist, filename, -1);
     playlist->loading_playlist = FALSE;
 
-    return ret;
+    return ret ? TRUE : FALSE;
 }
 
 void
@@ -1753,7 +1748,8 @@
 {
     PlaylistContainer *plc;
     gchar *ext;
-
+    gint old_len, new_len;
+    
     g_return_val_if_fail(playlist != NULL, 0);
     g_return_val_if_fail(filename != NULL, 0);
 
@@ -1763,12 +1759,14 @@
     g_return_val_if_fail(plc != NULL, 0);
     g_return_val_if_fail(plc->plc_read != NULL, 0);
 
+    old_len = playlist_get_length(playlist);
     plc->plc_read(filename, pos);
+    new_len = playlist_get_length(playlist);
 
     playlist_generate_shuffle_list(playlist);
     playlistwin_update_list(playlist);
 
-    return 1;
+    return new_len - old_len;
 }
 
 GList *