changeset 3483:063b0d52e49e trunk

Automated merge with ssh://hg.atheme.org//hg/audacious
author William Pitcock <nenolod@atheme.org>
date Mon, 10 Sep 2007 00:47:23 -0500
parents 54d6336163fe (current diff) 308e5fb348db (diff)
children 7b5353d0ae50
files
diffstat 11 files changed, 429 insertions(+), 215 deletions(-) [+]
line wrap: on
line diff
--- a/po/ja.po	Mon Sep 10 00:47:18 2007 -0500
+++ b/po/ja.po	Mon Sep 10 00:47:23 2007 -0500
@@ -14,7 +14,7 @@
 "Project-Id-Version: audacious HEAD\n"
 "Report-Msgid-Bugs-To: http://bugs.audacious-media-player.org\n"
 "POT-Creation-Date: 2007-09-05 19:18+0200\n"
-"PO-Revision-Date: 2007-09-04 20:46+0900\n"
+"PO-Revision-Date: 2007-09-10 09:20+0900\n"
 "Last-Translator: dai <d+po@vdr.jp>\n"
 "Language-Team: Japanese <ja@li.org>\n"
 "MIME-Version: 1.0\n"
@@ -544,7 +544,7 @@
 
 #: src/audacious/glade/prefswin.glade:4364
 msgid "Interpolation Engine:"
-msgstr ""
+msgstr "インターポレーションエンジン:"
 
 #: src/audacious/glade/prefswin.glade:4593
 msgid "Reload Plugins"
@@ -1823,18 +1823,16 @@
 msgstr "選択範囲のソート"
 
 #: src/audacious/ui_manager.c:380
-#, fuzzy
 msgid "File"
-msgstr "ファイア"
+msgstr "ファイル"
 
 #: src/audacious/ui_manager.c:381
 msgid "Help"
-msgstr ""
+msgstr "ヘルプ"
 
 #: src/audacious/ui_manager.c:383
-#, fuzzy
 msgid "Plugin Services"
-msgstr "プラグイン"
+msgstr "プラグインサービス"
 
 #: src/audacious/ui_manager.c:385 src/audacious/ui_manager.c:388
 msgid "View Track Details"
--- a/src/audacious/dock.c	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/dock.c	Mon Sep 10 00:47:23 2007 -0500
@@ -224,7 +224,6 @@
     for (node = list; node; node = g_list_next(node)) {
         dw = node->data;
         gtk_window_move(dw->w, x + dw->offset_x, y + dw->offset_y);
-        gdk_flush();
     }
 }
 
@@ -471,7 +470,8 @@
         return;
 
     gtk_window_present(w);
-    gdk_window_get_pointer(GTK_WIDGET(w)->window, &mx, &my, NULL);
+    mx = event->x;
+    my = event->y;
     gtk_object_set_data(GTK_OBJECT(w), "move_offset_x", GINT_TO_POINTER(mx));
     gtk_object_set_data(GTK_OBJECT(w), "move_offset_y", GINT_TO_POINTER(my));
     if (move_list)
@@ -490,12 +490,10 @@
 void
 dock_move_motion(GtkWindow * w, GdkEventMotion * event)
 {
-    gint offset_x, offset_y, win_x, win_y, x, y, mx, my;
+    gint offset_x, offset_y, win_x, win_y, x, y;
     GList *dlist;
     GList *window_list;
 
-    gdk_flush();
-
     if (!gtk_object_get_data(GTK_OBJECT(w), "is_moving"))
         return;
 
@@ -508,10 +506,8 @@
 
     gtk_window_get_position(w, &win_x, &win_y);
 
-    gdk_window_get_pointer(NULL, &mx, &my, NULL);
-
-    x = mx - offset_x;
-    y = my - offset_y;
+    x = event->x_root - offset_x;
+    y = event->y_root - offset_y;
 
     calc_snap_offset(dlist, window_list, x, y, &offset_x, &offset_y);
     x += offset_x;
--- a/src/audacious/main.c	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/main.c	Mon Sep 10 00:47:23 2007 -0500
@@ -676,6 +676,120 @@
         cfg.get_info_on_demand = TRUE;
 }
 
