changeset 3512:6f8005df972f trunk

Automated merge with file:/home/ccr/audacious/core
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 11 Sep 2007 02:15:13 +0300
parents a1d398a05b52 (current diff) 87003549ac36 (diff)
children d74a68871159
files scripts/application.sh scripts/makerelease.sh src/audacious/playlist.c src/audacious/ui_playlist.c
diffstat 8 files changed, 399 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/po/ja.po	Sun Sep 09 23:21:49 2007 +0300
+++ b/po/ja.po	Tue Sep 11 02:15:13 2007 +0300
@@ -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"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/application.sh	Tue Sep 11 02:15:13 2007 +0300
@@ -0,0 +1,33 @@
+#!/bin/sh
+# application.sh: Special package building rules for audacious.
+#
+# Copyright (c) 2007 atheme.org
+#
+# Permission to use, copy, modify, and/or distribute this software for
+# any purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+if [ "x$TIP" = "x" ]; then
+	echo "Please don't run me directly."
+	exit
+fi
+
+# Audacious wants the hg tip to be in src/audacious/build_stamp.c
+echo "[audacious] Generating src/audacious/build_stamp.c for tip $TIP."
+cat << _EOF_ > src/audacious/build_stamp.c
+/* Generated automatically by makepackage. Any changes made here will be lost. */
+#include <glib.h>
+const gchar *svnstamp = "$TIP";
+_EOF_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/makerelease.sh	Tue Sep 11 02:15:13 2007 +0300
@@ -0,0 +1,100 @@
+#!/bin/sh
+# mkrelease.sh: Creates a release suitable for distfiles.atheme.org.
+#
+# Copyright (c) 2007 atheme.org
+#
+# Permission to use, copy, modify, and/or distribute this software for
+# any purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+if [ "x$1" = "x" ]; then
+	echo "usage: $0 releasename [--automatic]"
+	exit
+else
+	RELEASENAME="$1"
+fi
+
+if [ "x$2" = "x--automatic" ]; then
+	AUTOMATIC="yes"
+fi
+
+TIP=`hg tip --template "#rev#:#node|short#"`
+
+WRKDIR=`pwd`
+
+if [ -d $RELEASENAME ]; then
+	echo "Deleting previous release named $RELEASENAME."
+	rm -rf $WRKDIR/$RELEASENAME/
+fi
+
+echo "Making release named $RELEASENAME (tip $TIP)"
+
+echo
+echo "Building root: $RELEASENAME/"
+hg archive $RELEASENAME
+cd $RELEASENAME
+sh autogen.sh
+rm -rf autogen.sh autom4te.cache
+
+# Run application specific instructions here.
+if [ -x "$WRKDIR/application.sh" ]; then
+	source $WRKDIR/application.sh
+fi
+
+cd ..
+
+echo "Building $RELEASENAME.tgz from $RELEASENAME/"
+tar zcf $RELEASENAME.tgz $RELEASENAME/
+
+echo "Building $RELEASENAME.tbz2 from $RELEASENAME/"
+tar jcf $RELEASENAME.tbz2 $RELEASENAME/
+
+PUBLISH="yes"
+
+ok="0"
+if [ "x$AUTOMATIC" != "xyes" ]; then
+	echo
+	echo "Would you like to publish these releases now?"
+	while [ $ok -eq 0 ]; do
+		echo -n "[$PUBLISH] "
+
+		read INPUT
+		case $INPUT in
+			[Yy]*)
+				PUBLISH="yes"
+				ok=1
+				;;
+			[Nn]*)
+				PUBLISH="no"
+				ok=1
+				;;
+		esac
+	done
+fi
+
+if [ "x$PUBLISH" = "xyes" ]; then
+	scp $RELEASENAME.tgz sidhe.atheme.org:/var/www/distfiles/htdocs
+	scp $RELEASENAME.tbz2 sidhe.atheme.org:/var/www/distfiles/htdocs
+
+	echo
+	echo "The releases have been published, and will be available to the entire"
+	echo "distribution network within 15 minutes."
+fi
+
+echo
+echo "Done. If you have any bugs to report, report them against"
+echo "the distfiles.atheme.org component at http://bugzilla.atheme.org"
+echo "Thanks!"
+echo
--- a/src/audacious/Makefile	Sun Sep 09 23:21:49 2007 +0300
+++ b/src/audacious/Makefile	Tue Sep 11 02:15:13 2007 +0300
@@ -1,12 +1,11 @@
 include ../../mk/rules.mk
 include ../../mk/init.mk
+include ../../mk/objective.mk
 
 SUBDIRS = $(INTL_OBJECTIVE) glade images ui
 
 OBJECTIVE_BINS = audacious
 
-include ../../mk/objective.mk
-
 LDFLAGS += $(AUDLDFLAGS)
 
 LDADD = \
@@ -188,6 +187,10 @@
 
 build-prehook: $(PCH)
 
+audacious: $(OBJECTS) $(LIBDEP)
+	$(CXX) $(LDFLAGS) $(OBJECTS) $(LDADD) -o $@
+	@printf "%10s     %-20s\n" LINK $@
+
 dbus-server-bindings.h: $(DBUS_BINDINGS_SOURCES)
 	$(DBUS_BINDING_TOOL) --mode=glib-server --prefix=audacious_rc objects.xml > $@
 	$(DBUS_BINDING_TOOL) --mode=glib-server --prefix=mpris_root mpris_root.xml >> $@
--- a/src/audacious/main.c	Sun Sep 09 23:21:49 2007 +0300
+++ b/src/audacious/main.c	Tue Sep 11 02:15:13 2007 +0300
@@ -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	Sun Sep 09 23:21:49 2007 +0300
+++ b/src/audacious/playlist.c	Tue Sep 11 02:15:13 2007 +0300
@@ -279,8 +279,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;
@@ -291,11 +293,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);
@@ -361,22 +363,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)
 {
@@ -1574,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);
@@ -1581,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;
 }
@@ -1602,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;
 
@@ -1765,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 {
@@ -3249,8 +3290,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;
@@ -3336,3 +3377,23 @@
 
     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	Sun Sep 09 23:21:49 2007 +0300
+++ b/src/audacious/playlist.h	Tue Sep 11 02:15:13 2007 +0300
@@ -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);
@@ -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_playlist.c	Sun Sep 09 23:21:49 2007 +0300
+++ b/src/audacious/ui_playlist.c	Tue Sep 11 02:15:13 2007 +0300
@@ -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);