diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/totem-playlist.c | 29 | ||||
-rw-r--r-- | src/totem-playlist.h | 2 | ||||
-rw-r--r-- | src/totem-session.c | 30 |
3 files changed, 45 insertions, 16 deletions
diff --git a/src/totem-playlist.c b/src/totem-playlist.c index b65c74653..17e4ccc64 100644 --- a/src/totem-playlist.c +++ b/src/totem-playlist.c @@ -440,24 +440,39 @@ totem_playlist_save_iter_foreach (GtkTreeModel *model, void totem_playlist_save_session_playlist (TotemPlaylist *playlist, - const char *output_uri) + GFile *output) { + TotemPlPlaylist *pl_playlist; + GError *error = NULL; + gboolean retval; + if (playlist->priv->disable_save_to_disk) { /* On lockdown, we do not touch the disk, * even to remove the existing session */ return; } if (!playlist->priv->save || PL_LEN == 0) { - GFile *file; + g_file_delete (output, NULL, NULL); + return; + } + pl_playlist = totem_pl_playlist_new (); - file = g_file_new_for_uri (output_uri); - g_file_delete (file, NULL, NULL); - g_object_unref (file); - return; + gtk_tree_model_foreach (playlist->priv->model, + totem_playlist_save_iter_foreach, + pl_playlist); + + retval = totem_pl_parser_save (playlist->priv->parser, + pl_playlist, + output, + NULL, TOTEM_PL_PARSER_XSPF, &error); + + if (retval == FALSE) { + g_warning ("Failed to save the session playlist: %s", error->message); + g_error_free (error); } - totem_playlist_save_current_playlist_ext (playlist, output_uri, TOTEM_PL_PARSER_XSPF); + g_object_unref (pl_playlist); } void diff --git a/src/totem-playlist.h b/src/totem-playlist.h index 14db5e827..d28649e86 100644 --- a/src/totem-playlist.h +++ b/src/totem-playlist.h @@ -115,7 +115,7 @@ gboolean totem_playlist_add_mrls_finish (TotemPlaylist *self, GError **error); void totem_playlist_save_session_playlist (TotemPlaylist *playlist, - const char *output_uri); + GFile *output); void totem_playlist_save_current_playlist_ext (TotemPlaylist *playlist, const char *output, TotemPlParserType type); void totem_playlist_select_subtitle_dialog (TotemPlaylist *playlist, diff --git a/src/totem-session.c b/src/totem-session.c index 8956e56d5..be51f5df5 100644 --- a/src/totem-session.c +++ b/src/totem-session.c @@ -27,15 +27,29 @@ #include "totem-session.h" #include "totem-uri.h" -static char * -get_session_filename (void) +static GFile * +get_session_file (void) { - char *path, *uri; + GFile *file; + char *path; path = g_build_filename (g_get_user_config_dir (), "totem", "session_state.xspf", NULL); - uri = g_filename_to_uri (path, NULL, NULL); + file = g_file_new_for_path (path); g_free (path); + return file; +} + +static char * +get_session_filename (void) +{ + GFile *file; + char *uri; + + file = get_session_file (); + uri = g_file_get_uri (file); + g_object_unref (file); + return uri; } @@ -80,11 +94,11 @@ totem_session_try_restore (Totem *totem) void totem_session_save (Totem *totem) { - char *uri; + GFile *file; - uri = get_session_filename (); + file = get_session_file (); /* FIXME: Save the current seek time somehow */ /* FIXME: Check whether we actually want to be saved */ - totem_playlist_save_session_playlist (totem->playlist, uri); - g_free (uri); + totem_playlist_save_session_playlist (totem->playlist, file); + g_object_unref (file); } |