[Commits] [SCM] claws branch, litehtml, updated. 3.17.3-59-g5715da3

ticho at claws-mail.org ticho at claws-mail.org
Fri Jan 25 23:49:52 CET 2019


The branch, litehtml has been updated
       via  5715da3f64d1dafaeae55ea537d2ee3cf4aaf8a8 (commit)
      from  98f43b1f6806cba422527a71756161e016c4d0ae (commit)

Summary of changes:
 src/plugins/litehtml_viewer/http.cpp      |   12 +++++--
 src/plugins/litehtml_viewer/lh_widget.cpp |   52 ++++++++++++++---------------
 2 files changed, 35 insertions(+), 29 deletions(-)


- Log -----------------------------------------------------------------
commit 5715da3f64d1dafaeae55ea537d2ee3cf4aaf8a8
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Jan 25 23:49:32 2019 +0100

    Use debug_print() and g_warning() instead of g_log() in litehtml_viewer

diff --git a/src/plugins/litehtml_viewer/http.cpp b/src/plugins/litehtml_viewer/http.cpp
index 92023be..ad86191 100644
--- a/src/plugins/litehtml_viewer/http.cpp
+++ b/src/plugins/litehtml_viewer/http.cpp
@@ -1,6 +1,12 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <string.h>
 #include "http.h"
 
