[frogr] Only serialize the local tags, not to bloat the project file too much.
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Only serialize the local tags, not to bloat the project file too much.
- Date: Fri, 21 Dec 2012 10:04:01 +0000 (UTC)
commit 294ee42ba64ea818045f18d405ad537aa897d095
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Fri Dec 21 10:58:30 2012 +0100
Only serialize the local tags, not to bloat the project file too much.
The rest of the tags will be available as soon as they get retrieved
src/frogr-controller.c | 2 +-
src/frogr-model.c | 30 ++++++++++++++++++++++++++----
src/frogr-model.h | 2 ++
3 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 62fae25..3e951d2 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -3057,7 +3057,7 @@ frogr_controller_save_project_to_file (FrogrController *self, const gchar *path)
n_pictures = frogr_model_n_pictures (model);
n_photosets = frogr_model_n_photosets (model);
n_groups = frogr_model_n_groups (model);
- n_tags = frogr_model_n_tags (model);
+ n_tags = frogr_model_n_local_tags (model);
root_node = json_node_new (JSON_NODE_OBJECT);
root_object = json_object_new ();
diff --git a/src/frogr-model.c b/src/frogr-model.c
index e922bb0..9d6d035 100644
--- a/src/frogr-model.c
+++ b/src/frogr-model.c
@@ -249,6 +249,19 @@ _remove_all_tags (FrogrModel *self)
_remove_local_tags (self);
}
+static void
+_set_local_tags (FrogrModel *self, GSList *tags_list)
+{
+ FrogrModelPrivate *priv = NULL;
+
+ g_return_if_fail(FROGR_IS_MODEL (self));
+
+ _remove_local_tags (self);
+
+ priv = FROGR_MODEL_GET_PRIVATE (self);
+ priv->local_tags = tags_list;
+}
+
static JsonArray *
_serialize_list_to_json_array (GSList *list, GType g_type)
{
@@ -783,6 +796,12 @@ frogr_model_n_tags (FrogrModel *self)
return g_slist_length (frogr_model_get_tags (self));
}
+guint
+frogr_model_n_local_tags (FrogrModel *self)
+{
+ g_return_val_if_fail(FROGR_IS_MODEL (self), 0);
+ return g_slist_length (FROGR_MODEL_GET_PRIVATE (self)->local_tags);
+}
JsonObject *
frogr_model_serialize (FrogrModel *self)
@@ -807,8 +826,9 @@ frogr_model_serialize (FrogrModel *self)
json_array = _serialize_list_to_json_array (data_list, G_TYPE_OBJECT);
json_object_set_array_member (root_object, "groups", json_array);
- data_list = frogr_model_get_tags (self);
- json_array = _serialize_list_to_json_array (data_list, G_TYPE_STRING);
+ /* Only serialize the local tags, not to bloat the project file too much */
+ json_array = _serialize_list_to_json_array (FROGR_MODEL_GET_PRIVATE (self)->local_tags,
+ G_TYPE_STRING);
json_object_set_array_member (root_object, "tags", json_array);
return root_object;
@@ -838,10 +858,12 @@ frogr_model_deserialize (FrogrModel *self, JsonObject *root_object)
if (array_member)
tags = _deserialize_list_from_json_array (array_member, G_TYPE_STRING);
- /* We set the sets, groups and tags */
+ /* We set the sets and groups */
frogr_model_set_photosets (self, sets);
frogr_model_set_groups (self, groups);
- frogr_model_set_remote_tags (self, tags);
+
+ /* We only serialized local tags */
+ _set_local_tags (self, tags);
/* Pictures must be deserialized at the end, since they will hold
references to sets and groups previously imported in the model */
diff --git a/src/frogr-model.h b/src/frogr-model.h
index dcfc62a..9e32c58 100644
--- a/src/frogr-model.h
+++ b/src/frogr-model.h
@@ -109,6 +109,8 @@ GSList *frogr_model_get_tags (FrogrModel *self);
guint frogr_model_n_tags (FrogrModel *self);
+guint frogr_model_n_local_tags (FrogrModel *self);
+
/* Serialization */
JsonObject *frogr_model_serialize (FrogrModel *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]