[frogr] Rewritten frogr_serializer_current_session as frogr_serializer_save_session_to_file
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Rewritten frogr_serializer_current_session as frogr_serializer_save_session_to_file
- Date: Sun, 11 Nov 2012 00:07:02 +0000 (UTC)
commit 18e2512808b8e914769195456cd3624c0e19656f
Author: Mario Sanchez Prada <msanchez2 gnome org>
Date: Thu Nov 8 13:25:05 2012 +0100
Rewritten frogr_serializer_current_session as frogr_serializer_save_session_to_file
src/frogr-controller.c | 7 ++++---
src/frogr-controller.h | 2 +-
src/frogr-main-view.c | 9 ---------
src/frogr-serializer.c | 44 ++++++++++++++++++++++++++++++++++++--------
src/frogr-serializer.h | 11 ++++++++---
5 files changed, 49 insertions(+), 24 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index c5f851d..561dd62 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -2735,7 +2735,7 @@ frogr_controller_cancel_ongoing_request (FrogrController *self)
}
void
-frogr_controller_save_current_session (FrogrController *self)
+frogr_controller_save_session_to_file (FrogrController *self, const gchar *path)
{
FrogrControllerPrivate *priv = NULL;
FrogrMainViewModel *mainview_model = NULL;
@@ -2752,8 +2752,9 @@ frogr_controller_save_current_session (FrogrController *self)
photosets = frogr_main_view_model_get_photosets (mainview_model);
groups = frogr_main_view_model_get_groups (mainview_model);
- frogr_serializer_save_current_session (priv->serializer,
- pictures, photosets, groups);
+ frogr_serializer_save_session_to_file (priv->serializer,
+ pictures, photosets, groups,
+ path);
}
#ifdef GTK_API_VERSION_3
diff --git a/src/frogr-controller.h b/src/frogr-controller.h
index 8cfa8f4..68f2414 100644
--- a/src/frogr-controller.h
+++ b/src/frogr-controller.h
@@ -123,7 +123,7 @@ void frogr_controller_reorder_pictures (FrogrController *self);
void frogr_controller_cancel_ongoing_request (FrogrController *self);
-void frogr_controller_save_current_session (FrogrController *self);
+void frogr_controller_save_session_to_file (FrogrController *self, const gchar *path);
#ifdef GTK_API_VERSION_3
void frogr_controller_set_use_dark_theme (FrogrController *self, gboolean value);
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 6c93dff..374580a 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -1201,9 +1201,6 @@ _model_picture_added (FrogrController *controller,
/* Update upload size in state description */
_update_state_description (self);
-
- /* Make sure the session file is removed */
- frogr_controller_save_current_session (priv->controller);
}
static void
@@ -1245,9 +1242,6 @@ _model_picture_removed (FrogrController *controller,
/* Update upload size in state description */
_update_state_description (self);
-
- /* Make sure the session file is removed */
- frogr_controller_save_current_session (priv->controller);
}
static void
@@ -1262,9 +1256,6 @@ _model_pictures_reordered (FrogrController *controller,
priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
gtk_list_store_reorder (GTK_LIST_STORE (priv->tree_model), new_order);
-
- /* Make sure the session file is updated */
- frogr_controller_save_current_session (priv->controller);
}
static void
diff --git a/src/frogr-serializer.c b/src/frogr-serializer.c
index 477fd69..f44f489 100644
--- a/src/frogr-serializer.c
+++ b/src/frogr-serializer.c
@@ -150,17 +150,48 @@ serialize_list_to_json_array (GSList *list)
}
void
-frogr_serializer_save_current_session (FrogrSerializer *self,
+frogr_serializer_save_session (FrogrSerializer *self,
+ GSList *pictures,
+ GSList *photosets,
+ GSList *groups)
+{
+ FrogrSerializerPrivate *priv = NULL;
+ gchar *session_path = NULL;
+
+ g_return_if_fail(FROGR_IS_SERIALIZER (self));
+
+ priv = FROGR_SERIALIZER_GET_PRIVATE (self);
+ session_path = g_build_filename (priv->data_dir, SESSION_FILENAME, NULL);
+ frogr_serializer_save_session_to_file (self, pictures, photosets, groups, session_path);
+}
+
+void
+frogr_serializer_save_session_to_file (FrogrSerializer *self,
GSList *pictures,
GSList *photosets,
- GSList *groups)
+ GSList *groups,
+ const gchar *path)
{
FrogrSerializerPrivate *priv = NULL;
+ gchar *session_path = NULL;
+
+ g_return_if_fail(FROGR_IS_SERIALIZER (self));
+
+ priv = FROGR_SERIALIZER_GET_PRIVATE (self);
+ session_path = g_build_filename (priv->data_dir, SESSION_FILENAME, NULL);
+ frogr_serializer_save_session_to_file (self, pictures, photosets, session_path);
+}
+
+void
+frogr_serializer_save_session_to_file (FrogrSerializer *self,
+ GSList *pictures,
+ GSList *photosets,
+ const gchar *path)
+{
JsonGenerator *json_gen = NULL;
JsonArray *json_array = NULL;
JsonNode *root_node = NULL;
JsonObject *root_object = NULL;
- gchar *session_path = NULL;
GError *error = NULL;
g_return_if_fail(FROGR_IS_SERIALIZER (self));
@@ -185,14 +216,11 @@ frogr_serializer_save_current_session (FrogrSerializer *self,
json_node_free (root_node);
/* Save to disk */
- priv = FROGR_SERIALIZER_GET_PRIVATE (self);
- session_path = g_build_filename (priv->data_dir, SESSION_FILENAME, NULL);
- json_generator_to_file (json_gen, session_path, &error);
+ json_generator_to_file (json_gen, path, &error);
if (error)
{
DEBUG ("Error serializing current state to %s: %s",
- session_path, error->message);
+ path, error->message);
g_error_free (error);
}
- g_free (session_path);
}
diff --git a/src/frogr-serializer.h b/src/frogr-serializer.h
index 27cee81..3b154df 100644
--- a/src/frogr-serializer.h
+++ b/src/frogr-serializer.h
@@ -56,11 +56,16 @@ GType frogr_serializer_get_type (void) G_GNUC_CONST;
FrogrSerializer* frogr_serializer_get_instance (void);
-void frogr_serializer_save_current_session (FrogrSerializer *self,
+void frogr_serializer_save_session (FrogrSerializer *self,
+ GSList *pictures,
+ GSList *photosets,
+ GSList *groups);
+
+void frogr_serializer_save_session_to_file (FrogrSerializer *self,
GSList *pictures,
GSList *photosets,
- GSList *groups);
-
+ GSList *groups,
+ const gchar *path);
G_END_DECLS
#endif /* !_FROGR_SERIALIZER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]