[Commits] [SCM] claws branch, gtk3, updated. 3.16.0-573-g80fa9a9

iwkse at claws-mail.org iwkse at claws-mail.org
Wed Jan 9 00:01:14 CET 2019


The branch, gtk3 has been updated
       via  80fa9a93a2d7e9017098656ebb0c4e5c6d3d20e7 (commit)
       via  455fad8472ef92c266c8d7f3fabbe21d0ddbe86b (commit)
       via  92b48e4784711b0fcf121c786b939c4e123e6850 (commit)
       via  1cfd4d104dfe17eedcaa7205e994d179e807d811 (commit)
       via  5a29ec1740d96fb0515ba7418c6bd16375b17a0f (commit)
      from  421fce6ee3f290da26f97488eb7b75a7ecb3f88e (commit)

Summary of changes:
 configure.ac                     |    4 +-
 src/plugins/fancy/fancy_prefs.h  |    4 +-
 src/plugins/fancy/fancy_viewer.c |  287 ++++++++++++++++++++------------------
 src/plugins/fancy/fancy_viewer.h |   22 ++-
 4 files changed, 165 insertions(+), 152 deletions(-)


- Log -----------------------------------------------------------------
commit 80fa9a93a2d7e9017098656ebb0c4e5c6d3d20e7
Author: iwkse <iwkse at claws-mail.org>
Date:   Tue Jan 8 23:57:02 2019 +0100

    Fix zoom level button action

diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c
index cb5224c..99962cc 100644
--- a/src/plugins/fancy/fancy_viewer.c
+++ b/src/plugins/fancy/fancy_viewer.c
@@ -247,6 +247,8 @@ static gboolean fancy_set_contents(FancyViewer *viewer, gboolean use_defaults)
 	else {
 		const gchar *charset = NULL;
 		gchar *contents = NULL;
+        gdouble zoom_level;
+        zoom_level = (double) fancy_prefs.zoom_level / 100;
 		if (messageview && messageview->forced_charset)
 			charset = ((MimeViewer *)viewer)->mimeview->messageview->forced_charset;
 		else
@@ -257,8 +259,9 @@ static gboolean fancy_set_contents(FancyViewer *viewer, gboolean use_defaults)
 		g_object_set(viewer->settings, "default-charset", charset, NULL);
 		
 		if (use_defaults) {
-			debug_print("zoom_level: %i\n", fancy_prefs.zoom_level);
-			webkit_web_view_set_zoom_level(viewer->view, (fancy_prefs.zoom_level));
+			debug_print("zoom_level: %i\n", zoom_level);
+
+			webkit_web_view_set_zoom_level(viewer->view, zoom_level);
 
 			fancy_set_defaults(viewer);
 		}
@@ -949,14 +952,18 @@ static void zoom_in_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer)
 {
 	gtk_widget_grab_focus(widget);
     fancy_prefs.zoom_level += 10;
-    webkit_web_view_set_zoom_level(viewer->view, (fancy_prefs.zoom_level/100));
+    gdouble zoom_level;
+    zoom_level = (double) fancy_prefs.zoom_level / 100;
+    webkit_web_view_set_zoom_level(viewer->view, zoom_level);
 }
 static void zoom_out_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer)
 {
+    gdouble zoom_level;
 	gtk_widget_grab_focus(widget);
     fancy_prefs.zoom_level -= 10;
+    zoom_level = (double) fancy_prefs.zoom_level / 100;
     if (fancy_prefs.zoom_level)
-        webkit_web_view_set_zoom_level(viewer->view, (fancy_prefs.zoom_level/100));
+        webkit_web_view_set_zoom_level(viewer->view, zoom_level);
 }
 
 static void resource_load_failed_cb(WebKitWebView     *web_view,

commit 455fad8472ef92c266c8d7f3fabbe21d0ddbe86b
Author: iwkse <iwkse at claws-mail.org>
Date:   Tue Jan 8 23:27:43 2019 +0100

    Change stock images

diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c
index bf43717..cb5224c 100644
--- a/src/plugins/fancy/fancy_viewer.c
+++ b/src/plugins/fancy/fancy_viewer.c
@@ -1018,10 +1018,10 @@ static MimeViewer *fancy_viewer_create(void)
 	hbox = gtk_hbox_new(FALSE, 0);
 	viewer->progress = gtk_progress_bar_new();
 	/* Zoom Widgets */
-	viewer->zoom_100 = gtk_image_new_from_icon_name(GTK_STOCK_ZOOM_100, GTK_ICON_SIZE_LARGE_TOOLBAR);
-	viewer->zoom_in = gtk_image_new_from_icon_name(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_LARGE_TOOLBAR);
-	viewer->zoom_out = gtk_image_new_from_icon_name(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_LARGE_TOOLBAR);
-	viewer->stop_loading = gtk_image_new_from_icon_name(GTK_STOCK_CANCEL, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	viewer->zoom_100 = gtk_image_new_from_icon_name("zoom-original", GTK_ICON_SIZE_LARGE_TOOLBAR);
+	viewer->zoom_in = gtk_image_new_from_icon_name("zoom-in", GTK_ICON_SIZE_LARGE_TOOLBAR);
+	viewer->zoom_out = gtk_image_new_from_icon_name("zoom-out", GTK_ICON_SIZE_LARGE_TOOLBAR);
+	viewer->stop_loading = gtk_image_new_from_icon_name("gtk-cancel", GTK_ICON_SIZE_LARGE_TOOLBAR);
 	/* Event Widgets for the Zoom Widgets  */
 	viewer->ev_zoom_100 = gtk_event_box_new();
 	viewer->ev_zoom_in = gtk_event_box_new();
@@ -1032,7 +1032,7 @@ static MimeViewer *fancy_viewer_create(void)
 	viewer->l_link = gtk_label_new("");
 
 	/* Preferences Widgets to override preferences on the fly  */
-	viewer->fancy_prefs = gtk_image_new_from_icon_name(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	viewer->fancy_prefs = gtk_image_new_from_icon_name("preferences-system", GTK_ICON_SIZE_LARGE_TOOLBAR);
 	viewer->ev_fancy_prefs = gtk_event_box_new();
 
 	/* Popup Menu for preferences  */
@@ -1134,7 +1134,7 @@ static MimeViewerFactory fancy_viewer_factory =
 
 gint plugin_init(gchar **error)
 {
-	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
+	if (!check_plugin_version(MAKE_NUMERIC_VERSION(3,0,0,0),
 				  VERSION_NUMERIC, _("Fancy"), error))
 		return -1;
 	gchar *directory = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,

commit 92b48e4784711b0fcf121c786b939c4e123e6850
Author: iwkse <iwkse at claws-mail.org>
Date:   Tue Jan 8 04:08:19 2019 +0100

    WebKit2 GTK3 basic migration

diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c
index 5820faf..bf43717 100644
--- a/src/plugins/fancy/fancy_viewer.c
+++ b/src/plugins/fancy/fancy_viewer.c
@@ -44,7 +44,7 @@ over_link_cb (WebKitWebView *view, const gchar *wtf, const gchar *link,
 
 
 static void
-load_progress_cb(WebKitWebView *view, GParamSpec* pspec, FancyViewer *viewer);
+load_progress_cb(WebKitWebView *view, gdouble progress, FancyViewer *viewer);
 
 static MimeViewerFactory fancy_viewer_factory;
 
@@ -83,11 +83,11 @@ static void fancy_apply_prefs(FancyViewer *viewer)
 {
 	g_object_set(viewer->settings,
 		"auto-load-images", viewer->override_prefs_images,
-		"enable-scripts", viewer->override_prefs_scripts,
+		"enable-javascript", viewer->override_prefs_scripts,
 		"enable-plugins", viewer->override_prefs_plugins,
-		"enable-java-applet", viewer->override_prefs_java,
-	        "enable-dns-prefetching", viewer->override_prefs_remote_content,
-	        "user-stylesheet-uri", viewer->override_stylesheet,
+		"enable-java", viewer->override_prefs_java,
+	    "enable-dns-prefetching", viewer->override_prefs_remote_content,
+/*	    "selected-stylesheet-set", viewer->override_stylesheet,*/
 #ifdef G_OS_WIN32
 		"default-font-family", "Arial",
 		"cursive-font-family", "Comic Sans MS",
@@ -145,25 +145,27 @@ static void fancy_set_defaults(FancyViewer *viewer)
 	viewer->override_prefs_java = fancy_prefs.enable_java;
 
 	gchar *tmp;
-#ifdef G_OS_WIN32
+/*
+#ifdef G_OS_WIN32*/
 	/* Replace backslashes with forward slashes, since we'll be
-	 * using this string in an URI. */
+	 * using this string in an URI. 
 	gchar *tmp2 = g_strdup(fancy_prefs.stylesheet);
 	subst_char(tmp2, '\\', '/');
 
-	/* Escape string for use in an URI, keeping dir separators
-	 * and colon for Windows drive name ("C:") intact. */
+	 Escape string for use in an URI, keeping dir separators
+	 * and colon for Windows drive name ("C:") intact. 
 	tmp = g_uri_escape_string(tmp2, "/:", TRUE);
 	g_free(tmp2);
 #else
-	/* Escape string for use in an URI, keeping dir separators
-	 * intact. */
+	 Escape string for use in an URI, keeping dir separators
+	 * intact. 
 	tmp = g_uri_escape_string(fancy_prefs.stylesheet, "/", TRUE);
 #endif
 	viewer->override_stylesheet = g_strconcat("file://", tmp, NULL);
 	g_free(tmp);
 	debug_print("Passing '%s' as stylesheet URI to Webkit\n",
 			viewer->override_stylesheet);
+*/
 
 	g_signal_handlers_block_by_func(G_OBJECT(viewer->enable_images),
 		fancy_auto_load_images_activated, viewer);
@@ -252,11 +254,11 @@ static gboolean fancy_set_contents(FancyViewer *viewer, gboolean use_defaults)
 		if (!charset)
 			charset = conv_get_locale_charset_str();
 		debug_print("using %s charset\n", charset);
-		g_object_set(viewer->settings, "default-encoding", charset, NULL);
+		g_object_set(viewer->settings, "default-charset", charset, NULL);
 		
 		if (use_defaults) {
 			debug_print("zoom_level: %i\n", fancy_prefs.zoom_level);
-			webkit_web_view_set_zoom_level(viewer->view, (fancy_prefs.zoom_level / 100.0));
+			webkit_web_view_set_zoom_level(viewer->view, (fancy_prefs.zoom_level));
 
 			fancy_set_defaults(viewer);
 		}
@@ -351,11 +353,11 @@ static void fancy_print(MimeViewer *_viewer)
 	g_free(printoperation);
 }
 
-static gchar *fancy_get_selection (MimeViewer *_viewer)
+/*static gchar *fancy_get_selection (MimeViewer *_viewer)
 {
 	debug_print("fancy_get_selection\n");
 	FancyViewer *viewer = (FancyViewer *) _viewer;
-	viewer->doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(viewer->view));
+	viewer->doc = webkit_web_page_get_dom_document(WEBKIT_WEB_VIEW(viewer->view));
 	viewer->window = webkit_dom_document_get_default_view (viewer->doc);
 	viewer->selection = webkit_dom_dom_window_get_selection (viewer->window);
 	if (viewer->selection == NULL)
@@ -369,7 +371,7 @@ static gchar *fancy_get_selection (MimeViewer *_viewer)
 		return NULL;
 	}
 	return sel;
-}
+}*/
 
 static void fancy_clear_viewer(MimeViewer *_viewer)
 {
@@ -381,7 +383,7 @@ static void fancy_clear_viewer(MimeViewer *_viewer)
 	webkit_web_view_load_uri(viewer->view, "about:blank");
 
 	debug_print("fancy_clear_viewer\n");
-	fancy_prefs.zoom_level = webkit_web_view_get_zoom_level(viewer->view) * 100;
+	fancy_prefs.zoom_level = webkit_web_view_get_zoom_level(viewer->view);
 	viewer->to_load = NULL;
 	vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(viewer->scrollwin));
 	gtk_adjustment_set_value(vadj, 0.0);
@@ -391,51 +393,49 @@ static void fancy_clear_viewer(MimeViewer *_viewer)
 static void fancy_destroy_viewer(MimeViewer *_viewer)
 {
 	FancyViewer *viewer = (FancyViewer *) _viewer;
-	fancy_prefs.zoom_level = webkit_web_view_get_zoom_level(viewer->view) * 100;
+	fancy_prefs.zoom_level = webkit_web_view_get_zoom_level(viewer->view);
 	debug_print("fancy_destroy_viewer\n");
 	g_free(viewer->filename);
 	g_free(viewer);
 }
 
 static gboolean
-navigation_policy_cb (WebKitWebView             *web_view,
-		      WebKitWebFrame            *frame,
-		      WebKitNetworkRequest      *request,
-		      WebKitWebNavigationAction *navigation_action,
-		      WebKitWebPolicyDecision   *policy_decision,
+navigation_policy_cb (WebKitWebView    *web_view,
+		      WebKitPolicyDecision *policy_decision,
+		      WebKitPolicyDecisionType policy_decision_type,
 		      FancyViewer		*viewer)
 {
-	const gchar *uri = webkit_network_request_get_uri(request);
-
-	debug_print("navigation requested to %s\n", uri);
-
-	if (!strncmp(uri, "mailto:", 7)) {
-		debug_print("Opening message window\n");
-		compose_new(NULL, uri + 7, NULL);
-		webkit_web_policy_decision_ignore(policy_decision);
-	} else if (!strncmp(uri, "file://", 7) || !strcmp(uri, "about:blank")) {
-		debug_print("local navigation request ACCEPTED\n");
-		webkit_web_policy_decision_use(policy_decision);
-	} else if (viewer->override_prefs_remote_content) {
-		debug_print("remote navigation request ACCEPTED\n");
-		webkit_web_policy_decision_use(policy_decision);
-	} else {
-		debug_print("remote navigation request IGNORED\n");
-		fancy_show_notice(viewer, _("Remote content loading is disabled."));
-		webkit_web_policy_decision_ignore(policy_decision);
-	}
+
+	debug_print("navigation requested to %s\n", viewer->cur_link);
+
+    if (viewer->cur_link) {
+        if (!strncmp(viewer->cur_link, "mailto:", 7)) {
+            debug_print("Opening message window\n");
+            compose_new(NULL, viewer->cur_link + 7, NULL);
+            webkit_policy_decision_ignore(policy_decision);
+        } else if (!strncmp(viewer->cur_link, "file://", 7) || !strcmp(viewer->cur_link, "about:blank")) {
+            debug_print("local navigation request ACCEPTED\n");
+            webkit_policy_decision_use(policy_decision);
+        } else if (viewer->override_prefs_remote_content) {
+            debug_print("remote navigation request ACCEPTED\n");
+            webkit_policy_decision_use(policy_decision);
+        } else {
+            debug_print("remote avigation request IGNORED\n");
+            fancy_show_notice(viewer, _("Remote content loading is disabled."));
+            webkit_policy_decision_ignore(policy_decision);
+        }
+    }
 
 	return true;
 }
 
 static void resource_request_starting_cb(WebKitWebView		*view,
-					 WebKitWebFrame		*frame,
 					 WebKitWebResource	*resource,
-					 WebKitNetworkRequest	*request,
-					 WebKitNetworkResponse	*response,
+					 WebKitURIRequest	*request,
+					 WebKitURIResponse	*response,
 					 FancyViewer		*viewer)
 {
-	const gchar *uri = webkit_network_request_get_uri(request);
+	const gchar *uri = webkit_uri_request_get_uri(request);
 	gchar *filename;
 	gchar *image;
 	gint err;
@@ -455,7 +455,7 @@ static void resource_request_starting_cb(WebKitWebView		*view,
 					alertpanel_error(_("Couldn't save the part of multipart message: %s"),
 										g_strerror(-err));
 				gchar *file_uri = g_filename_to_uri(filename, NULL, NULL);
-				webkit_network_request_set_uri(request, file_uri);
+				webkit_uri_request_set_uri(request, file_uri);
 				g_free(file_uri);
 				g_free(filename);
 				break;
@@ -465,28 +465,28 @@ static void resource_request_starting_cb(WebKitWebView		*view,
 	}
 	
 	/* refresh URI that may have changed */
-	uri = webkit_network_request_get_uri(request);
+	uri = webkit_uri_request_get_uri(request);
 	if (!viewer->override_prefs_remote_content
 	    && strncmp(uri, "file://", 7) && strncmp(uri, "data:", 5)) {
 		debug_print("Preventing load of %s\n", uri);
-		webkit_network_request_set_uri(request, "about:blank");
+		webkit_uri_request_set_uri(request, "about:blank");
 	}
 	else
 		debug_print("Starting request of %"G_GSIZE_FORMAT" %s\n", strlen(uri), uri);
 }
 
-static gboolean fancy_text_search(MimeViewer *_viewer, gboolean backward,
+/*static gboolean fancy_text_search(MimeViewer *_viewer, gboolean backward,
 				  const gchar *str, gboolean case_sens)
 {
 	return webkit_web_view_search_text(((FancyViewer*)_viewer)->view, str,
 					   case_sens, !backward, TRUE);
-}
+}*/
 
 static gboolean fancy_prefs_cb(GtkWidget *widget, GdkEventButton *ev, FancyViewer *viewer)
 {
 	if ((ev->button == 1) && (ev->type == GDK_BUTTON_PRESS)) {
-		gtk_menu_popup(GTK_MENU(viewer->fancy_prefs_menu), NULL, NULL, NULL, NULL,
-				ev->button, ev->time);
+		gtk_menu_popup_at_widget(GTK_MENU(viewer->fancy_prefs_menu), 
+                                 NULL, GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER ,	NULL);
 		return TRUE;
 	}
 	return FALSE;
@@ -595,31 +595,26 @@ static void over_link_cb(WebKitWebView *view, const gchar *wtf,
 	gtk_label_set_text(GTK_LABEL(viewer->l_link), link);
 }
 
-static void load_progress_cb(WebKitWebView *view, GParamSpec* pspec,
+static void load_progress_cb(WebKitWebView *view, gdouble progress,
 			     FancyViewer *viewer)
 {
-	WebKitLoadStatus status = webkit_web_view_get_load_status(viewer->view);
-	gdouble pbar = webkit_web_view_get_progress(viewer->view);
-	const gchar *uri = webkit_web_view_get_uri(viewer->view);
+//	WebKitLoadEvent status = webkit_web_view_get_load_status(viewer->view);
+//	gdouble pbar = webkit_web_view_get_progress(viewer->view);
+//	const gchar *uri = webkit_web_view_get_uri(viewer->view);
 
-	gchar *label = g_strdup_printf("%d%% Loading...", (gint)(pbar * 100));
-	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(viewer->progress), pbar);
+	gchar *label = g_strdup_printf("%d%% Loading...", (gint)(progress * 100));
+	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(viewer->progress), progress);
 	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(viewer->progress),
 				  (const gchar*)label);
 	g_free(label);
 
-	switch (status) {
-		case WEBKIT_LOAD_PROVISIONAL:
+/*	switch (status) {
 		case WEBKIT_LOAD_COMMITTED:
-		case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
-			break;
-		case WEBKIT_LOAD_FAILED:
-			debug_print("Load failed: %s\n", uri);
 			break;
 		case WEBKIT_LOAD_FINISHED:
 			debug_print("Load finished: %s\n", uri);
 			break;
-	}
+	}*/
 }
 
 static void stop_loading_cb(GtkWidget *widget, GdkEvent *ev,
@@ -629,7 +624,7 @@ static void stop_loading_cb(GtkWidget *widget, GdkEvent *ev,
 	gtk_widget_hide(viewer->progress);
 	gtk_widget_hide(viewer->ev_stop_loading);
 }
-
+/*
 static void search_the_web_cb(GtkWidget *widget, FancyViewer *viewer)
 {
 	debug_print("Clicked on Search on Web\n");
@@ -646,7 +641,7 @@ static void search_the_web_cb(GtkWidget *widget, FancyViewer *viewer)
 		g_free(search);
 		g_free(tmp);
 	}
-}
+}*/
 
 static void open_in_browser_cb(GtkWidget *widget, FancyViewer *viewer)
 {
@@ -753,10 +748,10 @@ static void viewer_menu_handler(GtkWidget *menuitem, FancyViewer *viewer)
 				"Search the Web")) {
 			gtk_label_set_text(GTK_LABEL(menul), _("Search the Web"));
 			viewer->cur_link = NULL;
-			GtkImageMenuItem *m_search = GTK_IMAGE_MENU_ITEM(menuitem);
+/*			GtkImageMenuItem *m_search = GTK_IMAGE_MENU_ITEM(menuitem);
 			g_signal_connect(G_OBJECT(m_search), "activate",
 					 G_CALLBACK(search_the_web_cb),
-					 (gpointer *) viewer);
+					 (gpointer *) viewer);*/
 		}
 
 		if (!g_ascii_strcasecmp(gtk_label_get_text(GTK_LABEL(menul)),
@@ -765,7 +760,7 @@ static void viewer_menu_handler(GtkWidget *menuitem, FancyViewer *viewer)
 			if (viewer->override_prefs_remote_content)
 				gtk_label_set_text(GTK_LABEL(menul), _("Open in Viewer"));
 			else
-				gtk_label_set_text(GTK_LABEL(menul), _("Open in Viewer (enable remote content)"));
+				gtk_label_set_text(GTK_LABEL(menul), _("pen in Viewer (enable remote content)"));
 
 			GtkImageMenuItem *m_new = GTK_IMAGE_MENU_ITEM(menuitem);
 			gtk_widget_set_sensitive(GTK_WIDGET(m_new), viewer->override_prefs_remote_content);
@@ -828,26 +823,24 @@ static void viewer_menu_handler(GtkWidget *menuitem, FancyViewer *viewer)
 	}
 }
 
-static gboolean context_menu_cb (WebKitWebView *view, GtkWidget *menu,
-		WebKitHitTestResult *hit_test_result,
+static gboolean context_menu_cb (WebKitWebView *view, WebKitContextMenu *menu,
+        GdkEvent *event, WebKitHitTestResult *hit_test_result,
 		gboolean triggered_with_keyboard,
 		gpointer user_data)
 {
 	FancyViewer *viewer = (FancyViewer *)user_data;
 	Plugin *plugin = plugin_get_loaded_by_name("RSSyl");
 	WebKitHitTestResultContext context;
+    context = webkit_hit_test_result_get_context(hit_test_result);
 	gchar *link_uri = NULL;
 
-	g_object_get(G_OBJECT(hit_test_result),
-			"context", &context,
-			"link-uri", &link_uri,
-			NULL);
+    link_uri = webkit_hit_test_result_get_link_uri(hit_test_result);
 
 	debug_print("context %d, link-uri '%s'\n", context,
 			(link_uri != NULL ? link_uri : "(null)"));
 	if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK &&
 			link_uri != NULL) {
-		if (viewer->cur_link != NULL)
+		if (viewer != NULL || viewer->cur_link != NULL)
 			g_free(viewer->cur_link);
 		/* g_object_get() already made a copy, no need to strdup() here */
 		viewer->cur_link = link_uri;
@@ -859,8 +852,6 @@ static gboolean context_menu_cb (WebKitWebView *view, GtkWidget *menu,
 
 	if (plugin) {
 		GtkWidget *rssyl = gtk_image_menu_item_new_with_label(_("Import feed"));
-		GtkWidget *img = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
-		gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(rssyl), img);
 		gtk_widget_show(GTK_WIDGET(rssyl));
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), rssyl);
 		g_signal_connect(G_OBJECT(rssyl), "activate",
@@ -890,8 +881,7 @@ static gint keypress_events_cb (GtkWidget *widget, GdkEventKey *event,
 	return FALSE;
 }
 
-static gboolean release_button_cb (WebKitWebView *view, GdkEvent *ev,
-				   FancyViewer *viewer)
+/*static gboolean release_button_cb (WebKitWebView *view, GdkEvent *ev, FancyViewer *viewer)
 {
 	if (ev->button.button == 1 && viewer->cur_link && viewer->override_prefs_external) {
 		gint x, y;
@@ -901,9 +891,9 @@ static gboolean release_button_cb (WebKitWebView *view, GdkEvent *ev,
 				"x", &x, "y", &y,
 				NULL);
 
-		/* If this button release is end of a drag or selection event
+		*//* If this button release is end of a drag or selection event
 		 * (button press happened on different coordinates), we do not
-		 * want to open the link. */
+		 * want to open the link. *//*
 		if ((x != viewer->click_x || y != viewer->click_y))
 			return FALSE;
 
@@ -938,7 +928,7 @@ static gboolean press_button_cb (WebKitWebView *view, GdkEvent *ev,
 	}
 	if (link != NULL) {
 		debug_print("press on %s\n", link);
-		viewer->cur_link = link; /* g_context returned a newly-allocated string */
+		viewer->cur_link = link;i*/ /* g_context returned a newly-allocated string 
 	}
 
 	viewer->doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(viewer->view));
@@ -947,7 +937,7 @@ static gboolean press_button_cb (WebKitWebView *view, GdkEvent *ev,
 	if (viewer->selection != NULL)
 		webkit_dom_dom_selection_empty(viewer->selection);
 	return FALSE;
-}
+}*/
 
 static void zoom_100_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer)
 {
@@ -958,16 +948,18 @@ static void zoom_100_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer)
 static void zoom_in_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer)
 {
 	gtk_widget_grab_focus(widget);
-	webkit_web_view_zoom_in(viewer->view);
+    fancy_prefs.zoom_level += 10;
+    webkit_web_view_set_zoom_level(viewer->view, (fancy_prefs.zoom_level/100));
 }
 static void zoom_out_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer)
 {
 	gtk_widget_grab_focus(widget);
-	webkit_web_view_zoom_out(viewer->view);
+    fancy_prefs.zoom_level -= 10;
+    if (fancy_prefs.zoom_level)
+        webkit_web_view_set_zoom_level(viewer->view, (fancy_prefs.zoom_level/100));
 }
 
 static void resource_load_failed_cb(WebKitWebView     *web_view,
-				    WebKitWebFrame    *web_frame,
 				    WebKitWebResource *web_resource,
 				    GError            *error,
 				    FancyViewer	      *viewer)
@@ -985,19 +977,22 @@ static MimeViewer *fancy_viewer_create(void)
 	viewer = g_new0(FancyViewer, 1);
 	viewer->mimeviewer.factory = &fancy_viewer_factory;
 	viewer->mimeviewer.get_widget = fancy_get_widget;
-	viewer->mimeviewer.get_selection = fancy_get_selection;
+//	viewer->mimeviewer.get_selection = fancy_get_selection;
 	viewer->mimeviewer.show_mimepart = fancy_show_mimepart;
 	viewer->mimeviewer.print = fancy_print;
 	viewer->mimeviewer.clear_viewer = fancy_clear_viewer;
 	viewer->mimeviewer.destroy_viewer = fancy_destroy_viewer;
-	viewer->mimeviewer.text_search = fancy_text_search;
+//	viewer->mimeviewer.text_search = fancy_text_search;
 	viewer->mimeviewer.scroll_page = fancy_scroll_page;
 	viewer->mimeviewer.scroll_one_line = fancy_scroll_one_line;
 	viewer->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
 
-#ifdef HAVE_LIBSOUP_GNOME
+/*#ifdef HAVE_LIBSOUP_GNOME
+  TODO webkit_get_default_session() missing 
+   *     enum WebKitNetworkProxySettings
+   * */
  /* Use GNOME proxy settings through libproxy */
-	if (fancy_prefs.enable_gnome_proxy) {
+/*	if (fancy_prefs.enable_gnome_proxy) {
 		SoupSession *session = webkit_get_default_session();
 		soup_session_add_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_GNOME);
 	}
@@ -1008,8 +1003,8 @@ static MimeViewer *fancy_viewer_create(void)
 		SoupURI* pURI = soup_uri_new(fancy_prefs.proxy_str);
 		g_object_set(session, "proxy-uri", pURI, NULL);
 	}
-
-	viewer->settings = webkit_web_settings_new();
+*/
+	viewer->settings = webkit_settings_new();
 	g_object_set(viewer->settings, "user-agent", "Fancy Viewer", NULL);
 	viewer->scrollwin = gtk_scrolled_window_new(NULL, NULL);
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(viewer->scrollwin),
@@ -1023,10 +1018,10 @@ static MimeViewer *fancy_viewer_create(void)
 	hbox = gtk_hbox_new(FALSE, 0);
 	viewer->progress = gtk_progress_bar_new();
 	/* Zoom Widgets */
-	viewer->zoom_100 = gtk_image_new_from_stock(GTK_STOCK_ZOOM_100, GTK_ICON_SIZE_MENU);
-	viewer->zoom_in = gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU);
-	viewer->zoom_out = gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_MENU);
-	viewer->stop_loading = gtk_image_new_from_stock(GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU);
+	viewer->zoom_100 = gtk_image_new_from_icon_name(GTK_STOCK_ZOOM_100, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	viewer->zoom_in = gtk_image_new_from_icon_name(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	viewer->zoom_out = gtk_image_new_from_icon_name(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	viewer->stop_loading = gtk_image_new_from_icon_name(GTK_STOCK_CANCEL, GTK_ICON_SIZE_LARGE_TOOLBAR);
 	/* Event Widgets for the Zoom Widgets  */
 	viewer->ev_zoom_100 = gtk_event_box_new();
 	viewer->ev_zoom_in = gtk_event_box_new();
@@ -1037,7 +1032,7 @@ static MimeViewer *fancy_viewer_create(void)
 	viewer->l_link = gtk_label_new("");
 
 	/* Preferences Widgets to override preferences on the fly  */
-	viewer->fancy_prefs = gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
+	viewer->fancy_prefs = gtk_image_new_from_icon_name(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_LARGE_TOOLBAR);
 	viewer->ev_fancy_prefs = gtk_event_box_new();
 
 	/* Popup Menu for preferences  */
@@ -1092,22 +1087,22 @@ static MimeViewer *fancy_viewer_create(void)
 	g_signal_connect(G_OBJECT(viewer->view), "hovering-over-link",
 			G_CALLBACK(over_link_cb), viewer);
 
-	g_signal_connect(G_OBJECT(viewer->view), "notify::progress",
+	g_signal_connect(G_OBJECT(viewer->view), "estimate-progress",
 			 G_CALLBACK(load_progress_cb), viewer);
-	g_signal_connect(G_OBJECT(viewer->view), "notify::load-status",
+	g_signal_connect(G_OBJECT(viewer->view), "estimage-load-progress",
 			 G_CALLBACK(load_progress_cb), viewer);
 
-	g_signal_connect(G_OBJECT(viewer->view), "navigation-policy-decision-requested",
+	g_signal_connect(G_OBJECT(viewer->view), "decide-policy",
 			 G_CALLBACK(navigation_policy_cb), viewer);
 
 	g_signal_connect(G_OBJECT(viewer->view), "resource-request-starting",
 			G_CALLBACK(resource_request_starting_cb), viewer);
 	g_signal_connect(G_OBJECT(viewer->view), "context-menu",
 			G_CALLBACK(context_menu_cb), viewer);
-	g_signal_connect(G_OBJECT(viewer->view), "button-press-event",
+/*	g_signal_connect(G_OBJECT(viewer->view), "button-press-event",
 			 G_CALLBACK(press_button_cb), viewer);
 	g_signal_connect(G_OBJECT(viewer->view), "button-release-event",
-			 G_CALLBACK(release_button_cb), viewer);
+			 G_CALLBACK(release_button_cb), viewer);*/
 	g_signal_connect(G_OBJECT(viewer->ev_zoom_100), "button-press-event",
 			 G_CALLBACK(zoom_100_cb), (gpointer*)viewer);
 	g_signal_connect(G_OBJECT(viewer->ev_zoom_in), "button-press-event",
@@ -1183,7 +1178,7 @@ const gchar *plugin_desc(void)
 
 const gchar *plugin_type(void)
 {
-	return "GTK2";
+	return "GTK3";
 }
 
 const gchar *plugin_licence(void)
diff --git a/src/plugins/fancy/fancy_viewer.h b/src/plugins/fancy/fancy_viewer.h
index 30d4907..f72ecfd 100644
--- a/src/plugins/fancy/fancy_viewer.h
+++ b/src/plugins/fancy/fancy_viewer.h
@@ -86,7 +86,7 @@ struct _FancyViewer
 	GtkWidget         *enable_images;
 	GtkWidget         *enable_scripts;
 	GtkWidget         *enable_plugins;
-	GtkWidget	  *enable_java;
+	GtkWidget         *enable_java;
 	GtkWidget         *enable_remote_content;
 	GtkWidget         *open_external;
 	GtkWidget         *stylesheet;
@@ -99,8 +99,8 @@ struct _FancyViewer
 	gboolean          override_prefs_scripts;
 	gboolean          override_prefs_plugins;
 	gboolean          override_prefs_external;
-	gboolean	  override_prefs_java;
-	gchar		 *override_stylesheet;
+	gboolean          override_prefs_java;
+	gchar             *override_stylesheet;
 
 	const gchar       *curlfile;
 	FILE              *stream;
@@ -116,11 +116,12 @@ struct _FancyViewer
 	gint              click_y;
 
 	/* DOM Objects */
-	WebKitDOMDocument	  *doc;
+	WebKitDOMDocument     *doc;
 	WebKitDOMDOMWindow    *window;
 	WebKitDOMDOMSelection *selection;
-	WebKitDOMRange		  *range;
+	WebKitDOMRange        *range;
 };
+
 #define OPEN_INTERNAL FALSE
 #define OPEN_EXTERNAL TRUE
 #define CTRL_KEY 4

commit 1cfd4d104dfe17eedcaa7205e994d179e807d811
Author: Michael Rasmussen <mir at datanom.net>
Date:   Mon Nov 5 17:27:02 2018 +0100

    Fix a memory leak
    
    Signed-off-by: Michael Rasmussen <mir at datanom.net>

diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c
index 4b18613..5820faf 100644
--- a/src/plugins/fancy/fancy_viewer.c
+++ b/src/plugins/fancy/fancy_viewer.c
@@ -347,6 +347,8 @@ static void fancy_print(MimeViewer *_viewer)
 	    printing_store_settings(
 		webkit_print_operation_get_print_settings(printoperation));
 	}
+
+	g_free(printoperation);
 }
 
 static gchar *fancy_get_selection (MimeViewer *_viewer)

commit 5a29ec1740d96fb0515ba7418c6bd16375b17a0f
Author: Michael Rasmussen <mir at datanom.net>
Date:   Mon Nov 5 17:13:50 2018 +0100

    Migrate fancy to GTK3 and fix fancy_print
    
    Signed-off-by: Michael Rasmussen <mir at datanom.net>

diff --git a/configure.ac b/configure.ac
index 0805631..0bdd48a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1156,7 +1156,7 @@ AC_SUBST(EXPAT_CFLAGS)
 AC_SUBST(EXPAT_LIBS)
 
 dnl webkit *********************************************************************
-PKG_CHECK_MODULES(WEBKIT, webkit-1.0 >= 1.10.0, HAVE_WEBKIT=yes, HAVE_WEBKIT=no)
+PKG_CHECK_MODULES(WEBKIT, webkit2gtk-4.0 >= 2.18.0, HAVE_WEBKIT=yes, HAVE_WEBKIT=no)
 AC_SUBST(WEBKIT_LIBS)
 AC_SUBST(WEBKIT_CFLAGS)
 
@@ -1517,7 +1517,7 @@ if test x"$enable_fancy_plugin" != xno; then
 	dependencies_missing=""
 
 	if test x"$HAVE_WEBKIT" = xno; then
-		dependencies_missing="libwebkit-1.0 $dependencies_missing"
+		dependencies_missing="libwebkit2gtk-4.0 $dependencies_missing"
 	fi
 	if test x"$HAVE_CURL" = xno; then
 		dependencies_missing="libcurl $dependencies_missing"
diff --git a/src/plugins/fancy/fancy_prefs.h b/src/plugins/fancy/fancy_prefs.h
index 2c95e8c..fcb8408 100644
--- a/src/plugins/fancy/fancy_prefs.h
+++ b/src/plugins/fancy/fancy_prefs.h
@@ -21,12 +21,12 @@
 #define FANCY_PREFS_H
 
 #include <glib.h>
-#include <webkit/webkitwebsettings.h>
+#include <webkit2/webkit2.h>
 typedef struct _FancyPrefs FancyPrefs;
 
 struct _FancyPrefs
 	{
-	WebKitWebSettings *web_settings;
+	WebKitSettings *web_settings;
 
 	gboolean enable_images;
 	gboolean enable_remote_content;
diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c
index a6eddb2..4b18613 100644
--- a/src/plugins/fancy/fancy_viewer.c
+++ b/src/plugins/fancy/fancy_viewer.c
@@ -31,7 +31,6 @@
 #include <file-utils.h>
 
 #include <printing.h>
-#include <webkit/webkithittestresult.h>
 
 static void
 load_start_cb (WebKitWebView *view, gint progress, FancyViewer *viewer);
@@ -263,10 +262,8 @@ static gboolean fancy_set_contents(FancyViewer *viewer, gboolean use_defaults)
 		}
 
 		contents = file_read_to_str_no_recode(viewer->filename);
-		webkit_web_view_load_string(viewer->view,
+		webkit_web_view_load_html(viewer->view,
 					    contents,
-					    "text/html",
-					    charset,
 					    NULL);
 		g_free(contents);
 	}
@@ -301,38 +298,54 @@ static void fancy_show_mimepart(MimeViewer *_viewer, const gchar *infile,
 	g_timeout_add(5, (GSourceFunc)fancy_show_mimepart_prepare, viewer);
 }
 
+static void fancy_print_fail_cb(WebKitPrintOperation *print_operation,
+                               GError               *error,
+                               gpointer              user_data) {
+    /* avoid warning for unused variable
+    FancyViewer *viewer = (FancyViewer *) user_data;
+    */
+
+    debug_print("Error printing message: %s\n",
+                            error ? error->message : "no details");
+}
+
 static void fancy_print(MimeViewer *_viewer)
 {
 	FancyViewer *viewer = (FancyViewer *) _viewer;
-	GtkPrintOperationResult res;
-	GError *error = NULL;
-	GtkPrintOperation *op;
+	WebKitPrintOperationResponse res;
+	WebKitPrintOperation *printoperation;
+	GtkPrintSettings *printsettings;
+	GtkPageSetup *pagesetup;
 
 	gtk_widget_realize(GTK_WIDGET(viewer->view));
 
 	while (viewer->loading)
 		claws_do_idle();
 
-	op = gtk_print_operation_new();
-
-	/* Config for printing */
-	gtk_print_operation_set_print_settings(op, printing_get_settings());
-	gtk_print_operation_set_default_page_setup(op, printing_get_page_setup());
-        /* enable Page Size and Orientation in the print dialog */
-	gtk_print_operation_set_embed_page_setup(op, TRUE);
-
-	/* Start printing process */
-	res = webkit_web_frame_print_full(webkit_web_view_get_main_frame(viewer->view),
-					  op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
-					  &error);
-
-	if (res == GTK_PRINT_OPERATION_RESULT_ERROR) {
-		gtk_print_operation_get_error(op, &error);
-		debug_print("Error printing message: %s\n",
-			    error ? error->message : "no details");
-	} else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
-		/* store settings for next printing session */
-		printing_store_settings(gtk_print_operation_get_print_settings(op));
+	printoperation = webkit_print_operation_new(viewer->view);
+	g_signal_connect(G_OBJECT(printoperation), "failed",
+			 G_CALLBACK(fancy_print_fail_cb), viewer);
+
+	printsettings = webkit_print_operation_get_print_settings(printoperation);
+	if (!printsettings) {
+	    printsettings = printing_get_settings();
+	    webkit_print_operation_set_print_settings(printoperation, printsettings);
+	}
+	pagesetup = webkit_print_operation_get_page_setup(printoperation);
+	if (!pagesetup) {
+	    pagesetup = printing_get_page_setup();
+	    webkit_print_operation_set_page_setup(printoperation, pagesetup);
+	}
+
+	MainWindow *mainwin = mainwindow_get_mainwindow();
+	res = webkit_print_operation_run_dialog(
+	    printoperation,
+	    mainwin ? GTK_WINDOW(mainwin->window):NULL);
+
+	if (res == WEBKIT_PRINT_OPERATION_RESPONSE_PRINT) {
+	    // store settings for next printing session
+	    printing_store_settings(
+		webkit_print_operation_get_print_settings(printoperation));
 	}
 }
 
diff --git a/src/plugins/fancy/fancy_viewer.h b/src/plugins/fancy/fancy_viewer.h
index c22ca40..30d4907 100644
--- a/src/plugins/fancy/fancy_viewer.h
+++ b/src/plugins/fancy/fancy_viewer.h
@@ -29,13 +29,8 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <webkit/webkitwebview.h>
-#include <webkit/webkitversion.h>
-#include <webkit/webkitwebframe.h>
-#include <webkit/webkitnetworkrequest.h>
-#include <webkit/webkitwebnavigationaction.h>
-#include <webkit/webkitwebpolicydecision.h>
-#include <webkit/webkitglobals.h>
+#include <webkit2/webkit2.h>
+#include <webkitdom/webkitdom.h>
 #include <prefs_common.h>
 #include "common/claws.h"
 #include "common/version.h"
@@ -97,7 +92,7 @@ struct _FancyViewer
 	GtkWidget         *stylesheet;
 
 	GtkWidget         *progress;
-	WebKitWebSettings *settings;
+	WebKitSettings    *settings;
 	gboolean          printing;
 	gboolean          override_prefs_images;
 	gboolean          override_prefs_remote_content;

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list