[frogr] Move state_description from model to the main view



commit 91d9e7a377e25fd3a911097976c6fb7cfb4d6e97
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Thu Aug 25 09:18:02 2011 +0200

    Move state_description from model to the main view

 src/frogr-main-view-model.c |   41 -------------------------------------
 src/frogr-main-view-model.h |    5 ----
 src/frogr-main-view.c       |   47 ++++++++++--------------------------------
 3 files changed, 11 insertions(+), 82 deletions(-)
---
diff --git a/src/frogr-main-view-model.c b/src/frogr-main-view-model.c
index 2a4274b..e788aa3 100644
--- a/src/frogr-main-view-model.c
+++ b/src/frogr-main-view-model.c
@@ -47,8 +47,6 @@ struct _FrogrMainViewModelPrivate
 
   GSList *tags_list;
   guint n_tags;
-
-  gchar* state_description;
 };
 
 /* Signals */
@@ -169,19 +167,10 @@ _frogr_main_view_model_dispose (GObject* object)
 }
 
 static void
-_frogr_main_view_model_finalize (GObject* object)
-{
-  FrogrMainViewModelPrivate *priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (object);
-  g_free (priv->state_description);
-  G_OBJECT_CLASS (frogr_main_view_model_parent_class)->finalize (object);
-}
-
-static void
 frogr_main_view_model_class_init(FrogrMainViewModelClass *klass)
 {
   GObjectClass *obj_class = G_OBJECT_CLASS(klass);
   obj_class->dispose = _frogr_main_view_model_dispose;
-  obj_class->finalize = _frogr_main_view_model_finalize;
 
   signals[PICTURE_ADDED] =
     g_signal_new ("picture-added",
@@ -237,8 +226,6 @@ frogr_main_view_model_init (FrogrMainViewModel *self)
 
   priv->tags_list = NULL;
   priv->n_tags = 0;
-
-  priv->state_description = NULL;
 }
 
 /* Public API */
@@ -609,31 +596,3 @@ frogr_main_view_model_n_tags (FrogrMainViewModel *self)
   priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
   return priv->n_tags;
 }
-
-const gchar *
-frogr_main_view_model_get_state_description (FrogrMainViewModel *self)
-{
-  FrogrMainViewModelPrivate *priv = NULL;
-
-  g_return_val_if_fail (FROGR_IS_MAIN_VIEW_MODEL (self), NULL);
-
-  priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
-  return priv->state_description;
-}
-
-void
-frogr_main_view_model_set_state_description (FrogrMainViewModel *self,
-                                             const gchar *description)
-{
-  FrogrMainViewModelPrivate *priv = NULL;
-
-  g_return_if_fail (FROGR_IS_MAIN_VIEW_MODEL (self));
-
-  priv = FROGR_MAIN_VIEW_MODEL_GET_PRIVATE (self);
-  if (priv->state_description)
-    g_free (priv->state_description);
-
-  priv->state_description = g_strdup (description);
-
-  g_signal_emit (self, signals[DESCRIPTION_UPDATED], 0);
-}
diff --git a/src/frogr-main-view-model.h b/src/frogr-main-view-model.h
index 3affa05..ec69f6a 100644
--- a/src/frogr-main-view-model.h
+++ b/src/frogr-main-view-model.h
@@ -103,11 +103,6 @@ void frogr_main_view_model_remove_all_tags (FrogrMainViewModel *self);
 
 guint frogr_main_view_model_n_tags (FrogrMainViewModel *self);
 
