[Commits] [SCM] claws branch, litehtml, updated. 3.17.3-113-g5e45d75

ticho at claws-mail.org ticho at claws-mail.org
Fri Feb 8 20:10:35 CET 2019


The branch, litehtml has been updated
       via  5e45d75cdd95e744448fddb575d08050c668ed4a (commit)
       via  dcf9a231df4165baa013b093fbdabd24cf794ed7 (commit)
      from  8f77d1194e4d3226833c943e9a6d50080bf8111b (commit)

Summary of changes:
 src/plugins/litehtml_viewer/container_linux.cpp |    6 +++++-
 src/plugins/litehtml_viewer/container_linux.h   |    2 +-
 src/plugins/litehtml_viewer/lh_prefs.c          |   26 +++++++++++++++++++++++
 src/plugins/litehtml_viewer/lh_prefs.h          |    1 +
 src/plugins/litehtml_viewer/lh_widget.cpp       |    4 ++++
 5 files changed, 37 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit 5e45d75cdd95e744448fddb575d08050c668ed4a
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Feb 8 20:09:38 2019 +0100

    Show number of cleared Litehtml cache images on debug

diff --git a/src/plugins/litehtml_viewer/container_linux.cpp b/src/plugins/litehtml_viewer/container_linux.cpp
index e4d3c1d..0993f8d 100644
--- a/src/plugins/litehtml_viewer/container_linux.cpp
+++ b/src/plugins/litehtml_viewer/container_linux.cpp
@@ -834,9 +834,10 @@ void container_linux::clear_images()
 	m_images.clear();
 }
 
-void container_linux::clear_images(gint desired_size)
+gint container_linux::clear_images(gint desired_size)
 {
 	gint size = 0;
+	gint num = 0;
 
 	/* First, tally up size of all the stored GdkPixbufs and
 	 * deallocate those which make the total size be above
@@ -854,6 +855,7 @@ void container_linux::clear_images(gint desired_size)
 		if (size + cursize > desired_size) {
 			g_object_unref(img->second);
 			img->second = NULL;
+			num++;
 		} else {
 			size += cursize;
 		}
@@ -865,6 +867,8 @@ void container_linux::clear_images(gint desired_size)
 				return true;
 			return false;
 			});
+
+	return num;
 }
 
 const litehtml::tchar_t* container_linux::get_default_font_name() const
diff --git a/src/plugins/litehtml_viewer/container_linux.h b/src/plugins/litehtml_viewer/container_linux.h
index 8298437..c6cda8e 100644
--- a/src/plugins/litehtml_viewer/container_linux.h
+++ b/src/plugins/litehtml_viewer/container_linux.h
@@ -88,7 +88,7 @@ public:
 
 	/* Trim down images cache to less than desired_size [bytes],
 	 * starting from oldest stored. */
-	void								clear_images(gint desired_size);
+	gint								clear_images(gint desired_size);
 
 protected:
 	virtual void						draw_ellipse(cairo_t* cr, int x, int y, int width, int height, const litehtml::web_color& color, int line_width);
diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
index 3fcb359..61abf61 100644
--- a/src/plugins/litehtml_viewer/lh_widget.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -217,7 +217,10 @@ statusbar_pop:
 
 void lh_widget::open_html(const gchar *contents)
 {
-	clear_images(lh_prefs_get()->image_cache_size * 1024 * 1000);
+	gint num = clear_images(lh_prefs_get()->image_cache_size * 1024 * 1000);
+
+	debug_print("LH: cleared %d images from image cache\n", num);
+
 	lh_widget_statusbar_push("Loading HTML part ...");
 	m_html = litehtml::document::createFromString(contents, this, &m_context);
 	m_rendered_width = 0;

commit dcf9a231df4165baa013b093fbdabd24cf794ed7
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Feb 8 20:05:06 2019 +0100

    Add image_cache_size pref to Litehtml

diff --git a/src/plugins/litehtml_viewer/lh_prefs.c b/src/plugins/litehtml_viewer/lh_prefs.c
index fec2ff5..7dcc7aa 100644
--- 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
index 25dcbd2..d226fe6 100644
--- 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
index 152053d..3fcb359 100644
--- 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;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list