[totem] main: Split off saving of the session playlist
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] main: Split off saving of the session playlist
- Date: Mon, 11 Mar 2013 13:21:45 +0000 (UTC)
commit 3aa062419c13142300812cbdf733100d186bb4eb
Author: Bastien Nocera <hadess hadess net>
Date: Mon Mar 11 13:42:58 2013 +0100
main: Split off saving of the session playlist
We were using the same code as the interactive playlist saving,
which meant that error messages popped up in an error dialogue
as we were closing the application.
src/totem-playlist.c | 29 ++++++++++++++++++++++-------
src/totem-playlist.h | 2 +-
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 b65c746..17e4ccc 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 14db5e8..d28649e 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 8956e56..be51f5d 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]