+
+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;
+ }
+}
+
+void
+modest_main_window_set_style (ModestMainWindow *self,
+ ModestMainWindowStyle style)
+{
+ ModestMainWindowPrivate *priv;
+ ModestWindowPrivate *parent_priv;
+ GtkAction *action;
+ gboolean active;
+
+ g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
+
+ /* no change -> nothing to do */
+ if (priv->style == style)
+ return;
+
+ /* Get toggle button and update the state if needed. This will
+ happen only when the set_style is not invoked from the UI,
+ for example when it's called from widget memory */
+ action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToggleFolders");
+ active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ if ((active && style == MODEST_MAIN_WINDOW_STYLE_SIMPLE) ||
+ (!active && style == MODEST_MAIN_WINDOW_STYLE_SPLIT)) {
+ g_signal_handlers_block_by_func (action, modest_ui_actions_toggle_folders_view, self);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), !active);
+ g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, self);
+ }
+
+ priv->style = style;
+ switch (style) {
+ case MODEST_MAIN_WINDOW_STYLE_SIMPLE:
+ /* Remove main paned */
+ g_object_ref (priv->main_paned);
+ gtk_container_remove (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
+
+ /* Reparent the contents widget to the main vbox */
+ gtk_widget_reparent (priv->header_win, priv->main_vbox);
+
+ break;
+ case MODEST_MAIN_WINDOW_STYLE_SPLIT:
+ /* Remove header view */
+ g_object_ref (priv->header_win);
+ gtk_container_remove (GTK_CONTAINER (priv->main_vbox), priv->header_win);
+
+ /* Reparent the main paned */
+ gtk_paned_add2 (GTK_PANED (priv->main_paned), priv->header_win);
+ gtk_container_add (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
+
+ break;
+ default:
+ g_return_if_reached ();
+ }
+
+/* /\* Let header view grab the focus if it's being shown *\/ */
+/* if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) */
+/* gtk_widget_grab_focus (GTK_WIDGET (priv->header_view)); */
+/* else */
+/* gtk_widget_grab_focus (GTK_WIDGET (priv->contents_widget)); */
+
+ /* Show changes */
+ gtk_widget_show_all (GTK_WIDGET (priv->main_vbox));
+}
+
+
+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 ||!(*err)) {
+ ModestMsgView *msg_preview;
+
+ msg_preview = MODEST_MSG_VIEW (user_data);
+ tny_msg_view_set_msg (TNY_MSG_VIEW (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,
+ (TnyGetMsgCallback) get_msg_callback,
+ NULL,
+ priv->msg_preview);
+}
+
+void
+modest_main_window_notify_send_receive_initied (ModestMainWindow *self)
+{
+ g_message("NOT IMPLEMENTED %s", __FUNCTION__);
+}
+void
+modest_main_window_notify_send_receive_completed (ModestMainWindow *self)
+{
+ g_message("NOT IMPLEMENTED %s", __FUNCTION__);
+}
+
+gboolean
+modest_main_window_transfer_mode_enabled (ModestMainWindow *self)
+{
+ g_message("NOT IMPLEMENTED %s", __FUNCTION__);
+ return FALSE;
+}
+
+gboolean
+modest_main_window_on_msg_view_window_msg_changed (ModestMsgViewWindow *view_window,
+ GtkTreeModel *model,
+ GtkTreeRowReference *row_reference,
+ ModestMainWindow *self)
+{
+ g_message("NOT IMPLEMENTED %s", __FUNCTION__);
+ return FALSE;
+}
+
+gboolean
+modest_main_window_screen_is_on (ModestMainWindow *self)
+{
+ g_message("NOT IMPLEMENTED %s", __FUNCTION__);
+ return TRUE;
+}
+
+static void
+save_state (ModestWindow *window)
+{
+ ModestConf *conf;
+ ModestMainWindow* self = MODEST_MAIN_WINDOW(window);
+ ModestMainWindowPrivate *priv;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+ conf = modest_runtime_get_conf ();
+
+ modest_widget_memory_save (conf, G_OBJECT(self),
+ MODEST_CONF_MAIN_WINDOW_KEY);
+ modest_widget_memory_save (conf, G_OBJECT(priv->main_paned),
+ MODEST_CONF_MAIN_PANED_KEY);
+ modest_widget_memory_save (conf, G_OBJECT(priv->folder_view),
+ MODEST_CONF_FOLDER_VIEW_KEY);
+}