gulong row_deleted_handler;
gulong row_inserted_handler;
gulong rows_reordered_handler;
+ gulong fetch_image_redraw_handler;
guint purge_timeout;
GtkWidget *remove_attachment_banner;
gchar *msg_uid;
TnyMimePart *other_body;
+ TnyMsg * top_msg;
GSList *sighandlers;
};
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;
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;
}
+ if (priv->top_msg != NULL) {
+ g_object_unref (priv->top_msg);
+ priv->top_msg = NULL;
+ }
+
if (priv->header_model != NULL) {
g_object_unref (priv->header_model);
priv->header_model = NULL;
modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+ priv->top_msg = NULL;
/* Remember the message list's TreeModel so we can detect changes
* and change the list selection when necessary: */
modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+ priv->top_msg = NULL;
is_merge = g_str_has_prefix (msg_uid, "merge:");
modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+ priv->top_msg = NULL;
/* Remember the message list's TreeModel so we can detect changes
* and change the list selection when necessary: */
modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+ priv->top_msg = NULL;
/* Remember that this is a search result,
* so we can disable some UI appropriately: */
ModestWindow *
modest_msg_view_window_new_with_other_body (TnyMsg *msg,
TnyMimePart *other_body,
+ TnyMsg *top_msg,
const gchar *modest_account_name,
const gchar *mailbox,
const gchar *msg_uid)
} else {
tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
}
+ if (top_msg) {
+ priv->top_msg = g_object_ref (top_msg);
+ } else {
+ priv->top_msg = NULL;
+ }
update_window_title (MODEST_MSG_VIEW_WINDOW (obj));
update_branding (MODEST_MSG_VIEW_WINDOW (obj));
}
ModestWindow *
-modest_msg_view_window_new_for_attachment (TnyMsg *msg,
+modest_msg_view_window_new_for_attachment (TnyMsg *msg,
+ TnyMsg *top_msg,
const gchar *modest_account_name,
const gchar *mailbox,
const gchar *msg_uid)
{
- return modest_msg_view_window_new_with_other_body (msg, NULL, modest_account_name, mailbox, msg_uid);
+ return modest_msg_view_window_new_with_other_body (msg, NULL, top_msg, modest_account_name, mailbox, msg_uid);
}
static void
return tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view));
}
+TnyMsg*
+modest_msg_view_window_get_top_message (ModestMsgViewWindow *self)
+{
+ ModestMsgViewWindowPrivate *priv;
+
+ g_return_val_if_fail (self, NULL);
+
+ priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(self);
+
+ if (priv->top_msg)
+ return g_object_ref (priv->top_msg);
+ else
+ return NULL;
+}
+
const gchar*
modest_msg_view_window_get_message_uid (ModestMsgViewWindow *self)
{
{
DecodeAsyncHelper *helper = (DecodeAsyncHelper *) user_data;
const gchar *content_type;
+ ModestMsgViewWindowPrivate *priv;
+
+ priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (helper->self);
if (cancelled || err) {
if (err) {
set_progress_hint (helper->self, FALSE);
content_type = tny_mime_part_get_content_type (mime_part);
- if (g_str_has_prefix (content_type, "message/rfc822")) {
+ if (content_type && g_str_has_prefix (content_type, "message/rfc822")) {
ModestWindowMgr *mgr;
ModestWindow *msg_win = NULL;
TnyMsg * msg;
fd = g_open (helper->file_path, O_RDONLY, 0644);
if (fd != -1) {
+ TnyMsg *top_msg;
file_stream = tny_fs_stream_new (fd);
mgr = modest_runtime_get_window_mgr ();
msg = tny_camel_msg_new ();
tny_camel_msg_parse (msg, file_stream);
- msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (msg), account, mailbox, helper->attachment_uid);
+
+ if (priv->top_msg)
+ top_msg = g_object_ref (priv->top_msg);
+ else
+ top_msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view));
+
+ msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (msg), top_msg,
+ account, mailbox, helper->attachment_uid);
+ if (top_msg) g_object_unref (top_msg);
modest_window_set_zoom (MODEST_WINDOW (msg_win),
modest_window_get_zoom (MODEST_WINDOW (helper->self)));
if (modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (helper->self)))
if (found) {
g_debug ("window for this body is already being created");
} else {
+ TnyMsg *top_msg;
/* it's not found, so create a new window for it */
modest_window_mgr_register_header (mgr, header, attachment_uid); /* register the uid before building the window */
const gchar *mailbox = modest_window_get_active_mailbox (MODEST_WINDOW (window));
if (!account)
account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ());
+
+ if (priv->top_msg)
+ top_msg = g_object_ref (priv->top_msg);
+ else
+ top_msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view));
- msg_win = modest_msg_view_window_new_with_other_body (TNY_MSG (current_msg), TNY_MIME_PART (mime_part),
+ msg_win = modest_msg_view_window_new_with_other_body (TNY_MSG (current_msg), TNY_MIME_PART (mime_part), top_msg,
account, mailbox, attachment_uid);
+
+ if (top_msg) g_object_unref (top_msg);
modest_window_set_zoom (MODEST_WINDOW (msg_win),
modest_window_get_zoom (MODEST_WINDOW (window)));
* thus, we don't do anything */
g_debug ("window for is already being created");
} else {
+ TnyMsg *top_msg;
/* it's not found, so create a new window for it */
modest_window_mgr_register_header (mgr, header, attachment_uid); /* register the uid before building the window */
gchar *account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (window)));
const gchar *mailbox = modest_window_get_active_mailbox (MODEST_WINDOW (window));
if (!account)
account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ());
- msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (mime_part), account,
- mailbox, attachment_uid);
+ if (priv->top_msg)
+ top_msg = g_object_ref (priv->top_msg);
+ else
+ top_msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view));
+ msg_win = modest_msg_view_window_new_for_attachment (
+ TNY_MSG (mime_part), top_msg, account,
+ mailbox, attachment_uid);
modest_window_set_zoom (MODEST_WINDOW (msg_win),
modest_window_get_zoom (MODEST_WINDOW (window)));
if (modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (window)))
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);
} 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));
+ /* Note that priv->msg_view is set to NULL when this window is
+ distroyed */
+ if (priv->msg_view && 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)
{
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 ();