X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-edit-window.c;h=d322a215fb629023410c64fbec7101ccd7e4a51d;hp=2cba7b24c3b69957d6fe380c9319940024339378;hb=dfd322a4731d53c0de56278bdebc867f55eedfc2;hpb=587841e2cb7a496338354f15385eea4deee3a3e1 diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 2cba7b2..d322a21 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -105,11 +105,6 @@ static void text_buffer_can_redo (GtkTextBuffer *buffer, gboolean can_redo, Mod static void text_buffer_apply_tag (GtkTextBuffer *buffer, GtkTextTag *tag, GtkTextIter *start, GtkTextIter *end, gpointer userdata); -static void text_buffer_insert_text (GtkTextBuffer *buffer, - GtkTextIter *location, - gchar *text, - gint len, - ModestMsgEditWindow *window); static void text_buffer_delete_images_by_id (GtkTextBuffer *buffer, const gchar * image_id); static void subject_field_changed (GtkEditable *editable, ModestMsgEditWindow *window); static void subject_field_insert_text (GtkEditable *editable, @@ -178,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) { @@ -632,8 +627,9 @@ copy_clipboard_check (GtkTextView *text_view, } } -void vadj_changed (GtkAdjustment *adj, - ModestMsgEditWindow *window) +static void +vadj_changed (GtkAdjustment *adj, + ModestMsgEditWindow *window) { ModestMsgEditWindowPrivate *priv; @@ -646,6 +642,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; @@ -662,8 +666,6 @@ connect_signals (ModestMsgEditWindow *obj) G_CALLBACK (body_changed), obj); g_signal_connect (G_OBJECT (priv->text_buffer), "modified-changed", G_CALLBACK (body_changed), obj); - g_signal_connect (G_OBJECT (priv->text_buffer), "insert-text", - G_CALLBACK (text_buffer_insert_text), obj); g_signal_connect (G_OBJECT (obj), "window-state-event", G_CALLBACK (modest_msg_edit_window_window_state_event), NULL); @@ -715,7 +717,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 @@ -848,9 +850,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 @@ -998,6 +1000,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; } } @@ -1219,17 +1223,9 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) if (preserve_is_rich && !is_html) { wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), FALSE); - /* We must do this here in order to reset the undo - list, because otherwise this action could be - reverted */ - wp_text_buffer_reset_buffer (WP_TEXT_BUFFER (priv->text_buffer), FALSE); /* Get the default format required from configuration */ - } else if (!modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_PREFER_FORMATTED_TEXT, NULL)) { + } else if (!preserve_is_rich && !modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_PREFER_FORMATTED_TEXT, NULL)) { wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), FALSE); - /* We must do this here in order to reset the undo - list, because otherwise this action could be - reverted */ - wp_text_buffer_reset_buffer (WP_TEXT_BUFFER (priv->text_buffer), FALSE); } /* Set the default focus depending on having already a To: field or not */ @@ -1594,6 +1590,8 @@ get_formatted_data (ModestMsgEditWindow *edit_window) wp_text_buffer_save_document (WP_TEXT_BUFFER(priv->text_buffer), get_formatted_data_cb, &string_buffer); + modest_text_utils_hyperlinkify (string_buffer); + gtk_text_buffer_set_modified (priv->text_buffer, TRUE); return g_string_free (string_buffer, FALSE); @@ -1897,8 +1895,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 @@ -2160,6 +2162,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: @@ -2272,7 +2278,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) { @@ -2323,7 +2329,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); @@ -2366,8 +2371,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, + dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); return 0; } } else @@ -2430,7 +2435,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; @@ -2459,11 +2463,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; } @@ -2825,6 +2829,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); } } @@ -2852,7 +2857,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); @@ -2888,6 +2893,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)); @@ -2977,7 +2984,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 @@ -3345,48 +3351,6 @@ subject_field_insert_text (GtkEditable *editable, g_string_free (result, TRUE); } -static void -text_buffer_insert_text (GtkTextBuffer *buffer, - GtkTextIter *iter, - gchar *new_text, - gint new_text_length, - ModestMsgEditWindow *window) -{ - GString *result = g_string_new (""); - gchar *current; - gint result_len = 0; - gboolean changed = FALSE; - - for (current = new_text; current != NULL && *current != '\0'; current = g_utf8_next_char (current)) { - gunichar c = g_utf8_get_char_validated (current, 8); - /* Invalid unichar, stop */ - if (c == -1) - break; - /* a bullet */ - switch (c) { - case 0x2022: - result = g_string_append_c (result, ' '); - changed = TRUE; - break; - default: - result = g_string_append_unichar (result, c); - } - result_len++; - } - - if (changed) { - g_signal_stop_emission_by_name (G_OBJECT (buffer), "insert-text"); - g_signal_handlers_block_by_func(G_OBJECT(buffer), G_CALLBACK(text_buffer_insert_text), window); - g_signal_emit_by_name (buffer, "insert-text", - (gpointer) iter, - (gpointer) result->str, (gpointer) result->len, - (gpointer) window); - g_signal_handlers_unblock_by_func(G_OBJECT(buffer), G_CALLBACK(text_buffer_insert_text), window); - } - - g_string_free (result, TRUE); -} - void modest_msg_edit_window_toggle_find_toolbar (ModestMsgEditWindow *window, gboolean show) @@ -3585,7 +3549,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; @@ -3600,7 +3564,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);