[frogr] New function frogr_controller_save_current_session()
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] New function frogr_controller_save_current_session()
- Date: Sun, 11 Nov 2012 00:06:07 +0000 (UTC)
commit 3dc2ff7ff6dd4856fc738179b41ffa5fd03bdf50
Author: Mario Sanchez Prada <msanchez2 gnome org>
Date: Thu Nov 8 13:25:05 2012 +0100
New function frogr_controller_save_current_session()
It gets the list of pictures loaded from the model and asks the
FrogrSerializer (a Singleton) to save state to disk.
src/frogr-controller.c | 29 +++++++++++++++++++++++++++++
src/frogr-controller.h | 2 ++
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 2063dbb..f93e3c0 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -32,6 +32,7 @@
#include "frogr-file-loader.h"
#include "frogr-global-defs.h"
#include "frogr-main-view.h"
+#include "frogr-serializer.h"
#include "frogr-settings-dialog.h"
#include "frogr-util.h"
@@ -65,6 +66,7 @@ struct _FrogrControllerPrivate
FrogrMainView *mainview;
FrogrConfig *config;
+ FrogrSerializer *serializer;
FrogrAccount *account;
FspSession *session;
@@ -2002,6 +2004,12 @@ _frogr_controller_dispose (GObject* object)
priv->config = NULL;
}
+ if (priv->serializer)
+ {
+ g_object_unref (priv->serializer);
+ priv->serializer = NULL;
+ }
+
if (priv->account)
{
g_object_unref (priv->account);
@@ -2070,6 +2078,9 @@ frogr_controller_init (FrogrController *self)
priv->config = frogr_config_get_instance ();
g_object_ref (priv->config);
+ priv->serializer = frogr_serializer_get_instance ();
+ g_object_ref (priv->serializer);
+
priv->session = fsp_session_new (API_KEY, SHARED_SECRET, NULL);
priv->cancellable = NULL;
priv->app_running = FALSE;
@@ -2725,6 +2736,24 @@ frogr_controller_cancel_ongoing_request (FrogrController *self)
priv->cancellable = NULL;
}
+void
+frogr_controller_save_current_session (FrogrController *self)
+{
+ FrogrControllerPrivate *priv = NULL;
+ FrogrMainViewModel *mainview_model = NULL;
+ GSList *pictures = NULL;
+
+ g_return_if_fail(FROGR_IS_CONTROLLER (self));
+
+ priv = FROGR_CONTROLLER_GET_PRIVATE (self);
+ mainview_model = frogr_main_view_get_model (priv->mainview);
+
+ if (frogr_main_view_model_n_pictures (mainview_model) > 0)
+ pictures = frogr_main_view_model_get_pictures_as_loaded (mainview_model);
+
+ frogr_serializer_save_current_session (priv->serializer, pictures);
+}
+
#ifdef GTK_API_VERSION_3
void
frogr_controller_set_use_dark_theme (FrogrController *self, gboolean value)
diff --git a/src/frogr-controller.h b/src/frogr-controller.h
index 8877f50..8cfa8f4 100644
--- a/src/frogr-controller.h
+++ b/src/frogr-controller.h
@@ -123,6 +123,8 @@ void frogr_controller_reorder_pictures (FrogrController *self);
void frogr_controller_cancel_ongoing_request (FrogrController *self);
+void frogr_controller_save_current_session (FrogrController *self);
+
#ifdef GTK_API_VERSION_3
void frogr_controller_set_use_dark_theme (FrogrController *self, gboolean value);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]