diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-display.c | 60 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 128 |
2 files changed, 6 insertions, 182 deletions
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index 46cf48a306..1793ae74cd 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -89,15 +89,6 @@ static const gchar *ui = " </popup>" "</ui>"; -static const gchar *image_ui = -"<ui>" -" <popup name='context'>" -" <placeholder name='custom-actions-2'>" -" <menuitem action='image-save'/>" -" </placeholder>" -" </popup>" -"</ui>"; - static GtkActionEntry mailto_entries[] = { { "add-to-address-book", @@ -138,16 +129,6 @@ static GtkActionEntry mailto_entries[] = { NULL } }; -static GtkActionEntry image_entries[] = { - - { "image-save", - GTK_STOCK_SAVE, - N_("Save _Image..."), - NULL, - N_("Save the image to a file"), - NULL /* Handled by EMailReader */ }, -}; - G_DEFINE_TYPE ( EMailDisplay, e_mail_display, @@ -1288,13 +1269,9 @@ static gboolean mail_display_button_press_event (GtkWidget *widget, GdkEventButton *event) { - WebKitHitTestResult *hit_test; - WebKitHitTestResultContext context; - gchar *image_src; - gboolean visible; - GtkAction *action; - GList *extensions, *iter; EWebView *web_view = E_WEB_VIEW (widget); + WebKitHitTestResult *hit_test; + GList *list, *link; if (event->button != 3) goto chainup; @@ -1302,29 +1279,10 @@ mail_display_button_press_event (GtkWidget *widget, hit_test = webkit_web_view_get_hit_test_result ( WEBKIT_WEB_VIEW (web_view), event); - g_object_get ( - G_OBJECT (hit_test), - "context", &context, - "image-uri", &image_src, - NULL); - - if ((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE)) { - visible = image_src && g_str_has_prefix (image_src, "cid:"); - if (!visible && image_src) - visible = mail_display_image_exists_in_cache (image_src); - - if (image_src != NULL) - g_free (image_src); - - action = e_web_view_get_action (web_view, "image-save"); - if (action != NULL) - gtk_action_set_visible (action, visible); - } - - extensions = e_extensible_list_extensions ( + list = e_extensible_list_extensions ( E_EXTENSIBLE (web_view), E_TYPE_EXTENSION); - for (iter = extensions; iter; iter = g_list_next (iter)) { - EExtension *extension = iter->data; + for (link = list; link != NULL; link = g_list_next (link)) { + EExtension *extension = link->data; if (!E_IS_MAIL_DISPLAY_POPUP_EXTENSION (extension)) continue; @@ -1332,7 +1290,7 @@ mail_display_button_press_event (GtkWidget *widget, e_mail_display_popup_extension_update_actions ( E_MAIL_DISPLAY_POPUP_EXTENSION (extension), hit_test); } - g_list_free (extensions); + g_list_free (list); g_object_unref (hit_test); @@ -1698,12 +1656,6 @@ e_mail_display_init (EMailDisplay *display) ui_manager = e_web_view_get_ui_manager (E_WEB_VIEW (display)); gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL); - actions = e_web_view_get_action_group (E_WEB_VIEW (display), "image"); - gtk_action_group_add_actions ( - actions, image_entries, - G_N_ELEMENTS (image_entries), display); - gtk_ui_manager_add_ui_from_string (ui_manager, image_ui, -1, NULL); - e_web_view_install_request_handler ( E_WEB_VIEW (display), E_TYPE_MAIL_REQUEST); e_web_view_install_request_handler ( diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 5122aa2247..ecf07c50f9 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -271,128 +271,6 @@ exit: } static void -attachment_load_finish (EAttachment *attachment, - GAsyncResult *result, - GFile *file) -{ - EShell *shell; - GtkWindow *parent; - - e_attachment_load_finish (attachment, result, NULL); - - shell = e_shell_get_default (); - parent = e_shell_get_active_window (shell); - - e_attachment_save_async ( - attachment, file, (GAsyncReadyCallback) - e_attachment_save_handle_error, parent); - - g_object_unref (file); -} - -static void -action_mail_image_save_cb (GtkAction *action, - EMailReader *reader) -{ - EShell *shell; - EMailBackend *backend; - EMailDisplay *display; - EWebView *web_view; - EMailPartList *parts; - const gchar *image_src; - CamelMimePart *part; - CamelMimeMessage *message; - EAttachment *attachment; - GFile *file; - - backend = e_mail_reader_get_backend (reader); - shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend)); - - display = e_mail_reader_get_mail_display (reader); - if (display == NULL) - return; - - web_view = E_WEB_VIEW (display); - image_src = e_web_view_get_cursor_image_src (web_view); - if (image_src == NULL) - return; - - parts = e_mail_display_get_part_list (display); - g_return_if_fail (parts != NULL); - - message = e_mail_part_list_get_message (parts); - g_return_if_fail (message != NULL); - - if (g_str_has_prefix (image_src, "cid:")) { - part = camel_mime_message_get_part_by_content_id ( - message, image_src + 4); - g_return_if_fail (part != NULL); - - g_object_ref (part); - } else { - CamelStream *image_stream; - CamelDataWrapper *dw; - CamelDataCache *cache; - const gchar *filename; - const gchar *user_cache_dir; - - /* Open cache and find the file there */ - user_cache_dir = e_get_user_cache_dir (); - cache = camel_data_cache_new (user_cache_dir, NULL); - image_stream = camel_data_cache_get ( - cache, "http", image_src, NULL); - if (image_stream == NULL) { - g_object_unref (cache); - return; - } - - filename = strrchr (image_src, '/'); - if (filename != NULL) { - if (strchr (filename, '?') == NULL) - filename++; - else - filename = NULL; - } - - part = camel_mime_part_new (); - if (filename != NULL) - camel_mime_part_set_filename (part, filename); - - dw = camel_data_wrapper_new (); - camel_data_wrapper_set_mime_type ( - dw, "application/octet-stream"); - camel_data_wrapper_construct_from_stream_sync ( - dw, image_stream, NULL, NULL); - camel_medium_set_content (CAMEL_MEDIUM (part), dw); - g_object_unref (dw); - - camel_mime_part_set_encoding ( - part, CAMEL_TRANSFER_ENCODING_BASE64); - - g_object_unref (image_stream); - g_object_unref (cache); - } - - file = e_shell_run_save_dialog ( - shell, _("Save Image"), - camel_mime_part_get_filename (part), - NULL, NULL, NULL); - if (file == NULL) { - g_object_unref (part); - return; - } - - attachment = e_attachment_new (); - e_attachment_set_mime_part (attachment, part); - - e_attachment_load_async ( - attachment, (GAsyncReadyCallback) - attachment_load_finish, file); - - g_object_unref (part); -} - -static void action_mail_charset_cb (GtkRadioAction *action, GtkRadioAction *current, EMailReader *reader) @@ -3957,12 +3835,6 @@ e_mail_reader_init (EMailReader *reader, action, "activate", G_CALLBACK (action_search_folder_sender_cb), reader); - action_name = "image-save"; - action = e_mail_display_get_action (display, action_name); - g_signal_connect ( - action, "activate", - G_CALLBACK (action_mail_image_save_cb), reader); - #ifndef G_OS_WIN32 /* Lockdown integration. */ |