[Commits] [SCM] claws branch, litehtml, updated. 3.17.0-164-gf19d70a

miras at claws-mail.org miras at claws-mail.org
Fri Nov 9 17:00:58 CET 2018


The branch, litehtml has been updated
       via  f19d70af7292805b4578e9fc7d8d847f81d384fe (commit)
      from  5427888c812e7b2df34a8f8c7a225c1e78ef8c16 (commit)

Summary of changes:
 src/plugins/litehtml_viewer/lh_widget.cpp |   44 +++++++++++++++++++++++------
 src/plugins/litehtml_viewer/lh_widget.h   |    3 +-
 2 files changed, 38 insertions(+), 9 deletions(-)


- Log -----------------------------------------------------------------
commit f19d70af7292805b4578e9fc7d8d847f81d384fe
Author: Michael Rasmussen <mir at datanom.net>
Date:   Fri Nov 9 17:00:50 2018 +0100

    Change cursor type when hoover over link
    
    Signed-off-by: Michael Rasmussen <mir at datanom.net>

diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
index f92cd3d..0b0839b 100644
--- a/src/plugins/litehtml_viewer/lh_widget.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -123,13 +123,6 @@ void lh_widget::on_anchor_click(const litehtml::tchar_t* url, const litehtml::el
 	return;
 }
 
-void lh_widget::set_cursor(const litehtml::tchar_t* cursor)
-{
-	g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget set_cursor");
-	if (cursor == NULL)
-		return;
-}
-
 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");
@@ -286,6 +279,36 @@ void lh_widget::clear()
 	m_rendered_width = 0;
 }
 
+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);
+    if (cursor)
+    {
+	if (m_cursor != cursor)
+	{
+	    m_cursor = cursor;
+	    update_cursor();
+	}
+    }
+}
+
+void lh_widget::update_cursor()
+{
+    g_log(NULL, G_LOG_LEVEL_MESSAGE, "lh_widget update_cursor %s", m_cursor);
+    GdkCursorType cursType = GDK_ARROW;
+    if(m_cursor == _t("pointer"))
+    {
+        cursType = GDK_HAND1;
+    }
+    if(cursType == GDK_ARROW)
+    {
+        gdk_window_set_cursor(gtk_widget_get_window(m_drawing_area), NULL);
+    } else
+    {
+        gdk_window_set_cursor(gtk_widget_get_window(m_drawing_area), gdk_cursor_new(cursType));
+    }
+}
+
 static gboolean expose_event_cb(GtkWidget *widget, GdkEvent *event,
 		gpointer user_data)
 {
@@ -320,6 +343,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);
                 gtk_widget_queue_draw_area(widget, pos.x, pos.y, pos.width, pos.height);
             }
         }
@@ -342,6 +366,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);
                 gtk_widget_queue_draw_area(widget, pos.x, pos.y, pos.width, pos.height);
             }
         }
@@ -366,6 +391,7 @@ 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);
                 gtk_widget_queue_draw_area(widget, pos.x, pos.y, pos.width, pos.height);
             }
         }
@@ -373,7 +399,9 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
         if (!w->m_clicked_url.empty())
         {
                 g_log(NULL, G_LOG_LEVEL_MESSAGE, "Open in browser: %s", w->m_clicked_url.c_str());
-                gtk_show_uri(NULL, w->m_clicked_url.c_str(), GDK_CURRENT_TIME, &error);
+		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_ERROR, "Failed opening url(%s): %s", w->m_clicked_url, error->message);
                     g_clear_error(&error);
diff --git a/src/plugins/litehtml_viewer/lh_widget.h b/src/plugins/litehtml_viewer/lh_widget.h
index 32d751c..2f4eb11 100644
--- a/src/plugins/litehtml_viewer/lh_widget.h
+++ b/src/plugins/litehtml_viewer/lh_widget.h
@@ -28,8 +28,9 @@ class lh_widget : public container_linux
 		void redraw();
 		void open_html(const gchar *contents);
 		void clear();
+		void update_cursor();
 
-        litehtml::document::ptr m_html;
+		litehtml::document::ptr m_html;
 		litehtml::tstring m_clicked_url;
 
 	private:

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list