[frogr] New signal 'model-deserialized', to notify when the proces is finished.
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] New signal 'model-deserialized', to notify when the proces is finished.
- Date: Sun, 11 Nov 2012 00:09:23 +0000 (UTC)
commit 86c58ea38176e9c90e66dad94461385de1854a75
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Fri Nov 9 17:47:56 2012 +0100
New signal 'model-deserialized', to notify when the proces is finished.
Also, connected from the proper places in the controller and the main view
src/frogr-controller.c | 21 ++++++++++++++++-----
src/frogr-main-view-model.c | 9 +++++++++
src/frogr-main-view.c | 12 ++++++++++++
3 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index f73cd1e..9eee149 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -211,6 +211,8 @@ 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 _fetch_everything (FrogrController *self, gboolean force_fetch);
static void _fetch_photosets (FrogrController *self);
@@ -1342,6 +1344,13 @@ _on_files_loaded (FrogrFileLoader *loader, FrogrController *self)
}
static void
+_on_model_deserialized (FrogrMainViewModel *model, FrogrController *self)
+{
+ g_return_if_fail (FROGR_IS_CONTROLLER (self));
+ _set_state (self, FROGR_STATE_IDLE);
+}
+
+static void
_fetch_everything (FrogrController *self, gboolean force_fetch)
{
FrogrControllerPrivate *priv = NULL;
@@ -2745,6 +2754,7 @@ frogr_controller_load_project_from_file (FrogrController *self, const gchar *pat
GError *error = NULL;
g_return_if_fail(FROGR_IS_CONTROLLER (self));
+ g_return_if_fail(path);
/* Load from disk */
json_parser = json_parser_new ();
@@ -2761,10 +2771,11 @@ frogr_controller_load_project_from_file (FrogrController *self, const gchar *pat
FrogrMainViewModel *mainview_model = NULL;
JsonNode *json_root = NULL;
- priv = FROGR_CONTROLLER_GET_PRIVATE (self);
+ _set_state (self, FROGR_STATE_LOADING_PICTURES);
/* Make sure we are not fetching any data from the network at
this moment, or cancel otherwise, so the model is ready */
+ priv = FROGR_CONTROLLER_GET_PRIVATE (self);
if (priv->fetching_photosets || priv->fetching_groups || priv->fetching_tags)
frogr_controller_cancel_ongoing_requests (self);
@@ -2773,11 +2784,11 @@ frogr_controller_load_project_from_file (FrogrController *self, const gchar *pat
json_root = json_parser_get_root (json_parser);
frogr_main_view_model_deserialize (mainview_model, json_root);
- /* TODO: We now should have the relevant data in the model, and
- so we would just need to load the pixbufs for all the pictures */
-
json_node_free (json_root);
- }
+ g_signal_connect (G_OBJECT (mainview_model), "model-deserialized",
+ G_CALLBACK (_on_model_deserialized),
+ self);
+ }
g_object_unref (json_parser);
diff --git a/src/frogr-main-view-model.c b/src/frogr-main-view-model.c
index d0f46c5..79df2b0 100644
--- a/src/frogr-main-view-model.c
+++ b/src/frogr-main-view-model.c
@@ -56,6 +56,7 @@ enum {
PICTURE_REMOVED,
PICTURES_REORDERED,
MODEL_CHANGED,
+ MODEL_DESERIALIZED,
N_SIGNALS
};
@@ -269,6 +270,14 @@ frogr_main_view_model_class_init(FrogrMainViewModelClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[MODEL_DESERIALIZED] =
+ g_signal_new ("model-deserialized",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
g_type_class_add_private (obj_class, sizeof (FrogrMainViewModelPrivate));
}
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 1e5a2a1..a7150a4 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -249,6 +249,8 @@ static void _model_pictures_reordered (FrogrController *controller,
static void _model_changed (FrogrController *controller, gpointer data);
+static void _model_deserialized (FrogrController *controller, gpointer data);
+
static void _update_account_menu_items (FrogrMainView *mainview);
static void _update_state_description (FrogrMainView *mainview);
@@ -1519,6 +1521,13 @@ _model_changed (FrogrController *controller, gpointer data)
}
static void
+_model_deserialized (FrogrController *controller, gpointer data)
+{
+ /* Reflect that the current state is not 'dirty' (just loaded) */
+ _update_window_title (FROGR_MAIN_VIEW (data), FALSE);
+}
+
+static void
_update_account_menu_items (FrogrMainView *mainview)
{
FrogrMainViewPrivate *priv = NULL;
@@ -2100,6 +2109,9 @@ frogr_main_view_init (FrogrMainView *self)
g_signal_connect (G_OBJECT (priv->model), "model-changed",
G_CALLBACK (_model_changed), self);
+ g_signal_connect (G_OBJECT (priv->model), "model-deserialized",
+ G_CALLBACK (_model_deserialized), self);
+
gtk_builder_connect_signals (builder, self);
/* Show the UI */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]