changeset 2636:517d13842fe7 trunk

[svn] improve support for static playlist. - Playlist.attribute has been introduced. if loading playlist file is marked as static playlist, this value would be set. - now user can specify whether save as a static playlist or not. - thanks to Playlist.attribute, meaningful mtime in a static playlist will be preserved.
author yaz
date Wed, 21 Mar 2007 02:13:02 -0700
parents 9b763f1f4e6a
children 420ce282920d
files ChangeLog src/audacious/build_stamp.c src/audacious/playlist.c src/audacious/playlist.h src/audacious/ui_playlist.c
diffstat 5 files changed, 48 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 21 01:59:48 2007 -0700
+++ b/ChangeLog	Wed Mar 21 02:13:02 2007 -0700
@@ -1,3 +1,17 @@
+2007-03-21 08:59:48 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [4288]
+  tweak UI behaviors:
+  - pressing ctrl-p raises preferences window if it has been opened.
+  - pressing Esc closes preferences window.
+  - centering "Save Playlist" dialog and the replace confirmation dialog.
+  
+  trunk/src/audacious/glade/prefswin.glade |    1 +
+  trunk/src/audacious/ui_playlist.c        |    1 +
+  trunk/src/audacious/ui_preferences.c     |    6 ++----
+  trunk/src/audacious/util.c               |    1 +
+  4 files changed, 5 insertions(+), 4 deletions(-)
+
+
 2007-03-21 06:58:31 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [4286]
   - fixes for mowgli pre-GIT.
--- a/src/audacious/build_stamp.c	Wed Mar 21 01:59:48 2007 -0700
+++ b/src/audacious/build_stamp.c	Wed Mar 21 02:13:02 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070321-4286";
+const gchar *svn_stamp = "20070321-4288";
--- a/src/audacious/playlist.c	Wed Mar 21 01:59:48 2007 -0700
+++ b/src/audacious/playlist.c	Wed Mar 21 02:13:02 2007 -0700
@@ -197,9 +197,9 @@
         return TRUE;
 
     if (entry->tuple == NULL || entry->tuple->mtime > 0 || entry->tuple->mtime == -1)
-	modtime = playlist_get_mtime(entry->filename);
+        modtime = playlist_get_mtime(entry->filename);
     else
-	modtime = 0;  /* URI -nenolod */
+        modtime = 0;  /* URI -nenolod */
 
     if (entry->decoder == NULL)
         entry->decoder = input_check_file(entry->filename, FALSE);
@@ -2484,7 +2484,8 @@
             for (node = playlist->entries; node; node = g_list_next(node)) {
                 entry = node->data;
 
-                if(entry->tuple && (entry->tuple->length > -1)) {
+                if(playlist->attribute & PLAYLIST_STATIC ||
+                   (entry->tuple && entry->tuple->length > -1 && entry->tuple->mtime != -1)) {
                     update_playlistwin = TRUE;
                     continue;
                 }
@@ -2534,7 +2535,8 @@
 
                     entry = node->data;
 
-                    if(entry->tuple && (entry->tuple->length > -1)) {
+                    if(playlist->attribute & PLAYLIST_STATIC ||
+                       (entry->tuple && entry->tuple->length > -1 && entry->tuple->mtime != -1)) {
                         update_playlistwin = TRUE;
                         continue;
                     }
--- a/src/audacious/playlist.h	Wed Mar 21 01:59:48 2007 -0700
+++ b/src/audacious/playlist.h	Wed Mar 21 02:13:02 2007 -0700
@@ -73,6 +73,13 @@
 } PlaylistEntry;
 
 #define PLAYLIST(x)  ((Playlist *)(x))
+
+typedef enum {
+    PLAYLIST_PLAIN = 0,
+    PLAYLIST_STATIC = 1,
+//  PLAYLIST_FOO = 1 << 1, // for future use.
+} PlaylistAttribute;
+
 typedef struct _Playlist {
     gchar         *title;
     gchar         *filename;
@@ -88,6 +95,7 @@
     gboolean       loading_playlist;
     GMutex        *mutex;       /* this is required for multiple playlist */
     GList *tail; /* marker for the last element in playlist->entries */
+    gint           attribute; /* PlaylistAttribute */
 } Playlist;
 
 typedef enum {
--- a/src/audacious/ui_playlist.c	Wed Mar 21 01:59:48 2007 -0700
+++ b/src/audacious/ui_playlist.c	Wed Mar 21 02:13:02 2007 -0700
@@ -889,17 +889,36 @@
     return filename;
 }
 
+static void
+on_static_toggle(GtkToggleButton *button, gpointer data)
+{
+    Playlist *playlist = playlist_get_active();
+
+    playlist->attribute =
+        gtk_toggle_button_get_active(button) & PLAYLIST_STATIC ? PLAYLIST_STATIC : PLAYLIST_PLAIN;
+    g_print("static_toggle: e: attribute = %d\n", playlist->attribute);
+}
+
+
 static gchar *
 playlist_file_selection_save(const gchar * title,
                         const gchar * default_filename)
 {
     GtkWidget *dialog;
     gchar *filename;
+    GtkWidget *toggle;
 
     g_return_val_if_fail(title != NULL, NULL);
 
     dialog = make_filebrowser(title, TRUE);
     gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), default_filename);
+
+    /* static playlist */
+    toggle = gtk_check_button_new_with_label("Save as a Static Playlist");
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle),
+                                 (playlist_get_active()->attribute & PLAYLIST_STATIC) ? TRUE : FALSE);
+    gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), toggle);
+    g_signal_connect(G_OBJECT(toggle), "toggled", G_CALLBACK(on_static_toggle), dialog);
    
     if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
         filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));