[Commits] [SCM] claws branch, litehtml, updated. 3.17.0-187-g254cb24

miras at claws-mail.org miras at claws-mail.org
Fri Nov 16 17:19:56 CET 2018


The branch, litehtml has been updated
       via  254cb24a2621a5b58057de9fb5746ca8af0732d4 (commit)
       via  790ccdd745f8ea81b2fe6207d305d25c752306ad (commit)
       via  d47c438e3cda8991dd388cd6534a8c7141289673 (commit)
       via  a0f4466a9c2c879f740f824abe95214dfb91a2b4 (commit)
       via  85f10a0e2c357bb2d67cd41891aa06a7af818b49 (commit)
       via  b040d141d67d2fccf9e0fe56443edbfa3244ba13 (commit)
       via  5b177bbac61e0c9daa64b64e5e6c45d7aec76121 (commit)
       via  4c1d17a798553d4d0ce2c6bb29a8baeff25dbe8a (commit)
       via  c27905f5dc36acedbbf022d26ed52719c9289241 (commit)
       via  e725cc0f9d8fc64f896977c786b016b56d15d087 (commit)
      from  ebeafcdc76f44cb141afeb488d193b60a82c4124 (commit)

Summary of changes:
 src/common/file-utils.c                         |   11 ++--
 src/common/ssl_certificate.c                    |   24 ++++++---
 src/plugins/litehtml_viewer/http.cpp            |    5 +-
 src/plugins/litehtml_viewer/lh_viewer.c         |   50 ++++++++++++++++---
 src/plugins/litehtml_viewer/lh_widget.cpp       |   34 ++++++++++---
 src/plugins/litehtml_viewer/lh_widget.h         |    1 +
 src/plugins/litehtml_viewer/lh_widget_wrapped.h |    3 ++
 src/plugins/rssyl/rssyl.c                       |    6 ++-
 src/plugins/rssyl/rssyl_add_item.c              |    2 +-
 src/plugins/rssyl/rssyl_deleted.c               |   61 ++++++++++++-----------
 src/plugins/rssyl/rssyl_deleted.h               |    7 +--
 src/plugins/rssyl/rssyl_parse_feed.c            |    6 ---
 src/plugins/rssyl/rssyl_update_feed.c           |    4 ++
 src/prefs_summaries.c                           |   28 +++++------
 src/prefs_summary_open.c                        |    6 +--
 15 files changed, 165 insertions(+), 83 deletions(-)


- Log -----------------------------------------------------------------
commit 254cb24a2621a5b58057de9fb5746ca8af0732d4
Merge: 790ccdd a0f4466
Author: Michael Rasmussen <mir at datanom.net>
Date:   Fri Nov 16 17:19:41 2018 +0100

    Merge branch 'master' of ssh+git://git.claws-mail.org/home/git/claws into litehtml


commit 790ccdd745f8ea81b2fe6207d305d25c752306ad
Author: Michael Rasmussen <mir at datanom.net>
Date:   Fri Nov 16 17:18:45 2018 +0100

    Use statusbar for notification. Begin print implementation
    
    Signed-off-by: Michael Rasmussen <mir at datanom.net>

diff --git a/src/plugins/litehtml_viewer/lh_viewer.c b/src/plugins/litehtml_viewer/lh_viewer.c
index c8912e2..f127917 100644
--- a/src/plugins/litehtml_viewer/lh_viewer.c
+++ b/src/plugins/litehtml_viewer/lh_viewer.c
@@ -24,6 +24,8 @@
 
 #include <codeconv.h>
 #include "common/utils.h"
+#include "mainwindow.h"
+#include "statusbar.h"
 #include "lh_viewer.h"
 
 static gchar *content_types[] = { "text/html", NULL };
