[frogr] Renamed FrogrMainViewModel to FrogrModel
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Renamed FrogrMainViewModel to FrogrModel
- Date: Sun, 11 Nov 2012 00:10:44 +0000 (UTC)
commit 604b20238717e9528d46a7c9067bd674d6098090
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Sat Nov 10 03:51:35 2012 +0100
Renamed FrogrMainViewModel to FrogrModel
src/Makefile.am | 4 +-
src/frogr-add-tags-dialog.c | 8 +-
src/frogr-add-to-group-dialog.c | 8 +-
src/frogr-add-to-set-dialog.c | 8 +-
src/frogr-controller.c | 92 ++++----
src/frogr-controller.h | 4 +-
src/frogr-create-new-set-dialog.c | 10 +-
src/frogr-details-dialog.c | 10 +-
src/frogr-main-view-model.h | 118 ---------
src/frogr-main-view.c | 18 +-
src/frogr-main-view.h | 4 +-
src/{frogr-main-view-model.c => frogr-model.c} | 304 ++++++++++++------------
src/frogr-model.h | 118 +++++++++
src/frogr-picture.c | 10 +-
14 files changed, 358 insertions(+), 358 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index e009941..3ddbeb2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,10 +73,10 @@ frogr_SOURCES = \
frogr-live-entry.h \
frogr-location.c \
frogr-location.h \
- frogr-main-view-model.c \
- frogr-main-view-model.h \
frogr-main-view.c \
frogr-main-view.h \
+ frogr-model.c \
+ frogr-model.h \
frogr-photoset.c \
frogr-photoset.h \
frogr-picture.c \
diff --git a/src/frogr-add-tags-dialog.c b/src/frogr-add-tags-dialog.c
index 8c85925..bb14e4f 100644
--- a/src/frogr-add-tags-dialog.c
+++ b/src/frogr-add-tags-dialog.c
@@ -25,7 +25,7 @@
#include "frogr-global-defs.h"
#include "frogr-live-entry.h"
#include "frogr-main-view.h"
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include "frogr-picture.h"
#include <config.h>
@@ -85,7 +85,7 @@ _dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
/* Check if there's something to add */
if (tags && !g_str_equal (tags, ""))
{
- FrogrMainViewModel *model = NULL;
+ FrogrModel *model = NULL;
FrogrPicture *picture = NULL;
GSList *item = NULL;
@@ -99,8 +99,8 @@ _dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
}
/* Add tags to the model */
- model = frogr_controller_get_main_view_model (frogr_controller_get_instance ());
- frogr_main_view_model_add_local_tags_from_string (model, tags);
+ model = frogr_controller_get_model (frogr_controller_get_instance ());
+ frogr_model_add_local_tags_from_string (model, tags);
}
/* Free */
diff --git a/src/frogr-add-to-group-dialog.c b/src/frogr-add-to-group-dialog.c
index 2ee8be0..1ae3fcf 100644
--- a/src/frogr-add-to-group-dialog.c
+++ b/src/frogr-add-to-group-dialog.c
@@ -22,7 +22,7 @@
#include "frogr-controller.h"
#include "frogr-group.h"
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include "frogr-picture.h"
#include <config.h>
@@ -401,7 +401,7 @@ _update_pictures (FrogrAddToGroupDialog *self)
selected_groups = _get_selected_groups (self);
if (selected_groups)
{
- FrogrMainViewModel *model = NULL;
+ FrogrModel *model = NULL;
for (item = priv->pictures; item; item = g_slist_next (item))
{
@@ -412,8 +412,8 @@ _update_pictures (FrogrAddToGroupDialog *self)
frogr_picture_set_groups (picture, g_slist_copy (selected_groups));
}
- model = frogr_controller_get_main_view_model (frogr_controller_get_instance ());
- frogr_main_view_model_notify_changes_in_pictures (model);
+ model = frogr_controller_get_model (frogr_controller_get_instance ());
+ frogr_model_notify_changes_in_pictures (model);
}
g_slist_free (selected_groups);
}
diff --git a/src/frogr-add-to-set-dialog.c b/src/frogr-add-to-set-dialog.c
index 6b641dd..ab300a0 100644
--- a/src/frogr-add-to-set-dialog.c
+++ b/src/frogr-add-to-set-dialog.c
@@ -21,7 +21,7 @@
#include "frogr-add-to-set-dialog.h"
#include "frogr-controller.h"
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include "frogr-photoset.h"
#include "frogr-picture.h"
@@ -402,7 +402,7 @@ _update_pictures (FrogrAddToSetDialog *self)
selected_sets = _get_selected_photosets (self);
if (selected_sets)
{
- FrogrMainViewModel *model = NULL;
+ FrogrModel *model = NULL;
for (item = priv->pictures; item; item = g_slist_next (item))
{
@@ -413,8 +413,8 @@ _update_pictures (FrogrAddToSetDialog *self)
frogr_picture_set_photosets (picture, g_slist_copy (selected_sets));
}
- model = frogr_controller_get_main_view_model (frogr_controller_get_instance ());
- frogr_main_view_model_notify_changes_in_pictures (model);
+ model = frogr_controller_get_model (frogr_controller_get_instance ());
+ frogr_model_notify_changes_in_pictures (model);
}
g_slist_free (selected_sets);
}
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 095f4e2..1b6a46a 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -211,7 +211,7 @@ static void _on_file_loaded (FrogrFileLoader *loader, FrogrPicture *picture, Fro
static void _on_files_loaded (FrogrFileLoader *loader, FrogrController *self);
-static void _on_model_deserialized (FrogrMainViewModel *model, FrogrController *self);
+static void _on_model_deserialized (FrogrModel *model, FrogrController *self);
static void _fetch_everything (FrogrController *self, gboolean force_fetch);
@@ -1304,9 +1304,9 @@ _complete_picture_upload_on_idle (gpointer data)
if (!up_data->error)
{
/* Remove it from the model if no error happened */
- FrogrMainViewModel *mainview_model = NULL;
- mainview_model = frogr_main_view_get_model (priv->mainview);
- frogr_main_view_model_remove_picture (mainview_model, picture);
+ FrogrModel *model = NULL;
+ model = frogr_main_view_get_model (priv->mainview);
+ frogr_model_remove_picture (model, picture);
}
else {
up_data->current = NULL;
@@ -1325,15 +1325,15 @@ static void
_on_file_loaded (FrogrFileLoader *loader, FrogrPicture *picture, FrogrController *self)
{
FrogrControllerPrivate *priv = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
g_return_if_fail (FROGR_IS_CONTROLLER (self));
g_return_if_fail (FROGR_IS_PICTURE (picture));
priv = FROGR_CONTROLLER_GET_PRIVATE (self);
- mainview_model = frogr_main_view_get_model (priv->mainview);
- frogr_main_view_model_add_picture (mainview_model, picture);
+ model = frogr_main_view_get_model (priv->mainview);
+ frogr_model_add_picture (model, picture);
}
static void
@@ -1344,7 +1344,7 @@ _on_files_loaded (FrogrFileLoader *loader, FrogrController *self)
}
static void
-_on_model_deserialized (FrogrMainViewModel *model, FrogrController *self)
+_on_model_deserialized (FrogrModel *model, FrogrController *self)
{
g_return_if_fail (FROGR_IS_CONTROLLER (self));
_set_state (self, FROGR_STATE_IDLE);
@@ -1401,7 +1401,7 @@ _fetch_photosets_cb (GObject *object, GAsyncResult *res, gpointer data)
FspSession *session = NULL;
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GSList *data_sets_list = NULL;
GSList *sets_list = NULL;
GError *error = NULL;
@@ -1451,8 +1451,8 @@ _fetch_photosets_cb (GObject *object, GAsyncResult *res, gpointer data)
}
/* Update main view's model */
- mainview_model = frogr_main_view_get_model (priv->mainview);
- frogr_main_view_model_set_remote_photosets (mainview_model, sets_list);
+ model = frogr_main_view_get_model (priv->mainview);
+ frogr_model_set_remote_photosets (model, sets_list);
priv->fetching_photosets = FALSE;
}
@@ -1481,7 +1481,7 @@ _fetch_groups_cb (GObject *object, GAsyncResult *res, gpointer data)
FspSession *session = NULL;
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GSList *data_groups_list = NULL;
GSList *groups_list = NULL;
GError *error = NULL;
@@ -1530,8 +1530,8 @@ _fetch_groups_cb (GObject *object, GAsyncResult *res, gpointer data)
}
/* Update main view's model */
- mainview_model = frogr_main_view_get_model (priv->mainview);
- frogr_main_view_model_set_groups (mainview_model, groups_list);
+ model = frogr_main_view_get_model (priv->mainview);
+ frogr_model_set_groups (model, groups_list);
priv->fetching_groups = FALSE;
}
@@ -1705,7 +1705,7 @@ _fetch_tags_cb (GObject *object, GAsyncResult *res, gpointer data)
FspSession *session = NULL;
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GSList *tags_list = NULL;
GError *error = NULL;
@@ -1732,8 +1732,8 @@ _fetch_tags_cb (GObject *object, GAsyncResult *res, gpointer data)
priv->tags_fetched = TRUE;
/* Update main view's model */
- mainview_model = frogr_main_view_get_model (priv->mainview);
- frogr_main_view_model_set_remote_tags (mainview_model, tags_list);
+ model = frogr_main_view_get_model (priv->mainview);
+ frogr_model_set_remote_tags (model, tags_list);
priv->fetching_tags = FALSE;
}
@@ -1805,7 +1805,7 @@ _show_details_dialog_on_idle (GSList *pictures)
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
FrogrMainView *mainview = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GtkWindow *window = NULL;
GSList *tags_list = NULL;
@@ -1819,8 +1819,8 @@ _show_details_dialog_on_idle (GSList *pictures)
frogr_main_view_hide_progress (mainview);
- mainview_model = frogr_main_view_get_model (priv->mainview);
- tags_list = frogr_main_view_model_get_tags (mainview_model);
+ model = frogr_main_view_get_model (priv->mainview);
+ tags_list = frogr_model_get_tags (model);
/* Sets already pre-fetched: show the dialog */
window = frogr_main_view_get_window (priv->mainview);
@@ -1839,7 +1839,7 @@ _show_add_tags_dialog_on_idle (GSList *pictures)
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
FrogrMainView *mainview = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GtkWindow *window = NULL;
GSList *tags_list = NULL;
@@ -1853,8 +1853,8 @@ _show_add_tags_dialog_on_idle (GSList *pictures)
frogr_main_view_hide_progress (mainview);
- mainview_model = frogr_main_view_get_model (priv->mainview);
- tags_list = frogr_main_view_model_get_tags (mainview_model);
+ model = frogr_main_view_get_model (priv->mainview);
+ tags_list = frogr_model_get_tags (model);
/* Sets already pre-fetched: show the dialog */
window = frogr_main_view_get_window (priv->mainview);
@@ -1873,7 +1873,7 @@ _show_create_new_set_dialog_on_idle (GSList *pictures)
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
FrogrMainView *mainview = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GtkWindow *window = NULL;
GSList *photosets = NULL;
@@ -1887,8 +1887,8 @@ _show_create_new_set_dialog_on_idle (GSList *pictures)
frogr_main_view_hide_progress (mainview);
- mainview_model = frogr_main_view_get_model (priv->mainview);
- photosets = frogr_main_view_model_get_photosets (mainview_model);
+ model = frogr_main_view_get_model (priv->mainview);
+ photosets = frogr_model_get_photosets (model);
window = frogr_main_view_get_window (priv->mainview);
frogr_create_new_set_dialog_show (window, pictures, photosets);
@@ -1906,7 +1906,7 @@ _show_add_to_set_dialog_on_idle (GSList *pictures)
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
FrogrMainView *mainview = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GtkWindow *window = NULL;
GSList *photosets = NULL;
@@ -1920,11 +1920,11 @@ _show_add_to_set_dialog_on_idle (GSList *pictures)
frogr_main_view_hide_progress (mainview);
- mainview_model = frogr_main_view_get_model (priv->mainview);
- photosets = frogr_main_view_model_get_photosets (mainview_model);
+ model = frogr_main_view_get_model (priv->mainview);
+ photosets = frogr_model_get_photosets (model);
window = frogr_main_view_get_window (priv->mainview);
- if (frogr_main_view_model_n_photosets (mainview_model) > 0)
+ if (frogr_model_n_photosets (model) > 0)
frogr_add_to_set_dialog_show (window, pictures, photosets);
else if (priv->photosets_fetched)
frogr_util_show_info_dialog (window, _("No sets found"));
@@ -1942,7 +1942,7 @@ _show_add_to_group_dialog_on_idle (GSList *pictures)
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
FrogrMainView *mainview = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GtkWindow *window = NULL;
GSList *groups = NULL;
@@ -1956,11 +1956,11 @@ _show_add_to_group_dialog_on_idle (GSList *pictures)
frogr_main_view_hide_progress (mainview);
- mainview_model = frogr_main_view_get_model (priv->mainview);
- groups = frogr_main_view_model_get_groups (mainview_model);
+ model = frogr_main_view_get_model (priv->mainview);
+ groups = frogr_model_get_groups (model);
window = frogr_main_view_get_window (priv->mainview);
- if (frogr_main_view_model_n_groups (mainview_model) > 0)
+ if (frogr_model_n_groups (model) > 0)
frogr_add_to_group_dialog_show (window, pictures, groups);
else if (priv->groups_fetched)
frogr_util_show_info_dialog (window, _("No groups found"));
@@ -2154,8 +2154,8 @@ frogr_controller_get_main_view (FrogrController *self)
return priv->mainview;
}
-FrogrMainViewModel *
-frogr_controller_get_main_view_model (FrogrController *self)
+FrogrModel *
+frogr_controller_get_model (FrogrController *self)
{
FrogrControllerPrivate *priv = NULL;
@@ -2695,11 +2695,11 @@ frogr_controller_upload_pictures (FrogrController *self)
}
else
{
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
GSList *pictures = NULL;
- mainview_model = frogr_main_view_get_model (priv->mainview);
- pictures = frogr_main_view_model_get_pictures (mainview_model);
+ model = frogr_main_view_get_model (priv->mainview);
+ pictures = frogr_model_get_pictures (model);
if (pictures)
{
UploadPicturesData *up_data = g_slice_new0 (UploadPicturesData);
@@ -2768,7 +2768,7 @@ frogr_controller_load_project_from_file (FrogrController *self, const gchar *pat
else
{
FrogrControllerPrivate *priv = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
JsonNode *json_root = NULL;
_set_state (self, FROGR_STATE_LOADING_PICTURES);
@@ -2780,11 +2780,11 @@ frogr_controller_load_project_from_file (FrogrController *self, const gchar *pat
frogr_controller_cancel_ongoing_requests (self);
/* Deserialize from the JSON data and update the model */
- mainview_model = frogr_main_view_get_model (priv->mainview);
+ model = frogr_main_view_get_model (priv->mainview);
json_root = json_parser_get_root (json_parser);
- frogr_main_view_model_deserialize (mainview_model, json_root);
+ frogr_model_deserialize (model, json_root);
- g_signal_connect (G_OBJECT (mainview_model), "model-deserialized",
+ g_signal_connect (G_OBJECT (model), "model-deserialized",
G_CALLBACK (_on_model_deserialized),
self);
}
@@ -2796,7 +2796,7 @@ void
frogr_controller_save_project_to_file (FrogrController *self, const gchar *path)
{
FrogrControllerPrivate *priv = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
JsonGenerator *json_gen = NULL;
JsonNode *serialized_model = NULL;
GError *error = NULL;
@@ -2804,9 +2804,9 @@ frogr_controller_save_project_to_file (FrogrController *self, const gchar *path)
g_return_if_fail(FROGR_IS_CONTROLLER (self));
priv = FROGR_CONTROLLER_GET_PRIVATE (self);
- mainview_model = frogr_main_view_get_model (priv->mainview);
+ model = frogr_main_view_get_model (priv->mainview);
- serialized_model = frogr_main_view_model_serialize (mainview_model);
+ serialized_model = frogr_model_serialize (model);
/* Create a JsonGenerator using the JsonNode as root */
json_gen = json_generator_new ();
diff --git a/src/frogr-controller.h b/src/frogr-controller.h
index 08a1b35..a929ebd 100644
--- a/src/frogr-controller.h
+++ b/src/frogr-controller.h
@@ -23,7 +23,7 @@
#include "frogr-account.h"
#include "frogr-main-view.h"
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include "frogr-picture.h"
#include <config.h>
@@ -67,7 +67,7 @@ FrogrController *frogr_controller_get_instance (void);
FrogrMainView *frogr_controller_get_main_view (FrogrController *self);
-FrogrMainViewModel *frogr_controller_get_main_view_model (FrogrController *self);
+FrogrModel *frogr_controller_get_model (FrogrController *self);
gboolean frogr_controller_run_app (FrogrController *self);
diff --git a/src/frogr-create-new-set-dialog.c b/src/frogr-create-new-set-dialog.c
index 9e85ca9..7a38806 100644
--- a/src/frogr-create-new-set-dialog.c
+++ b/src/frogr-create-new-set-dialog.c
@@ -22,7 +22,7 @@
#include "frogr-photoset.h"
#include "frogr-controller.h"
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include "frogr-picture.h"
#include "frogr-util.h"
@@ -170,18 +170,18 @@ _update_model (FrogrCreateNewSetDialog *self,
{
FrogrCreateNewSetDialogPrivate *priv = NULL;
FrogrController *controller = NULL;
- FrogrMainViewModel *mainview_model = NULL;
+ FrogrModel *model = NULL;
FrogrPhotoSet *new_set = NULL;
FrogrPicture *picture = NULL;
GSList *item = NULL;
priv = FROGR_CREATE_NEW_SET_DIALOG_GET_PRIVATE (self);
controller = frogr_controller_get_instance ();
- mainview_model = frogr_controller_get_main_view_model (controller);
+ model = frogr_controller_get_model (controller);
/* Add the set to the model */
new_set = frogr_photoset_new_local (title, description);
- frogr_main_view_model_add_local_photoset (mainview_model, new_set);
+ frogr_model_add_local_photoset (model, new_set);
/* Add the set to the list of sets for each picture */
for (item = priv->pictures; item; item = g_slist_next (item))
@@ -197,7 +197,7 @@ _update_model (FrogrCreateNewSetDialog *self,
}
}
- frogr_main_view_model_notify_changes_in_pictures (mainview_model);
+ frogr_model_notify_changes_in_pictures (model);
}
static void
diff --git a/src/frogr-details-dialog.c b/src/frogr-details-dialog.c
index 9f10249..57e7f29 100644
--- a/src/frogr-details-dialog.c
+++ b/src/frogr-details-dialog.c
@@ -26,7 +26,7 @@
#include "frogr-gtk-compat.h"
#include "frogr-live-entry.h"
#include "frogr-main-view.h"
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include "frogr-picture.h"
#include "frogr-util.h"
@@ -949,12 +949,12 @@ _save_data (FrogrDetailsDialog *self)
/* validate dialog */
if (_validate_dialog_data (self))
{
- FrogrMainViewModel *model = NULL;
+ FrogrModel *model = NULL;
FrogrPicture *picture;
GSList *item;
guint n_pictures;
- model = frogr_controller_get_main_view_model (frogr_controller_get_instance ());
+ model = frogr_controller_get_model (frogr_controller_get_instance ());
/* Iterate over the rest of elements */
n_pictures = g_slist_length (priv->pictures);
@@ -1001,10 +1001,10 @@ _save_data (FrogrDetailsDialog *self)
/* Add tags to the model */
if (!g_str_equal (tags, ""))
- frogr_main_view_model_add_local_tags_from_string (model, tags);
+ frogr_model_add_local_tags_from_string (model, tags);
/* Notify the model that pictures details have probably changed */
- frogr_main_view_model_notify_changes_in_pictures (model);
+ frogr_model_notify_changes_in_pictures (model);
}
else
{
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 86d43b2..c6a502f 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -28,7 +28,7 @@
#include "frogr-controller.h"
#include "frogr-global-defs.h"
#include "frogr-gtk-compat.h"
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include "frogr-picture.h"
#include "frogr-util.h"
@@ -63,7 +63,7 @@ G_DEFINE_TYPE (FrogrMainView, frogr_main_view, G_TYPE_OBJECT)
/* Private Data */
typedef struct _FrogrMainViewPrivate {
- FrogrMainViewModel *model;
+ FrogrModel *model;
FrogrController *controller;
FrogrConfig *config;
@@ -958,7 +958,7 @@ _n_pictures (FrogrMainView *self)
FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
/* Just return the number of pictures in the model */
- return frogr_main_view_model_n_pictures (priv->model);
+ return frogr_model_n_pictures (priv->model);
}
static void
@@ -1289,7 +1289,7 @@ _remove_selected_pictures (FrogrMainView *self)
for (item = selected_pictures; item; item = g_slist_next (item))
{
FrogrPicture *picture = FROGR_PICTURE (item->data);
- frogr_main_view_model_remove_picture (priv->model, picture);
+ frogr_model_remove_picture (priv->model, picture);
}
/* Update UI */
@@ -1365,7 +1365,7 @@ _reorder_pictures (FrogrMainView *self, SortingCriteria criteria, gboolean rever
new_order = g_new0 (gint, g_slist_length (current_list));
/* Use the original list (as loaded) as reference for sorting */
- list_as_loaded = g_slist_copy (frogr_main_view_model_get_pictures (priv->model));
+ list_as_loaded = g_slist_copy (frogr_model_get_pictures (priv->model));
if (property_name)
list_as_loaded = g_slist_sort_with_data (list_as_loaded,
(GCompareDataFunc) _compare_pictures_by_property,
@@ -1726,8 +1726,8 @@ _craft_state_description (FrogrMainView *mainview)
}
/* Check size of the loaded pictures, if any */
- pictures = frogr_main_view_model_get_pictures (priv->model);
- n_pictures = frogr_main_view_model_n_pictures (priv->model);
+ pictures = frogr_model_get_pictures (priv->model);
+ n_pictures = frogr_model_n_pictures (priv->model);
if (n_pictures)
{
GSList *item = NULL;
@@ -1927,7 +1927,7 @@ frogr_main_view_init (FrogrMainView *self)
#endif
/* Init model, controller and configuration */
- priv->model = frogr_main_view_model_new ();
+ priv->model = frogr_model_new ();
priv->controller = g_object_ref (frogr_controller_get_instance ());
priv->config = g_object_ref (frogr_config_get_instance ());
@@ -2386,7 +2386,7 @@ frogr_main_view_reorder_pictures (FrogrMainView *self)
_reorder_pictures (self, priv->sorting_criteria, priv->sorting_reversed);
}
-FrogrMainViewModel *
+FrogrModel *
frogr_main_view_get_model (FrogrMainView *self)
{
FrogrMainViewPrivate *priv = NULL;
diff --git a/src/frogr-main-view.h b/src/frogr-main-view.h
index 2472fdd..c0df2df 100644
--- a/src/frogr-main-view.h
+++ b/src/frogr-main-view.h
@@ -21,7 +21,7 @@
#ifndef FROGR_MAIN_VIEW_H
#define FROGR_MAIN_VIEW_H
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include <gtk/gtk.h>
@@ -69,7 +69,7 @@ void frogr_main_view_hide_progress (FrogrMainView *self);
void frogr_main_view_reorder_pictures (FrogrMainView *self);
-FrogrMainViewModel *frogr_main_view_get_model (FrogrMainView *self);
+FrogrModel *frogr_main_view_get_model (FrogrMainView *self);
G_END_DECLS
diff --git a/src/frogr-main-view-model.c b/src/frogr-model.c
similarity index 66%
rename from src/frogr-main-view-model.c
rename to src/frogr-model.c
index 44dc703..d524058 100644
--- a/src/frogr-main-view-model.c
+++ b/src/frogr-model.c
@@ -1,5 +1,5 @@
/*
- * frogr-main-view-model.c -- Main view model in frogr
+ * frogr-model.c -- Main view model in frogr
*
* Copyright (C) 2009-2012 Mario Sanchez Prada
* Authors: Mario Sanchez Prada <msanchez gnome org>
@@ -18,23 +18,23 @@
*
*/
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include "frogr-account.h"
#include "frogr-file-loader.h"
#define TAGS_DELIMITER " "
-#define FROGR_MAIN_VIEW_MODEL_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- FROGR_TYPE_MAIN_VIEW_MODEL, \
- FrogrMainViewModelPrivate))
+#define FROGR_MODEL_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ FROGR_TYPE_MODEL, \
+ FrogrModelPrivate))
-G_DEFINE_TYPE (FrogrMainViewModel, frogr_main_view_model, G_TYPE_OBJECT)
+G_DEFINE_TYPE (FrogrModel, frogr_model, G_TYPE_OBJECT)
/* Private struct */
-typedef struct _FrogrMainViewModelPrivate FrogrMainViewModelPrivate;
-struct _FrogrMainViewModelPrivate
+typedef struct _FrogrModelPrivate FrogrModelPrivate;
+struct _FrogrModelPrivate
{
GSList *pictures;
@@ -79,16 +79,16 @@ _compare_photosets (FrogrPhotoSet *photoset1, FrogrPhotoSet *photoset2)
}
static void
-_remove_remote_photosets (FrogrMainViewModel *self)
+_remove_remote_photosets (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
FrogrPhotoSet *set = NULL;
GSList *item = NULL;
const gchar *id = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
if (!priv->remote_sets)
return;
@@ -112,15 +112,15 @@ _remove_remote_photosets (FrogrMainViewModel *self)
}
static void
-_remove_local_photosets (FrogrMainViewModel *self)
+_remove_local_photosets (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
FrogrPhotoSet *set = NULL;
GSList *item = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
if (!priv->local_sets)
return;
@@ -137,14 +137,14 @@ _remove_local_photosets (FrogrMainViewModel *self)
}
static void
-_remove_pictures (FrogrMainViewModel *self)
+_remove_pictures (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
FrogrPicture *picture = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
while (priv->pictures)
{
picture = FROGR_PICTURE (priv->pictures->data);
@@ -160,13 +160,13 @@ _remove_pictures (FrogrMainViewModel *self)
}
static void
-_remove_all_photosets (FrogrMainViewModel *self)
+_remove_all_photosets (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
if (priv->all_sets)
{
g_slist_free (priv->all_sets);
@@ -181,13 +181,13 @@ _remove_all_photosets (FrogrMainViewModel *self)
}
static void
-_remove_groups (FrogrMainViewModel *self)
+_remove_groups (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
if (priv->groups)
{
g_slist_foreach (priv->groups, (GFunc)g_object_unref, NULL);
@@ -200,13 +200,13 @@ _remove_groups (FrogrMainViewModel *self)
}
static void
-_remove_remote_tags (FrogrMainViewModel *self)
+_remove_remote_tags (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
if (!priv->remote_tags)
return;
@@ -216,13 +216,13 @@ _remove_remote_tags (FrogrMainViewModel *self)
}
static void
-_remove_local_tags (FrogrMainViewModel *self)
+_remove_local_tags (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
if (!priv->local_tags)
return;
@@ -232,13 +232,13 @@ _remove_local_tags (FrogrMainViewModel *self)
}
static void
-_remove_all_tags (FrogrMainViewModel *self)
+_remove_all_tags (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
if (priv->all_tags)
{
g_slist_free (priv->all_tags);
@@ -304,23 +304,23 @@ _deserialize_list_from_json_array (JsonArray *array, GType g_type)
}
static void
-_on_file_loaded (FrogrFileLoader *loader, FrogrPicture *picture, FrogrMainViewModel *self)
+_on_file_loaded (FrogrFileLoader *loader, FrogrPicture *picture, FrogrModel *self)
{
- g_return_if_fail (FROGR_IS_MAIN_VIEW_MODEL (self));
- frogr_main_view_model_add_picture (self, picture);
+ g_return_if_fail (FROGR_IS_MODEL (self));
+ frogr_model_add_picture (self, picture);
}
static void
-_on_files_loaded (FrogrFileLoader *loader, FrogrMainViewModel *self)
+_on_files_loaded (FrogrFileLoader *loader, FrogrModel *self)
{
g_signal_emit (self, signals[MODEL_DESERIALIZED], 0);
}
static void
-_frogr_main_view_model_dispose (GObject* object)
+_frogr_model_dispose (GObject* object)
{
- FrogrMainViewModel *self = FROGR_MAIN_VIEW_MODEL (object);
- FrogrMainViewModelPrivate *priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (object);
+ FrogrModel *self = FROGR_MODEL (object);
+ FrogrModelPrivate *priv = FROGR_MODEL_GET_PRIVATE (object);
_remove_pictures (self);
_remove_all_photosets (self);
@@ -339,14 +339,14 @@ _frogr_main_view_model_dispose (GObject* object)
priv->groups_table = NULL;
}
- G_OBJECT_CLASS (frogr_main_view_model_parent_class)->dispose (object);
+ G_OBJECT_CLASS (frogr_model_parent_class)->dispose (object);
}
static void
-frogr_main_view_model_class_init(FrogrMainViewModelClass *klass)
+frogr_model_class_init(FrogrModelClass *klass)
{
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- obj_class->dispose = _frogr_main_view_model_dispose;
+ obj_class->dispose = _frogr_model_dispose;
signals[PICTURE_ADDED] =
g_signal_new ("picture-added",
@@ -380,14 +380,14 @@ frogr_main_view_model_class_init(FrogrMainViewModelClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- g_type_class_add_private (obj_class, sizeof (FrogrMainViewModelPrivate));
+ g_type_class_add_private (obj_class, sizeof (FrogrModelPrivate));
}
static void
-frogr_main_view_model_init (FrogrMainViewModel *self)
+frogr_model_init (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv =
- FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ FrogrModelPrivate *priv =
+ FROGR_MODEL_GET_PRIVATE (self);
/* Init private data */
priv->pictures = NULL;
@@ -412,23 +412,23 @@ frogr_main_view_model_init (FrogrMainViewModel *self)
/* Public API */
-FrogrMainViewModel *
-frogr_main_view_model_new (void)
+FrogrModel *
+frogr_model_new (void)
{
- GObject *new = g_object_new(FROGR_TYPE_MAIN_VIEW_MODEL, NULL);
- return FROGR_MAIN_VIEW_MODEL (new);
+ GObject *new = g_object_new(FROGR_TYPE_MODEL, NULL);
+ return FROGR_MODEL (new);
}
void
-frogr_main_view_model_add_picture (FrogrMainViewModel *self,
- FrogrPicture *picture)
+frogr_model_add_picture (FrogrModel *self,
+ FrogrPicture *picture)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
g_return_if_fail(FROGR_IS_PICTURE (picture));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
priv->pictures = g_slist_append (priv->pictures, g_object_ref (picture));
g_signal_emit (self, signals[PICTURE_ADDED], 0, picture);
@@ -436,14 +436,14 @@ frogr_main_view_model_add_picture (FrogrMainViewModel *self,
}
void
-frogr_main_view_model_remove_picture (FrogrMainViewModel *self,
- FrogrPicture *picture)
+frogr_model_remove_picture (FrogrModel *self,
+ FrogrPicture *picture)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
priv->pictures = g_slist_remove (priv->pictures, picture);
@@ -453,51 +453,51 @@ frogr_main_view_model_remove_picture (FrogrMainViewModel *self,
}
guint
-frogr_main_view_model_n_pictures (FrogrMainViewModel *self)
+frogr_model_n_pictures (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), 0);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), 0);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
return g_slist_length (priv->pictures);
}
GSList *
-frogr_main_view_model_get_pictures (FrogrMainViewModel *self)
+frogr_model_get_pictures (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), NULL);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), NULL);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
return priv->pictures;
}
void
-frogr_main_view_model_notify_changes_in_pictures (FrogrMainViewModel *self)
+frogr_model_notify_changes_in_pictures (FrogrModel *self)
{
/* Just emit the signal so the main view gets notified too */
g_signal_emit (self, signals[MODEL_CHANGED], 0);
}
void
-frogr_main_view_model_set_remote_photosets (FrogrMainViewModel *self,
- GSList *remote_sets)
+frogr_model_set_remote_photosets (FrogrModel *self,
+ GSList *remote_sets)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
FrogrPhotoSet *set = NULL;
GSList *item = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
/* Remove all the remote photosets */
_remove_remote_photosets (self);
/* Set photosets now (and update the hash table) */
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
for (item = remote_sets; item; item = g_slist_next (item))
{
set = FROGR_PHOTOSET (item->data);
@@ -509,36 +509,36 @@ frogr_main_view_model_set_remote_photosets (FrogrMainViewModel *self,
}
void
-frogr_main_view_model_add_local_photoset (FrogrMainViewModel *self,
- FrogrPhotoSet *set)
+frogr_model_add_local_photoset (FrogrModel *self,
+ FrogrPhotoSet *set)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
g_return_if_fail(FROGR_IS_PHOTOSET (set));
/* When adding one by one we prepend always to keep the order */
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
priv->local_sets = g_slist_prepend (priv->local_sets, g_object_ref (set));
/* Update the hash table too! */
g_hash_table_insert (priv->sets_table,
- g_strdup (frogr_photoset_get_id (set)),
+ g_strdup (frogr_photoset_get_local_id (set)),
g_object_ref (set));
g_signal_emit (self, signals[MODEL_CHANGED], 0);
}
GSList *
-frogr_main_view_model_get_photosets (FrogrMainViewModel *self)
+frogr_model_get_photosets (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
GSList *list = NULL;
GSList *current = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), 0);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), 0);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
/* Copy the list of remote sets and add those locally added */
list = g_slist_copy (priv->remote_sets);
@@ -557,14 +557,14 @@ frogr_main_view_model_get_photosets (FrogrMainViewModel *self)
}
void
-frogr_main_view_model_set_photosets (FrogrMainViewModel *self,
- GSList *photosets)
+frogr_model_set_photosets (FrogrModel *self,
+ GSList *photosets)
{
FrogrPhotoSet *set = NULL;
GSList *item = NULL;
GSList *next_item = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
/* Remove all sets */
_remove_all_photosets (self);
@@ -578,7 +578,7 @@ frogr_main_view_model_set_photosets (FrogrMainViewModel *self,
{
next_item = item->next;
photosets = g_slist_remove_link (photosets, item);
- frogr_main_view_model_add_local_photoset (self, set);
+ frogr_model_add_local_photoset (self, set);
g_object_unref (set);
g_slist_free (item);
@@ -589,64 +589,64 @@ frogr_main_view_model_set_photosets (FrogrMainViewModel *self,
}
/* Once separated the local photosets, we assign the remote ones */
- frogr_main_view_model_set_remote_photosets (self, photosets);
+ frogr_model_set_remote_photosets (self, photosets);
}
guint
-frogr_main_view_model_n_photosets (FrogrMainViewModel *self)
+frogr_model_n_photosets (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), 0);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), 0);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
return g_slist_length (priv->remote_sets) + g_slist_length (priv->local_sets);
}
FrogrPhotoSet *
-frogr_main_view_model_get_photoset_by_id (FrogrMainViewModel *self, const gchar *id)
+frogr_model_get_photoset_by_id (FrogrModel *self, const gchar *id)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), NULL);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), NULL);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
return g_hash_table_lookup (priv->sets_table, id);
}
guint
-frogr_main_view_model_n_groups (FrogrMainViewModel *self)
+frogr_model_n_groups (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), 0);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), 0);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
return g_slist_length (priv->groups);
}
GSList *
-frogr_main_view_model_get_groups (FrogrMainViewModel *self)
+frogr_model_get_groups (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), NULL);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), NULL);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
return priv->groups;
}
void
-frogr_main_view_model_set_groups (FrogrMainViewModel *self,
- GSList *groups)
+frogr_model_set_groups (FrogrModel *self,
+ GSList *groups)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
FrogrGroup *group = NULL;
GSList *item = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
/* Remove all groups */
_remove_groups (self);
@@ -665,37 +665,37 @@ frogr_main_view_model_set_groups (FrogrMainViewModel *self,
}
FrogrGroup *
-frogr_main_view_model_get_group_by_id (FrogrMainViewModel *self, const gchar *id)
+frogr_model_get_group_by_id (FrogrModel *self, const gchar *id)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), NULL);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), NULL);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
return g_hash_table_lookup (priv->groups_table, id);
}
void
-frogr_main_view_model_set_remote_tags (FrogrMainViewModel *self, GSList *tags_list)
+frogr_model_set_remote_tags (FrogrModel *self, GSList *tags_list)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
_remove_remote_tags (self);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
priv->remote_tags = tags_list;
}
void
-frogr_main_view_model_remove_remote_tags (FrogrMainViewModel *self)
+frogr_model_remove_remote_tags (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
g_slist_foreach (priv->remote_tags, (GFunc)g_free, NULL);
g_slist_free (priv->remote_tags);
@@ -704,13 +704,13 @@ frogr_main_view_model_remove_remote_tags (FrogrMainViewModel *self)
}
void
-frogr_main_view_model_add_local_tags_from_string (FrogrMainViewModel *self,
- const gchar *tags_string)
+frogr_model_add_local_tags_from_string (FrogrModel *self,
+ const gchar *tags_string)
{
gchar *stripped_tags = NULL;
gboolean added_new_tags = FALSE;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
if (!tags_string || !tags_string[0])
return;
@@ -718,13 +718,13 @@ frogr_main_view_model_add_local_tags_from_string (FrogrMainViewModel *self,
stripped_tags = g_strstrip (g_strdup (tags_string));
if (!g_str_equal (stripped_tags, ""))
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
gchar **tags_array = NULL;
gchar *tag;
gint i;
/* Now iterate over every token, adding it to the list */
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
tags_array = g_strsplit (stripped_tags, TAGS_DELIMITER, -1);
for (i = 0; tags_array[i]; i++)
{
@@ -749,15 +749,15 @@ frogr_main_view_model_add_local_tags_from_string (FrogrMainViewModel *self,
}
GSList *
-frogr_main_view_model_get_tags (FrogrMainViewModel *self)
+frogr_model_get_tags (FrogrModel *self)
{
- FrogrMainViewModelPrivate *priv = NULL;
+ FrogrModelPrivate *priv = NULL;
GSList *list = NULL;
GSList *current = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), 0);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), 0);
- priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
+ priv = FROGR_MODEL_GET_PRIVATE (self);
/* Copy the list of remote tags and add those locally added */
list = g_slist_copy (priv->remote_tags);
@@ -777,30 +777,30 @@ frogr_main_view_model_get_tags (FrogrMainViewModel *self)
}
JsonNode *
-frogr_main_view_model_serialize (FrogrMainViewModel *self)
+frogr_model_serialize (FrogrModel *self)
{
JsonArray *json_array = NULL;
JsonNode *root_node = NULL;
JsonObject *root_object = NULL;
GSList *data_list = NULL;
- g_return_val_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self), NULL);
+ g_return_val_if_fail(FROGR_IS_MODEL (self), NULL);
root_object = json_object_new ();
- data_list = frogr_main_view_model_get_pictures (self);
+ data_list = frogr_model_get_pictures (self);
json_array = _serialize_list_to_json_array (data_list, G_TYPE_OBJECT);
json_object_set_array_member (root_object, "pictures", json_array);
- data_list = frogr_main_view_model_get_photosets (self);
+ data_list = frogr_model_get_photosets (self);
json_array = _serialize_list_to_json_array (data_list, G_TYPE_OBJECT);
json_object_set_array_member (root_object, "photosets", json_array);
- data_list = frogr_main_view_model_get_groups (self);
+ data_list = frogr_model_get_groups (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_main_view_model_get_tags (self);
+ data_list = frogr_model_get_tags (self);
json_array = _serialize_list_to_json_array (data_list, G_TYPE_STRING);
json_object_set_array_member (root_object, "tags", json_array);
@@ -811,7 +811,7 @@ frogr_main_view_model_serialize (FrogrMainViewModel *self)
}
void
-frogr_main_view_model_deserialize (FrogrMainViewModel *self, JsonNode *json_node)
+frogr_model_deserialize (FrogrModel *self, JsonNode *json_node)
{
FrogrFileLoader *loader = NULL;
JsonObject *root_object = NULL;
@@ -821,7 +821,7 @@ frogr_main_view_model_deserialize (FrogrMainViewModel *self, JsonNode *json_node
GSList *groups = NULL;
GSList *tags = NULL;
- g_return_if_fail(FROGR_IS_MAIN_VIEW_MODEL (self));
+ g_return_if_fail(FROGR_IS_MODEL (self));
/* First we get the different lists with data */
root_object = json_node_get_object (json_node);
@@ -843,9 +843,9 @@ frogr_main_view_model_deserialize (FrogrMainViewModel *self, JsonNode *json_node
tags = _deserialize_list_from_json_array (array_member, G_TYPE_STRING);
/* We set the sets, groups and tags */
- frogr_main_view_model_set_photosets (self, sets);
- frogr_main_view_model_set_groups (self, groups);
- frogr_main_view_model_set_remote_tags (self, tags);
+ frogr_model_set_photosets (self, sets);
+ frogr_model_set_groups (self, groups);
+ frogr_model_set_remote_tags (self, tags);
/* Now we take the list of pictures and carefully ad them into the
model as long as the associated thumbnails are being loaded */
diff --git a/src/frogr-model.h b/src/frogr-model.h
new file mode 100644
index 0000000..7fb9786
--- /dev/null
+++ b/src/frogr-model.h
@@ -0,0 +1,118 @@
+/*
+ * frogr-model.h -- Main view model in frogr
+ *
+ * Copyright (C) 2009-2012 Mario Sanchez Prada
+ * Authors: Mario Sanchez Prada <msanchez gnome org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 3 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef _FROGR_MODEL_H
+#define _FROGR_MODEL_H
+
+#include "frogr-account.h"
+#include "frogr-photoset.h"
+#include "frogr-picture.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <json-glib/json-glib.h>
+
+G_BEGIN_DECLS
+
+#define FROGR_TYPE_MODEL (frogr_model_get_type())
+#define FROGR_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, FROGR_TYPE_MODEL, FrogrModel))
+#define FROGR_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, FROGR_TYPE_MODEL, FrogrModelClass))
+#define FROGR_IS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, FROGR_TYPE_MODEL))
+#define FROGR_IS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), FROGR_TYPE_MODEL))
+#define FROGR_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FROGR_TYPE_MODEL, FrogrModelClass))
+
+typedef struct _FrogrModel FrogrModel;
+typedef struct _FrogrModelClass FrogrModelClass;
+
+struct _FrogrModel
+{
+ GObject parent_instance;
+};
+
+struct _FrogrModelClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType frogr_model_get_type(void) G_GNUC_CONST;
+
+FrogrModel *frogr_model_new (void);
+
+/* Pictures */
+
+void frogr_model_add_picture (FrogrModel *self,
+ FrogrPicture *fset);
+void frogr_model_remove_picture (FrogrModel *self,
+ FrogrPicture *fset);
+
+guint frogr_model_n_pictures (FrogrModel *self);
+
+GSList *frogr_model_get_pictures (FrogrModel *self);
+
+void frogr_model_notify_changes_in_pictures (FrogrModel *self);
+
+/* Photosets */
+
+void frogr_model_set_remote_photosets (FrogrModel *self,
+ GSList *photosets_list);
+
+void frogr_model_add_local_photoset (FrogrModel *self,
+ FrogrPhotoSet *fset);
+
+GSList *frogr_model_get_photosets (FrogrModel *self);
+
+void frogr_model_set_photosets (FrogrModel *self,
+ GSList *photosets);
+
+guint frogr_model_n_photosets (FrogrModel *self);
+
+FrogrPhotoSet *frogr_model_get_photoset_by_id (FrogrModel *self,
+ const gchar *id);
+/* Groups */
+
+guint frogr_model_n_groups (FrogrModel *self);
+
+GSList *frogr_model_get_groups (FrogrModel *self);
+
+void frogr_model_set_groups (FrogrModel *self,
+ GSList *groups_list);
+
+FrogrGroup *frogr_model_get_group_by_id (FrogrModel *self,
+ const gchar *id);
+/* Tags */
+
+void frogr_model_set_remote_tags (FrogrModel *self,
+ GSList *tags_list);
+
+void frogr_model_add_local_tags_from_string (FrogrModel *self,
+ const gchar *tags_string);
+
+GSList *frogr_model_get_tags (FrogrModel *self);
+
+/* Serialization */
+
+JsonNode *frogr_model_serialize (FrogrModel *self);
+
+void frogr_model_deserialize (FrogrModel *self, JsonNode *json_node);
+
+G_END_DECLS
+
+#endif
diff --git a/src/frogr-picture.c b/src/frogr-picture.c
index d32f16d..d3b91df 100644
--- a/src/frogr-picture.c
+++ b/src/frogr-picture.c
@@ -21,7 +21,7 @@
#include "frogr-picture.h"
#include "frogr-controller.h"
-#include "frogr-main-view-model.h"
+#include "frogr-model.h"
#include <json-glib/json-glib.h>
@@ -299,7 +299,7 @@ _serialize_list (GSList *objects_list, GType g_type)
static gboolean
_deserialize_list (JsonNode *node, GValue *value, GType g_type)
{
- FrogrMainViewModel *model = NULL;
+ FrogrModel *model = NULL;
JsonArray *array = NULL;
GSList *objects = NULL;
GObject *object = NULL;
@@ -316,15 +316,15 @@ _deserialize_list (JsonNode *node, GValue *value, GType g_type)
/* We need to get the groups and sets from the model by ID, so it's
mandatory to have imported those first for this to work OK */
- model = frogr_controller_get_main_view_model (frogr_controller_get_instance ());
+ model = frogr_controller_get_model (frogr_controller_get_instance ());
for (i = 0; i < n_elements; i++)
{
const gchar *id = NULL;
id = json_array_get_string_element (array, i);
if (g_type == FROGR_TYPE_PHOTOSET)
- object = G_OBJECT (frogr_main_view_model_get_photoset_by_id (model, id));
+ object = G_OBJECT (frogr_model_get_photoset_by_id (model, id));
if (g_type == FROGR_TYPE_GROUP)
- object = G_OBJECT (frogr_main_view_model_get_group_by_id (model, id));
+ object = G_OBJECT (frogr_model_get_group_by_id (model, id));
if (object)
objects = g_slist_prepend (objects, g_object_ref (object));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]