* Added a new signal "updating-msg-list" to the header view
authorSergio Villar Senin <svillar@igalia.com>
Thu, 4 Oct 2007 08:12:40 +0000 (08:12 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Thu, 4 Oct 2007 08:12:40 +0000 (08:12 +0000)
* Now the Main window shows an "updating banner" whenever the refresh of a folder takes more than 2 seconds

pmo-trunk-r3465

src/maemo/modest-main-window.c
src/modest-account-mgr.c
src/widgets/modest-header-view.c
src/widgets/modest-header-view.h

index 2183f14..c6cbb22 100644 (file)
@@ -173,6 +173,10 @@ static void      modest_main_window_on_folder_selection_changed (ModestFolderVie
                                                
 static void set_at_least_one_account_visible(ModestMainWindow *self);
 
+static void on_updating_msg_list (ModestHeaderView *header_view,
+                                 gboolean starting,
+                                 gpointer user_data);
+
 typedef struct _ModestMainWindowPrivate ModestMainWindowPrivate;
 struct _ModestMainWindowPrivate {
        GtkWidget *msg_paned;
@@ -217,6 +221,10 @@ struct _ModestMainWindowPrivate {
        /* Signal handler UIDs */
        GList *queue_err_signals;
        GSList *sighandlers;
+
+       /* "Updating" banner for header view */
+       GtkWidget *updating_banner;
+       guint updating_banner_timeout;
 };
 #define MODEST_MAIN_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
                                                 MODEST_TYPE_MAIN_WINDOW, \
@@ -340,6 +348,8 @@ modest_main_window_init (ModestMainWindow *obj)
        priv->send_receive_in_progress  = FALSE;
        priv->progress_bar_timeout = 0;
        priv->sighandlers = NULL;
+       priv->updating_banner = NULL;
+       priv->updating_banner_timeout = 0;
 }
 
 static void
@@ -364,6 +374,11 @@ modest_main_window_finalize (GObject *obj)
                priv->progress_bar_timeout = 0;
        }
 
+       if (priv->updating_banner_timeout > 0) {
+               g_source_remove (priv->updating_banner_timeout);
+               priv->updating_banner_timeout = 0;
+       }
+
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
@@ -836,6 +851,12 @@ connect_signals (ModestMainWindow *self)
        priv->sighandlers = 
                modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (priv->header_view), "focus-in-event",
                                           G_CALLBACK (on_header_view_focus_in), self);
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,
+                                          G_OBJECT (priv->header_view), 
+                                          "updating-msg-list",
+                                          G_CALLBACK (on_updating_msg_list), 
+                                          self);
        
        /* Header view CSM */
        menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/HeaderViewCSM");
@@ -958,7 +979,7 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
        gtk_widget_show (GTK_WIDGET (priv->folder_view));
 
        /* Connect signals */
-       connect_signals ((ModestMainWindow*)self);
+       connect_signals (MODEST_MAIN_WINDOW (self));
 
        /* Set account store */
        tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
@@ -2417,3 +2438,54 @@ modest_main_window_on_msg_view_window_msg_changed (ModestMsgViewWindow *view_win
        return TRUE;
 }
 
