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 handleplumb(Client *c, WebKitWebView *w, const gchar *uri);
return "";
}
+void
+setstyle(Client *c, const char *style)
+{
+ WebKitWebSettings *settings = webkit_web_view_get_settings(c->view);
+
+ g_object_set(G_OBJECT(settings), "user-stylesheet-uri", style, NULL);
+}
+
void
handleplumb(Client *c, WebKitWebView *w, const gchar *uri)
{
WebKitWebFrame *frame;
WebKitWebDataSource *src;
WebKitNetworkRequest *request;
- WebKitWebSettings *set = webkit_web_view_get_settings(c->view);
SoupMessage *msg;
char *uri;
}
setatom(c, AtomUri, uri);
- if (enablestyles) {
- g_object_set(G_OBJECT(set), "user-stylesheet-uri",
- getstyle(uri), NULL);
- }
+ if (enablestyles)
+ setstyle(c, getstyle(uri));
break;
case WEBKIT_LOAD_FINISHED:
c->progress = 100;
if (!(ua = getenv("SURF_USERAGENT")))
ua = useragent;
g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
- if (enablestyles) {
- g_object_set(G_OBJECT(settings),
- "user-stylesheet-uri", getstyle("about:blank"),
- NULL);
- }
g_object_set(G_OBJECT(settings),
"auto-load-images", loadimages, NULL);
g_object_set(G_OBJECT(settings),
"default-font-size", defaultfontsize, NULL);
g_object_set(G_OBJECT(settings),
"resizable-text-areas", 1, NULL);
+ if (enablestyles)
+ setstyle(c, getstyle("about:blank"));
/*
* While stupid, CSS specifies that a pixel represents 1/96 of an inch.
void
togglestyle(Client *c, const Arg *arg)
{
- WebKitWebSettings *settings = webkit_web_view_get_settings(c->view);
-
enablestyles = !enablestyles;
- g_object_set(G_OBJECT(settings), "user-stylesheet-uri",
- enablestyles ? getstyle(geturi(c)) : "", NULL);
+ setstyle(c, enablestyles ? getstyle(geturi(c)) : "");
updatetitle(c);
}