talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 98b4e701430e6767bae77a7d23f5b0903959aaf8
parent 37bf908cb79995f438dadd4a771369a90c34261f
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Fri,  8 Feb 2019 20:05:06 +0100

Add image_cache_size pref to Litehtml

Diffstat:
Msrc/plugins/litehtml_viewer/lh_prefs.c | 26++++++++++++++++++++++++++
Msrc/plugins/litehtml_viewer/lh_prefs.h | 1+
Msrc/plugins/litehtml_viewer/lh_widget.cpp | 1+
3 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/plugins/litehtml_viewer/lh_prefs.c b/src/plugins/litehtml_viewer/lh_prefs.c @@ -43,12 +43,15 @@ LHPrefs lh_prefs; struct _LHPrefsPage { PrefsPage page; GtkWidget *enable_remote_content; + GtkWidget *image_cache_size; }; typedef struct _LHPrefsPage LHPrefsPage; static PrefParam param[] = { { "enable_remote_content", "FALSE", &lh_prefs.enable_remote_content, P_BOOL, NULL, NULL, NULL }, + { "image_cache_size", "20", &lh_prefs.image_cache_size, P_INT, + NULL, NULL, NULL }, { NULL, NULL, NULL, 0, NULL, NULL, NULL } }; @@ -91,9 +94,12 @@ static void create_lh_prefs_page(PrefsPage *page, GtkWindow *window, LHPrefsPage *prefs_page = (LHPrefsPage *)page; GtkWidget *vbox; GtkWidget *vbox_remote; + GtkWidget *hbox; GtkWidget *frame; GtkWidget *label; GtkWidget *enable_remote_content; + GtkWidget *image_cache_size; + GtkObject *adj; vbox = gtk_vbox_new(FALSE, 3); gtk_container_set_border_width(GTK_CONTAINER(vbox), VBOX_BORDER); @@ -115,7 +121,25 @@ static void create_lh_prefs_page(PrefsPage *page, GtkWindow *window, gtk_box_pack_start(GTK_BOX(vbox_remote), enable_remote_content, FALSE, FALSE, 0); gtk_widget_show_all(vbox_remote); + /* Image cache size */ + hbox = gtk_hbox_new(FALSE, 8); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new(_("Size of image cache in megabytes")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + + adj = gtk_adjustment_new(0, 0, 99999, 1, 10, 0); + image_cache_size = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0); + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(image_cache_size), TRUE); + gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(image_cache_size), FALSE); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(image_cache_size), + lh_prefs.image_cache_size); + gtk_box_pack_start(GTK_BOX(hbox), image_cache_size, FALSE, FALSE, 0); + + gtk_widget_show_all(hbox); + prefs_page->enable_remote_content = enable_remote_content; + prefs_page->image_cache_size = image_cache_size; prefs_page->page.widget = vbox; } @@ -129,6 +153,8 @@ static void save_lh_prefs_page(PrefsPage *page) lh_prefs.enable_remote_content = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(prefs_page->enable_remote_content)); + lh_prefs.image_cache_size = gtk_spin_button_get_value_as_int( + GTK_SPIN_BUTTON(prefs_page->image_cache_size)); save_prefs(); } diff --git a/src/plugins/litehtml_viewer/lh_prefs.h b/src/plugins/litehtml_viewer/lh_prefs.h @@ -29,6 +29,7 @@ typedef struct _LHPrefs LHPrefs; struct _LHPrefs { gboolean enable_remote_content; + gint image_cache_size; }; LHPrefs *lh_prefs_get(void); diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp @@ -217,6 +217,7 @@ statusbar_pop: void lh_widget::open_html(const gchar *contents) { + clear_images(lh_prefs_get()->image_cache_size * 1024 * 1000); lh_widget_statusbar_push("Loading HTML part ..."); m_html = litehtml::document::createFromString(contents, this, &m_context); m_rendered_width = 0;