+ modest_msg_edit_window_set_priority_flags (MODEST_MSG_EDIT_WINDOW(self),
+ priority_flags);
+ modest_tny_msg_get_references (TNY_MSG (msg), NULL, &(priv->references), &(priv->in_reply_to));
+
+ modest_attachments_view_set_message (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), msg);
+ priv->attachments = modest_attachments_view_get_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
+ update_next_cid (self, priv->attachments);
+
+ body_part = modest_tny_msg_find_body_part (msg, FALSE);
+ if (body_part) {
+ TnyStream *stream;
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->msg_body), FALSE);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body));
+ stream = TNY_STREAM (tny_gtk_text_buffer_stream_new (buffer));
+ tny_stream_reset (stream);
+ tny_mime_part_decode_to_stream (body_part, stream, NULL);
+ tny_stream_reset (stream);
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->msg_body), TRUE);
+ }
+
+ /* Set the default focus depending on having already a To: field or not */
+ if ((!to)||(*to == '\0')) {
+ modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field));
+ } else {
+ gtk_widget_grab_focus (priv->msg_body);
+ }
+
+
+ modest_msg_edit_window_set_modified (self, FALSE);
+ text_buffer_can_undo (priv->text_buffer, FALSE, self);
+ text_buffer_can_redo (priv->text_buffer, FALSE, self);
+
+ if (priv->msg_uid) {
+ g_free (priv->msg_uid);
+ priv->msg_uid = NULL;
+ }
+
+ /* we should set a reference to the incoming message if it is a draft */
+ msg_folder = tny_msg_get_folder (msg);
+ if (msg_folder) {
+ if (modest_tny_folder_is_local_folder (msg_folder)) {
+ TnyFolderType type = modest_tny_folder_get_local_or_mmc_folder_type (msg_folder);
+ if (type == TNY_FOLDER_TYPE_INVALID)
+ g_warning ("%s: BUG: TNY_FOLDER_TYPE_INVALID", __FUNCTION__);
+
+ if (type == TNY_FOLDER_TYPE_DRAFTS)
+ priv->draft_msg = g_object_ref(msg);
+ if (type == TNY_FOLDER_TYPE_OUTBOX)
+ priv->outbox_msg = g_object_ref(msg);
+ priv->msg_uid = modest_tny_folder_get_header_unique_id (header);
+ }
+ g_object_unref (msg_folder);
+ }
+
+ g_free (subject);
+ g_free (to);
+ g_free (cc);
+ g_free (bcc);
+}
+
+static void
+modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window)
+{
+ ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
+ GtkWidget *tool_item;
+
+ /* Toolbar */
+ parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
+
+ /* Set expand and homogeneous for remaining items */
+ tool_item = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarSend");
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), FALSE);
+ gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), FALSE);
+ gtk_tool_item_set_is_important (GTK_TOOL_ITEM (tool_item), TRUE);
+ tool_item = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarAttach");
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), FALSE);
+ gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), FALSE);
+ gtk_tool_item_set_is_important (GTK_TOOL_ITEM (tool_item), TRUE);
+
+ gtk_toolbar_set_tooltips (GTK_TOOLBAR (parent_priv->toolbar), TRUE);
+
+}
+
+static void
+on_account_removed (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ /* Do nothing if it's a store account, because we use the
+ transport to send the messages */
+ if (tny_account_get_account_type(account) == TNY_ACCOUNT_TYPE_TRANSPORT) {
+ const gchar *parent_acc = NULL;
+ const gchar *our_acc = NULL;
+
+ our_acc = modest_window_get_active_account (MODEST_WINDOW (user_data));
+ parent_acc = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+ /* Close this window if I'm showing a message of the removed account */
+ if (strcmp (parent_acc, our_acc) == 0)
+ modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (user_data));
+ }