X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-edit-window.c;h=d322a215fb629023410c64fbec7101ccd7e4a51d;hp=65cefee819448ce9a976311fa6d85fd046f694a9;hb=dfd322a4731d53c0de56278bdebc867f55eedfc2;hpb=b3c8a32f002d101d3c94dedcfa68ce6255f97a71 diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 65cefee..d322a21 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -104,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, @@ -177,14 +173,8 @@ static void text_buffer_mark_set (GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextMark *mark, ModestMsgEditWindow *userdata); -void vadj_changed (GtkAdjustment *adj, - ModestMsgEditWindow *window); - -static ModestPair *find_transport_from_message_sender (ModestPairList *transports, - TnyMsg *msg); - - - +static void vadj_changed (GtkAdjustment *adj, + ModestMsgEditWindow *window); static void DEBUG_BUFFER (WPTextBuffer *buffer) { @@ -246,7 +236,7 @@ struct _ModestMsgEditWindowPrivate { ModestPairList *from_field_protos; GtkWidget *from_field; - const gchar *original_account_name; + gchar *original_account_name; GtkWidget *to_field; GtkWidget *cc_field; @@ -274,11 +264,13 @@ struct _ModestMsgEditWindowPrivate { GtkWidget *find_toolbar; gchar *last_search; + GtkWidget *font_dialog; + GtkWidget *scroll; guint scroll_drag_timeout_id; gdouble last_upper; - gint last_cid; + gint next_cid; TnyList *attachments; TnyList *images; guint64 images_size; @@ -419,7 +411,7 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj) priv->images = TNY_LIST (tny_simple_list_new ()); priv->images_size = 0; priv->images_count = 0; - priv->last_cid = 0; + priv->next_cid = 0; priv->cc_caption = NULL; priv->bcc_caption = NULL; @@ -446,6 +438,8 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj) priv->scroll_drag_timeout_id = 0; priv->last_upper = 0.0; + priv->font_dialog = NULL; + modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(), GTK_WINDOW(obj),"applications_email_editor"); @@ -498,41 +492,6 @@ get_transports (void) return transports; } -/** - * Search an (account, address) ModestPairList for a pair whose - * address matches the one in the From: header of a TnyMsg - * - * @result: A ModestPair * with a matching address, or NULL if none found - */ -static ModestPair * -find_transport_from_message_sender (ModestPairList *transports, TnyMsg *msg) -{ - g_return_val_if_fail (transports, NULL); - g_return_val_if_fail (msg, NULL); - - ModestPair *account_pair = NULL; - TnyHeader *header = tny_msg_get_header (msg); - - if (header != NULL && tny_header_get_from (header)) { - char *from_addr = modest_text_utils_get_email_address (tny_header_get_from (header)); - GSList *iter; - for (iter = transports; iter && !account_pair; iter = iter->next) { - ModestPair *pair = (ModestPair *) iter->data; - char *account_addr = modest_text_utils_get_email_address ((char *) pair->second); - if (account_addr && !strcasecmp(from_addr, account_addr)) { - account_pair = pair; - } - g_free (account_addr); - } - g_free (from_addr); - } - - if (header) - g_object_unref (header); - - return account_pair; -} - static void window_focus (GtkWindow *window, GtkWidget *widget, gpointer userdata) @@ -668,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; @@ -682,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; @@ -698,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); @@ -751,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 @@ -884,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 @@ -959,6 +925,10 @@ modest_msg_edit_window_finalize (GObject *obj) call this function before */ modest_msg_edit_window_disconnect_signals (MODEST_WINDOW (obj)); + if (priv->font_dialog != NULL) { + gtk_dialog_response (GTK_DIALOG (priv->font_dialog), GTK_RESPONSE_NONE); + } + if (priv->clipboard_text != NULL) { g_free (priv->clipboard_text); priv->clipboard_text = NULL; @@ -990,6 +960,8 @@ modest_msg_edit_window_finalize (GObject *obj) g_source_remove (priv->clipboard_owner_idle); priv->clipboard_owner_idle = 0; } + if (priv->original_account_name) + g_free (priv->original_account_name); g_free (priv->msg_uid); g_free (priv->last_search); g_slist_free (priv->font_items_group); @@ -1028,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; } } @@ -1147,7 +1121,7 @@ get_related_images (ModestMsgEditWindow *self, TnyMsg *msg) } static void -update_last_cid (ModestMsgEditWindow *self, TnyList *attachments) +update_next_cid (ModestMsgEditWindow *self, TnyList *attachments) { TnyIterator *iter; ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self); @@ -1160,8 +1134,8 @@ update_last_cid (ModestMsgEditWindow *self, TnyList *attachments) if (cid != NULL) { char *invalid = NULL; gint int_cid = strtol (cid, &invalid, 10); - if ((invalid != NULL) && (*invalid == '\0') && (int_cid > priv->last_cid)) { - priv->last_cid = int_cid; + if ((invalid != NULL) && (*invalid == '\0') && (int_cid >= priv->next_cid)) { + priv->next_cid = int_cid + 1; } } g_object_unref (part); @@ -1173,7 +1147,7 @@ static void set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) { TnyHeader *header; - const gchar *to, *cc, *bcc, *subject; + gchar *to, *cc, *bcc, *subject; gchar *body; ModestMsgEditWindowPrivate *priv; GtkTextIter iter; @@ -1187,10 +1161,10 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self); header = tny_msg_get_header (msg); - to = tny_header_get_to (header); - cc = tny_header_get_cc (header); - bcc = tny_header_get_bcc (header); - subject = tny_header_get_subject (header); + to = tny_header_dup_to (header); + cc = tny_header_dup_cc (header); + bcc = tny_header_dup_bcc (header); + subject = tny_header_dup_subject (header); priority_flags = tny_header_get_priority (header); if (to) @@ -1243,14 +1217,14 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) gtk_widget_show_all (priv->attachments_caption); } get_related_images (self, msg); - update_last_cid (self, priv->attachments); - update_last_cid (self, priv->images); + update_next_cid (self, priv->attachments); + update_next_cid (self, priv->images); replace_with_images (self, priv->images); if (preserve_is_rich && !is_html) { wp_text_buffer_enable_rich_text (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); } @@ -1298,6 +1272,11 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) } g_object_unref (msg_folder); } + + g_free (to); + g_free (subject); + g_free (cc); + g_free (bcc); } static void @@ -1496,7 +1475,6 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre GObject *obj; ModestWindowPrivate *parent_priv; ModestMsgEditWindowPrivate *priv; - ModestPair *account_pair = NULL; ModestDimmingRulesGroup *menu_rules_group = NULL; ModestDimmingRulesGroup *toolbar_rules_group = NULL; ModestDimmingRulesGroup *clipboard_rules_group = NULL; @@ -1517,6 +1495,7 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre hildon_window_set_menu (HILDON_WINDOW (obj), GTK_MENU (parent_priv->menubar)); priv->from_field_protos = get_transports (); modest_combo_box_set_pair_list (MODEST_COMBO_BOX (priv->from_field), priv->from_field_protos); + modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->from_field), (gpointer) account_name); modest_msg_edit_window_setup_toolbar (MODEST_MSG_EDIT_WINDOW (obj)); hildon_window_add_toolbar (HILDON_WINDOW (obj), GTK_TOOLBAR (priv->find_toolbar)); @@ -1527,14 +1506,7 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre modest_window_set_active_account (MODEST_WINDOW(obj), account_name); - account_pair = find_transport_from_message_sender (priv->from_field_protos, msg); - if (account_pair == NULL) { - account_pair = modest_pair_list_find_by_first_as_string (priv->from_field_protos, account_name); - } - if (account_pair != NULL) - modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->from_field), account_pair->first); - - priv->original_account_name = account_pair ? (const gchar *) account_pair->first : NULL; + priv->original_account_name = (account_name) ? g_strdup (account_name) : NULL; parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new (); menu_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_MENU, FALSE); @@ -1618,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); @@ -1921,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 @@ -2134,7 +2112,8 @@ modest_msg_edit_window_select_background_color (ModestMsgEditWindow *window) -static TnyStream* create_stream_for_uri (const gchar* uri) +static TnyStream* +create_stream_for_uri (const gchar* uri) { if (!uri) return NULL; @@ -2144,9 +2123,22 @@ static TnyStream* create_stream_for_uri (const gchar* uri) GnomeVFSHandle *handle = NULL; GnomeVFSResult test = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ); if (test == GNOME_VFS_OK) { - /* Create the tinymail stream: */ - /* Presumably tinymai will call gnome_vfs_close (handle) later. */ - result = TNY_STREAM (tny_vfs_stream_new (handle)); + TnyStream *vfssstream = TNY_STREAM (tny_vfs_stream_new (handle)); + /* Streams over OBEX (Bluetooth) are not seekable but + * we expect them to be (we might need to read them + * several times). So if this is a Bluetooth URI just + * read the whole file into memory (this is not a fast + * protocol so we can assume that these files are not + * going to be very big) */ + if ((g_ascii_strncasecmp (uri, "obex://", 7) == 0)|| + (g_ascii_strncasecmp (uri, "upnpav://", 9) == 0)) { + TnyStream *memstream = tny_camel_mem_stream_new (); + tny_stream_write_to_stream (vfssstream, memstream); + g_object_unref (vfssstream); + result = memstream; + } else { + result = vfssstream; + } } return result; @@ -2170,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: @@ -2199,6 +2195,7 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window) GnomeVFSURI *vfs_uri; guint64 stream_size; + gnome_vfs_close (handle); vfs_uri = gnome_vfs_uri_new (uri); escaped_filename = g_path_get_basename (gnome_vfs_uri_get_path (vfs_uri)); @@ -2216,12 +2213,22 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window) (modest_runtime_get_platform_factory ()); TnyStream *stream = create_stream_for_uri (uri); + + if (stream == NULL) { + + modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); + + g_object_unref (mime_part); + gnome_vfs_file_info_unref (info); + continue; + } + tny_mime_part_construct (mime_part, stream, mime_type, "base64"); - content_id = g_strdup_printf ("%d", priv->last_cid); + content_id = g_strdup_printf ("%d", priv->next_cid); tny_mime_part_set_content_id (mime_part, content_id); g_free (content_id); - priv->last_cid++; + priv->next_cid++; basename = g_path_get_basename (filename); tny_mime_part_set_filename (mime_part, basename); @@ -2256,10 +2263,22 @@ modest_msg_edit_window_offer_attach_file (ModestMsgEditWindow *window) gint response = 0; GSList *uris = NULL; GSList *uri_node; + GnomeVFSFileSize total_size, allowed_size; + ModestMsgEditWindowPrivate *priv; + gint att_num; + guint64 att_size; + + g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(window)); + + priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window); + + if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE)) + return; 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), GTK_WINDOW (window)); response = gtk_dialog_run (GTK_DIALOG (dialog)); switch (response) { @@ -2271,25 +2290,47 @@ modest_msg_edit_window_offer_attach_file (ModestMsgEditWindow *window) } gtk_widget_destroy (dialog); + /* allowed size is the maximum size - what's already there */ + modest_attachments_view_get_sizes ( + MODEST_ATTACHMENTS_VIEW (priv->attachments_view), + &att_num, &att_size); + allowed_size = MODEST_MAX_ATTACHMENT_SIZE - att_size; + + total_size = 0; for (uri_node = uris; uri_node != NULL; uri_node = g_slist_next (uri_node)) { + const gchar *uri = (const gchar *) uri_node->data; - modest_msg_edit_window_attach_file_one (window, uri); + + total_size += modest_msg_edit_window_attach_file_one + (window, uri, allowed_size); + + if (total_size > allowed_size) { + g_warning ("%s: total size: %u", + __FUNCTION__, (unsigned int)total_size); + break; + } + + allowed_size -= total_size; + + } g_slist_foreach (uris, (GFunc) g_free, NULL); g_slist_free (uris); } -void -modest_msg_edit_window_attach_file_one ( - ModestMsgEditWindow *window, - const gchar *uri) + +GnomeVFSFileSize +modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window, + const gchar *uri, + GnomeVFSFileSize allowed_size) + { GnomeVFSHandle *handle = NULL; ModestMsgEditWindowPrivate *priv; GnomeVFSResult result; - - g_return_if_fail (window); - g_return_if_fail (uri); + GnomeVFSFileSize size = 0; + g_return_val_if_fail (window, 0); + g_return_val_if_fail (uri, 0); priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window); @@ -2305,6 +2346,7 @@ modest_msg_edit_window_attach_file_one ( GnomeVFSFileInfo *info; GnomeVFSURI *vfs_uri; + gnome_vfs_close (handle); vfs_uri = gnome_vfs_uri_new (uri); @@ -2322,16 +2364,38 @@ modest_msg_edit_window_attach_file_one ( mime_type = gnome_vfs_file_info_get_mime_type (info); mime_part = tny_platform_factory_new_mime_part (modest_runtime_get_platform_factory ()); - stream = TNY_STREAM (tny_vfs_stream_new (handle)); - tny_mime_part_construct (mime_part, stream, mime_type, "base64"); + /* try to get the attachment's size; this may fail for weird + * file systems, like obex, upnp... */ + if (allowed_size != 0 && + info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) { + size = info->size; + if (size > allowed_size) { + modest_platform_information_banner (NULL, NULL, + dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); + return 0; + } + } else + g_warning ("%s: could not get attachment size", __FUNCTION__); + + stream = create_stream_for_uri (uri); + + if (stream == NULL) { + + modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed")); + g_object_unref (mime_part); + gnome_vfs_file_info_unref (info); + return 0; + } + + tny_mime_part_construct (mime_part, stream, mime_type, "base64"); g_object_unref (stream); - content_id = g_strdup_printf ("%d", priv->last_cid); + content_id = g_strdup_printf ("%d", priv->next_cid); tny_mime_part_set_content_id (mime_part, content_id); g_free (content_id); - priv->last_cid++; + priv->next_cid++; basename = g_path_get_basename (filename); tny_mime_part_set_filename (mime_part, basename); @@ -2348,6 +2412,8 @@ modest_msg_edit_window_attach_file_one ( g_object_unref (mime_part); gnome_vfs_file_info_unref (info); } + + return size; } void @@ -2369,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; @@ -2382,7 +2447,7 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window, if (TNY_IS_MSG (part)) { TnyHeader *header = tny_msg_get_header (TNY_MSG (part)); if (header) { - filename = g_strdup (tny_header_get_subject (header)); + filename = tny_header_dup_subject (header); g_object_unref (header); } if (filename == NULL) { @@ -2396,13 +2461,13 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window, filename = g_strdup (""); } message = g_strdup_printf (ngettext("emev_nc_delete_attachment", "emev_nc_delete_attachments", - (tny_list_get_length (att_list) == 1)), filename); + 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; } @@ -2602,6 +2667,13 @@ modest_msg_edit_window_open_addressbook (ModestMsgEditWindow *window, g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window)); g_return_if_fail ((editor == NULL) || (MODEST_IS_RECPT_EDITOR (editor))); + + /* we check for low-mem; in that case, show a warning, and don't allow + * for the addressbook + */ + if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE)) + return; + priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window); if (editor == NULL) { @@ -2757,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); } } @@ -2783,6 +2856,8 @@ modest_msg_edit_window_select_font (ModestMsgEditWindow *window) priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (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 (window)); /* First we get the currently selected font information */ wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), &oldfmt, TRUE); @@ -2818,8 +2893,12 @@ 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)); + priv->font_dialog = NULL; if (response == GTK_RESPONSE_OK) { g_object_get( dialog, @@ -2905,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 @@ -3273,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) @@ -3513,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; @@ -3528,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);