#include <glib/gi18n.h>
#include <gtk/gtktreeviewcolumn.h>
#include <tny-account-store-view.h>
+#include <tny-simple-list.h>
+#include <tny-error.h>
#include <widgets/modest-main-window.h>
#include <widgets/modest-window-priv.h>
gint total,
ModestMainWindow *main_window);
+static void on_header_selected (ModestHeaderView *header_view,
+ TnyHeader *header,
+ ModestMainWindow *main_window);
+
/* list my signals */
enum {
/* MY_SIGNAL_1, */
MODEST_TYPE_MAIN_WINDOW, \
ModestMainWindowPrivate))
-typedef struct _GetMsgAsyncHelper {
- ModestMainWindowPrivate *main_window_private;
- guint action;
- ModestTnyMsgReplyType reply_type;
- ModestTnyMsgForwardType forward_type;
- gchar *from;
- TnyIterator *iter;
-} GetMsgAsyncHelper;
-
/* globals */
static GtkWindowClass *parent_class = NULL;
conf = modest_runtime_get_conf ();
modest_widget_memory_restore (conf, G_OBJECT(priv->folder_paned),
- "modest-folder-paned");
+ MODEST_CONF_FOLDER_PANED_KEY);
modest_widget_memory_restore (conf, G_OBJECT(priv->msg_paned),
- "modest-msg-paned");
+ MODEST_CONF_MSG_PANED_KEY);
modest_widget_memory_restore (conf, G_OBJECT(priv->main_paned),
- "modest-main-paned");
- modest_widget_memory_restore (conf, G_OBJECT(priv->header_view),"header-view");
- modest_widget_memory_restore (conf,G_OBJECT(self), "modest-main-window");
+ MODEST_CONF_MAIN_PANED_KEY);
+ modest_widget_memory_restore (conf, G_OBJECT(priv->header_view),
+ MODEST_CONF_HEADER_VIEW_KEY);
+ modest_widget_memory_restore (conf, G_OBJECT(self),
+ MODEST_CONF_MAIN_WINDOW_KEY);
}
conf = modest_runtime_get_conf ();
- modest_widget_memory_save (conf,G_OBJECT(self), "modest-main-window");
modest_widget_memory_save (conf, G_OBJECT(priv->folder_paned),
- "modest-folder-paned");
+ MODEST_CONF_FOLDER_PANED_KEY);
modest_widget_memory_save (conf, G_OBJECT(priv->msg_paned),
- "modest-msg-paned");
+ MODEST_CONF_MSG_PANED_KEY);
modest_widget_memory_save (conf, G_OBJECT(priv->main_paned),
- "modest-main-paned");
- modest_widget_memory_save (conf, G_OBJECT(priv->header_view), "header-view");
+ MODEST_CONF_MAIN_PANED_KEY);
+ modest_widget_memory_save (conf, G_OBJECT(priv->header_view),
+ MODEST_CONF_HEADER_VIEW_KEY);
+ modest_widget_memory_save (conf, G_OBJECT(self),
+ MODEST_CONF_MAIN_WINDOW_KEY);
}
static void
-on_connection_changed (TnyDevice *device, gboolean online, ModestMainWindow *self)
+on_account_store_connecting_finished (TnyAccountStore *store, ModestMainWindow *self)
{
+ const gboolean online = TRUE;
+
GtkWidget *icon;
const gchar *icon_name;
ModestMainWindowPrivate *priv;
/* If Modest has became online and the header view has a
header selected then show it */
- /* FIXME: there is a race condition if some account needs to
+ /* TODO: FIXME: there is a race condition if some account needs to
ask the user for a password */
/* if (online) { */
device = modest_runtime_get_device ();
online = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->online_toggle));
- if (online)
+ if (online) {
+ /* TODO: Just attempt to go online, instead of forcing the online status: */
tny_device_force_online (device);
+ }
else
tny_device_force_offline (device);
}
G_CALLBACK(on_header_status_update), self);
g_signal_connect (G_OBJECT(priv->header_view), "header_selected",
G_CALLBACK(modest_ui_actions_on_header_selected), self);
+ g_signal_connect (G_OBJECT(priv->header_view), "header_selected",
+ G_CALLBACK(on_header_selected), self);
g_signal_connect (G_OBJECT(priv->header_view), "header_activated",
G_CALLBACK(modest_ui_actions_on_header_activated), self);
g_signal_connect (G_OBJECT(priv->header_view), "item_not_found",
G_CALLBACK(modest_ui_actions_on_msg_recpt_activated), self);
/* Account store */
+ /* Emmitted by our TnyAccountStore::get_password_func() implementation,
+ * This is not a normal part of tinymail: */
g_signal_connect (G_OBJECT (modest_runtime_get_account_store()), "password_requested",
G_CALLBACK (modest_ui_actions_on_password_requested), self);
/* Device */
- g_signal_connect (G_OBJECT(modest_runtime_get_device()), "connection_changed",
- G_CALLBACK(on_connection_changed), self);
+ g_signal_connect (G_OBJECT(modest_runtime_get_account_store()), "connecting-finished",
+ G_CALLBACK(on_account_store_connecting_finished), self);
g_signal_connect (G_OBJECT(priv->online_toggle), "toggled",
G_CALLBACK(on_online_toggle_toggled), self);
/* TODO */
}
-void
-modest_main_window_set_toolbar_mode (ModestMainWindow *self,
- ModestToolBarModes mode)
-{
- /* TODO */
-}
ModestMainWindowStyle
modest_main_window_get_style (ModestMainWindow *self)
{
/* 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);
+}