+static gboolean
+show_updating_banner (gpointer user_data)
+{
+       ModestMainWindowPrivate *priv = NULL;
+
+       priv = MODEST_MAIN_WINDOW_GET_PRIVATE (user_data);
+
+       priv->updating_banner = 
+               modest_platform_animation_banner (GTK_WIDGET (user_data), NULL,
+                                                 _CS ("ckdg_pb_updating"));
+
+       /* Remove timeout */
+       priv->updating_banner_timeout = 0;
+       return FALSE;
+}
+
+/**
+ * We use this function to show/hide a progress banner showing
+ * "Updating" while the header view is being filled. We're not showing
+ * it unless the update takes more than 2 seconds
+ *
+ * If starting = TRUE then the refresh is starting, otherwise it means
+ * that is has just finished
+ */
+static void 
+on_updating_msg_list (ModestHeaderView *header_view,
+                     gboolean starting,
+                     gpointer user_data)
+{
+       ModestMainWindowPrivate *priv = NULL;
+
+       priv = MODEST_MAIN_WINDOW_GET_PRIVATE (user_data);
+
+       /* Remove old timeout */
+       if (priv->updating_banner_timeout > 0) {
+               g_source_remove (priv->updating_banner_timeout);
+               priv->updating_banner_timeout = 0;
+       }
+
+       /* Create a new timeout */
+       if (starting) {
+               priv->updating_banner_timeout = 
+                       g_timeout_add (2000, show_updating_banner, user_data);
+       } else {
+               /* Remove the banner if exists */
+               if (priv->updating_banner) {
+                       gtk_widget_destroy (priv->updating_banner);
+                       priv->updating_banner = NULL;
+               }
+       }
+}
index d8866b3..ae3848b 100644 (file)
@@ -812,7 +812,7 @@ modest_account_mgr_get_list (ModestAccountMgr *self, const gchar *name,
                             const gchar *key, ModestConfValueType list_type,
                             gboolean server_account)
 {
-       ModestAccountMgrPrivate *priv;
+       ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
 
        const gchar *keyname;
        GSList *retval;
index d42381e..bd69084 100644 (file)
@@ -164,6 +164,7 @@ enum {
        HEADER_ACTIVATED_SIGNAL,
        ITEM_NOT_FOUND_SIGNAL,
        MSG_COUNT_CHANGED_SIGNAL,
+       UPDATING_MSG_LIST_SIGNAL,
        LAST_SIGNAL
 };
 
@@ -257,6 +258,15 @@ modest_header_view_class_init (ModestHeaderViewClass *klass)
                              NULL, NULL,
                              modest_marshal_VOID__POINTER_POINTER,
                              G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+
+       signals[UPDATING_MSG_LIST_SIGNAL] =
+               g_signal_new ("updating-msg-list",
+                             G_TYPE_FROM_CLASS (gobject_class),
+                             G_SIGNAL_RUN_FIRST,
+                             G_STRUCT_OFFSET (ModestHeaderViewClass, updating_msg_list),
+                             NULL, NULL,
+                             g_cclosure_marshal_VOID__BOOLEAN,
+                             G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
 }
 
 static void
@@ -635,7 +645,6 @@ modest_header_view_new (TnyFolder *folder, ModestHeaderViewStyle style)
        priv = MODEST_HEADER_VIEW_GET_PRIVATE(self);
        
        modest_header_view_set_style   (self, style);
-/*     modest_header_view_set_folder (self, NULL, NULL, NULL); */
 
        gtk_tree_view_columns_autosize (GTK_TREE_VIEW(obj));
        gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW(obj),TRUE);
@@ -1120,6 +1129,10 @@ folder_refreshed_cb (ModestMailOperation *mail_op,
        tny_folder_add_observer (folder, TNY_FOLDER_OBSERVER (info->header_view));
        g_mutex_unlock (priv->observers_lock);
 
+       /* Notify the observers that the update is over */
+       g_signal_emit (G_OBJECT (info->header_view), 
+                      signals[UPDATING_MSG_LIST_SIGNAL], 0, FALSE, NULL);
+
        /* Frees */
        g_free (info);
 }
@@ -1164,6 +1177,10 @@ modest_header_view_set_folder (ModestHeaderView *self,
                gtk_tree_selection_unselect_all(selection);
                g_signal_emit (G_OBJECT(self), signals[HEADER_SELECTED_SIGNAL], 0, NULL);
 
+               /* Notify the observers that the update begins */
+               g_signal_emit (G_OBJECT (self), signals[UPDATING_MSG_LIST_SIGNAL], 
+                              0, TRUE, NULL);
+
                /* create the helper */
                info = g_malloc0 (sizeof(SetFolderHelper));
                info->header_view = self;
@@ -1196,6 +1213,10 @@ modest_header_view_set_folder (ModestHeaderView *self,
                modest_header_view_notify_observers(self, NULL, NULL);
 
                g_mutex_unlock (priv->observers_lock);
+
+               /* Notify the observers that the update is over */
+               g_signal_emit (G_OBJECT (self), signals[UPDATING_MSG_LIST_SIGNAL], 
+                              0, FALSE, NULL);
        }
 }
 
index a1b746b..b2f6d00 100644 (file)
@@ -122,6 +122,10 @@ struct _ModestHeaderViewClass {
                                   TnyFolder *folder,
                                   TnyFolderChange *change,
                                   gpointer user_data);
+
+       void (*updating_msg_list) (ModestHeaderView *self,
+                                  gboolean starting,
+                                  gpointer user_data);
 };
 
 /**