diff options
author | Dan Vrátil <dvratil@redhat.com> | 2012-03-29 00:38:11 +0800 |
---|---|---|
committer | Dan Vrátil <dvratil@redhat.com> | 2012-03-29 00:38:25 +0800 |
commit | 6d2c382788a4042d53f49a080acd11b499aa52f6 (patch) | |
tree | 3834f0836340918ba17594a603ba61c13b9929a0 /modules/mail | |
parent | 6bd1c6833a2c51898ac45865767dd01ba66a95c5 (diff) | |
download | gsoc2013-evolution-6d2c382788a4042d53f49a080acd11b499aa52f6.tar gsoc2013-evolution-6d2c382788a4042d53f49a080acd11b499aa52f6.tar.gz gsoc2013-evolution-6d2c382788a4042d53f49a080acd11b499aa52f6.tar.bz2 gsoc2013-evolution-6d2c382788a4042d53f49a080acd11b499aa52f6.tar.lz gsoc2013-evolution-6d2c382788a4042d53f49a080acd11b499aa52f6.tar.xz gsoc2013-evolution-6d2c382788a4042d53f49a080acd11b499aa52f6.tar.zst gsoc2013-evolution-6d2c382788a4042d53f49a080acd11b499aa52f6.zip |
WebKit port - port formatter and mail module
Diffstat (limited to 'modules/mail')
-rw-r--r-- | modules/mail/e-mail-config-format-html.c | 5 | ||||
-rw-r--r-- | modules/mail/e-mail-config-web-view.c | 6 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-backend.c | 57 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-content.c | 9 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 116 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-private.c | 100 | ||||
-rw-r--r-- | modules/mail/em-mailer-prefs.c | 6 |
7 files changed, 142 insertions, 157 deletions
diff --git a/modules/mail/e-mail-config-format-html.c b/modules/mail/e-mail-config-format-html.c index 31ca88b744..dad5f9a518 100644 --- a/modules/mail/e-mail-config-format-html.c +++ b/modules/mail/e-mail-config-format-html.c @@ -76,6 +76,11 @@ mail_config_format_html_constructed (GObject *object) extensible, "show-real-date", G_BINDING_SYNC_CREATE); + g_object_bind_property ( + shell_settings, "mail-show-animated-images", + extensible, "animate-images", + G_BINDING_SYNC_CREATE); + /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (parent_class)->constructed (object); } diff --git a/modules/mail/e-mail-config-web-view.c b/modules/mail/e-mail-config-web-view.c index 80f3f65c0f..813256efd1 100644 --- a/modules/mail/e-mail-config-web-view.c +++ b/modules/mail/e-mail-config-web-view.c @@ -151,12 +151,6 @@ mail_config_web_view_realize (GtkWidget *widget, { g_object_bind_property ( extension->shell_settings, - "mail-show-animated-images", - widget, "animate", - G_BINDING_SYNC_CREATE); - - g_object_bind_property ( - extension->shell_settings, "composer-inline-spelling", widget, "inline-spelling", G_BINDING_SYNC_CREATE); diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 25902f34df..a30c0240de 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -835,37 +835,70 @@ e_mail_labels_get_filter_options (void) return g_slist_reverse (list); } +static void +message_parsed_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + EMFormatHTML *formatter = EM_FORMAT_HTML (source_object); + GObject *preview = user_data; + EMailDisplay *display; + + display = g_object_get_data (preview, "mbox-imp-display"); + e_mail_display_set_formatter (display, formatter); + e_mail_display_load (display, EM_FORMAT (formatter)->uri_base); +} + /* utility functions for mbox importer */ static void mbox_create_preview_cb (GObject *preview, GtkWidget **preview_widget) { - EMFormatHTMLDisplay *format; - EWebView *web_view; + EMailDisplay *display; g_return_if_fail (preview != NULL); g_return_if_fail (preview_widget != NULL); - format = em_format_html_display_new (); - g_object_set_data_full ( - preview, "mbox-imp-formatter", format, g_object_unref); - web_view = em_format_html_get_web_view (EM_FORMAT_HTML (format)); + display = g_object_new (E_TYPE_MAIL_DISPLAY, NULL); + g_object_set_data_full (preview, "mbox-imp-display", + g_object_ref (display), g_object_unref); - *preview_widget = GTK_WIDGET (web_view); + *preview_widget = GTK_WIDGET (display); } static void mbox_fill_preview_cb (GObject *preview, CamelMimeMessage *msg) { - EMFormatHTMLDisplay *format; + EMailDisplay *display; + EMFormat *formatter; + GHashTable *formatters; + SoupSession *session; + gchar *mail_uri; g_return_if_fail (preview != NULL); g_return_if_fail (msg != NULL); - format = g_object_get_data (preview, "mbox-imp-formatter"); - g_return_if_fail (format != NULL); + display = g_object_get_data (preview, "mbox-imp-display"); + g_return_if_fail (display != NULL); + + session = webkit_get_default_session (); + formatters = g_object_get_data (G_OBJECT (session), "formatters"); + if (!formatters) { + formatters = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, NULL); + g_object_set_data (G_OBJECT (session), "formatters", formatters); + } + + mail_uri = em_format_build_mail_uri (NULL, msg->message_id, NULL, NULL); + + formatter = EM_FORMAT (em_format_html_display_new ()); + formatter->message_uid = g_strdup (msg->message_id); + formatter->uri_base = g_strdup (mail_uri); + + /* Don't free the mail_uri!! */ + g_hash_table_insert (formatters, mail_uri, formatter); - /* FIXME Not passing a GCancellable here. */ - em_format_format (EM_FORMAT (format), NULL, NULL, msg, NULL); + em_format_parse_async (formatter, msg, NULL, NULL, + message_parsed_cb, preview); } diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c index 5bb60e3784..1bf6d4e29a 100644 --- a/modules/mail/e-mail-shell-content.c +++ b/modules/mail/e-mail-shell-content.c @@ -307,8 +307,8 @@ mail_shell_content_get_backend (EMailReader *reader) return e_mail_reader_get_backend (reader); } -static EMFormatHTML * -mail_shell_content_get_formatter (EMailReader *reader) +static EMailDisplay * +mail_shell_content_get_mail_display (EMailReader *reader) { EMailShellContent *mail_shell_content; @@ -317,8 +317,7 @@ mail_shell_content_get_formatter (EMailReader *reader) /* Forward this to our internal EMailView, which * also implements the EMailReader interface. */ reader = E_MAIL_READER (mail_shell_content->priv->mail_view); - - return e_mail_reader_get_formatter (reader); + return e_mail_reader_get_mail_display (reader); } static gboolean @@ -464,7 +463,7 @@ e_mail_shell_content_reader_init (EMailReaderInterface *interface) { interface->get_action_group = mail_shell_content_get_action_group; interface->get_backend = mail_shell_content_get_backend; - interface->get_formatter = mail_shell_content_get_formatter; + interface->get_mail_display = mail_shell_content_get_mail_display; interface->get_hide_deleted = mail_shell_content_get_hide_deleted; interface->get_message_list = mail_shell_content_get_message_list; interface->get_popup_menu = mail_shell_content_get_popup_menu; diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index b39d22d13d..5487920c74 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -891,14 +891,16 @@ action_mail_smart_backward_cb (GtkAction *action, EMailShellContent *mail_shell_content; EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; - EMFormatHTML *formatter; EMailReader *reader; EMailView *mail_view; GtkWidget *message_list; GtkToggleAction *toggle_action; - EWebView *web_view; + GtkWidget *window; + GtkAdjustment *adj; + EMailDisplay *display; gboolean caret_mode; gboolean magic_spacebar; + gdouble value; /* This implements the so-called "Magic Backspace". */ @@ -914,7 +916,7 @@ action_mail_smart_backward_cb (GtkAction *action, folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); reader = E_MAIL_READER (mail_view); - formatter = e_mail_reader_get_formatter (reader); + display = e_mail_reader_get_mail_display (reader); message_list = e_mail_reader_get_message_list (reader); magic_spacebar = e_shell_settings_get_boolean ( @@ -923,32 +925,43 @@ action_mail_smart_backward_cb (GtkAction *action, toggle_action = GTK_TOGGLE_ACTION (ACTION (MAIL_CARET_MODE)); caret_mode = gtk_toggle_action_get_active (toggle_action); - web_view = em_format_html_get_web_view (formatter); - - if (e_web_view_scroll_backward (web_view)) + window = gtk_widget_get_parent (GTK_WIDGET (display)); + if (!GTK_IS_SCROLLED_WINDOW (window)) return; - if (caret_mode || !magic_spacebar) - return; + adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (window)); + value = gtk_adjustment_get_value (adj); + if (value == 0) { - /* XXX Are two separate calls really necessary? */ + if (caret_mode || !magic_spacebar) + return; - if (message_list_select ( - MESSAGE_LIST (message_list), - MESSAGE_LIST_SELECT_PREVIOUS, - 0, CAMEL_MESSAGE_SEEN)) - return; + /* XXX Are two separate calls really necessary? */ - if (message_list_select ( - MESSAGE_LIST (message_list), - MESSAGE_LIST_SELECT_PREVIOUS | - MESSAGE_LIST_SELECT_WRAP, 0, - CAMEL_MESSAGE_SEEN)) - return; + if (message_list_select ( + MESSAGE_LIST (message_list), + MESSAGE_LIST_SELECT_PREVIOUS, + 0, CAMEL_MESSAGE_SEEN)) + return; + + if (message_list_select ( + MESSAGE_LIST (message_list), + MESSAGE_LIST_SELECT_PREVIOUS | + MESSAGE_LIST_SELECT_WRAP, + 0, CAMEL_MESSAGE_SEEN)) + return; + + em_folder_tree_select_next_path (folder_tree, TRUE); - em_folder_tree_select_prev_path (folder_tree, TRUE); + gtk_widget_grab_focus (message_list); - gtk_widget_grab_focus (message_list); + } else { + + gtk_adjustment_set_value (adj, + value - gtk_adjustment_get_page_increment (adj)); + + return; + } } static void @@ -962,14 +975,17 @@ action_mail_smart_forward_cb (GtkAction *action, EMailShellContent *mail_shell_content; EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; - EMFormatHTML *formatter; EMailReader *reader; EMailView *mail_view; GtkWidget *message_list; + GtkWidget *window; + GtkAdjustment *adj; GtkToggleAction *toggle_action; - EWebView *web_view; + EMailDisplay *display; gboolean caret_mode; gboolean magic_spacebar; + gdouble value; + gdouble upper; /* This implements the so-called "Magic Spacebar". */ @@ -985,7 +1001,7 @@ action_mail_smart_forward_cb (GtkAction *action, folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); reader = E_MAIL_READER (mail_view); - formatter = e_mail_reader_get_formatter (reader); + display = e_mail_reader_get_mail_display (reader); message_list = e_mail_reader_get_message_list (reader); magic_spacebar = e_shell_settings_get_boolean ( @@ -994,32 +1010,44 @@ action_mail_smart_forward_cb (GtkAction *action, toggle_action = GTK_TOGGLE_ACTION (ACTION (MAIL_CARET_MODE)); caret_mode = gtk_toggle_action_get_active (toggle_action); - web_view = em_format_html_get_web_view (formatter); - - if (e_web_view_scroll_forward (web_view)) + window = gtk_widget_get_parent (GTK_WIDGET (display)); + if (!GTK_IS_SCROLLED_WINDOW (window)) return; - if (caret_mode || !magic_spacebar) - return; + adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (window)); + value = gtk_adjustment_get_value (adj); + upper = gtk_adjustment_get_upper (adj); + if (value + gtk_adjustment_get_page_size (adj) >= upper) { - /* XXX Are two separate calls really necessary? */ + if (caret_mode || !magic_spacebar) + return; - if (message_list_select ( - MESSAGE_LIST (message_list), - MESSAGE_LIST_SELECT_NEXT, - 0, CAMEL_MESSAGE_SEEN)) - return; + /* XXX Are two separate calls really necessary? */ - if (message_list_select ( - MESSAGE_LIST (message_list), - MESSAGE_LIST_SELECT_NEXT | - MESSAGE_LIST_SELECT_WRAP, - 0, CAMEL_MESSAGE_SEEN)) - return; + if (message_list_select ( + MESSAGE_LIST (message_list), + MESSAGE_LIST_SELECT_NEXT, + 0, CAMEL_MESSAGE_SEEN)) + return; + + if (message_list_select ( + MESSAGE_LIST (message_list), + MESSAGE_LIST_SELECT_NEXT | + MESSAGE_LIST_SELECT_WRAP, + 0, CAMEL_MESSAGE_SEEN)) + return; + + em_folder_tree_select_next_path (folder_tree, TRUE); - em_folder_tree_select_next_path (folder_tree, TRUE); + gtk_widget_grab_focus (message_list); - gtk_widget_grab_focus (message_list); + } else { + + gtk_adjustment_set_value (adj, + value + gtk_adjustment_get_page_increment (adj)); + + return; + } } static void diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 8838f1a1ae..9a58f9d2b7 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -331,11 +331,10 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view, const gchar *uri) { EMailShellContent *mail_shell_content; - EMFormatHTML *formatter; + EMailDisplay *display; EShellView *shell_view; EMailReader *reader; EMailView *mail_view; - EWebView *web_view; GtkMenu *menu; if (uri != NULL) @@ -345,10 +344,9 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view, mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); reader = E_MAIL_READER (mail_view); - formatter = e_mail_reader_get_formatter (reader); - web_view = em_format_html_get_web_view (formatter); + display = e_mail_reader_get_mail_display (reader); - if (e_web_view_get_cursor_image (web_view) != NULL) + if (e_web_view_get_cursor_image (E_WEB_VIEW (display)) != NULL) return FALSE; menu = e_mail_reader_get_popup_menu (reader); @@ -368,76 +366,19 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view, } static void -mail_shell_view_scroll_cb (EMailShellView *mail_shell_view, - GtkOrientation orientation, - GtkScrollType scroll_type, - gfloat position, - GtkHTML *html) -{ - EShell *shell; - EShellView *shell_view; - EShellWindow *shell_window; - EShellSettings *shell_settings; - EMailShellContent *mail_shell_content; - EMailReader *reader; - EMailView *mail_view; - EWebView *web_view; - GtkWidget *message_list; - gboolean magic_spacebar; - - web_view = E_WEB_VIEW (html); - - if (html->binding_handled || e_web_view_get_caret_mode (web_view)) - return; - - if (orientation != GTK_ORIENTATION_VERTICAL) - return; - - shell_view = E_SHELL_VIEW (mail_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - shell = e_shell_window_get_shell (shell_window); - shell_settings = e_shell_get_shell_settings (shell); - - magic_spacebar = e_shell_settings_get_boolean ( - shell_settings, "mail-magic-spacebar"); - - if (!magic_spacebar) - return; - - mail_shell_content = mail_shell_view->priv->mail_shell_content; - mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); - - reader = E_MAIL_READER (mail_view); - message_list = e_mail_reader_get_message_list (reader); - - if (scroll_type == GTK_SCROLL_PAGE_FORWARD) - message_list_select ( - MESSAGE_LIST (message_list), - MESSAGE_LIST_SELECT_NEXT, - 0, CAMEL_MESSAGE_SEEN); - else - message_list_select ( - MESSAGE_LIST (message_list), - MESSAGE_LIST_SELECT_PREVIOUS, - 0, CAMEL_MESSAGE_SEEN); -} - -static void mail_shell_view_reader_changed_cb (EMailShellView *mail_shell_view, EMailReader *reader) { GtkWidget *message_list; - EMFormatHTML *formatter; - EWebView *web_view; + EMailDisplay *display; EShellView *shell_view; EShellTaskbar *shell_taskbar; shell_view = E_SHELL_VIEW (mail_shell_view); shell_taskbar = e_shell_view_get_shell_taskbar (shell_view); - formatter = e_mail_reader_get_formatter (reader); + display = e_mail_reader_get_mail_display (reader); message_list = e_mail_reader_get_message_list (reader); - web_view = em_format_html_get_web_view (formatter); e_shell_view_update_actions (E_SHELL_VIEW (mail_shell_view)); e_mail_shell_view_update_sidebar (mail_shell_view); @@ -464,23 +405,17 @@ mail_shell_view_reader_changed_cb (EMailShellView *mail_shell_view, mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( - web_view, "key-press-event", + display, "key-press-event", G_CALLBACK (mail_shell_view_key_press_event_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( - web_view, "popup-event", + display, "popup-event", G_CALLBACK (mail_shell_view_popup_event_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( - web_view, "scroll", - G_CALLBACK (mail_shell_view_scroll_cb), - mail_shell_view, - G_CONNECT_AFTER | G_CONNECT_SWAPPED); - - g_signal_connect_object ( - web_view, "status-message", + display, "status-message", G_CALLBACK (e_shell_taskbar_set_message), shell_taskbar, G_CONNECT_SWAPPED); } @@ -634,7 +569,6 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) EShellTaskbar *shell_taskbar; EShellWindow *shell_window; EShellSearchbar *searchbar; - EMFormatHTML *formatter; EMFolderTree *folder_tree; EActionComboBox *combo_box; ERuleContext *context; @@ -647,7 +581,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) EMailSession *session; EMailReader *reader; EMailView *mail_view; - EWebView *web_view; + EMailDisplay *display; const gchar *source; guint merge_id; gint ii = 0; @@ -691,7 +625,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) combo_box = e_shell_searchbar_get_scope_combo_box (searchbar); reader = E_MAIL_READER (shell_content); - formatter = e_mail_reader_get_formatter (reader); + display = e_mail_reader_get_mail_display (reader); message_list = e_mail_reader_get_message_list (reader); em_folder_tree_set_selectable_widget (folder_tree, message_list); @@ -710,8 +644,6 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) G_CALLBACK (mail_shell_view_search_filter_changed_cb), mail_shell_view, G_CONNECT_SWAPPED); - web_view = em_format_html_get_web_view (formatter); - g_signal_connect_object ( folder_tree, "folder-selected", G_CALLBACK (mail_shell_view_folder_tree_selected_cb), @@ -784,23 +716,17 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( - web_view, "key-press-event", + display, "key-press-event", G_CALLBACK (mail_shell_view_key_press_event_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( - web_view, "popup-event", + display, "popup-event", G_CALLBACK (mail_shell_view_popup_event_cb), mail_shell_view, G_CONNECT_SWAPPED); g_signal_connect_object ( - web_view, "scroll", - G_CALLBACK (mail_shell_view_scroll_cb), - mail_shell_view, - G_CONNECT_AFTER | G_CONNECT_SWAPPED); - - g_signal_connect_object ( - web_view, "status-message", + display, "status-message", G_CALLBACK (e_shell_taskbar_set_message), shell_taskbar, G_CONNECT_SWAPPED); diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c index 3f5e371296..d81656f997 100644 --- a/modules/mail/em-mailer-prefs.c +++ b/modules/mail/em-mailer-prefs.c @@ -529,10 +529,10 @@ toggle_button_init (EMMailerPrefs *prefs, const gchar *key, GCallback toggled) { - gboolean bool; + gboolean v_bool; - bool = g_settings_get_boolean (prefs->settings, key); - gtk_toggle_button_set_active (toggle, not ? !bool : bool); + v_bool = g_settings_get_boolean (prefs->settings, key); + gtk_toggle_button_set_active (toggle, not ? !v_bool : v_bool); if (toggled) { g_object_set_data ((GObject *) toggle, "key", (gpointer) key); |