+
+static void
+on_queue_changed (ModestMailOperationQueue *queue,
+ ModestMailOperation *mail_op,
+ ModestMailOperationQueueNotification type,
+ ModestMainWindow *self)
+{
+ GSList *tmp;
+ ModestMainWindowPrivate *priv;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ tmp = priv->progress_widgets;
+
+ switch (type) {
+ case MODEST_MAIL_OPERATION_QUEUE_OPERATION_ADDED:
+ while (tmp) {
+ modest_progress_object_add_operation (MODEST_PROGRESS_OBJECT (tmp->data),
+ mail_op);
+ tmp = g_slist_next (tmp);
+ }
+ break;
+ case MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED:
+ while (tmp) {
+ modest_progress_object_remove_operation (MODEST_PROGRESS_OBJECT (tmp->data),
+ mail_op);
+ tmp = g_slist_next (tmp);
+ }
+ break;
+ }
+}
+
+static void
+on_header_status_update (ModestHeaderView *header_view,
+ const gchar *msg, gint num,
+ gint total, ModestMainWindow *self)
+{
+ ModestMainWindowPrivate *priv;
+ gchar *txt;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ /* Set progress */
+ txt = g_strdup_printf (_("Downloading %d of %d"), num, total);
+ modest_gnome_info_bar_set_progress (MODEST_GNOME_INFO_BAR (priv->main_bar),
+ (const gchar*) txt,
+ num, total);
+ g_free (txt);
+
+ /* Set status message */
+ modest_gnome_info_bar_set_message (MODEST_GNOME_INFO_BAR (priv->main_bar), msg);
+}
+
+gboolean
+modest_main_window_close_all (ModestMainWindow *self)
+{
+ /* TODO: show a dialog to ask the user for permission to close
+ all */
+ return TRUE;
+}
+
+void
+modest_main_window_set_style (ModestMainWindow *self,
+ ModestMainWindowStyle style)
+{
+ /* TODO */
+}
+
+
+ModestMainWindowStyle
+modest_main_window_get_style (ModestMainWindow *self)
+{
+ /* TODO */
+ return MODEST_MAIN_WINDOW_STYLE_SPLIT;
+}
+
+void
+modest_main_window_set_contents_style (ModestMainWindow *self,
+ ModestMainWindowContentsStyle style)
+{
+ /* TODO */
+}
+
+ModestMainWindowContentsStyle
+modest_main_window_get_contents_style (ModestMainWindow *self)
+{
+ /* TODO */
+ return MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS;
+}
+
+
+static void
+get_msg_callback (TnyFolder *folder,
+ gboolean cancelled,
+ TnyMsg *msg,
+ GError **err,
+ gpointer user_data)
+{
+ if (!(*err)) {
+ ModestMsgView *msg_preview;
+
+ msg_preview = MODEST_MSG_VIEW (user_data);
+ modest_msg_view_set_message (msg_preview, msg);
+ }
+
+ /* Frees */
+ g_object_unref (folder);
+}
+
+static void
+on_header_selected (ModestHeaderView *header_view,
+ TnyHeader *header,
+ ModestMainWindow *main_window)
+{
+ TnyFolder *folder;
+ ModestMainWindowPrivate *priv;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE (main_window);
+
+ if (!header)
+ return;
+
+ folder = tny_header_get_folder (header);
+
+ /* FIXME: do not use this directly. Use a mail operation
+ instead in order to get progress info */
+ tny_folder_get_msg_async (folder,
+ header,
+ get_msg_callback,
+ NULL,
+ priv->msg_preview);
+}