+static gboolean
+save_extra_playlist(const gchar * path, const gchar * basename,
+        gpointer savedlist)
+{
+    GList *playlists, *iter;
+    GList **saved;
+    Playlist *playlist;
+    int found;
+    gchar *filename;
+
+    playlists = playlist_get_playlists();
+    saved = (GList **) savedlist;
+
+    found = 0;
+    for (iter = playlists; iter; iter = iter->next) {
+        playlist = (Playlist *) iter->data;
+        if (g_list_find(*saved, playlist)) continue;
+        filename = playlist_filename_get(playlist);
+        if (!filename) continue;
+        if (strcmp(filename, path) == 0) {
+            /* Save playlist */
+            playlist_save(playlist, path);
+            *saved = g_list_prepend(*saved, playlist);
+            found = 1;
+            g_free(filename);
+            break;
+        }
+        g_free(filename);
+    }
+
+    if(!found) {
+        /* Remove playlist */
+        unlink(path);
+    }
+
+    return FALSE; /* process other playlists */
+}
+
+static void
+save_other_playlists(GList *saved)
+{
+    GList *playlists, *iter;
+    Playlist *playlist;
+    gchar *pos, *ext, *basename, *filename, *newbasename;
+    int i, num, isdigits;
+
+    playlists = playlist_get_playlists();
+    for(iter = playlists; iter; iter = iter->next) {
+        playlist = (Playlist *) iter->data;
+        if (g_list_find(saved, playlist)) continue;
+        filename = playlist_filename_get(playlist);
+        if (!filename || !filename[0]
+                || g_file_test(filename, G_FILE_TEST_IS_DIR)) {
+            /* default basename */
+#ifdef HAVE_XSPF_PLAYLIST
+            basename = g_strdup("playlist_01.xspf");
+#else
+            basename = g_strdup("playlist_01.m3u");
+#endif
+        } else {
+            basename = g_path_get_basename(filename);
+        }
+        g_free(filename);
+        if ((pos = strrchr(basename, '.'))) {
+            *pos = '\0';
+        }
+#ifdef HAVE_XSPF_PLAYLIST
+        ext = ".xspf";
+#else
+        ext = ".m3u";
+#endif
+        num = -1;
+        if ((pos = strrchr(basename, '_'))) {
+            isdigits = 0;
+            for (i=1; pos[i]; i++) {
+                if (!g_ascii_isdigit(pos[i])) {
+                    isdigits = 0;
+                    break;
+                }
+                isdigits = 1;
+            }
+            if (isdigits) {
+                num = atoi(pos+1) + 1;
+                *pos = '\0';
+            }
+        }
+        /* attempt to generate unique filename */
+        filename = NULL;
+        do {
+            g_free(filename);
+            if (num < 0) {
+                /* try saving without number first */
+                newbasename = g_strdup_printf("%s%s", basename, ext);
+                num = 1;
+            } else {
+                newbasename = g_strdup_printf("%s_%02d%s", basename, num, ext);
+                num++;
+                if (num < 0) {
+                    g_warning("Playlist number in filename overflowed."
+                            " Not saving playlist.\n");
+                    goto cleanup;
+                }
+            }
+            filename = g_build_filename(bmp_paths[BMP_PATH_PLAYLISTS_DIR],
+                    newbasename, NULL);
+            g_free(newbasename);
+        } while (g_file_test(filename, G_FILE_TEST_EXISTS));
+
+        playlist_save(playlist, filename);
+cleanup:
+        g_free(filename);
+        g_free(basename);
+    }
+}
 
 void
 bmp_config_save(void)
@@ -684,6 +798,7 @@
     gchar *str;
     gint i, cur_pb_time;
     ConfigDb *db;
+    GList *saved;
     Playlist *playlist = playlist_get_active();
 
     cfg.disabled_iplugins = input_stringify_disabled_list();
@@ -820,6 +935,16 @@
     bmp_cfg_db_close(db);
 
     playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]);
+
+    /* Save extra playlists that were loaded from PLAYLISTS_DIR  */
+    saved = NULL;
+    if(!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], save_extra_playlist,
+            &saved, NULL)) {
+        g_warning("Could not save extra playlists\n");
+    }
+
+    /* Save other playlists to PLAYLISTS_DIR */
+    save_other_playlists(saved);
 }
 
 static void
@@ -1108,6 +1233,35 @@
     return TRUE;
 }
 
+static gboolean
+load_extra_playlist(const gchar * path, const gchar * basename,
+        gpointer def)
+{
+    const gchar *title;
+    Playlist *playlist;
+    Playlist *deflist;
+
+    deflist = (Playlist *)def;
+    playlist = playlist_new();
+    if (!playlist) {
+        g_warning("Couldn't create new playlist\n");
+        return FALSE;
+    }
+
+    playlist_add_playlist(playlist);
+    playlist_load(playlist, path);
+
+    title = playlist_get_current_name(playlist);
+
+    if (playlist_playlists_equal(playlist, deflist)) {
+        /* same as default playlist */
+        playlist_remove_playlist(playlist);
+        playlist_filename_set(deflist, path);
+    }
+
+    return FALSE; /* keep loading other playlists */
+}
+
 gint
 main(gint argc, gchar ** argv)
 {
@@ -1231,6 +1385,12 @@
     playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]);
     playlist_set_position(playlist, cfg.playlist_position);
 
+    /* Load extra playlists */
+    if(!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], load_extra_playlist,
+            playlist, NULL)) {
+        g_warning("Could not load extra playlists\n");
+    }
+
     /* this needs to be called after all 3 windows are created and
      * input plugins are setup'ed 
      * but not if we're running headless --nenolod
--- a/src/audacious/playlist.c	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/playlist.c	Mon Sep 10 00:47:23 2007 -0500
@@ -282,8 +282,10 @@
 void
 playlist_remove_playlist(Playlist *playlist)
 {
+    gboolean active;
+    active = (playlist && playlist == playlist_get_active());
     /* users suppose playback will be stopped on removing playlist */
