summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2015-11-20 00:13:07 +0100
committerQuentin Rameau <quinq@fifth.space>2015-11-20 00:34:22 +0100
commitba8617e4ee9ff35a45059930ef611cb85ed33af2 (patch)
tree857154ca3218b67589825b77b77cb7dc78a06366
parent701815a5f22c76dafb6b25c08d0ceb87252782c0 (diff)
downloadsurf-ba8617e4ee9ff35a45059930ef611cb85ed33af2.tar.gz
surf-ba8617e4ee9ff35a45059930ef611cb85ed33af2.tar.bz2
surf-ba8617e4ee9ff35a45059930ef611cb85ed33af2.zip
Adapt setstyle()
We can't anymore pass a simple path to a stylefile, we have to read the entire file to create a stylesheet and apply it to the view.
-rw-r--r--surf.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/surf.c b/surf.c
index 5e1aa8d..f227d4c 100644
--- a/surf.c
+++ b/surf.c
@@ -135,7 +135,7 @@ static void gettogglestat(Client *c);
static void getpagestat(Client *c);
static char *geturi(Client *c);
static const gchar *getstyle(const char *uri);
-static void setstyle(Client *c, const char *style);
+static void setstyle(Client *c, const char *stylefile);
static void handleplumb(Client *c, const gchar *uri);
@@ -670,11 +670,23 @@ getstyle(const char *uri)
}
void
-setstyle(Client *c, const char *style)
+setstyle(Client *c, const char *stylefile)
{
- WebKitWebSettings *settings = webkit_web_view_get_settings(c->view);
+ gchar *style;
+
+ if (!g_file_get_contents(stylefile, &style, NULL, NULL)) {
+ fprintf(stderr, "Could not read style file: %s\n", stylefile);
+ return;
+ }
+
+ webkit_user_content_manager_add_style_sheet(
+ webkit_web_view_get_user_content_manager(c->view),
+ webkit_user_style_sheet_new(style,
+ WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
+ WEBKIT_USER_STYLE_LEVEL_USER,
+ NULL, NULL));
- g_object_set(G_OBJECT(settings), "user-stylesheet-uri", style, NULL);
+ g_free(style);
}
void