[frogr] Allow more fine-grained detail handling states for the whole app.



commit b7ce1c1a841eb37b71a1dac7cb69acfbb738fcce
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Fri Apr 22 18:42:43 2011 +0200

    Allow more fine-grained detail handling states for the whole app.
    
    Now it's possible to distinguish between 3 (4) states: unknown (not
    actually a state), idle, loading pictures and uploading pictures. Also
    provided a FROGR_STATE_IS_BUSY(state) macro as a convenient way to
    check in a single statement whether the application is busy.

 src/frogr-controller.c |   10 +++++-----
 src/frogr-controller.h |    7 +++++--
 src/frogr-main-view.c  |    7 ++++---
 3 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/src/frogr-controller.c b/src/frogr-controller.c
index 0bb4806..03ccacf 100644
--- a/src/frogr-controller.c
+++ b/src/frogr-controller.c
@@ -1881,7 +1881,7 @@ frogr_controller_set_active_account (FrogrController *self,
 FrogrAccount *
 frogr_controller_get_active_account (FrogrController *self)
 {
-  g_return_val_if_fail(FROGR_IS_CONTROLLER (self), FROGR_STATE_UKNOWN);
+  g_return_val_if_fail(FROGR_IS_CONTROLLER (self), FROGR_STATE_UNKNOWN);
 
   FrogrControllerPrivate *priv = FROGR_CONTROLLER_GET_PRIVATE (self);
   return priv->account;
@@ -1890,7 +1890,7 @@ frogr_controller_get_active_account (FrogrController *self)
 GSList *
 frogr_controller_get_all_accounts (FrogrController *self)
 {
-  g_return_val_if_fail(FROGR_IS_CONTROLLER (self), FROGR_STATE_UKNOWN);
+  g_return_val_if_fail(FROGR_IS_CONTROLLER (self), FROGR_STATE_UNKNOWN);
 
   FrogrControllerPrivate *priv = FROGR_CONTROLLER_GET_PRIVATE (self);
   return frogr_config_get_accounts (priv->config);
@@ -1899,7 +1899,7 @@ frogr_controller_get_all_accounts (FrogrController *self)
 FrogrControllerState
 frogr_controller_get_state (FrogrController *self)
 {
-  g_return_val_if_fail(FROGR_IS_CONTROLLER (self), FROGR_STATE_UKNOWN);
+  g_return_val_if_fail(FROGR_IS_CONTROLLER (self), FROGR_STATE_UNKNOWN);
 
   FrogrControllerPrivate *priv = FROGR_CONTROLLER_GET_PRIVATE (self);
   return priv->state;
@@ -2148,7 +2148,7 @@ frogr_controller_load_pictures (FrogrController *self,
                                        (FrogrPicturesLoadedCallback) _on_pictures_loaded,
                                        self);
   /* Load the pictures! */
-  _set_state (self, FROGR_STATE_BUSY);
+  _set_state (self, FROGR_STATE_LOADING_PICTURES);
 
   frogr_picture_loader_load (fploader);
 }
@@ -2189,7 +2189,7 @@ frogr_controller_upload_pictures (FrogrController *self)
                                         (FrogrPicturesUploadedCallback) _on_pictures_uploaded,
                                         self);
           /* Load the pictures! */
-          _set_state (self, FROGR_STATE_BUSY);
+          _set_state (self, FROGR_STATE_UPLOADING_PICTURES);
           frogr_picture_uploader_upload (fpuploader);
         }
     }
diff --git a/src/frogr-controller.h b/src/frogr-controller.h
index 54ac074..fd2e39a 100644
--- a/src/frogr-controller.h
+++ b/src/frogr-controller.h
@@ -53,11 +53,14 @@ struct _FrogrController
 };
 
 typedef enum {
-  FROGR_STATE_UKNOWN,
+  FROGR_STATE_UNKNOWN,
   FROGR_STATE_IDLE,
-  FROGR_STATE_BUSY
+  FROGR_STATE_LOADING_PICTURES,
+  FROGR_STATE_UPLOADING_PICTURES
 } FrogrControllerState;
 
+#define FROGR_STATE_IS_BUSY(state) ((state) != FROGR_STATE_UNKNOWN && (state) != FROGR_STATE_IDLE)
+
 GType frogr_controller_get_type (void) G_GNUC_CONST;
 
 FrogrController *frogr_controller_get_instance (void);
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index a56de61..bf1abf1 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -524,8 +524,8 @@ _on_icon_view_drag_data_received (GtkWidget *widget,
   self = FROGR_MAIN_VIEW (data);
   priv = FROGR_MAIN_VIEW_GET_PRIVATE (data);
 
-  /* Do anything when the application is busy doing something else */
-  if (frogr_controller_get_state (priv->controller) == FROGR_STATE_BUSY)
+  /* Do nothing when the application is busy doing something else */
+  if (FROGR_STATE_IS_BUSY(frogr_controller_get_state (priv->controller)))
     return;
 
   target = gtk_selection_data_get_target (selection_data);
@@ -1322,7 +1322,8 @@ _update_ui (FrogrMainView *self)
   /* Set sensitiveness */
   switch (frogr_controller_get_state (priv->controller))
     {
-    case FROGR_STATE_BUSY:
+    case FROGR_STATE_LOADING_PICTURES:
+    case FROGR_STATE_UPLOADING_PICTURES:
       gtk_widget_set_sensitive (priv->add_button, FALSE);
       gtk_widget_set_sensitive (priv->add_menu_item, FALSE);
       gtk_widget_set_sensitive (priv->remove_button, FALSE);



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