static void gettogglestat(Client *c);
static void getpagestat(Client *c);
static char *geturi(Client *c);
-static gchar *getstyle(const char *uri);
+static const gchar *getstyle(const char *uri);
static void handleplumb(Client *c, WebKitWebView *w, const gchar *uri);
return uri;
}
-gchar *
+const gchar *
getstyle(const char *uri)
{
int i;
if (stylefile != NULL)
- return g_strconcat("file://", stylefile, NULL);
+ return stylefile;
for (i = 0; i < LENGTH(styles); i++) {
if (styles[i].regex && !regexec(&(styles[i].re), uri, 0,
NULL, 0))
- return g_strconcat("file://", styles[i].style, NULL);
+ return styles[i].style;
}
- return g_strdup("");
+
+ return "";
}
void
setup(void)
{
int i;
- char *proxy;
- char *new_proxy;
+ char *proxy, *new_proxy;
+ char *styledirfile, *stylepath;
SoupURI *puri;
SoupSession *s;
GError *error = NULL;
cookiefile = buildfile(cookiefile);
scriptfile = buildfile(scriptfile);
cachefolder = buildpath(cachefolder);
- styledir = buildpath(styledir);
if (stylefile == NULL) {
+ styledir = buildpath(styledir);
for (i = 0; i < LENGTH(styles); i++) {
if (regcomp(&(styles[i].re), styles[i].regex,
REG_EXTENDED)) {
styles[i].regex);
styles[i].regex = NULL;
}
- styles[i].style = buildfile(g_strconcat(styledir, "/",
- styles[i].style, NULL));
+ styledirfile = g_strconcat(styledir, "/",
+ styles[i].style, NULL);
+ stylepath = buildfile(styledirfile);
+ styles[i].style = g_strconcat("file://", stylepath,
+ NULL);
+ g_free(styledirfile);
+ g_free(stylepath);
}
+ g_free(styledir);
} else {
- stylefile = buildfile(stylefile);
+ stylepath = buildfile(stylefile);
+ stylefile = g_strconcat("file://", stylepath, NULL);
+ g_free(stylepath);
}
/* request handler */
togglestyle(Client *c, const Arg *arg)
{
WebKitWebSettings *settings = webkit_web_view_get_settings(c->view);
- char *uri;
enablestyles = !enablestyles;
- uri = enablestyles ? getstyle(geturi(c)) : g_strdup("");
- g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
+ g_object_set(G_OBJECT(settings), "user-stylesheet-uri",
+ enablestyles ? getstyle(geturi(c)) : "", NULL);
updatetitle(c);
}