+#include "utils.h"
+
 struct Data {
   char *memory;
   size_t size;
@@ -30,7 +36,7 @@ size_t http::curl_write_data(char* ptr, size_t size, size_t nmemb, void* data_pt
     char *input = (char *) g_realloc(data->memory, data->size + realsize + 1);
     if(input == NULL) {
         /* out of memory! */
-        g_log(NULL, G_LOG_LEVEL_WARNING, "not enough memory (realloc returned NULL)");
+        g_warning("not enough memory (realloc returned NULL)");
         return 0;
     }
     
@@ -68,7 +74,7 @@ GInputStream *http::load_url(const gchar *url, GError **error)
 	if (g_file_get_contents(newurl ? newurl : url, &content, &len, &_error)) {
 	    stream = g_memory_input_stream_new_from_data(content, len, http::destroy_giostream);
 	} else {
-	    g_log(NULL, G_LOG_LEVEL_MESSAGE, "%s", _error->message);
+	    debug_print("Got error: %s\n", _error->message);
 	}
 	g_free(newurl);
     } else {
@@ -80,7 +86,7 @@ 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 {
-	    g_log(NULL, G_LOG_LEVEL_MESSAGE, "Image size: %d", data.size);
+	    debug_print("Image size: %d\n", 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);
 	}
diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
index 5e779fb..4a8551a 100644
--- a/src/plugins/litehtml_viewer/lh_widget.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -30,6 +30,8 @@
 #include <curl/curl.h>
 #include <gdk/gdk.h>
 
+#include "utils.h"
+
 #include "litehtml/litehtml.h"
 
 #include "lh_widget.h"
@@ -108,19 +110,19 @@ GtkWidget *lh_widget::get_widget() const
 
 void lh_widget::set_caption(const litehtml::tchar_t* caption)
 {
-	g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget set_caption");
+	debug_print("lh_widget set_caption\n");
 	return;
 }
 
 void lh_widget::set_base_url(const litehtml::tchar_t* base_url)
 {
-	g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget set_base_url");
+	debug_print("lh_widget set_base_url\n");
 	return;
 }
 
 void lh_widget::on_anchor_click(const litehtml::tchar_t* url, const litehtml::element::ptr& el)
 {
-	g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget on_anchor_click. url -> %s", url);
+	debug_print("lh_widget on_anchor_click. url -> %s\n", url);
 	m_clicked_url = url;
 	
 	return;
@@ -128,7 +130,7 @@ void lh_widget::on_anchor_click(const litehtml::tchar_t* url, const litehtml::el
 
 void lh_widget::import_css(litehtml::tstring& text, const litehtml::tstring& url, litehtml::tstring& baseurl)
 {
-	g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget import_css");
+	debug_print("lh_widget import_css\n");
 	baseurl = master_css;
 }
 
@@ -142,7 +144,7 @@ void lh_widget::get_client_rect(litehtml::position& client) const
 	client.x = 0;
 	client.y = 0;
 
-//	g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget::get_client_rect: %dx%d",
+//	debug_print("lh_widget::get_client_rect: %dx%d\n",
 //			client.width, client.height);
 }
 
@@ -151,7 +153,7 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
 	GError *error = NULL;
 	GdkPixbuf *pixbuf = NULL;
 
-	g_log(NULL, G_LOG_LEVEL_MESSAGE, "Loading... %s", url);
+	debug_print("Loading... %s\n", url);
 	gchar *msg = g_strdup_printf("Loading %s ...", url);
         lh_widget_statusbar_push(msg);
 	g_free(msg);
@@ -161,7 +163,7 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
     
 	if (error || !image) {
 	    if (error) {
-		g_log(NULL, G_LOG_LEVEL_WARNING, "lh_widget::get_image: Could not create pixbuf %s", error->message);
+		g_warning("lh_widget::get_image: Could not create pixbuf %s", error->message);
 		g_clear_error(&error);
 	    }
 	    goto statusbar_pop;
@@ -169,7 +171,7 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
 
 	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);
+	    g_warning("lh_widget::get_image: Could not create pixbuf %s", error->message);
 	    //g_object_unref(pixbuf);
 	    pixbuf = NULL;
 	    g_clear_error(&error);
@@ -192,7 +194,7 @@ void lh_widget::open_html(const gchar *contents)
 	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");
+		debug_print("lh_widget::open_html created document\n");
 		redraw();
 	}
 	lh_widget_statusbar_pop();
@@ -228,7 +230,7 @@ void lh_widget::redraw()
 	cairo_t *cr;
 
 	if (m_html == NULL) {
-		g_log(NULL, G_LOG_LEVEL_WARNING, "lh_widget::redraw: No document!");
+		g_warning("lh_widget::redraw: No document!");
 		return;
 	}
 
@@ -238,8 +240,7 @@ void lh_widget::redraw()
 
 	/* If the available width has changed, rerender the HTML content. */
 	if (m_rendered_width != width) {
-		g_log(NULL, G_LOG_LEVEL_MESSAGE,
-				"lh_widget::redraw: width changed: %d != %d",
+		debug_print("lh_widget::redraw: width changed: %d != %d\n",
 				m_rendered_width, width);
 
 		/* Update our internally stored width, mainly so that
@@ -250,8 +251,7 @@ void lh_widget::redraw()
 		/* Re-render HTML for this width. */
 		m_html->media_changed();
 		m_html->render(m_rendered_width);
-		g_log(NULL, G_LOG_LEVEL_MESSAGE, "render is %dx%d",
-				m_html->width(), m_html->height());
+		debug_print("render is %dx%d\n", m_html->width(), m_html->height());
 
 		/* Change drawing area's size to match what was rendered. */
 		gtk_widget_set_size_request(m_drawing_area,
@@ -263,7 +263,7 @@ void lh_widget::redraw()
 	/* Paint the rendered HTML. */
 	gdkwin = gtk_widget_get_window(m_drawing_area);
 	if (gdkwin == NULL) {
-		g_log(NULL, G_LOG_LEVEL_WARNING, "lh_widget::redraw: No GdkWindow to draw on!");
+		g_warning("lh_widget::redraw: No GdkWindow to draw on!");
 		return;
 	}
 	cr = gdk_cairo_create(GDK_DRAWABLE(gdkwin));
@@ -276,7 +276,7 @@ void lh_widget::paint_white()
 {
 	GdkWindow *gdkwin = gtk_widget_get_window(m_drawing_area);
 	if (gdkwin == NULL) {
-		g_log(NULL, G_LOG_LEVEL_WARNING, "lh_widget::clear: No GdkWindow to draw on!");
+		g_warning("lh_widget::clear: No GdkWindow to draw on!");
 		return;
 	}
 	cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gdkwin));
@@ -357,7 +357,7 @@ void lh_widget::update_cursor()
 
 void lh_widget::print()
 {
-    g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget print");
+    debug_print("lh_widget print\n");
     gtk_widget_realize(GTK_WIDGET(m_drawing_area));
 }
 
@@ -374,7 +374,7 @@ static void size_allocate_cb(GtkWidget *widget, GdkRectangle *allocation,
 {
 	lh_widget *w = (lh_widget *)user_data;
 
-	g_log(NULL, G_LOG_LEVEL_MESSAGE, "size_allocate_cb: %dx%d",
+	debug_print("size_allocate_cb: %dx%d\n",
 			allocation->width, allocation->height);
 
 	w->setHeight(allocation->height);
@@ -387,7 +387,7 @@ static gboolean button_press_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_button_press_event");
+    debug_print("lh_widget on_button_press_event\n");
 
     if(w->m_html)
     {    
@@ -395,7 +395,7 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
         {
             for(auto& pos : redraw_boxes)
             {
-		g_log(NULL, G_LOG_LEVEL_MESSAGE, "x: %d y:%d w: %d h: %d", pos.x, pos.y, pos.width, pos.height);
+		debug_print("x: %d y:%d w: %d h: %d\n", pos.x, pos.y, pos.width, pos.height);
                 gtk_widget_queue_draw_area(widget, pos.x, pos.y, pos.width, pos.height);
             }
         }
@@ -410,7 +410,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");
+    //debug_print("lh_widget on_motion_notify_event\n");
 
     if(w->m_html)
     {    
@@ -419,7 +419,7 @@ static gboolean motion_notify_event(GtkWidget *widget, GdkEventButton *event,
         {
             for (auto& pos : redraw_boxes)
             {
-		g_log(NULL, G_LOG_LEVEL_MESSAGE, "x: %d y:%d w: %d h: %d", pos.x, pos.y, pos.width, pos.height);
+		debug_print("x: %d y:%d w: %d h: %d\n", pos.x, pos.y, pos.width, pos.height);
                 gtk_widget_queue_draw_area(widget, pos.x, pos.y, pos.width, pos.height);
             }
         }
@@ -435,7 +435,7 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
     lh_widget *w = (lh_widget *)user_data;
     GError* error = NULL;
 
-	g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget on_button_release_event");
+	debug_print("lh_widget on_button_release_event\n");
 	
 	if(w->m_html)
 	{
@@ -444,19 +444,19 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
         {
             for (auto& pos : redraw_boxes)
             {
-		g_log(NULL, G_LOG_LEVEL_MESSAGE, "x: %d y:%d w: %d h: %d", pos.x, pos.y, pos.width, pos.height);
+		debug_print("x: %d y:%d w: %d h: %d\n", pos.x, pos.y, pos.width, pos.height);
                 gtk_widget_queue_draw_area(widget, pos.x, pos.y, pos.width, pos.height);
             }
         }
         
         if (!w->m_clicked_url.empty())
         {
-                g_log(NULL, G_LOG_LEVEL_MESSAGE, "Open in browser: %s", w->m_clicked_url.c_str());
+                debug_print("Open in browser: %s\n", w->m_clicked_url.c_str());
 		gtk_show_uri(gdk_screen_get_default(),
 			     w->m_clicked_url.c_str(),
 			     GDK_CURRENT_TIME, &error);
                 if (error) {
-                    g_log(NULL, G_LOG_LEVEL_WARNING, "Failed opening url(%s): %s", w->m_clicked_url, error->message);
+                    g_warning("Failed opening url(%s): %s", w->m_clicked_url, error->message);
                     g_clear_error(&error);
                 }
         }

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list