-    if (playback_get_playing()) {
+    if (active && playback_get_playing()) {
         ip_data.stop = TRUE;
         playback_stop();
         ip_data.stop = FALSE;
@@ -294,11 +296,11 @@
     if (g_list_length(playlists) < 2) {
         playlist_clear(playlist);
         playlist_set_current_name(playlist, NULL);
+        playlist_filename_set(playlist, NULL);
         return;
     }
 
-    if (playlist == playlist_get_active())
-        playlist_select_next();
+    if (active) playlist_select_next();
 
     /* upon removal, a playlist should be cleared and freed */
     playlists = g_list_remove(playlists, playlist);
@@ -364,22 +366,50 @@
     return playlist->title;
 }
 
-/* filename is real filename here. --yaz */
+/* This function now sets the playlist title, not the playlist filename.
+ * See playlist_filename_set */
 gboolean
-playlist_set_current_name(Playlist *playlist, const gchar * filename)
+playlist_set_current_name(Playlist *playlist, const gchar * title)
 {
-    if (playlist->title)
-        g_free(playlist->title);
-
-    if (!filename) {
+    gchar *oldtitle;
+    oldtitle = playlist->title;
+
+    if (!title) {
         playlist->title = NULL;
+        if(oldtitle) g_free(oldtitle);
         return FALSE;
     }
 
-    playlist->title = filename_to_utf8(filename);
+    playlist->title = str_to_utf8(title);
+    if(oldtitle) g_free(oldtitle);
     return TRUE;
 }
 
+/* Setting the filename allows the original playlist to be modified later */
+gboolean
+playlist_filename_set(Playlist *playlist, const gchar * filename)
+{
+    gchar *old;
+    old = playlist->filename;
+
+    if(!filename) {
+        playlist->filename = NULL;
+        if(old) g_free(old);
+        return FALSE;
+    }
+
+    playlist->filename = filename_to_utf8(filename);
+    if(old) g_free(old);
+    return TRUE;
+}
+
+gchar *
+playlist_filename_get(Playlist *playlist)
+{
+    if(!playlist->filename) return NULL;
+    return g_filename_from_utf8(playlist->filename, -1, NULL, NULL, NULL);
+}
+
 static GList *
 find_playlist_position_list(Playlist *playlist)
 {
@@ -413,7 +443,7 @@
 void
 playlist_clear_only(Playlist *playlist)
 {
-    PLAYLIST_LOCK( playlist->mutex );
+    PLAYLIST_LOCK(playlist);
 
     g_list_foreach(playlist->entries, (GFunc) playlist_entry_free, NULL);
     g_list_free(playlist->entries);
@@ -422,7 +452,7 @@
     playlist->tail = NULL;
     playlist->attribute = PLAYLIST_PLAIN;
 
-    PLAYLIST_UNLOCK( playlist->mutex );
+    PLAYLIST_UNLOCK(playlist);
 }
 
 void
@@ -459,11 +489,11 @@
         *set_info_text = TRUE;
 
         if (playback_get_playing()) {
-            PLAYLIST_UNLOCK(playlist->mutex);
+            PLAYLIST_UNLOCK(playlist);
             ip_data.stop = TRUE;
             playback_stop();
             ip_data.stop = FALSE;
-            PLAYLIST_LOCK(playlist->mutex);
+            PLAYLIST_LOCK(playlist);
             *restart_playing = TRUE;
         }
 
@@ -505,18 +535,18 @@
     if (!playlist)
         return;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     node = g_list_nth(playlist->entries, pos);
 
     if (!node) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
 
     playlist_delete_node(playlist, node, &set_info_text, &restart_playing);
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_recalc_total_time(playlist);
 
@@ -538,7 +568,7 @@
     GList *node, *fnode;
     gboolean set_info_text = FALSE, restart_playing = FALSE;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     for (fnode = filenames; fnode; fnode = g_list_next(fnode)) {
         node = playlist->entries;
@@ -554,7 +584,7 @@
         }
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_recalc_total_time(playlist);
     playlistwin_update_list(playlist);
@@ -579,7 +609,7 @@
 
     g_return_if_fail(playlist != NULL);
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     node = playlist->entries;
 
@@ -595,7 +625,7 @@
         node = next_node;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_recalc_total_time(playlist);
 
@@ -621,11 +651,11 @@
 {
     g_return_if_fail(filename != NULL);
 
-    PLAYLIST_LOCK( playlist->mutex );
+    PLAYLIST_LOCK(playlist);
     playlist->entries = g_list_insert(playlist->entries,
                              playlist_entry_new(filename, title, len, dec),
                              pos);
-    PLAYLIST_UNLOCK( playlist->mutex );
+    PLAYLIST_UNLOCK(playlist);
 
     g_mutex_lock(mutex_scan);
     playlist_get_info_scan_active = TRUE;
@@ -649,7 +679,8 @@
     if(!playlist->tail)
         playlist->tail = g_list_last(playlist->entries);
 
-    PLAYLIST_LOCK( playlist->mutex );
+    PLAYLIST_LOCK(playlist);
+    
     if(pos == -1) { // the common case
         GList *element;
         element = g_list_alloc();
@@ -671,7 +702,8 @@
         playlist->entries = g_list_insert(playlist->entries, entry, pos);
     }
 
-    PLAYLIST_UNLOCK( playlist->mutex );
+    PLAYLIST_UNLOCK(playlist);
+    
     if (tuple != NULL) {
         const gchar *formatter = tuple_get_string(tuple, "formatter");
         entry->title = tuple_formatter_make_title_string(tuple, formatter ?
@@ -1003,9 +1035,9 @@
 
         g_free(decoded);
 
-        PLAYLIST_LOCK(playlist->mutex);
+        PLAYLIST_LOCK(playlist);
         node = g_list_nth(playlist->entries, pos);
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
 
         entries += i;
 
@@ -1097,23 +1129,23 @@
     if (!playlist)
         return;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     if (!playlist->position || !playlistwin_list) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
 
     pos = g_list_index(playlist->entries, playlist->position);
 
     if (playlistwin_item_visible(pos)) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
 
     bottom = MAX(0, playlist_get_length(playlist) -
                  UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible);
     row = CLAMP(pos - UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible / 2, 0, bottom);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     playlistwin_set_toprow(row);
     g_cond_signal(cond_scan);
 }
@@ -1126,7 +1158,7 @@
     if (!playlist_get_length(playlist))
         return;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if ((playlist_position_before_jump != NULL) && playlist->queue == NULL)
     {
@@ -1137,17 +1169,17 @@
     plist_pos_list = find_playlist_position_list(playlist);
 
     if (!cfg.repeat && !g_list_next(plist_pos_list) && playlist->queue == NULL) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
 
     if (playback_get_playing()) {
         /* We need to stop before changing playlist_position */
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         ip_data.stop = TRUE;
         playback_stop();
         ip_data.stop = FALSE;
-        PLAYLIST_LOCK(playlist->mutex);
+        PLAYLIST_LOCK(playlist);
         restart_playing = TRUE;
     }
 
@@ -1164,7 +1196,7 @@
         else
             playlist->position = playlist->entries->data;
     }
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     playlist_check_pos_current(playlist);
 
     if (restart_playing)
@@ -1182,7 +1214,7 @@
     if (!playlist_get_length(playlist))
         return;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if ((playlist_position_before_jump != NULL) && playlist->queue == NULL)
     {
@@ -1193,17 +1225,17 @@
     plist_pos_list = find_playlist_position_list(playlist);
 
     if (!cfg.repeat && !g_list_previous(plist_pos_list)) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
 
     if (playback_get_playing()) {
         /* We need to stop before changing playlist_position */
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         ip_data.stop = TRUE;
         playback_stop();
         ip_data.stop = FALSE;
-        PLAYLIST_LOCK(playlist->mutex);
+        PLAYLIST_LOCK(playlist);
         restart_playing = TRUE;
     }
 
@@ -1223,7 +1255,7 @@
             playlist->position = node->data;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_check_pos_current(playlist);
 
@@ -1239,7 +1271,7 @@
     GList *list = playlist_get_selected(playlist);
     GList *it = list;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if ((cfg.shuffle) && (playlist_position_before_jump == NULL))
     {
@@ -1265,7 +1297,7 @@
 
     playlist->queue = g_list_concat(playlist->queue, list);
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_recalc_total_time(playlist);
     playlistwin_update_list(playlist);
@@ -1277,7 +1309,7 @@
     GList *tmp;
     PlaylistEntry *entry;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if ((cfg.shuffle) && (playlist_position_before_jump == NULL))
     {
@@ -1292,7 +1324,7 @@
     }
     else
         playlist->queue = g_list_append(playlist->queue, entry);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_recalc_total_time(playlist);
     playlistwin_update_list(playlist);
@@ -1304,10 +1336,10 @@
     PlaylistEntry *entry;
     GList *tmp;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     entry = g_list_nth_data(playlist->entries, pos);
     tmp = g_list_find(playlist->queue, entry);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     return tmp != NULL;
 }
@@ -1318,10 +1350,10 @@
     PlaylistEntry *entry;
     gint tmp;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     entry = g_list_nth_data(playlist->entries, pos);
     tmp = g_list_index(playlist->queue, entry);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     return tmp;
 }
@@ -1332,10 +1364,10 @@
     PlaylistEntry *entry;
     gint tmp;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     entry = g_list_nth_data(playlist->queue, pos);
     tmp = g_list_index(playlist->entries, entry);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     return tmp;
 }
@@ -1343,10 +1375,10 @@
 void
 playlist_clear_queue(Playlist *playlist)
 {
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     g_list_free(playlist->queue);
     playlist->queue = NULL;
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_recalc_total_time(playlist);
     playlistwin_update_list(playlist);
@@ -1357,10 +1389,10 @@
 {
     void *entry;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     entry = g_list_nth_data(playlist->entries, pos);
     playlist->queue = g_list_remove(playlist->queue, entry);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlistwin_update_list(playlist);
 }
@@ -1380,21 +1412,21 @@
     if (!playlist)
         return;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     node = g_list_nth(playlist->entries, pos);
     if (!node) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
 
     if (playback_get_playing()) {
         /* We need to stop before changing playlist_position */
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         ip_data.stop = TRUE;
         playback_stop();
         ip_data.stop = FALSE;
-        PLAYLIST_LOCK(playlist->mutex);
+        PLAYLIST_LOCK(playlist);
         restart_playing = TRUE;
     }
 
@@ -1405,7 +1437,7 @@
     }
 
     playlist->position = node->data;
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     playlist_check_pos_current(playlist);
 
     if (restart_playing)
@@ -1427,7 +1459,7 @@
 
     hook_call("playback end", playlist->position);
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     
     if ((playlist_position_before_jump != NULL) && playlist->queue == NULL)
     {
@@ -1438,7 +1470,7 @@
     plist_pos_list = find_playlist_position_list(playlist);
 
     if (cfg.no_playlist_advance) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         mainwin_clear_song_info();
         if (cfg.repeat)
             playback_initiate();
@@ -1446,7 +1478,7 @@
     }
 
     if (cfg.stopaftersong) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         mainwin_clear_song_info();
         mainwin_set_stopaftersong(FALSE);
         return;
@@ -1464,7 +1496,7 @@
             playlist->position = playlist->entries->data;
 
         if (!cfg.repeat) {
-            PLAYLIST_UNLOCK(playlist->mutex);
+            PLAYLIST_UNLOCK(playlist);
 	    hook_call("playlist end reached", playlist->position);
             mainwin_clear_song_info();
             return;
@@ -1473,7 +1505,7 @@
     else
         playlist->position = g_list_next(plist_pos_list)->data;
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_check_pos_current(playlist);
     playback_initiate();
@@ -1485,9 +1517,9 @@
 {
     gint length;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     length = g_list_length(playlist->queue);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     return length;
 }
@@ -1505,9 +1537,9 @@
 
     g_return_val_if_fail(playlist != NULL, NULL);
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     if (!playlist->position) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return NULL;
     }
 
@@ -1543,7 +1575,7 @@
     else
         length = g_strdup("");
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     text = convert_title_text(g_strconcat(numbers, title, length, NULL));
 
@@ -1572,6 +1604,7 @@
 playlist_save(Playlist * playlist, const gchar * filename)
 {
     PlaylistContainer *plc = NULL;
+    GList *old_iter;
     gchar *ext;
 
     g_return_val_if_fail(playlist != NULL, FALSE);
@@ -1579,16 +1612,22 @@
 
     ext = strrchr(filename, '.') + 1;
 
-    if (!playlist->title || !playlist->title[0])
-        playlist_set_current_name(playlist, filename);
-
     if ((plc = playlist_container_find(ext)) == NULL)
         return FALSE;
 
     if (plc->plc_write == NULL)
         return FALSE;
 
-    plc->plc_write(filename, 0);
+    /* Save the right playlist to disk */
+    if (playlist != playlist_get_active()) {
+        old_iter = playlists_iter;
+        playlists_iter = g_list_find(playlists, playlist);
+        if(!playlists_iter) playlists_iter = old_iter;
+        plc->plc_write(filename, 0);
+        playlists_iter = old_iter;
+    } else {
+        plc->plc_write(filename, 0);
+    }
 
     return TRUE;
 }
@@ -1600,6 +1639,10 @@
     g_return_val_if_fail(playlist != NULL, FALSE);
 
     playlist->loading_playlist = TRUE;
+    if(!playlist_get_length(playlist)) {
+        /* Loading new playlist */
+        playlist_filename_set(playlist, filename);
+    }
     ret = playlist_load_ins(playlist, filename, -1);
     playlist->loading_playlist = FALSE;
 
@@ -1763,7 +1806,7 @@
     if (playlist != playlist_get_active()) {
         old_iter = playlists_iter;
         playlists_iter = g_list_find(playlists, playlist);
-        if (!playlists_iter) playlists_iter = playlists;
+        if (!playlists_iter) playlists_iter = old_iter;
         plc->plc_read(filename, pos);
         playlists_iter = old_iter;
     } else {
@@ -1798,9 +1841,9 @@
 {
     gint pos;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     pos = playlist_get_position_nolock(playlist);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     return pos;
 }
@@ -1815,16 +1858,16 @@
     if (!playlist)
         return NULL;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     node = g_list_nth(playlist->entries, pos);
     if (!node) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return NULL;
     }
     entry = node->data;
 
     filename = g_strdup(entry->filename);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     return filename;
 }
@@ -1840,10 +1883,10 @@
     if (!playlist)
         return NULL;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if (!(node = g_list_nth(playlist->entries, pos))) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return NULL;
     }
 
@@ -1865,7 +1908,7 @@
         title = entry->title;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     if (!title) {
         gchar *realfn = NULL;
@@ -2195,11 +2238,11 @@
 playlist_sort(Playlist *playlist, PlaylistSortType type)
 {
     playlist_remove_dead_files(playlist);
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     playlist->entries =
         g_list_sort(playlist->entries,
                     (GCompareFunc) playlist_compare_func_table[type]);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 }
 
 static GList *
@@ -2254,19 +2297,19 @@
 void
 playlist_sort_selected(Playlist *playlist, PlaylistSortType type)
 {
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     playlist->entries = playlist_sort_selected_generic(playlist->entries, (GCompareFunc)
                                                        playlist_compare_func_table
                                                        [type]);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 }
 
 void
 playlist_reverse(Playlist *playlist)
 {
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     playlist->entries = g_list_reverse(playlist->entries);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 }
 
 static GList *
@@ -2316,9 +2359,9 @@
 void
 playlist_random(Playlist *playlist)
 {
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     playlist->entries = playlist_shuffle_list(playlist, playlist->entries);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 }
 
 GList *
@@ -2327,13 +2370,13 @@
     GList *node, *list = NULL;
     gint i = 0;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     for (node = playlist->entries; node; node = g_list_next(node), i++) {
         PlaylistEntry *entry = node->data;
         if (entry->selected)
             list = g_list_prepend(list, GINT_TO_POINTER(i));
     }
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     return g_list_reverse(list);
 }
 
@@ -2343,11 +2386,11 @@
     GList *node = NULL;
     gint i = 0;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     for (node = playlist->entries; node; node = g_list_next(node), i++) {
         PLAYLIST_ENTRY(node->data)->selected = FALSE;
     }
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     playlist_recalc_total_time(playlist);
     playlist_manager_update();
 }
@@ -2358,13 +2401,13 @@
     GList *node;
     gint num = 0;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     for (node = playlist->entries; node; node = g_list_next(node)) {
         PlaylistEntry *entry = node->data;
         if (entry->selected)
             num++;
     }
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     return num;
 }
 
