* Nick 2013-02-16 15:12
> +static void
> +togglestyle(Client *c, const Arg *arg) {
> + WebKitWebSettings *settings;
> + char *uri;
> +
> + settings = webkit_web_view_get_settings(c->view);
> + g_object_get(G_OBJECT(settings), "user-stylesheet-uri", &uri, NULL);
> + uri = uri[0] ? g_strdup("") : g_strconcat("file://", stylefile, NULL);
> + g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
> +
> + update(c);
> +}
I use this all the time, slightly differently though. I have "text
styles" for "day" and "night" since the light conditions make difference
for convinient reading. You seem to ignore the Arg function argument,
which I use for saying which stylw. In combination with a modified
simplyread() Javascript heurisic someone posted here a while ago,
browsing is ok.
Attached the relevant code.
cheers
--s.
{MODKEY, GDK_t, setstyle, { .v =
"/home/stanio/.surf/text_style.css" } },
{MODKEY|GDK_SHIFT_MASK,GDK_t, setstyle, { .v =
"/home/stanio/.surf/text_style_day.css" } },
{MODKEY, GDK_w, setstyle, { .v = (const char *)NULL} },
setstyle(Client *c, const Arg *arg){
WebKitWebSettings *settings;
char *uri, *customstylefile;
customstylefile = arg->v==NULL?stylefile:(char *)arg->v;
settings = webkit_web_view_get_settings(c->view);
uri = g_strconcat("file://", customstylefile, NULL);
g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
}