@@ -44,20 +46,32 @@ static GtkWidget *lh_get_widget(MimeViewer *_viewer)
 }
 
 static gchar *get_utf8_string(const gchar *string) {
-        gchar *utf8;
+        gchar *utf8 = NULL;
         gsize length;
         GError *error = NULL;
+        gchar *locale = NULL;
 
 	if (!g_utf8_validate(string, -1, NULL)) {
 		const gchar *cur_locale = conv_get_current_locale();
-		utf8 = g_convert(string, -1, "utf-8", cur_locale, NULL, &length, &error);
-		if (error) {
-			debug_print("Failed convertion to current locale: %s", error->message);
-			g_error_free(error);
-			error = NULL;
+		gchar* split = g_strstr_len(cur_locale, -1, ".");
+		if (split) {
+		    locale = ++split;
+		} else {
+		    locale = (gchar *) cur_locale;
+		}
+		debug_print("Try converting to UTF-8 from %s\n", locale);
+		if (g_ascii_strcasecmp("utf-8", locale) != 0) {
+		    utf8 = g_convert(string, -1, "utf-8", locale, NULL, &length, &error);
+		    if (error) {
+			    debug_print("Failed convertion to current locale: %s\n", error->message);
+			    g_clear_error(&error);
+			}
+	    }
+	    if (!utf8) {
+	        debug_print("Use iso-8859-1 as last resort\n");
 			utf8 = g_convert(string, -1, "utf-8", "iso-8859-1", NULL, &length, &error);
 			if (error) {
-				debug_print("Charset detection failed");
+				debug_print("Charset detection failed. Use text as is\n");
 				utf8 = g_strdup(string);
 				g_clear_error(&error);
 			}
@@ -121,6 +135,14 @@ static void lh_destroy_viewer(MimeViewer *_viewer)
 //	lh_widget_destroy(viewer->widget);
 }
 
+static void lh_print_viewer (MimeViewer *_viewer)
+{
+    debug_print("LH: print_viewer\n");
+    
+    LHViewer* viewer = (LHViewer *) _viewer;
+    lh_widget_print(viewer->widget);    
+}
+
 /***************************************************************/
 MimeViewer *lh_viewer_create()
 {
@@ -135,6 +157,8 @@ MimeViewer *lh_viewer_create()
 
 	viewer->mimeviewer.clear_viewer = lh_clear_viewer;
 	viewer->mimeviewer.destroy_viewer = lh_destroy_viewer;
+	
+	viewer->mimeviewer.print = lh_print_viewer;
 
 	viewer->vbox = gtk_vbox_new(FALSE, 0);
 
@@ -147,3 +171,15 @@ MimeViewer *lh_viewer_create()
 	return (MimeViewer *)viewer;
 }
 
+void lh_widget_statusbar_push(gchar* msg)
+{
+	MainWindow *mainwin = mainwindow_get_mainwindow();
+	STATUSBAR_PUSH(mainwin, msg);
+        g_free(msg);
+}
+
+void lh_widget_statusbar_pop()
+{
+        MainWindow *mainwin = mainwindow_get_mainwindow();
+        STATUSBAR_POP(mainwin);
+}
diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
index ec96a16..a4528c0 100644
--- a/src/plugins/litehtml_viewer/lh_widget.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -149,12 +149,19 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
 	GdkPixbuf *pixbuf = NULL;
 
 	g_log(NULL, G_LOG_LEVEL_MESSAGE, "Loading... %s", url);
-
+        lh_widget_statusbar_push(g_strconcat("Loading ", url, " ...", NULL));
+	
 	http http_loader;
 	GInputStream *image = http_loader.load_url(url, &error);
     
-	if (!image) return NULL;
-	
+	if (error || !image) {
+	    if (error) {
+		g_log(NULL, G_LOG_LEVEL_WARNING, "lh_widget::get_image: Could not create pixbuf %s", error->message);
+		g_clear_error(&error);
+	    }
+	    goto statusbar_pop;
+	}
+
 	pixbuf = gdk_pixbuf_new_from_stream(image, NULL, &error);
 	if (error) {
 	    g_log(NULL, G_LOG_LEVEL_WARNING, "lh_widget::get_image: Could not create pixbuf %s", error->message);
@@ -167,18 +174,23 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
 /*	if (redraw_on_ready) {
 		redraw();
 	}*/
+
+statusbar_pop:
+	lh_widget_statusbar_pop();
 	
 	return pixbuf;
 }
 
 void lh_widget::open_html(const gchar *contents)
 {
+	lh_widget_statusbar_push(g_strconcat("Loading HTML part", " ...", NULL));
 	m_html = litehtml::document::createFromString(contents, this, &m_context);
 	m_rendered_width = 0;
 	if (m_html != NULL) {
 		g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget::open_html created document");
 		redraw();
 	}
+	lh_widget_statusbar_pop();
 }
 
 void lh_widget::draw(cairo_t *cr)
@@ -281,7 +293,7 @@ void lh_widget::clear()
 
 void lh_widget::set_cursor(const litehtml::tchar_t* cursor)
 {
-    g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget set_cursor %s:%s", m_cursor, cursor);
+    //g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget set_cursor %s:%s", m_cursor, cursor);
     if (cursor)
     {
 	if (m_cursor != cursor)
@@ -294,7 +306,7 @@ void lh_widget::set_cursor(const litehtml::tchar_t* cursor)
 
 void lh_widget::update_cursor()
 {
-    g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget update_cursor %s", m_cursor);
+    //g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget update_cursor %s", m_cursor);
     GdkCursorType cursType = GDK_ARROW;
     if(m_cursor == _t("pointer"))
     {
@@ -309,6 +321,12 @@ void lh_widget::update_cursor()
     }
 }
 
+void lh_widget::print()
+{
+    g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget print");
+    gtk_widget_realize(GTK_WIDGET(m_drawing_area));
+}
+
 static gboolean expose_event_cb(GtkWidget *widget, GdkEvent *event,
 		gpointer user_data)
 {
@@ -358,7 +376,7 @@ static gboolean motion_notify_event(GtkWidget *widget, GdkEventButton *event,
     litehtml::position::vector redraw_boxes;
     lh_widget *w = (lh_widget *)user_data;
     
-    g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget on_motion_notify_event");
+    //g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget on_motion_notify_event");
 
     if(w->m_html)
     {    
@@ -440,4 +458,8 @@ void lh_widget_destroy(lh_widget_wrapped *w)
 	delete w;
 }
 
+void lh_widget_print(lh_widget_wrapped *w) {
+	w->print();
+}
+
 } /* extern "C" */
diff --git a/src/plugins/litehtml_viewer/lh_widget.h b/src/plugins/litehtml_viewer/lh_widget.h
index 2f4eb11..ed56f7d 100644
--- a/src/plugins/litehtml_viewer/lh_widget.h
+++ b/src/plugins/litehtml_viewer/lh_widget.h
@@ -29,6 +29,7 @@ class lh_widget : public container_linux
 		void open_html(const gchar *contents);
 		void clear();
 		void update_cursor();
+		void print();
 
 		litehtml::document::ptr m_html;
 		litehtml::tstring m_clicked_url;
diff --git a/src/plugins/litehtml_viewer/lh_widget_wrapped.h b/src/plugins/litehtml_viewer/lh_widget_wrapped.h
index 521c7f4..64085fa 100644
--- a/src/plugins/litehtml_viewer/lh_widget_wrapped.h
+++ b/src/plugins/litehtml_viewer/lh_widget_wrapped.h
@@ -12,6 +12,9 @@ GtkWidget *lh_widget_get_widget(lh_widget_wrapped *w);
 void lh_widget_open_html(lh_widget_wrapped *w, const gchar *path);
 void lh_widget_clear(lh_widget_wrapped *w);
 void lh_widget_destroy(lh_widget_wrapped *w);
+void lh_widget_statusbar_push(gchar* msg);
+void lh_widget_statusbar_pop();
+void lh_widget_print(lh_widget_wrapped *w);
 
 #ifdef __cplusplus
 } /* extern "C" */

commit d47c438e3cda8991dd388cd6534a8c7141289673
Author: Michael Rasmussen <mir at datanom.net>
Date:   Fri Nov 16 17:13:05 2018 +0100

    Proper fix for memory leak
    
    Signed-off-by: Michael Rasmussen <mir at datanom.net>

diff --git a/src/plugins/litehtml_viewer/http.cpp b/src/plugins/litehtml_viewer/http.cpp
index 68af736..92023be 100644
--- a/src/plugins/litehtml_viewer/http.cpp
+++ b/src/plugins/litehtml_viewer/http.cpp
@@ -80,10 +80,9 @@ GInputStream *http::load_url(const gchar *url, GError **error)
 	if (res != CURLE_OK) {
 	    _error = g_error_new_literal(G_FILE_ERROR, res, curl_easy_strerror(res));
 	} else {
-	    void *bytes = g_memdup(data.memory, data.size);
+	    g_log(NULL, G_LOG_LEVEL_MESSAGE, "Image size: %d", data.size);
+	    stream = g_memory_input_stream_new_from_data(g_memdup(data.memory, data.size), data.size, http::destroy_giostream);
 	    g_free(data.memory);
-	    stream = g_memory_input_stream_new_from_data(bytes, data.size, http::destroy_giostream);
-	    g_free(bytes);
 	}
     }
 

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list