Branch: refs/heads/master Author: Frank Lanitz frank@frank.uvena.de Committer: GitHub noreply@github.com Date: Sun, 03 Jun 2018 06:58:01 UTC Commit: 6705c54352b9b89a69e6c49bed6629cd43d2900f https://github.com/geany/geany-plugins/commit/6705c54352b9b89a69e6c49bed6629...
Log Message: ----------- Merge pull request #746 from codebrainz/markdown-webkit2gtk
Markdown: add support for webkit2gtk
Modified Paths: -------------- build/markdown.m4 markdown/src/Makefile.am markdown/src/viewer.c markdown/src/viewer.h
Modified: build/markdown.m4 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -49,13 +49,13 @@ AC_DEFUN([GP_CHECK_MARKDOWN], GTK_VERSION=2.16 WEBKIT_VERSION=1.1.13
- GP_CHECK_GTK3([webkit_package=webkitgtk-3.0], + GP_CHECK_GTK3([webkit_package=webkit2gtk-4.0], [webkit_package=webkit-1.0]) - GP_CHECK_PLUGIN_DEPS([markdown], [MARKDOWN], [$GP_GTK_PACKAGE >= ${GTK_VERSION} $webkit_package >= ${WEBKIT_VERSION} gthread-2.0]) + AM_CONDITIONAL([MARKDOWN_WEBKIT2], [test "$webkit_package" = webkit2gtk-4.0])
GP_COMMIT_PLUGIN_STATUS([Markdown])
Modified: markdown/src/Makefile.am 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -35,4 +35,8 @@ markdown_la_CFLAGS += $(LIBMARKDOWN_CFLAGS) markdown_la_LIBADD += $(LIBMARKDOWN_LIBS) endif
+if MARKDOWN_WEBKIT2 +markdown_la_CFLAGS += -DMARKDOWN_WEBKIT2 +endif + include $(top_srcdir)/build/cppcheck.mk
Modified: markdown/src/viewer.c 29 lines changed, 28 insertions(+), 1 deletions(-) =================================================================== @@ -22,7 +22,11 @@ #include "config.h" #include <string.h> #include <gtk/gtk.h> -#include <webkit/webkitwebview.h> +#ifdef MARKDOWN_WEBKIT2 +# include <webkit2/webkit2.h> +#else +# include <webkit/webkitwebview.h> +#endif #include <geanyplugin.h> #ifndef FULL_PRICE # include <mkdio.h> @@ -296,6 +300,18 @@ pop_scroll_pos(MarkdownViewer *self) return popped; }
+#ifdef MARKDOWN_WEBKIT2 +static void +on_webview_load_changed(MarkdownViewer *self, + WebKitLoadEvent load_event, + WebKitWebView *web_view) +{ + /* When the webkit is done loading, reset the scroll position. */ + if (load_event == WEBKIT_LOAD_FINISHED) { + pop_scroll_pos(self); + } +} +#else static void on_webview_load_status_notify(WebKitWebView *view, GParamSpec *pspec, MarkdownViewer *self) @@ -309,6 +325,7 @@ on_webview_load_status_notify(WebKitWebView *view, GParamSpec *pspec, pop_scroll_pos(self); } } +#endif
gchar * markdown_viewer_get_html(MarkdownViewer *self) @@ -388,13 +405,23 @@ markdown_viewer_update_view(MarkdownViewer *self) /* Connect a signal handler (only needed once) to restore the scroll * position once the webview is reloaded. */ if (self->priv->load_handle == 0) { +#ifdef MARKDOWN_WEBKIT2 + self->priv->load_handle = + g_signal_connect_swapped(WEBKIT_WEB_VIEW(self), "load-changed", + G_CALLBACK(on_webview_load_changed), self); +#else self->priv->load_handle = g_signal_connect_swapped(WEBKIT_WEB_VIEW(self), "notify::load-status", G_CALLBACK(on_webview_load_status_notify), self); +#endif }
+#ifdef MARKDOWN_WEBKIT2 + webkit_web_view_load_html(WEBKIT_WEB_VIEW(self), html, base_uri); +#else webkit_web_view_load_string(WEBKIT_WEB_VIEW(self), html, "text/html", self->priv->enc, base_uri); +#endif
g_free(base_uri); g_free(html);
Modified: markdown/src/viewer.h 6 lines changed, 5 insertions(+), 1 deletions(-) =================================================================== @@ -23,7 +23,11 @@ #define MARKDOWN_VIEWER_H 1
#include <gtk/gtk.h> -#include <webkit/webkitwebview.h> +#ifdef MARKDOWN_WEBKIT2 +# include <webkit2/webkit2.h> +#else +# include <webkit/webkitwebview.h> +#endif
G_BEGIN_DECLS
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org