Switch to WebKit 4.0 API
This commit is contained in:
parent
8575fec162
commit
8aeec229f3
@ -35,7 +35,7 @@ PKG_CHECK_MODULES([GOBJECT], [gobject-2.0])
|
||||
PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.12])
|
||||
PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
|
||||
PKG_CHECK_MODULES([LIBXSLT], [libexslt])
|
||||
PKG_CHECK_MODULES([WEBKIT], [webkit2gtk-3.0])
|
||||
PKG_CHECK_MODULES([WEBKIT], [webkit2gtk-4.0])
|
||||
PKG_CHECK_MODULES([GDA], [libgda-5.0 libgda-sqlite-5.0])
|
||||
PKG_CHECK_MODULES([SWE_GLIB], [swe-glib >= 2.1.0])
|
||||
|
||||
|
27
src/ag-app.c
27
src/ag-app.c
@ -9,7 +9,7 @@
|
||||
#include "astrognome.h"
|
||||
|
||||
typedef struct _AgAppPrivate {
|
||||
WebKitWebViewGroup *web_view_group;
|
||||
WebKitUserContentManager *manager;
|
||||
} AgAppPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(AgApp, ag_app, GTK_TYPE_APPLICATION);
|
||||
@ -58,7 +58,7 @@ ag_app_create_window(AgApp *app)
|
||||
GtkWidget *window;
|
||||
AgAppPrivate *priv = ag_app_get_instance_private(app);
|
||||
|
||||
window = ag_window_new(app, priv->web_view_group);
|
||||
window = ag_window_new(app, priv->manager);
|
||||
gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW(window));
|
||||
gtk_widget_show_all(window);
|
||||
|
||||
@ -424,13 +424,14 @@ ag_app_new(void)
|
||||
static void
|
||||
ag_app_init(AgApp *app)
|
||||
{
|
||||
AgAppPrivate *priv;
|
||||
GBytes *css_data;
|
||||
const gchar *css_source;
|
||||
gsize css_length;
|
||||
AgAppPrivate *priv;
|
||||
GBytes *css_data;
|
||||
const gchar *css_source;
|
||||
gsize css_length;
|
||||
WebKitUserStyleSheet *stylesheet;
|
||||
|
||||
priv = ag_app_get_instance_private(app);
|
||||
priv->web_view_group = webkit_web_view_group_new(NULL);
|
||||
priv->manager = webkit_user_content_manager_new();
|
||||
|
||||
css_data = g_resources_lookup_data(
|
||||
"/eu/polonkai/gergely/Astrognome/ui/chart-default.css",
|
||||
@ -439,14 +440,14 @@ ag_app_init(AgApp *app)
|
||||
);
|
||||
|
||||
if ((css_source = g_bytes_get_data(css_data, &css_length)) != NULL) {
|
||||
webkit_web_view_group_add_user_style_sheet(
|
||||
priv->web_view_group,
|
||||
stylesheet = webkit_user_style_sheet_new(
|
||||
css_source,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
WEBKIT_INJECTED_CONTENT_FRAMES_TOP_ONLY
|
||||
WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
|
||||
WEBKIT_USER_STYLE_LEVEL_USER,
|
||||
NULL, NULL
|
||||
);
|
||||
webkit_user_content_manager_add_style_sheet(priv->manager, stylesheet);
|
||||
webkit_user_style_sheet_unref(stylesheet);
|
||||
}
|
||||
|
||||
g_bytes_unref(css_data);
|
||||
|
@ -393,9 +393,14 @@ ag_window_redraw_aspect_table(AgWindow *window)
|
||||
void
|
||||
ag_window_redraw_chart(AgWindow *window)
|
||||
{
|
||||
gsize length;
|
||||
GError *err = NULL;
|
||||
AgWindowPrivate *priv = ag_window_get_instance_private(window);
|
||||
gchar *svg_content = ag_chart_create_svg(priv->chart, NULL, &err);
|
||||
gchar *svg_content = ag_chart_create_svg(
|
||||
priv->chart,
|
||||
&length,
|
||||
&err
|
||||
);
|
||||
|
||||
if (svg_content == NULL) {
|
||||
ag_app_message_dialog(
|
||||
@ -405,11 +410,16 @@ ag_window_redraw_chart(AgWindow *window)
|
||||
err->message
|
||||
);
|
||||
} else {
|
||||
webkit_web_view_load_html(
|
||||
GBytes *content;
|
||||
|
||||
content = g_bytes_new_take(svg_content, length);
|
||||
|
||||
webkit_web_view_load_bytes(
|
||||
WEBKIT_WEB_VIEW(priv->chart_web_view),
|
||||
svg_content, NULL
|
||||
content, "image/svg+xml",
|
||||
"UTF-8", NULL
|
||||
);
|
||||
g_free(svg_content);
|
||||
g_bytes_unref(content);
|
||||
}
|
||||
|
||||
ag_window_redraw_aspect_table(window);
|
||||
@ -1671,12 +1681,14 @@ ag_window_configure_event_cb(GtkWidget *widget,
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
ag_window_new(AgApp *app, WebKitWebViewGroup *web_view_group)
|
||||
ag_window_new(AgApp *app, WebKitUserContentManager *manager)
|
||||
{
|
||||
AgWindow *window = g_object_new(AG_TYPE_WINDOW, NULL);
|
||||
AgWindowPrivate *priv = ag_window_get_instance_private(window);
|
||||
|
||||
priv->chart_web_view = webkit_web_view_new_with_group(web_view_group);
|
||||
priv->chart_web_view = webkit_web_view_new_with_user_content_manager(
|
||||
manager
|
||||
);
|
||||
gtk_container_add(GTK_CONTAINER(priv->tab_chart), priv->chart_web_view);
|
||||
|
||||
// TODO: translate this error message!
|
||||
|
@ -41,7 +41,7 @@ struct _AgWindowClass {
|
||||
|
||||
GType ag_window_get_type(void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *ag_window_new(AgApp *app, WebKitWebViewGroup *web_view_group);
|
||||
GtkWidget *ag_window_new(AgApp *app, WebKitUserContentManager *manager);
|
||||
|
||||
void ag_window_set_chart(AgWindow *window,
|
||||
AgChart *chart);
|
||||
|
Loading…
Reference in New Issue
Block a user