From: Sergio Villar Senin Date: Thu, 14 Feb 2008 12:36:53 +0000 (+0000) Subject: * Replaced modest_msg_edit_window_reset_modified by modest_msg_edit_window_se... X-Git-Tag: git_migration_finished~1677 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=7c554315330b15c198391928a502333c821c6b40 * Replaced modest_msg_edit_window_reset_modified by modest_msg_edit_window_set_modified with a new boolean parametter * Added a new parametter to modest_ui_actions_compose_msg that instructs the method to set the edit window as modified or not * Opening a new editor from Contacts plugin and closing it without modifying it no longer shows the "Save message" dialog * Fixes NB#78911, set the edit window as modified when a new email is created from an external application pmo-trunk-r4177 --- diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index 0cc5cda..e705965 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -221,7 +221,7 @@ on_idle_mail_to(gpointer user_data) } gdk_threads_enter (); /* CHECKED */ - modest_ui_actions_compose_msg(NULL, to, cc, bcc, subject, body, NULL); + modest_ui_actions_compose_msg(NULL, to, cc, bcc, subject, body, NULL, FALSE); gdk_threads_leave (); /* CHECKED */ cleanup: @@ -271,6 +271,7 @@ on_idle_compose_mail(gpointer user_data) g_free(idle_data->attachments); idle_data->attachments = tmp; } + if (idle_data->attachments != NULL) { gchar **list = g_strsplit(idle_data->attachments, ",", 0); gint i = 0; @@ -279,10 +280,22 @@ on_idle_compose_mail(gpointer user_data) } g_strfreev(list); } + + /* If the message has nothing then mark the buffers as not + modified */ gdk_threads_enter (); /* CHECKED */ - modest_ui_actions_compose_msg(NULL, idle_data->to, idle_data->cc, - idle_data->bcc, idle_data->subject, - idle_data->body, attachments); + if (!strncmp (idle_data->to, "", 1) && + !strncmp (idle_data->to, "", 1) && + !strncmp (idle_data->cc, "", 1) && + !strncmp (idle_data->bcc, "", 1) && + !strncmp (idle_data->subject, "", 1) && + !strncmp (idle_data->body, "", 1) && + attachments == NULL) + modest_ui_actions_compose_msg(NULL, NULL, NULL, NULL, NULL, NULL, NULL, FALSE); + else + modest_ui_actions_compose_msg(NULL, idle_data->to, idle_data->cc, + idle_data->bcc, idle_data->subject, + idle_data->body, attachments, TRUE); gdk_threads_leave (); /* CHECKED */ cleanup: g_slist_foreach(attachments, (GFunc)g_free, NULL); diff --git a/src/gnome/modest-msg-edit-window.c b/src/gnome/modest-msg-edit-window.c index 63d1c8d..360147f 100644 --- a/src/gnome/modest-msg-edit-window.c +++ b/src/gnome/modest-msg-edit-window.c @@ -715,7 +715,8 @@ modest_msg_edit_window_get_child_widget (ModestMsgEditWindow *win, /* FUNCTIONS NOT IMPLEMENTED YET */ void -modest_msg_edit_window_reset_modified (ModestMsgEditWindow *window) +modest_msg_edit_window_set_modified (ModestMsgEditWindow *window, + gboolean modified) { g_message (__FUNCTION__); } diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 639ecb4..418638b 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -1255,7 +1255,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) gtk_text_buffer_get_start_iter (priv->text_buffer, &iter); gtk_text_buffer_place_cursor (priv->text_buffer, &iter); - modest_msg_edit_window_reset_modified (self); + modest_msg_edit_window_set_modified (self, FALSE); modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (self)); modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self)); @@ -1567,7 +1567,7 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre modest_window_check_dimming_rules_group (MODEST_WINDOW (obj), MODEST_DIMMING_RULES_CLIPBOARD); priv->update_caption_visibility = TRUE; - modest_msg_edit_window_reset_modified (MODEST_MSG_EDIT_WINDOW (obj)); + modest_msg_edit_window_set_modified (MODEST_MSG_EDIT_WINDOW (obj), FALSE); /* Track account-removed signal, this window should be closed in the case we're creating a mail associated to the account @@ -3022,18 +3022,19 @@ body_changed (GtkTextBuffer *buffer, ModestMsgEditWindow *editor) } void -modest_msg_edit_window_reset_modified (ModestMsgEditWindow *editor) +modest_msg_edit_window_set_modified (ModestMsgEditWindow *editor, + gboolean modified) { ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (editor); GtkTextBuffer *buffer; buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR(priv->to_field)); - gtk_text_buffer_set_modified (buffer, FALSE); + gtk_text_buffer_set_modified (buffer, modified); buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR(priv->cc_field)); - gtk_text_buffer_set_modified (buffer, FALSE); + gtk_text_buffer_set_modified (buffer, modified); buffer = modest_recpt_editor_get_buffer (MODEST_RECPT_EDITOR(priv->bcc_field)); - gtk_text_buffer_set_modified (buffer, FALSE); - gtk_text_buffer_set_modified (priv->text_buffer, FALSE); + gtk_text_buffer_set_modified (buffer, modified); + gtk_text_buffer_set_modified (priv->text_buffer, modified); } gboolean diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index d3cd601..c84fd69 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -703,7 +703,8 @@ modest_ui_actions_compose_msg(ModestWindow *win, const gchar *bcc_str, const gchar *subject_str, const gchar *body_str, - GSList *attachments) + GSList *attachments, + gboolean set_as_modified) { gchar *account_name = NULL; TnyMsg *msg = NULL; @@ -758,6 +759,8 @@ modest_ui_actions_compose_msg(ModestWindow *win, attachments = g_slist_next(attachments); } modest_window_mgr_register_window (modest_runtime_get_window_mgr(), msg_win); + modest_msg_edit_window_set_modified (MODEST_MSG_EDIT_WINDOW (msg_win), set_as_modified); + gtk_widget_show_all (GTK_WIDGET (msg_win)); cleanup: @@ -779,7 +782,7 @@ modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win) if (!modest_ui_actions_run_account_setup_wizard (win)) return; - modest_ui_actions_compose_msg(win, NULL, NULL, NULL, NULL, NULL, NULL); + modest_ui_actions_compose_msg(win, NULL, NULL, NULL, NULL, NULL, NULL, FALSE); } @@ -2334,7 +2337,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi /* info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts")); */ modest_platform_information_banner (NULL, NULL, _CS("sfil_ib_saving")); - modest_msg_edit_window_reset_modified (edit_window); + modest_msg_edit_window_set_modified (edit_window, FALSE); /* Frees */ g_free (from); diff --git a/src/modest-ui-actions.h b/src/modest-ui-actions.h index 7702b10..5f731b2 100644 --- a/src/modest-ui-actions.h +++ b/src/modest-ui-actions.h @@ -488,14 +488,17 @@ void modest_ui_actions_on_send_queue_status_changed (ModestTnySendQueue *send_qu gpointer user_data); /** + * modest_ui_actions_compose_msg + * @win: Modest main window (can be NULL) + * @to_str: "To:" header, or NULL + * @cc_str: "Cc:" header, or NULL + * @bcc_str: "Bcc:" header, or NULL + * @subject_str: Subject of the message, or NULL + * @body_str: Body of the message (without signature), or NULL + * @attachments: attachments List of file URIs to attach + * @set_as_modified: wheter or not the message is set initially as modified or not + * * Opens a new message editor for composing - * @param win Modest main window (can be NULL) - * @param to_str "To:" header, or NULL - * @param cc_str "Cc:" header, or NULL - * @param bcc_str "Bcc:" header, or NULL - * @param subject_str Subject of the message, or NULL - * @param body_str Body of the message (without signature), or NULL - * @param attachments List of file URIs to attach */ void modest_ui_actions_compose_msg (ModestWindow *win, const gchar *to_str, @@ -503,7 +506,8 @@ void modest_ui_actions_compose_msg (ModestWindow *win, const gchar *bcc_str, const gchar *subject_str, const gchar *body_str, - GSList *attachments); + GSList *attachments, + gboolean set_as_modified); void modest_ui_actions_on_account_connection_error (GtkWindow *parent_window, TnyAccount *account); diff --git a/src/widgets/modest-msg-edit-window.h b/src/widgets/modest-msg-edit-window.h index dad2dca..21a6f35 100644 --- a/src/widgets/modest-msg-edit-window.h +++ b/src/widgets/modest-msg-edit-window.h @@ -392,10 +392,13 @@ gboolean modest_msg_edit_window_is_modified (ModestMsgEditWindow /** * modest_msg_edit_window_reset_modified: * @window: a #ModestMsgEditWindow + * @modified: wheter or not we want to make the buffer as modified or not * - * Resets the message as not modified + * Sets the message as modified or not */ -void modest_msg_edit_window_reset_modified (ModestMsgEditWindow *window); +void modest_msg_edit_window_set_modified (ModestMsgEditWindow *window, + gboolean modified); + gboolean modest_msg_edit_window_get_sent (ModestMsgEditWindow *window); void modest_msg_edit_window_set_sent (ModestMsgEditWindow *window, diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index 0b0469b..3b62214 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -673,9 +673,8 @@ on_window_destroy (ModestWindow *window, /* If the user wants to close all the windows */ if ((dialog_response == GTK_RESPONSE_OK) - || (dialog_response == GTK_RESPONSE_ACCEPT) - || (dialog_response == GTK_RESPONSE_YES)) - { + || (dialog_response == GTK_RESPONSE_ACCEPT) + || (dialog_response == GTK_RESPONSE_YES)) { GList *iter = priv->window_list; do { if (iter->data != window) { @@ -688,11 +687,9 @@ on_window_destroy (ModestWindow *window, iter = g_list_next (iter); } } while (iter); - } - else - { - return TRUE; - } + } else { + return TRUE; + } } } else {