X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-msg-view-window.c;h=acf889c8e74a1795cfba0d86281e859289b2914b;hp=c6c39931c4df4c643a6f355ad7d4b9363ea7a10d;hb=57cedf59b21a6e53f87a7ad79b9d5c25b62f5db1;hpb=987916446f991f8bcbdc1a2b3694240f6ac1d760 diff --git a/src/hildon2/modest-msg-view-window.c b/src/hildon2/modest-msg-view-window.c index c6c3993..acf889c 100644 --- a/src/hildon2/modest-msg-view-window.c +++ b/src/hildon2/modest-msg-view-window.c @@ -524,22 +524,8 @@ init_window (ModestMsgViewWindow *obj) priv->msg_view = GTK_WIDGET (tny_platform_factory_new_msg_view (modest_tny_platform_factory_get_instance ())); modest_msg_view_set_shadow_type (MODEST_MSG_VIEW (priv->msg_view), GTK_SHADOW_NONE); main_vbox = gtk_vbox_new (FALSE, 6); -#ifdef MODEST_TOOLKIT_HILDON2 priv->main_scroll = hildon_pannable_area_new (); gtk_container_add (GTK_CONTAINER (priv->main_scroll), priv->msg_view); -#else -#ifdef MODEST_USE_MOZEMBED - priv->main_scroll = priv->msg_view; - gtk_widget_set_size_request (priv->msg_view, -1, 1600); -#else - priv->main_scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (priv->main_scroll), priv->msg_view); -#endif - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->main_scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->main_scroll), GTK_SHADOW_NONE); - modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->main_scroll), TRUE); - -#endif gtk_box_pack_start (GTK_BOX(main_vbox), priv->main_scroll, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER(obj), main_vbox); @@ -2435,6 +2421,11 @@ modest_msg_view_window_get_attachments (ModestMsgViewWindow *win) return selected_attachments; } +typedef struct { + ModestMsgViewWindow *self; + gchar *file_path; +} DecodeAsyncHelper; + static void on_decode_to_stream_async_handler (TnyMimePart *mime_part, gboolean cancelled, @@ -2442,7 +2433,11 @@ on_decode_to_stream_async_handler (TnyMimePart *mime_part, GError *err, gpointer user_data) { - gchar *filepath = (gchar *) user_data; + DecodeAsyncHelper *helper = (DecodeAsyncHelper *) user_data; + + /* It could happen that the window was closed */ + if (GTK_WIDGET_VISIBLE (helper->self)) + set_progress_hint (helper->self, FALSE); if (cancelled || err) { if (err) { @@ -2454,14 +2449,16 @@ on_decode_to_stream_async_handler (TnyMimePart *mime_part, } /* make the file read-only */ - g_chmod(filepath, 0444); + g_chmod(helper->file_path, 0444); /* Activate the file */ - modest_platform_activate_file (filepath, tny_mime_part_get_content_type (mime_part)); + modest_platform_activate_file (helper->file_path, tny_mime_part_get_content_type (mime_part)); free: /* Frees */ - g_free (filepath); + g_object_unref (helper->self); + g_free (helper->file_path); + g_slice_free (DecodeAsyncHelper, helper); } void @@ -2482,7 +2479,7 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, attachments = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view)); attachment_index = modest_list_index (attachments, (GObject *) mime_part); g_object_unref (attachments); - + if (msg_uid && attachment_index >= 0) { attachment_uid = g_strdup_printf ("%s/%d", msg_uid, attachment_index); } @@ -2522,10 +2519,19 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, &filepath); if (temp_stream != NULL) { - tny_mime_part_decode_to_stream_async (mime_part, TNY_STREAM (temp_stream), - on_decode_to_stream_async_handler, + DecodeAsyncHelper *helper; + + /* Activate progress hint */ + set_progress_hint (window, TRUE); + + helper = g_slice_new0 (DecodeAsyncHelper); + helper->self = g_object_ref (window); + helper->file_path = g_strdup (filepath); + + tny_mime_part_decode_to_stream_async (mime_part, TNY_STREAM (temp_stream), + on_decode_to_stream_async_handler, NULL, - g_strdup (filepath)); + helper); g_object_unref (temp_stream); /* NOTE: files in the temporary area will be automatically * cleaned after some time if they are no longer in use */ @@ -3236,6 +3242,13 @@ setup_menu (ModestMsgViewWindow *self) modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_viewer_addtocontacts"), NULL, APP_MENU_CALLBACK (modest_ui_actions_add_to_contacts), MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_add_to_contacts)); + + modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mail_bd_external_images"), NULL, + APP_MENU_CALLBACK (modest_ui_actions_on_fetch_images), + MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_fetch_images)); + modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_ti_message_properties"), NULL, + APP_MENU_CALLBACK (modest_ui_actions_on_details), + MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_details)); } void @@ -3319,3 +3332,41 @@ _modest_msg_view_window_map_event (GtkWidget *widget, return FALSE; } + +void +modest_msg_view_window_fetch_images (ModestMsgViewWindow *self) +{ + ModestMsgViewWindowPrivate *priv; + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); + + modest_msg_view_request_fetch_images (MODEST_MSG_VIEW (priv->msg_view)); +} + +gboolean +modest_msg_view_window_has_blocked_external_images (ModestMsgViewWindow *self) +{ + ModestMsgViewWindowPrivate *priv; + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); + + g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self), FALSE); + + return modest_msg_view_has_blocked_external_images (MODEST_MSG_VIEW (priv->msg_view)); +} + +void +modest_msg_view_window_reload (ModestMsgViewWindow *self) +{ + ModestMsgViewWindowPrivate *priv; + TnyHeader *header; + + g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self)); + + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); + header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (self)); + + if (!message_reader (self, priv, header, priv->row_reference)) { + g_warning ("Shouldn't happen, trying to reload a message failed"); + } + + g_object_unref (header); +}