the last changes in tinymail, fixes NB#62652.
* src/widgets/modest-platform.h, src/maemo/modest-platform.c:
* Added new function modest_platform_run_yes_no_dialog. It's
required in some dialogs in specs.
* src/widgets/modest-msg-edit-window.h,
src/maemo/modest-msg-edit-window.c:
* New method to set the draft message from outside. This is used
to properly update the draft message when it's a new one.
* On setting a new draft message, it replaces the registered
header in the window manager. This way we can open a drafts
message more than one time.
* src/widgets/modest-window-mgr.c:
* Now the save to drafts confirmation dialog shows Yes/no
alternatives instead of Ok/Cancel.
* src/modest-ui-actions.c:
* Now, when a draft is saved from the editor, we set the
created draft as the new draft message of editor. This
should make saving drafts more than one time work as
expected.
* src/modest-mail-operation.[ch]:
* Now ..._save_to_drafts returns the newly created message.
pmo-trunk-r2601
}
if (priv->draft_msg != NULL) {
+ TnyHeader *header = tny_msg_get_header (priv->draft_msg);
+ if (TNY_IS_HEADER (header)) {
+ ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
+ modest_window_mgr_unregister_header (mgr, header);
+ }
g_object_unref (priv->draft_msg);
priv->draft_msg = NULL;
}
}
+void
+modest_msg_edit_window_set_draft (ModestMsgEditWindow *window,
+ TnyMsg *draft)
+{
+ ModestMsgEditWindowPrivate *priv;
+ TnyHeader *header = NULL;
+
+ g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
+ g_return_if_fail ((draft == NULL)||(TNY_IS_MSG (draft)));
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+ ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
+
+ if (priv->draft_msg != NULL) {
+ header = tny_msg_get_header (priv->draft_msg);
+ if (TNY_IS_HEADER (header)) {
+ modest_window_mgr_unregister_header (mgr, header);
+ }
+ g_object_unref (priv->draft_msg);
+ }
+
+ if (draft != NULL) {
+ g_object_ref (draft);
+ header = tny_msg_get_header (draft);
+ if (TNY_IS_HEADER (header))
+ modest_window_mgr_register_header (mgr, header);
+ }
+
+ priv->draft_msg = draft;
+}
return response;
}
+gint
+modest_platform_run_yes_no_dialog (GtkWindow *parent_window,
+ const gchar *message)
+{
+ GtkWidget *dialog;
+ gint response;
+
+ dialog = hildon_note_new_confirmation_add_buttons (parent_window, message,
+ _("mcen_bd_yes"), GTK_RESPONSE_YES,
+ _("mcen_bd_no"), GTK_RESPONSE_NO,
+ NULL);
+ gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ return response;
+}
+
void
modest_platform_run_information_dialog (GtkWindow *parent_window,
const gchar *message)
g_object_unref (G_OBJECT (new_msg));
}
-void
+TnyMsg*
modest_mail_operation_save_to_drafts (ModestMailOperation *self,
TnyTransportAccount *transport_account,
TnyMsg *draft_msg,
TnyHeader *header = NULL;
ModestMailOperationPrivate *priv = NULL;
- g_return_if_fail (MODEST_IS_MAIL_OPERATION (self));
- g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT (transport_account));
+ g_return_val_if_fail (MODEST_IS_MAIL_OPERATION (self), NULL);
+ g_return_val_if_fail (TNY_IS_TRANSPORT_ACCOUNT (transport_account), NULL);
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
end:
- if (msg)
- g_object_unref (G_OBJECT(msg));
if (folder)
g_object_unref (G_OBJECT(folder));
modest_mail_operation_notify_end (self);
+ return msg;
}
typedef struct
* #TnyTransportAccount. This operation is synchronous, so the
* #ModestMailOperation should not be added to any
* #ModestMailOperationQueue
+ *
+ * Returns: the newly created message with an own reference.
**/
-void modest_mail_operation_save_to_drafts (ModestMailOperation *self,
+TnyMsg* modest_mail_operation_save_to_drafts (ModestMailOperation *self,
TnyTransportAccount *transport_account,
TnyMsg *draft_msg,
const gchar *from,
gint modest_platform_run_confirmation_dialog (GtkWindow *parent_window,
const gchar *message);
+/**
+ * modest_platform_run_yes_no_dialog:
+ * @parent_window: the parent #GtkWindow of the dialog
+ * @message: the message to show to the user
+ *
+ * runs a dialog that offers yes and no buttons.
+ *
+ * Returns: GTK_RESPONSE_YES or GTK_RESPONSE_NO
+ **/
+gint modest_platform_run_yes_no_dialog (GtkWindow *parent_window,
+ const gchar *message);
+
/**
* modest_platform_run_information_dialog:
gchar *account_name, *from;
ModestAccountMgr *account_mgr;
gchar *info_text = NULL;
+ TnyMsg *new_draft = NULL;
g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(edit_window));
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
- modest_mail_operation_save_to_drafts (mail_operation,
- transport_account,
- data->draft_msg,
- from,
- data->to,
- data->cc,
- data->bcc,
- data->subject,
- data->plain_body,
- data->html_body,
- data->attachments,
- data->priority_flags);
+ new_draft = modest_mail_operation_save_to_drafts (mail_operation,
+ transport_account,
+ data->draft_msg,
+ from,
+ data->to,
+ data->cc,
+ data->bcc,
+ data->subject,
+ data->plain_body,
+ data->html_body,
+ data->attachments,
+ data->priority_flags);
/* Frees */
g_free (from);
g_free (account_name);
modest_msg_edit_window_free_msg_data (edit_window, data);
+ modest_msg_edit_window_set_draft (edit_window, new_draft);
+ if (new_draft != NULL)
+ g_object_unref (new_draft);
+
info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts"));
modest_platform_information_banner (NULL, NULL, info_text);
g_free (info_text);
void modest_msg_edit_window_set_sent (ModestMsgEditWindow *window,
gboolean sent);
+/**
+ * modest_msg_edit_window_set_draft:
+ * @window: a #ModestMsgEditWindow
+ * @draft: a #TnyMsg, or %NULL
+ *
+ * Set @draft as the original draft message of the editor. This
+ * message will be removed on saving or sending the message.
+ */
+void modest_msg_edit_window_set_draft (ModestMsgEditWindow *window,
+ TnyMsg *draft);
+
G_END_DECLS
#endif /* __MODEST_MSG_EDIT_WINDOW_H__ */
if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
response =
- modest_platform_run_confirmation_dialog (GTK_WINDOW (window),
- _("mcen_nc_no_email_message_modified_save_changes"));
+ modest_platform_run_yes_no_dialog (GTK_WINDOW (window),
+ _("mcen_nc_no_email_message_modified_save_changes"));
/* Save to drafts */
- if (response != GTK_RESPONSE_CANCEL)
+ if (response != GTK_RESPONSE_NO)
modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window));
}