[totem] main: Optimise session saving
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] main: Optimise session saving
- Date: Tue, 9 Jul 2013 08:28:55 +0000 (UTC)
commit 589a29bb9aa7e4d1650412e9ac5512e517252d5e
Author: Bastien Nocera <hadess hadess net>
Date: Tue Jul 9 09:47:46 2013 +0200
main: Optimise session saving
src/totem-object.c | 1 +
src/totem-session.c | 26 ++++++++++++++------------
src/totem-session.h | 1 +
3 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/totem-object.c b/src/totem-object.c
index a924e2a..958c695 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -1181,6 +1181,7 @@ totem_object_action_exit (TotemObject *totem)
gdk_display_sync (display);
totem_session_save (totem);
+ totem_session_cleanup (totem);
if (totem->bvw)
bacon_video_widget_close (totem->bvw);
diff --git a/src/totem-session.c b/src/totem-session.c
index d703b8b..4664c94 100644
--- a/src/totem-session.c
+++ b/src/totem-session.c
@@ -27,30 +27,27 @@
#include "totem-session.h"
#include "totem-uri.h"
+static GFile *session_file = NULL;
+
static GFile *
get_session_file (void)
{
- GFile *file;
char *path;
+ if (session_file)
+ return session_file;
+
path = g_build_filename (totem_dot_dir (), "session_state.xspf", NULL);
- file = g_file_new_for_path (path);
+ session_file = g_file_new_for_path (path);
g_free (path);
- return file;
+ return session_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;
+ return g_file_get_uri (get_session_file ());
}
gboolean
@@ -107,5 +104,10 @@ totem_session_save (Totem *totem)
if (!totem_playing_dvd (totem->mrl))
curr = bacon_video_widget_get_current_time (totem->bvw);
totem_playlist_save_session_playlist (totem->playlist, file, curr);
- g_object_unref (file);
+}
+
+void
+totem_session_cleanup (Totem *totem)
+{
+ g_clear_object (&session_file);
}
diff --git a/src/totem-session.h b/src/totem-session.h
index 321c933..edee82d 100644
--- a/src/totem-session.h
+++ b/src/totem-session.h
@@ -29,6 +29,7 @@ G_BEGIN_DECLS
gboolean totem_session_try_restore (Totem *totem);
void totem_session_save (Totem *totem);
+void totem_session_cleanup (Totem *totem);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]