-const gchar *frogr_main_view_model_get_state_description (FrogrMainViewModel *self);
-
-void frogr_main_view_model_set_state_description (FrogrMainViewModel *self,
-                                                  const gchar *description);
-
 G_END_DECLS
 
 #endif
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 5b5db15..10252dc 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -86,6 +86,7 @@ typedef struct _FrogrMainViewPrivate {
   GtkWidget *progress_bar;
   GtkWidget *progress_label;
   gboolean progress_is_showing;
+  gchar* state_description;
 
   GtkTreeModel *tree_model;
   guint sb_context_id;
@@ -215,9 +216,6 @@ static void _model_pictures_reordered (FrogrController *controller,
                                        gpointer new_order,
                                        gpointer data);
 
-static void _model_description_updated (FrogrController *controller,
-                                        gpointer data);
-
 static void _update_account_menu_items (FrogrMainView *mainview);
 
 static void _update_state_description (FrogrMainView *mainview);
@@ -1191,26 +1189,6 @@ _model_pictures_reordered (FrogrController *controller,
 }
 
 static void
-_model_description_updated (FrogrController *controller,
-                            gpointer data)
-{
-  FrogrMainView *mainview = NULL;
-  FrogrMainViewPrivate *priv = NULL;
-
-  mainview = FROGR_MAIN_VIEW (data);
-  priv = FROGR_MAIN_VIEW_GET_PRIVATE (mainview);
-
-  /* Do not force updating the status bar when loading pictures */
-  if (frogr_controller_get_state (priv->controller) != FROGR_STATE_LOADING_PICTURES)
-    {
-      const gchar *description = NULL;
-
-      description = frogr_main_view_model_get_state_description (priv->model);
-      frogr_main_view_set_status_text (mainview, description);
-    }
-}
-
-static void
 _update_account_menu_items (FrogrMainView *mainview)
 {
   FrogrMainViewPrivate *priv = NULL;
@@ -1248,12 +1226,15 @@ static void
 _update_state_description (FrogrMainView *mainview)
 {
   FrogrMainViewPrivate *priv = NULL;
-  gchar *description = NULL;
 
   priv = FROGR_MAIN_VIEW_GET_PRIVATE (mainview);
-  description = _craft_state_description (mainview);
-  frogr_main_view_model_set_state_description (priv->model, description);
-  g_free (description);
+
+  g_free (priv->state_description);
+  priv->state_description = _craft_state_description (mainview);
+
+  /* Do not force updating the status bar when loading pictures */
+  if (frogr_controller_get_state (priv->controller) != FROGR_STATE_LOADING_PICTURES)
+    frogr_main_view_set_status_text (mainview, priv->state_description);
 }
 
 static gchar *
@@ -1412,12 +1393,7 @@ _update_ui (FrogrMainView *self)
 
   /* Update status bar from model's state description */
   if (frogr_controller_get_state (priv->controller) == FROGR_STATE_IDLE)
-    {
-      const gchar *state_description = NULL;
-
-      state_description = frogr_main_view_model_get_state_description (priv->model);
-      frogr_main_view_set_status_text (self, state_description);
-    }
+    frogr_main_view_set_status_text (self, priv->state_description);
 }
 
 static void
@@ -1465,6 +1441,7 @@ _frogr_main_view_finalize (GObject *object)
   FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (object);
 
   gtk_widget_destroy (GTK_WIDGET (priv->window));
+  g_free (priv->state_description);
 
   G_OBJECT_CLASS(frogr_main_view_parent_class)->finalize (object);
 }
@@ -1711,6 +1688,7 @@ frogr_main_view_init (FrogrMainView *self)
   priv->progress_bar = progress_bar;
   priv->progress_label = progress_label;
   priv->progress_is_showing = FALSE;
+  priv->state_description = NULL;
 
   /* Initialize model */
   priv->tree_model = GTK_TREE_MODEL (gtk_list_store_new (3,
@@ -1779,9 +1757,6 @@ frogr_main_view_init (FrogrMainView *self)
   g_signal_connect (G_OBJECT (priv->model), "pictures-reordered",
                     G_CALLBACK (_model_pictures_reordered), self);
 
-  g_signal_connect (G_OBJECT (priv->model), "description-updated",
-                    G_CALLBACK (_model_description_updated), self);
-
   gtk_builder_connect_signals (builder, self);
 
   /* Show the UI, but hiding some widgets */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]