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;
/* 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, \
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
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);
}
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");
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),
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;
+ }
+ }
+}
HEADER_ACTIVATED_SIGNAL,
ITEM_NOT_FOUND_SIGNAL,
MSG_COUNT_CHANGED_SIGNAL,
+ UPDATING_MSG_LIST_SIGNAL,
LAST_SIGNAL
};
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
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);
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);
}
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;
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);
}
}