[evolution/webkit: 88/100] Handle correctly image loading policy
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 88/100] Handle correctly image loading policy
- Date: Thu, 5 Jan 2012 16:21:30 +0000 (UTC)
commit 9c088ca303d3eefe6e78d7813bf791f2e49853d2
Author: Dan VrÃtil <dvratil redhat com>
Date: Mon Dec 19 19:18:10 2011 +0100
Handle correctly image loading policy
mail/e-mail-display.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
mail/e-mail-display.h | 2 +
mail/e-mail-reader.c | 4 +--
mail/em-format-html.c | 25 +++++++++-------------
mail/em-format-html.h | 2 +-
5 files changed, 68 insertions(+), 19 deletions(-)
---
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 0b3dc4c..33d5fde 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -134,6 +134,16 @@ static GtkActionEntry mailto_entries[] = {
};
static void
+formatter_image_loading_policy_changed_cb (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ EMailDisplay *display = user_data;
+
+ e_mail_display_load_images (display);
+}
+
+static void
mail_display_update_formatter_colors (EMailDisplay *display)
{
EMFormatHTMLColorType type;
@@ -543,9 +553,12 @@ static EWebView*
mail_display_setup_webview (EMailDisplay *display)
{
EWebView *web_view;
+ WebKitWebSettings *settings;
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
GError *error = NULL;
+ guint merge_id;
+ EMailImageLoadingPolicy policy;
web_view = E_WEB_VIEW (e_web_view_new ());
@@ -560,6 +573,12 @@ mail_display_setup_webview (EMailDisplay *display)
g_signal_connect (web_view, "notify::load-status",
G_CALLBACK (mail_display_webkit_finished), NULL);
+ settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view));
+ if (em_format_html_can_load_images (display->priv->formatter))
+ g_object_set (G_OBJECT (settings), "auto-load-images", TRUE, NULL);
+ else
+ g_object_set (G_OBJECT (settings), "auto-load-images", FALSE, NULL);
+
/* EWebView's action groups are added during its instance
* initialization function (like what we're in now), so it
* is safe to fetch them this early in construction. */
@@ -969,6 +988,9 @@ e_mail_display_set_formatter (EMailDisplay *display,
mail_display_update_formatter_colors (display);
+ g_signal_connect (formatter, "notify::image-loading-policy",
+ G_CALLBACK (formatter_image_loading_policy_changed_cb), display);
+
g_object_notify (G_OBJECT (display), "formatter");
}
@@ -1258,3 +1280,35 @@ e_mail_display_zoom_out (EMailDisplay *display)
gtk_container_foreach (GTK_CONTAINER (display),
(GtkCallback) webview_action, e_web_view_zoom_out);
}
+
+static void
+load_images (GtkWidget *widget,
+ gpointer user_data)
+{
+ if (GTK_IS_SCROLLED_WINDOW (widget)) {
+
+ WebKitWebSettings *settings;
+ WebKitWebView *web_view;
+
+ if (!E_IS_WEB_VIEW (gtk_bin_get_child (GTK_BIN (widget))))
+ return;
+
+ web_view = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (widget)));
+ settings = webkit_web_view_get_settings (web_view);
+ g_object_set (G_OBJECT (settings), "auto-load-images", TRUE, NULL);
+
+ } else if (E_IS_MAIL_DISPLAY (widget)) {
+
+ e_mail_display_load_images (E_MAIL_DISPLAY (widget));
+
+ }
+}
+
+void
+e_mail_display_load_images (EMailDisplay * display)
+{
+ g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+ gtk_container_foreach (GTK_CONTAINER (display->priv->box),
+ (GtkCallback) load_images, NULL);
+}
diff --git a/mail/e-mail-display.h b/mail/e-mail-display.h
index bb4fa8a..8d13d18 100644
--- a/mail/e-mail-display.h
+++ b/mail/e-mail-display.h
@@ -106,6 +106,8 @@ void e_mail_display_zoom_100 (EMailDisplay *display);
void e_mail_display_zoom_in (EMailDisplay *display);
void e_mail_display_zoom_out (EMailDisplay *display);
+void e_mail_display_load_images (EMailDisplay *display);
+
G_END_DECLS
#endif /* E_MAIL_DISPLAY_H */
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 0054a82..48f393b 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -667,12 +667,10 @@ action_mail_load_images_cb (GtkAction *action,
EMailReader *reader)
{
EMailDisplay *display;
- EMFormatHTML *formatter;
display = e_mail_reader_get_mail_display (reader);
- formatter = e_mail_display_get_formatter (display);
- em_format_html_load_images (formatter);
+ e_mail_display_load_images (display);
}
static void
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index bad3b6e..86758dc 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -1533,21 +1533,6 @@ em_format_html_get_type (void)
}
/*****************************************************************************/
-
-/* FIXME: This goes to EMailDisplay! */
-void
-em_format_html_load_images (EMFormatHTML *efh)
-{
- g_return_if_fail (EM_IS_FORMAT_HTML (efh));
-
- if (efh->priv->image_loading_policy == E_MAIL_IMAGE_LOADING_POLICY_ALWAYS)
- return;
-
- /* This will remain set while we're still
- * rendering the same message, then it wont be. */
- efh->priv->load_images_now = TRUE;
-}
-
void
em_format_html_get_color (EMFormatHTML *efh,
EMFormatHTMLColorType type,
@@ -2512,3 +2497,13 @@ efh_format_full_headers (EMFormatHTML *efh,
g_string_append (buffer, "</tr></table>");
}
+
+gboolean
+em_format_html_can_load_images (EMFormatHTML *efh)
+{
+ g_return_val_if_fail (EM_IS_FORMAT_HTML (efh), FALSE);
+
+ return ((efh->priv->image_loading_policy == E_MAIL_IMAGE_LOADING_POLICY_ALWAYS) ||
+ ((efh->priv->image_loading_policy == E_MAIL_IMAGE_LOADING_POLICY_SOMETIMES) &&
+ efh->priv->can_load_images));
+}
\ No newline at end of file
diff --git a/mail/em-format-html.h b/mail/em-format-html.h
index 9eda23d..363c44f 100644
--- a/mail/em-format-html.h
+++ b/mail/em-format-html.h
@@ -136,7 +136,6 @@ struct _EMFormatHTMLClass {
};
GType em_format_html_get_type (void);
-void em_format_html_load_images (EMFormatHTML *efh);
void em_format_html_get_color (EMFormatHTML *efh,
EMFormatHTMLColorType type,
GdkColor *color);
@@ -207,6 +206,7 @@ void em_format_html_format_header (EMFormat *emf,
guint32 flags,
const gchar *charset);
+gboolean em_format_html_can_load_images (EMFormatHTML *efh);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]