X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-edit-window.c;h=9fd2947db8d7555b594e7c6e203ec3923e8829ae;hp=09401e8700f2739d4d5a9d137dd405ceb617237f;hb=d8cca2763d3a9c9e46e827321a83bd26c40871e3;hpb=c1a90c249afda120478951d65df16ef94e6f6ff3 diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 09401e8..9fd2947 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -173,8 +173,8 @@ static void text_buffer_mark_set (GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextMark *mark, ModestMsgEditWindow *userdata); -void vadj_changed (GtkAdjustment *adj, - ModestMsgEditWindow *window); +static void vadj_changed (GtkAdjustment *adj, + ModestMsgEditWindow *window); static void DEBUG_BUFFER (WPTextBuffer *buffer) { @@ -288,6 +288,8 @@ struct _ModestMsgEditWindowPrivate { TnyMsg *draft_msg; TnyMsg *outbox_msg; gchar *msg_uid; + gchar *references; + gchar *in_reply_to; gboolean sent; }; @@ -425,6 +427,8 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj) priv->draft_msg = NULL; priv->outbox_msg = NULL; priv->msg_uid = NULL; + priv->references = NULL; + priv->in_reply_to = NULL; priv->can_undo = FALSE; priv->can_redo = FALSE; @@ -475,7 +479,7 @@ get_transports (void) gchar *from_string = NULL; if (account_name) { from_string = modest_account_mgr_get_from_string (account_mgr, - account_name); + account_name, NULL); } if (from_string && account_name) { @@ -627,8 +631,9 @@ copy_clipboard_check (GtkTextView *text_view, } } -void vadj_changed (GtkAdjustment *adj, - ModestMsgEditWindow *window) +static void +vadj_changed (GtkAdjustment *adj, + ModestMsgEditWindow *window) { ModestMsgEditWindowPrivate *priv; @@ -641,6 +646,14 @@ void vadj_changed (GtkAdjustment *adj, } static void +attachment_deleted (ModestAttachmentsView *attachments_view, + gpointer user_data) +{ + modest_msg_edit_window_remove_attachments (MODEST_MSG_EDIT_WINDOW (user_data), + NULL); +} + +static void connect_signals (ModestMsgEditWindow *obj) { ModestMsgEditWindowPrivate *priv; @@ -708,7 +721,7 @@ connect_signals (ModestMsgEditWindow *obj) g_signal_connect (G_OBJECT (priv->msg_body), "cut-clipboard", G_CALLBACK (cut_clipboard_check), NULL); g_signal_connect (G_OBJECT (priv->msg_body), "copy-clipboard", G_CALLBACK (copy_clipboard_check), NULL); - + g_signal_connect (G_OBJECT (priv->attachments_view), "delete", G_CALLBACK (attachment_deleted), obj); } static void @@ -841,9 +854,9 @@ init_window (ModestMsgEditWindow *obj) g_object_set (priv->text_buffer, "font_scale", DEFAULT_FONT_SCALE, NULL); wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), TRUE); #if (GTK_MINOR_VERSION >= 10) - gtk_text_buffer_register_serialize_tagset(GTK_TEXT_BUFFER(priv->text_buffer), "wp-text-buffer"); + gtk_text_buffer_register_serialize_tagset(GTK_TEXT_BUFFER(priv->text_buffer), NULL); deserialize_type = gtk_text_buffer_register_deserialize_tagset(GTK_TEXT_BUFFER(priv->text_buffer), - "wp-text-buffer"); + NULL); gtk_text_buffer_deserialize_set_can_create_tags (GTK_TEXT_BUFFER (priv->text_buffer), deserialize_type, TRUE); #endif @@ -954,6 +967,8 @@ modest_msg_edit_window_finalize (GObject *obj) if (priv->original_account_name) g_free (priv->original_account_name); g_free (priv->msg_uid); + g_free (priv->references); + g_free (priv->in_reply_to); g_free (priv->last_search); g_slist_free (priv->font_items_group); g_slist_free (priv->size_items_group); @@ -991,6 +1006,8 @@ pixbuf_from_stream (TnyStream *stream, const gchar *mime_type, guint64 *stream_s readed = tny_stream_read (TNY_STREAM (stream), (char *) read_buffer, 128); size += readed; if (!gdk_pixbuf_loader_write (loader, read_buffer, readed, &error)) { + if (error) + g_free (error); break; } } @@ -1178,6 +1195,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject); 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)); update_window_title (self); @@ -1459,7 +1477,10 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window) ModestWindow* -modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean preserve_is_rich) +modest_msg_edit_window_new (TnyMsg *msg, + const gchar *account_name, + const gchar *mailbox, /* ignored */ + gboolean preserve_is_rich) { GObject *obj; ModestWindowPrivate *parent_priv; @@ -1606,12 +1627,14 @@ modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window) /* don't free these (except from) */ data = g_slice_new0 (MsgData); data->from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(), - account_name); + account_name, NULL); data->account_name = g_strdup (account_name); data->to = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->to_field))); data->cc = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->cc_field))); data->bcc = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->bcc_field))); data->subject = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->subject_field))); + data->references = g_strdup (priv->references); + data->in_reply_to = g_strdup (priv->in_reply_to); if (priv->draft_msg) { data->draft_msg = g_object_ref (priv->draft_msg); } else if (priv->outbox_msg) { @@ -1711,6 +1734,8 @@ modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window, g_free (data->plain_body); g_free (data->html_body); g_free (data->account_name); + g_free (data->in_reply_to); + g_free (data->references); if (data->draft_msg != NULL) { g_object_unref (data->draft_msg); @@ -1884,8 +1909,12 @@ modest_msg_edit_window_set_format_state (ModestMsgEditWindow *self, text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), self); + g_free (buffer_format); g_free (current_format); + /* Check dimming rules */ + modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (self)); + modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self)); } static void @@ -2147,6 +2176,10 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window) modest_maemo_utils_setup_images_filechooser (GTK_FILE_CHOOSER (dialog)); + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), + GTK_WINDOW (dialog), + GTK_WINDOW (window)); + response = gtk_dialog_run (GTK_DIALOG (dialog)); switch (response) { case GTK_RESPONSE_OK: @@ -2197,7 +2230,8 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window) if (stream == NULL) { - modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); + modest_platform_information_banner (NULL, NULL, + _FM("sfil_ib_opening_not_allowed")); g_object_unref (mime_part); gnome_vfs_file_info_unref (info); @@ -2259,7 +2293,7 @@ modest_msg_edit_window_offer_attach_file (ModestMsgEditWindow *window) dialog = hildon_file_chooser_dialog_new (GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_window_set_title (GTK_WINDOW (dialog), _("mcen_ti_select_attachment_title")); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); - modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog)); + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), GTK_WINDOW (window)); response = gtk_dialog_run (GTK_DIALOG (dialog)); switch (response) { @@ -2310,7 +2344,6 @@ modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window, ModestMsgEditWindowPrivate *priv; GnomeVFSResult result; GnomeVFSFileSize size = 0; - g_return_val_if_fail (window, 0); g_return_val_if_fail (uri, 0); @@ -2353,8 +2386,8 @@ modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window, info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) { size = info->size; if (size > allowed_size) { - g_warning ("%s: attachment too big", __FUNCTION__); - modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); + modest_platform_information_banner (NULL, NULL, + _FM("sfil_ib_opening_not_allowed")); return 0; } } else @@ -2364,7 +2397,7 @@ modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window, if (stream == NULL) { - modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); + modest_platform_information_banner (NULL, NULL, _FM("sfil_ib_opening_not_allowed")); g_object_unref (mime_part); gnome_vfs_file_info_unref (info); @@ -2417,7 +2450,6 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window, if (tny_list_get_length (att_list) == 0) { hildon_banner_show_information (NULL, NULL, _("TODO: no attachments selected to remove")); } else { - GtkWidget *confirmation_dialog = NULL; gboolean dialog_response; gchar *message = NULL; gchar *filename = NULL; @@ -2446,11 +2478,11 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window, message = g_strdup_printf (ngettext("emev_nc_delete_attachment", "emev_nc_delete_attachments", tny_list_get_length (att_list)), filename); g_free (filename); - confirmation_dialog = hildon_note_new_confirmation (GTK_WINDOW (window), message); + + dialog_response = modest_platform_run_confirmation_dialog (GTK_WINDOW (window), message); g_free (message); - dialog_response = (gtk_dialog_run (GTK_DIALOG (confirmation_dialog))==GTK_RESPONSE_OK); - gtk_widget_destroy (confirmation_dialog); - if (!dialog_response) { + + if (dialog_response != GTK_RESPONSE_OK) { g_object_unref (att_list); return; } @@ -2812,6 +2844,7 @@ modest_msg_edit_window_set_file_format (ModestMsgEditWindow *window, break; } modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (window)); + modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window)); text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), window); } } @@ -2839,7 +2872,7 @@ modest_msg_edit_window_select_font (ModestMsgEditWindow *window) dialog = hildon_font_selection_dialog_new (GTK_WINDOW (window), NULL); modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), - GTK_WINDOW(dialog)); + GTK_WINDOW(dialog), GTK_WINDOW (window)); /* First we get the currently selected font information */ wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), &oldfmt, TRUE); @@ -2875,6 +2908,8 @@ modest_msg_edit_window_select_font (ModestMsgEditWindow *window) "family-set", !oldfmt.cs.font, NULL); + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), + GTK_WINDOW (dialog), GTK_WINDOW (window)); gtk_widget_show_all (dialog); priv->font_dialog = dialog; response = gtk_dialog_run (GTK_DIALOG (dialog)); @@ -2964,7 +2999,6 @@ modest_msg_edit_window_undo (ModestMsgEditWindow *window) modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (window)); modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window)); - } void @@ -3325,8 +3359,7 @@ subject_field_insert_text (GtkEditable *editable, if (result_len + old_length > 1000) { hildon_banner_show_information (GTK_WIDGET (window), NULL, - dgettext("hildon-common-strings", - "ckdg_ib_maximum_characters_reached")); + _CS("ckdg_ib_maximum_characters_reached")); } g_string_free (result, TRUE); @@ -3434,7 +3467,8 @@ modest_msg_edit_window_find_toolbar_search (GtkWidget *widget, g_free (priv->last_search); priv->last_search = NULL; /* Information banner about empty search */ - hildon_banner_show_information (NULL, NULL, dgettext ("hildon-common-strings", "ecdg_ib_find_rep_enter_text")); + hildon_banner_show_information (NULL, NULL, + _CS ("ecdg_ib_find_rep_enter_text")); return; } @@ -3450,14 +3484,16 @@ modest_msg_edit_window_find_toolbar_search (GtkWidget *widget, result = gtk_text_iter_forward_search_insensitive (&selection_end, current_search, &match_start, &match_end); if (!result) - hildon_banner_show_information (NULL, NULL, dgettext ("hildon-libs", "ckct_ib_find_search_complete")); + hildon_banner_show_information (NULL, NULL, + _HL ("ckct_ib_find_search_complete")); } else { GtkTextIter buffer_start; gtk_text_buffer_get_start_iter (priv->text_buffer, &buffer_start); result = gtk_text_iter_forward_search_insensitive (&buffer_start, current_search, &match_start, &match_end); if (!result) - hildon_banner_show_information (NULL, NULL, dgettext ("hildon-libs", "ckct_ib_find_no_matches")); + hildon_banner_show_information (NULL, NULL, + _HL ("ckct_ib_find_no_matches")); } /* Mark as selected the string found in search */ @@ -3530,7 +3566,7 @@ modest_msg_edit_window_set_draft (ModestMsgEditWindow *window, } priv->msg_uid = modest_tny_folder_get_header_unique_id (header); if (GTK_WIDGET_REALIZED (window)) - modest_window_mgr_register_window (mgr, MODEST_WINDOW (window)); + modest_window_mgr_register_window (mgr, MODEST_WINDOW (window), NULL); } priv->draft_msg = draft; @@ -3545,7 +3581,7 @@ text_buffer_apply_tag (GtkTextBuffer *buffer, GtkTextTag *tag, ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (userdata); gchar *tag_name; - if (tag == NULL+13) return; + if (tag == NULL) return; g_object_get (G_OBJECT (tag), "name", &tag_name, NULL); if ((tag_name != NULL) && (g_str_has_prefix (tag_name, "image-tag-replace-"))) { replace_with_images (window, priv->images); @@ -3645,7 +3681,8 @@ on_zoom_minus_plus_not_implemented (ModestWindow *window) { g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window), FALSE); - hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here")); + hildon_banner_show_information (NULL, NULL, + _CS("ckct_ib_cannot_zoom_here")); return FALSE; }