@@ -2372,9 +2415,9 @@
 static void
 playlist_generate_shuffle_list(Playlist *playlist)
 {
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     playlist_generate_shuffle_list_nolock(playlist);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 }
 
 static void
@@ -2414,7 +2457,7 @@
     ProbeResult *pr = NULL;
     time_t mtime;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if ((node = g_list_nth(playlist->entries, pos)))
     {
@@ -2423,7 +2466,7 @@
         path = g_strdup(entry->filename);
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     if (entry->tuple)
         mtime = tuple_get_int(entry->tuple, "mtime");
@@ -2472,7 +2515,7 @@
     gchar *path = NULL;
     Tuple *tuple = NULL;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if (playlist->entries && playlist->position)
     {
@@ -2482,7 +2525,7 @@
         tuple = playlist->position->tuple;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     if (tuple != NULL)
     {
@@ -2519,6 +2562,19 @@
 
 
 static gboolean
+playlist_get_info_scanning(void)
+{
+    gboolean result;
+
+    g_mutex_lock(mutex_scan);
+    result = playlist_get_info_scan_active;
+    g_mutex_unlock(mutex_scan);
+
+    return result;
+}
+
+
+static gboolean
 playlist_request_win_update(gpointer unused)
 {
     Playlist *playlist = playlist_get_active();
@@ -2539,7 +2595,7 @@
 
         // on_load
         if (cfg.use_pl_metadata && cfg.get_info_on_load &&
-            playlist_get_info_scan_active) {
+            playlist_get_info_scanning()) {
 
             for (node = playlist->entries; node; node = g_list_next(node)) {
                 entry = node->data;
@@ -2627,7 +2683,7 @@
             update_playlistwin = FALSE;
         }
 
-        if (playlist_get_info_scan_active) {
+        if (playlist_get_info_scanning()) {
             continue;
         }
 
@@ -2678,7 +2734,7 @@
 {
     GList *node, *next_node;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     for (node = playlist->entries; node; node = next_node) {
         PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
@@ -2713,7 +2769,7 @@
         playlist->entries = g_list_delete_link(playlist->entries, node);
     }
    
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     
     playlist_generate_shuffle_list(playlist);
     playlistwin_update_list(playlist);
@@ -2803,7 +2859,7 @@
         break;
     }
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     for (node = playlist->entries; node; node = next_node) {
         PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
@@ -2848,7 +2904,7 @@
         }
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlistwin_update_list(playlist);
     playlist_recalc_total_time(playlist);
@@ -2863,12 +2919,12 @@
                         gboolean * total_more,
                         gboolean * selection_more)
 {
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     *total_time = playlist->pl_total_time;
     *selection_time = playlist->pl_selection_time;
     *total_more = playlist->pl_total_more;
     *selection_more = playlist->pl_selection_more;
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 }
 
 
@@ -2905,9 +2961,9 @@
 static void
 playlist_recalc_total_time(Playlist *playlist)
 {
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     playlist_recalc_total_time_nolock(playlist);
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 }
 
 gint
@@ -2923,7 +2979,7 @@
     onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC );
     #endif
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if ( tuple_get_string(tuple, "title") != NULL )
     {
@@ -3061,7 +3117,7 @@
 
     g_list_free( found_list );
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     playlist_recalc_total_time(playlist);
 
     return num_of_entries_found;
@@ -3072,14 +3128,14 @@
 {
     GList *list;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     for (list = playlist->entries; list; list = g_list_next(list)) {
         PlaylistEntry *entry = list->data;
         entry->selected = set;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     playlist_recalc_total_time(playlist);
 }
 
@@ -3088,14 +3144,14 @@
 {
     GList *list;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     for (list = playlist->entries; list; list = g_list_next(list)) {
         PlaylistEntry *entry = list->data;
         entry->selected = !entry->selected;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     playlist_recalc_total_time(playlist);
 }
 
@@ -3105,7 +3161,7 @@
     GList *list;
     gboolean invert_ok = FALSE;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if ((list = g_list_nth(playlist->entries, pos))) {
         PlaylistEntry *entry = list->data;
@@ -3113,7 +3169,7 @@
         invert_ok = TRUE;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     playlist_recalc_total_time(playlist);
 
     return invert_ok;
@@ -3129,7 +3185,7 @@
     if (min_pos > max_pos)
         SWAP(min_pos, max_pos);
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     list = g_list_nth(playlist->entries, min_pos);
     for (i = min_pos; i <= max_pos && list; i++) {
@@ -3138,7 +3194,7 @@
         list = g_list_next(list);
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_recalc_total_time(playlist);
 }
@@ -3149,7 +3205,7 @@
     GList *node;
     gboolean retval = FALSE;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     for (node = playlist->entries; node; node = g_list_next(node)) {
         PlaylistEntry *entry = node->data;
@@ -3172,7 +3228,7 @@
         }
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlistwin_update_list(playlist);
     playlist_recalc_total_time(playlist);
@@ -3185,7 +3241,7 @@
 {
     GList *node;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if ((node = g_list_nth(playlist->entries, pos))) {
         PlaylistEntry *entry = node->data;
@@ -3194,7 +3250,7 @@
         playlist_entry_get_info(entry);
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlistwin_update_list(playlist);
     playlist_recalc_total_time(playlist);
@@ -3219,14 +3275,14 @@
     if (!playlist)
         return;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     playlist_position_before_jump = NULL;
 
     cfg.shuffle = shuffle;
     playlist_generate_shuffle_list_nolock(playlist);
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 }
 
 Playlist *
@@ -3235,8 +3291,8 @@
     Playlist *playlist = g_new0(Playlist, 1);
     playlist->mutex = g_mutex_new();
     playlist->loading_playlist = FALSE;
-
-    playlist_set_current_name(playlist, NULL);
+    playlist->title = NULL;
+    playlist->filename = NULL;
     playlist_clear(playlist);
 
     return playlist;
@@ -3245,6 +3301,9 @@
 void
 playlist_free(Playlist *playlist)
 {
+    if (!playlist)
+        return;
+    
     g_mutex_free( playlist->mutex );
     g_free( playlist );
 }
@@ -3258,7 +3317,7 @@
 
     playlist_add_playlist( newpl );
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     while ( list != NULL )
     {
@@ -3268,7 +3327,7 @@
         list = g_list_next(list);
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     playlist_recalc_total_time(newpl);
     playlistwin_update_list(playlist);
@@ -3284,7 +3343,7 @@
     if (!playlist)
         return NULL;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if (!playlist->position) {
         if (cfg.shuffle)
@@ -3295,7 +3354,7 @@
 
     filename = playlist->position->filename;
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     return filename;
 }
@@ -3306,7 +3365,7 @@
     if (!playlist)
         return NULL;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if (!playlist->position) {
         if (cfg.shuffle)
@@ -3315,7 +3374,27 @@
             playlist->position = playlist->entries->data;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     return playlist->position;
 }
+
+gboolean
+playlist_playlists_equal(Playlist *p1, Playlist *p2)
+{
+    GList *l1, *l2;
+    PlaylistEntry *e1, *e2;
+    if (!p1 || !p2) return FALSE;
+    l1 = p1->entries;
+    l2 = p2->entries;
+    do {
+        if (!l1 && !l2) break;
+        if (!l1 || !l2) return FALSE; /* different length */
+        e1 = (PlaylistEntry *) l1->data;
+        e2 = (PlaylistEntry *) l2->data;
+        if (strcmp(e1->filename, e2->filename) != 0) return FALSE;
+        l1 = l1->next;
+        l2 = l2->next;
+    } while(1);
+    return TRUE;
+}
--- a/src/audacious/playlist.h	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/playlist.h	Mon Sep 10 00:47:23 2007 -0500
@@ -214,8 +214,13 @@
 void playlist_clear_selected(Playlist *playlist);
 
 GList *get_playlist_nth(Playlist *playlist, guint);
-gboolean playlist_set_current_name(Playlist *playlist, const gchar * filename);
+
+gboolean playlist_set_current_name(Playlist *playlist, const gchar * title);
 const gchar *playlist_get_current_name(Playlist *playlist);
+
+gboolean playlist_filename_set(Playlist *playlist, const gchar * filename);
+gchar *playlist_filename_get(Playlist *playlist);
+
 Playlist *playlist_new(void);
 void playlist_free(Playlist *playlist);
 Playlist *playlist_new_from_selected(void);
@@ -223,8 +228,8 @@
 PlaylistFormat playlist_format_get_from_name(const gchar * filename);
 gboolean is_playlist_name(const gchar * filename);
 
-#define PLAYLIST_LOCK(m)    g_mutex_lock(m)
-#define PLAYLIST_UNLOCK(m)  g_mutex_unlock(m)
+#define PLAYLIST_LOCK(pl)    g_mutex_lock(pl->mutex)
+#define PLAYLIST_UNLOCK(pl)  g_mutex_unlock(pl->mutex)
 
 G_LOCK_EXTERN(playlists);
 
@@ -238,6 +243,8 @@
 
 Playlist *playlist_get_active(void);
 
+gboolean playlist_playlists_equal(Playlist *p1, Playlist *p2);
+
 G_END_DECLS
 
 #endif
--- a/src/audacious/ui_jumptotrack.c	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/ui_jumptotrack.c	Mon Sep 10 00:47:23 2007 -0500
@@ -347,7 +347,7 @@
 
     playlist = playlist_get_active();
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     for (playlist_glist = playlist->entries; playlist_glist;
          playlist_glist = g_list_next(playlist_glist))
@@ -403,7 +403,7 @@
         g_free(title); title = NULL;
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     /* attach the model again to the treeview */
     gtk_tree_view_set_model( GTK_TREE_VIEW(treeview) , GTK_TREE_MODEL(store) );
@@ -448,7 +448,7 @@
 
     playlist = playlist_get_active();
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     for (playlist_glist = playlist->entries; playlist_glist;
          playlist_glist = g_list_next(playlist_glist)) {
@@ -478,7 +478,7 @@
         }
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     /* attach liststore to treeview */
     gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(jtf_store));
--- a/src/audacious/ui_playlist.c	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/ui_playlist.c	Mon Sep 10 00:47:23 2007 -0500
@@ -53,6 +53,7 @@
 #include "ui_main.h"
 #include "ui_manager.h"
 #include "util.h"
+#include "config.h"
 
 #include "ui_skinned_window.h"
 #include "ui_skinned_button.h"
@@ -827,6 +828,7 @@
 static void
 playlistwin_load_playlist(const gchar * filename)
 {
+    const gchar *title;
     Playlist *playlist = playlist_get_active();
 
     g_return_if_fail(filename != NULL);
@@ -837,7 +839,9 @@
     mainwin_clear_song_info();
 
     playlist_load(playlist, filename);
-    playlist_set_current_name(playlist, filename);
+    title = playlist_get_current_name(playlist);
+    if(!title || !title[0])
+        playlist_set_current_name(playlist, filename);
 }
 
 static gchar *
@@ -949,12 +953,16 @@
         playlist_file_selection_save(_("Save Playlist"), default_filename);
 
     if (filename) {
-        /* Default to xspf if no filename has extension */
+        /* Default extension */
         basename = g_path_get_basename(filename);
         dot = strrchr(basename, '.');
         if( dot == NULL || dot == basename) {
             gchar *oldname = filename;
+#ifdef HAVE_XSPF_PLAYLIST
             filename = g_strconcat(oldname, ".xspf", NULL);
+#else
+            filename = g_strconcat(oldname, ".m3u", NULL);
+#endif
             g_free(oldname);
         }
         g_free(basename);
--- a/src/audacious/ui_playlist_manager.c	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/ui_playlist_manager.c	Mon Sep 10 00:47:23 2007 -0500
@@ -60,12 +60,12 @@
         gchar *pl_name = NULL;
         Playlist *playlist = (Playlist*)playlists->data;
 
-        PLAYLIST_LOCK(playlist->mutex);
+        PLAYLIST_LOCK(playlist);
         /* for each playlist, pick name and number of entries */
         pl_name = (gchar*)playlist_get_current_name( playlist );
         for (entries = playlist->entries; entries; entries = g_list_next(entries))
             entriesnum++;
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
 
         gtk_list_store_append( store , &iter );
         gtk_list_store_set( store, &iter,
@@ -207,7 +207,7 @@
         GtkWidget *pmenu = (GtkWidget*)g_object_get_data( G_OBJECT(lv) , "menu" );
         gtk_menu_popup( GTK_MENU(pmenu) , NULL , NULL , NULL , NULL ,
                         (event != NULL) ? event->button : 0,
-                        gdk_event_get_time((GdkEvent*)event));
+                        event->time);
         return TRUE;
     }
 
--- a/src/audacious/ui_skinned_playlist.c	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/ui_skinned_playlist.c	Mon Sep 10 00:47:23 2007 -0500
@@ -290,14 +290,14 @@
     if (!playlist)
         return;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     if ((list = playlist->entries) == NULL) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
     if (PLAYLIST_ENTRY(list->data)->selected) {
         /* We are at the top */
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
     while (list) {
@@ -305,7 +305,7 @@
             glist_moveup(list);
         list = g_list_next(list);
     }
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
     if (pl->prev_selected != -1)
         pl->prev_selected--;
     if (pl->prev_min != -1)
@@ -321,16 +321,16 @@
     if (!playlist)
         return;
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
 
     if (!(list = g_list_last(playlist->entries))) {
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
 
     if (PLAYLIST_ENTRY(list->data)->selected) {
         /* We are at the bottom */
-        PLAYLIST_UNLOCK(playlist->mutex);
+        PLAYLIST_UNLOCK(playlist);
         return;
     }
 
@@ -340,7 +340,7 @@
         list = g_list_previous(list);
     }
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     if (pl->prev_selected != -1)
         pl->prev_selected++;
@@ -484,7 +484,7 @@
 
     pl->first = CLAMP(pl->first, 0, max_first);
 
-    PLAYLIST_LOCK(playlist->mutex);
+    PLAYLIST_LOCK(playlist);
     list = playlist->entries;
     list = g_list_nth(list, pl->first);
 
@@ -763,7 +763,7 @@
     gdk_gc_set_clip_origin(gc, 0, 0);
     gdk_gc_set_clip_rectangle(gc, NULL);
 
-    PLAYLIST_UNLOCK(playlist->mutex);
+    PLAYLIST_UNLOCK(playlist);
 
     gdk_draw_drawable(widget->window, gc, obj, 0, 0, 0, 0, priv->width, priv->height);
 
--- a/src/audacious/util.c	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/util.c	Mon Sep 10 00:47:23 2007 -0500
@@ -894,7 +894,7 @@
  * Return value: A GTK widget handle for the message box.
  **/
 GtkWidget *
-xmms_show_message(const gchar * title, const gchar * text,
+audacious_info_dialog(const gchar * title, const gchar * text,
                   const gchar * button_text, gboolean modal,
                   GtkSignalFunc button_action, gpointer action_data)
 {
@@ -970,28 +970,3 @@
   return datadir;
 }
 
-
-/**
- * xmms_check_realtime_priority:
- *
- * Legacy function included for compatibility with XMMS.
- *
- * Return value: FALSE
- **/
-gboolean
-xmms_check_realtime_priority(void)
-{
-    return FALSE;
-}
-
-/**
- * xmms_usleep:
- * @usec: The amount of microseconds to sleep.
- *
- * Legacy function included for compatibility with XMMS.
- **/
-void
-xmms_usleep(gint usec)
-{
-    g_usleep(usec);
-}
--- a/src/audacious/util.h	Mon Sep 10 00:47:18 2007 -0500
+++ b/src/audacious/util.h	Mon Sep 10 00:47:23 2007 -0500
@@ -91,23 +91,14 @@
 
 GdkPixmap *audacious_pixmap_resize(GdkWindow *src, GdkGC *src_gc, GdkPixmap *in, gint width, gint height);
 
-/* XMMS names */
-
-#define bmp_info_dialog(title, text, button_text, model, button_action, action_data) \
-  xmms_show_message(title, text, button_text, model, button_action, action_data)
-
-#define bmp_usleep(usec) \
-  xmms_usleep(usec)
-
-#define bmp_check_realtime_priority() \
-  xmms_check_realtime_priority()
-
-GtkWidget *xmms_show_message(const gchar * title, const gchar * text,
+GtkWidget *audacious_info_dialog(const gchar * title, const gchar * text,
                              const gchar * button_text, gboolean modal,
                              GtkSignalFunc button_action,
                              gpointer action_data);
-gboolean xmms_check_realtime_priority(void);
-void xmms_usleep(gint usec);
+
+/* FIXME! Remove this completely -ccr */
+#define xmms_check_realtime_priority(N) FALSE
+
 
 GdkPixmap *create_dblsize_pixmap(GdkPixmap *pix);