X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-msg-view-window.c;h=66f04b21fbf7f49a691330855e2b782c71c2cd4b;hb=45659f37b6d5bb877b08c651b36af85f410e6f90;hp=48699f1c6e33f425591294af2f101779c9a19784;hpb=553b2c4a42fab8a5af0af01a8e630f2d4a7d554a;p=modest diff --git a/src/widgets/modest-msg-view-window.c b/src/widgets/modest-msg-view-window.c index 48699f1..66f04b2 100644 --- a/src/widgets/modest-msg-view-window.c +++ b/src/widgets/modest-msg-view-window.c @@ -37,7 +37,7 @@ #include "modest-marshal.h" #include "modest-platform.h" #include -#include +#include #include #include #include "modest-msg-view-window-ui-dimming.h" @@ -51,10 +51,7 @@ #include #include #include -#include -#include #include "modest-defs.h" -#include "modest-hildon-includes.h" #include "modest-ui-dimming-manager.h" #include #include @@ -70,7 +67,19 @@ #include #include #include +#include #include +#include + +#ifdef MODEST_PLATFORM_MAEMO +#include +#endif + +#ifdef MODEST_TOOLKIT_HILDON2 +#include +#endif +#include +#include #define MYDOCS_ENV "MYDOCSDIR" #define DOCS_FOLDER ".documents" @@ -117,6 +126,7 @@ struct _ModestMsgViewWindowPrivate { gulong row_deleted_handler; gulong row_inserted_handler; gulong rows_reordered_handler; + gulong fetch_image_redraw_handler; guint purge_timeout; GtkWidget *remove_attachment_banner; @@ -284,8 +294,8 @@ modest_msg_view_window_get_type (void) (GInstanceInitFunc) modest_msg_view_window_init, NULL }; -#ifdef MODEST_TOOLKIT_GTK - my_type = g_type_register_static (MODEST_TYPE_WINDOW, +#ifndef MODEST_TOOLKIT_HILDON2 + my_type = g_type_register_static (MODEST_TYPE_SHELL_WINDOW, "ModestMsgViewWindow", &my_info, 0); #else @@ -377,12 +387,10 @@ static void modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass) { GObjectClass *gobject_class; - HildonWindowClass *hildon_window_class; ModestWindowClass *modest_window_class; GtkBindingSet *binding_set; gobject_class = (GObjectClass*) klass; - hildon_window_class = (HildonWindowClass *) klass; modest_window_class = (ModestWindowClass *) klass; parent_class = g_type_class_peek_parent (klass); @@ -471,11 +479,6 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj) g_error_free (error); error = NULL; } - /* ****** */ - - /* Add accelerators */ - gtk_window_add_accel_group (GTK_WINDOW (obj), - gtk_ui_manager_get_accel_group (parent_priv->ui_manager)); priv->is_search_result = FALSE; priv->is_outbox = FALSE; @@ -490,6 +493,7 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj) priv->row_deleted_handler = 0; priv->row_inserted_handler = 0; priv->rows_reordered_handler = 0; + priv->fetch_image_redraw_handler = 0; priv->progress_hint = FALSE; priv->fetching_images = 0; @@ -637,6 +641,11 @@ modest_msg_view_window_finalize (GObject *obj) call this function before */ modest_msg_view_window_disconnect_signals (MODEST_WINDOW (obj)); + if (priv->fetch_image_redraw_handler > 0) { + g_source_remove (priv->fetch_image_redraw_handler); + priv->fetch_image_redraw_handler = 0; + } + if (priv->other_body != NULL) { g_object_unref (priv->other_body); priv->other_body = NULL; @@ -1591,7 +1600,7 @@ modest_msg_view_window_isearch_toolbar_search (GtkWidget *widget, current_search = modest_isearch_toolbar_get_search (MODEST_ISEARCH_TOOLBAR (widget)); if ((current_search == NULL) || (strcmp (current_search, "") == 0)) { - modest_platform_system_banner (NULL, NULL, _CS("ecdg_ib_find_rep_enter_text")); + modest_platform_system_banner (NULL, NULL, _CS_FIND_REP_ENTER_TEXT); return; } @@ -1603,7 +1612,7 @@ modest_msg_view_window_isearch_toolbar_search (GtkWidget *widget, priv->last_search); if (!result) { modest_platform_system_banner (NULL, NULL, - _HL("ckct_ib_find_no_matches")); + _HL_IB_FIND_NO_MATCHES); g_free (priv->last_search); priv->last_search = NULL; } else { @@ -1612,7 +1621,7 @@ modest_msg_view_window_isearch_toolbar_search (GtkWidget *widget, } else { if (!modest_isearch_view_search_next (MODEST_ISEARCH_VIEW (priv->msg_view))) { modest_platform_system_banner (NULL, NULL, - _HL("ckct_ib_find_search_complete")); + _HL_IB_FIND_COMPLETE); g_free (priv->last_search); priv->last_search = NULL; } else { @@ -1663,7 +1672,7 @@ modest_msg_view_window_zoom_plus (ModestWindow *window) if (zoom_level >= 2.0) { modest_platform_system_banner (NULL, NULL, - _CS("ckct_ib_max_zoom_level_reached")); + _CS_MAX_ZOOM_LEVEL_REACHED); return FALSE; } else if (zoom_level >= 1.5) { zoom_level = 2.0; @@ -1681,7 +1690,7 @@ modest_msg_view_window_zoom_plus (ModestWindow *window) /* set zoom level */ int_zoom = (gint) rint (zoom_level*100.0+0.1); - banner_text = g_strdup_printf (_HL("wdgt_ib_zoom"), int_zoom); + banner_text = g_strdup_printf (_HL_IB_ZOOM, int_zoom); modest_platform_information_banner (GTK_WIDGET (window), NULL, banner_text); g_free (banner_text); modest_zoomable_set_zoom (MODEST_ZOOMABLE (priv->msg_view), zoom_level); @@ -1704,7 +1713,7 @@ modest_msg_view_window_zoom_minus (ModestWindow *window) if (zoom_level <= 0.5) { modest_platform_system_banner (NULL, NULL, - _CS("ckct_ib_min_zoom_level_reached")); + _CS_MIN_ZOOM_LEVEL_REACHED); return FALSE; } else if (zoom_level <= 0.8) { zoom_level = 0.5; @@ -1722,7 +1731,7 @@ modest_msg_view_window_zoom_minus (ModestWindow *window) /* set zoom level */ int_zoom = (gint) rint (zoom_level*100.0+0.1); - banner_text = g_strdup_printf (_HL("wdgt_ib_zoom"), int_zoom); + banner_text = g_strdup_printf (_HL_IB_ZOOM, int_zoom); modest_platform_information_banner (GTK_WIDGET (window), NULL, banner_text); g_free (banner_text); modest_zoomable_set_zoom (MODEST_ZOOMABLE (priv->msg_view), zoom_level); @@ -1737,7 +1746,7 @@ modest_msg_view_window_key_event (GtkWidget *window, { GtkWidget *focus; - focus = gtk_window_get_focus (GTK_WINDOW (window)); + focus = gtk_container_get_focus_child ((GtkContainer *) window); /* for the isearch toolbar case */ if (focus && GTK_IS_ENTRY (focus)) { @@ -1886,7 +1895,7 @@ typedef struct { static void message_reader_performer (gboolean canceled, GError *err, - GtkWindow *parent_window, + ModestWindow *parent_window, TnyAccount *account, gpointer user_data) { @@ -1896,6 +1905,7 @@ message_reader_performer (gboolean canceled, info = (MsgReaderInfo *) user_data; if (canceled || err) { update_window_title (MODEST_MSG_VIEW_WINDOW (parent_window)); + modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (parent_window)); goto frees; } @@ -1956,7 +1966,7 @@ message_reader (ModestMsgViewWindow *window, /* We set the header from model while we're loading */ tny_header_view_set_header (TNY_HEADER_VIEW (priv->msg_view), header); - modest_window_set_title (MODEST_WINDOW (window), _CS("ckdg_pb_updating")); + modest_window_set_title (MODEST_WINDOW (window), _CS_UPDATING); if (header) folder = NULL; @@ -1972,9 +1982,10 @@ message_reader (ModestMsgViewWindow *window, we're not online */ if (!tny_device_is_online (modest_runtime_get_device())) { GtkResponseType response; + GtkWindow *toplevel; - response = modest_platform_run_confirmation_dialog (GTK_WINDOW (window), - _("mcen_nc_get_msg")); + toplevel = (GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *) window); + response = modest_platform_run_confirmation_dialog (toplevel, _("mcen_nc_get_msg")); if (response == GTK_RESPONSE_CANCEL) { update_window_title (window); return FALSE; @@ -2000,7 +2011,7 @@ message_reader (ModestMsgViewWindow *window, } /* Offer the connection dialog if necessary */ - modest_platform_connect_if_remote_and_perform ((GtkWindow *) window, + modest_platform_connect_if_remote_and_perform ((ModestWindow *) window, TRUE, TNY_FOLDER_STORE (folder), message_reader_performer, @@ -2032,7 +2043,7 @@ message_reader (ModestMsgViewWindow *window, else info->row_reference = NULL; - message_reader_performer (FALSE, NULL, (GtkWindow *) window, account, info); + message_reader_performer (FALSE, NULL, (ModestWindow *) window, account, info); if (account) g_object_unref (account); if (folder) @@ -2185,6 +2196,59 @@ view_msg_cb (ModestMailOperation *mail_op, gtk_tree_row_reference_free (row_reference); self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op); if (self) { + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); + /* First we check if the parent is a folder window */ + if (priv->msg_uid && !modest_window_mgr_get_folder_window (MODEST_WINDOW_MGR (modest_runtime_get_window_mgr ()))) { + gboolean is_merge; + TnyAccount *account = NULL; + GtkWidget *header_window = NULL; + + is_merge = g_str_has_prefix (priv->msg_uid, "merge:"); + + /* Get the account */ + if (!is_merge) + account = tny_account_store_find_account (TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()), + priv->msg_uid); + + if (is_merge || account) { + TnyFolder *folder = NULL; + + /* Try to get the message, if it's already downloaded + we don't need to connect */ + if (account) { + folder = modest_tny_folder_store_find_folder_from_uri (TNY_FOLDER_STORE (account), + priv->msg_uid); + } else { + ModestTnyAccountStore *account_store; + ModestTnyLocalFoldersAccount *local_folders_account; + + account_store = modest_runtime_get_account_store (); + local_folders_account = MODEST_TNY_LOCAL_FOLDERS_ACCOUNT ( + modest_tny_account_store_get_local_folders_account (account_store)); + folder = modest_tny_local_folders_account_get_merged_outbox (local_folders_account); + g_object_unref (local_folders_account); + } + if (account) g_object_unref (account); + + if (folder) { + header_window = (GtkWidget *) + modest_header_window_new ( + folder, + modest_window_get_active_account (MODEST_WINDOW (self)), + modest_window_get_active_mailbox (MODEST_WINDOW (self))); + if (!modest_window_mgr_register_window (modest_runtime_get_window_mgr (), + MODEST_WINDOW (header_window), + NULL)) { + gtk_widget_destroy (GTK_WIDGET (header_window)); + } else { + gtk_widget_show_all (GTK_WIDGET (header_window)); + } + g_object_unref (folder); + } + } + } + + /* Restore window title */ update_window_title (self); modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (self)); @@ -2193,6 +2257,30 @@ view_msg_cb (ModestMailOperation *mail_op, return; } + if (msg && TNY_IS_CAMEL_BS_MSG (msg)) { + TnyMimePart *body; + body = modest_tny_msg_find_body_part (msg, TRUE); + + if (body && !tny_camel_bs_mime_part_is_fetched (TNY_CAMEL_BS_MIME_PART (body))) { + /* We have body structure but not the body mime part. What we do + * is restarting load of message */ + self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op); + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); + + tny_header_unset_flag (TNY_HEADER (header), TNY_HEADER_FLAG_CACHED); + + modest_msg_view_window_reload (self); + + if (row_reference) + gtk_tree_row_reference_free (row_reference); + g_object_unref (body); + return; + } + + if (body) + g_object_unref (body); + } + /* Get the window */ self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op); g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self)); @@ -2370,7 +2458,12 @@ modest_msg_view_window_show_toolbar (ModestWindow *self, if (!parent_priv->toolbar) { parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar"); + +#ifdef MODEST_TOOLKIT_HILDON2 gtk_toolbar_set_icon_size (GTK_TOOLBAR (parent_priv->toolbar), HILDON_ICON_SIZE_FINGER); +#else + gtk_toolbar_set_icon_size (GTK_TOOLBAR (parent_priv->toolbar), GTK_ICON_SIZE_LARGE_TOOLBAR); +#endif gtk_widget_set_no_show_all (parent_priv->toolbar, TRUE); priv->next_toolitem = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarMessageNext"); @@ -2647,7 +2740,7 @@ on_decode_to_stream_async_handler (TnyMimePart *mime_part, account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ()); msg = tny_camel_msg_new (); - tny_camel_msg_parse (msg, file_stream); + tny_camel_msg_parse ((TnyCamelMsg *) msg, file_stream); msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (msg), account, mailbox, helper->attachment_uid); modest_window_set_zoom (MODEST_WINDOW (msg_win), modest_window_get_zoom (MODEST_WINDOW (helper->self))); @@ -2678,6 +2771,24 @@ on_decode_to_stream_async_handler (TnyMimePart *mime_part, g_slice_free (DecodeAsyncHelper, helper); } +static void +view_attachment_connect_handler (gboolean canceled, + GError *err, + GtkWindow *parent_window, + TnyAccount *account, + TnyMimePart *part) +{ + + if (canceled || err) { + g_object_unref (part); + return; + } + + modest_msg_view_window_view_attachment (MODEST_MSG_VIEW_WINDOW (parent_window), + part); + g_object_unref (part); +} + void modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart *mime_part) @@ -2727,6 +2838,28 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, if (tny_mime_part_is_purged (mime_part)) goto frees; + if (TNY_IS_CAMEL_BS_MIME_PART (mime_part) && + !tny_camel_bs_mime_part_is_fetched (TNY_CAMEL_BS_MIME_PART (mime_part))) { + gboolean is_merge; + TnyAccount *account; + + is_merge = g_str_has_prefix (priv->msg_uid, "merge:"); + account = NULL; + /* Get the account */ + if (!is_merge) + account = tny_account_store_find_account (TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()), + priv->msg_uid); + + if (!tny_device_is_online (modest_runtime_get_device())) { + modest_platform_connect_and_perform ((ModestWindow *) window, + TRUE, + TNY_ACCOUNT (account), + (ModestConnectedPerformer) view_attachment_connect_handler, + g_object_ref (mime_part)); + goto frees; + } + } + if (!modest_tny_mime_part_is_msg (mime_part) && tny_mime_part_get_filename (mime_part)) { gchar *filepath = NULL; const gchar *att_filename = tny_mime_part_get_filename (mime_part); @@ -2917,8 +3050,10 @@ idle_save_mime_part_show_result (SaveMimePartInfo *info) * modest_platform_system_banner is or does Gtk+ code */ gdk_threads_enter (); /* CHECKED */ - if (info->result == GNOME_VFS_OK) { - modest_platform_system_banner (NULL, NULL, _CS("sfil_ib_saved")); + if (info->result == GNOME_VFS_ERROR_CANCELLED) { + /* nothing */ + } else if (info->result == GNOME_VFS_OK) { + modest_platform_system_banner (NULL, NULL, _CS_SAVED); } else if (info->result == GNOME_VFS_ERROR_NO_SPACE) { gchar *msg = NULL; @@ -2938,6 +3073,48 @@ idle_save_mime_part_show_result (SaveMimePartInfo *info) return FALSE; } +static void +save_mime_part_to_file_connect_handler (gboolean canceled, + GError *err, + GtkWindow *parent_window, + TnyAccount *account, + SaveMimePartInfo *info) +{ + if (canceled || err) { + if (canceled && !err) { + info->result = GNOME_VFS_ERROR_CANCELLED; + } + g_idle_add ((GSourceFunc) idle_save_mime_part_show_result, info); + } else { + g_thread_create ((GThreadFunc)save_mime_part_to_file, info, FALSE, NULL); + } +} + +static gboolean +save_mime_part_to_file_connect_idle (SaveMimePartInfo *info) +{ + gboolean is_merge; + TnyAccount *account; + ModestMsgViewWindowPrivate *priv; + + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (info->window); + + is_merge = g_str_has_prefix (priv->msg_uid, "merge:"); + account = NULL; + + /* Get the account */ + if (!is_merge) + account = tny_account_store_find_account (TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()), + priv->msg_uid); + + modest_platform_connect_and_perform ((ModestWindow *) info->window, + TRUE, + TNY_ACCOUNT (account), + (ModestConnectedPerformer) save_mime_part_to_file_connect_handler, + info); + return FALSE; +} + static gpointer save_mime_part_to_file (SaveMimePartInfo *info) { @@ -2945,6 +3122,12 @@ save_mime_part_to_file (SaveMimePartInfo *info) TnyStream *stream; SaveMimePartPair *pair = (SaveMimePartPair *) info->pairs->data; + if (TNY_IS_CAMEL_BS_MIME_PART (pair->part) && + !tny_camel_bs_mime_part_is_fetched (TNY_CAMEL_BS_MIME_PART (pair->part))) { + g_idle_add ((GSourceFunc) save_mime_part_to_file_connect_idle, info); + return NULL; + } + info->result = gnome_vfs_create (&handle, pair->filename, GNOME_VFS_OPEN_WRITE, FALSE, 0644); if (info->result == GNOME_VFS_OK) { GError *error = NULL; @@ -3032,14 +3215,14 @@ save_mime_parts_to_file_with_checks (GtkWindow *parent, escaped_basename = g_uri_unescape_string (basename, NULL); message = g_strdup_printf ("%s\n%s", - _FM("docm_nc_replace_file"), + _FM_REPLACE_FILE, (escaped_basename) ? escaped_basename : ""); response = modest_platform_run_confirmation_dialog (parent, message); g_free (message); g_free (escaped_basename); } else { response = modest_platform_run_confirmation_dialog (parent, - _FM("docm_nc_replace_multiple")); + _FM_REPLACE_MULTIPLE); } if (response != GTK_RESPONSE_OK) is_ok = FALSE; @@ -3094,10 +3277,10 @@ save_attachments_response (GtkDialog *dialog, if (modest_maemo_utils_in_usb_mode ()) { err_msg = dgettext ("hildon-status-bar-usb", "usbh_ib_mmc_usb_connected"); } else { - err_msg = _FM("sfil_ib_readonly_location"); + err_msg = _FM_READ_ONLY_LOCATION; } #else - err_msg = _FM("sfil_ib_readonly_location"); + err_msg = _FM_READ_ONLY_LOCATION; #endif modest_platform_system_banner (NULL, NULL, err_msg); } else { @@ -3166,7 +3349,7 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, /* In Hildon 2.2 save and delete operate over all the attachments as there's no * selection available */ mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view)); - if (mime_parts && !modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, FALSE)) { + if (mime_parts && !modest_toolkit_utils_select_attachments (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (window))), mime_parts, FALSE)) { g_object_unref (mime_parts); return; } @@ -3207,12 +3390,11 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, num), num); } - /****** HILDON2:START - * creation of hildon file chooser dialog for saving - */ - save_dialog = hildon_file_chooser_dialog_new (GTK_WINDOW (window), - GTK_FILE_CHOOSER_ACTION_SAVE); - /****** HILDON2:END */ + /* Creation of hildon file chooser dialog for saving */ + save_dialog = modest_toolkit_factory_create_file_chooser_dialog (modest_runtime_get_toolkit_factory (), + "", + (GtkWindow *) window, + GTK_FILE_CHOOSER_ACTION_SAVE); /* Get last used folder */ conf_folder = modest_conf_get_string (modest_runtime_get_conf (), @@ -3249,7 +3431,7 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, /* if multiple, set multiple string */ if (save_multiple_str) { g_object_set (G_OBJECT (save_dialog), "save-multiple", save_multiple_str, NULL); - gtk_window_set_title (GTK_WINDOW (save_dialog), _FM("sfil_ti_save_objects_files")); + gtk_window_set_title (GTK_WINDOW (save_dialog), _FM_SAVE_OBJECT_FILES); g_free (save_multiple_str); } @@ -3302,6 +3484,7 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window)); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); +#ifdef MODEST_TOOLKIT_HILDON2 /* In hildon 2.2 we ignore the get_all flag as we always get all attachments. This is * because we don't have selection */ @@ -3322,11 +3505,36 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean g_object_unref (tmp); g_object_unref (iter); - if (!modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, TRUE) || + if (!modest_toolkit_utils_select_attachments (GTK_WINDOW (window), mime_parts, TRUE) || tny_list_get_length (mime_parts) == 0) { g_object_unref (mime_parts); return; } +#else + /* In gtk we get only selected attachments for the operation. + */ + mime_parts = modest_msg_view_get_selected_attachments (MODEST_MSG_VIEW (priv->msg_view)); + + /* Remove already purged messages from mime parts list. We use + a copy of the list to remove items in the original one */ + tmp = tny_list_copy (mime_parts); + iter = tny_list_create_iterator (tmp); + while (!tny_iterator_is_done (iter)) { + TnyMimePart *part = TNY_MIME_PART (tny_iterator_get_current (iter)); + if (tny_mime_part_is_purged (part)) + tny_list_remove (mime_parts, (GObject *) part); + + g_object_unref (part); + tny_iterator_next (iter); + } + g_object_unref (tmp); + g_object_unref (iter); + + if (tny_list_get_length (mime_parts) == 0) { + g_object_unref (mime_parts); + return; + } +#endif n_attachments = tny_list_get_length (mime_parts); if (n_attachments == 1) { @@ -3354,7 +3562,7 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean "mcen_nc_purge_files_text", n_attachments), n_attachments); } - response = modest_platform_run_confirmation_dialog (GTK_WINDOW (window), + response = modest_platform_run_confirmation_dialog (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (window))), confirmation_message); g_free (confirmation_message); @@ -3486,6 +3694,21 @@ typedef struct { } FetchImageData; gboolean +on_fetch_image_timeout_refresh_view (gpointer userdata) +{ + ModestMsgViewWindowPrivate *priv; + + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (userdata); + update_progress_hint (MODEST_MSG_VIEW_WINDOW (userdata)); + if (GTK_WIDGET_DRAWABLE (priv->msg_view)) { + gtk_widget_queue_draw (GTK_WIDGET (priv->msg_view)); + } + priv->fetch_image_redraw_handler = 0; + g_object_unref (userdata); + return FALSE; +} + +gboolean on_fetch_image_idle_refresh_view (gpointer userdata) { @@ -3497,8 +3720,10 @@ on_fetch_image_idle_refresh_view (gpointer userdata) priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (fidata->window); priv->fetching_images--; - gtk_widget_queue_draw (fidata->msg_view); - update_progress_hint (MODEST_MSG_VIEW_WINDOW (fidata->window)); + if (priv->fetch_image_redraw_handler == 0) { + priv->fetch_image_redraw_handler = g_timeout_add (500, on_fetch_image_timeout_refresh_view, g_object_ref (fidata->window)); + } + } gdk_threads_leave (); @@ -3650,7 +3875,6 @@ modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self) priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); GSList *recipients = NULL; TnyMsg *msg = NULL; - gboolean contacts_to_add = FALSE; msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view)); if (msg == NULL) { @@ -3666,56 +3890,11 @@ modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self) g_object_unref (msg); } - if (recipients != NULL) { - /****** HILDON2:START - * shows dialog with addresses not present in addressbook. User can choose one to - * add it to addressbook. - * */ - GtkWidget *picker_dialog; - GtkWidget *selector; - GSList *node; - gchar *selected = NULL; - - selector = hildon_touch_selector_new_text (); - g_object_ref (selector); - - for (node = recipients; node != NULL; node = g_slist_next (node)) { - if (!modest_address_book_has_address ((const gchar *) node->data)) { - hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), - (const gchar *) node->data); - contacts_to_add = TRUE; - } - } - - if (contacts_to_add) { - gint picker_result; - - picker_dialog = hildon_picker_dialog_new (GTK_WINDOW (self)); - gtk_window_set_title (GTK_WINDOW (picker_dialog), _("mcen_me_viewer_addtocontacts")); - - hildon_picker_dialog_set_selector (HILDON_PICKER_DIALOG (picker_dialog), - HILDON_TOUCH_SELECTOR (selector)); - - picker_result = gtk_dialog_run (GTK_DIALOG (picker_dialog)); - - if (picker_result == GTK_RESPONSE_OK) { - selected = hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector)); - } - gtk_widget_destroy (picker_dialog); - - if (selected) - modest_address_book_add_address (selected, (GtkWindow *) self); - g_free (selected); - - } else { - - g_object_unref (selector); - - } - /****** HILDON2:END */ + if (recipients) { + /* Offer the user to add recipients to the address book */ + modest_address_book_add_address_list_with_selector (recipients, (GtkWindow *) self); + g_slist_foreach (recipients, (GFunc) g_free, NULL); g_slist_free (recipients); } - - if (recipients) {g_slist_foreach (recipients, (GFunc) g_free, NULL); g_slist_free (recipients);} } static gboolean