Style inquisition.
This commit is contained in:
parent
bd5bbb7fc3
commit
69004b2ff6
56
surf.c
56
surf.c
|
@ -169,6 +169,7 @@ beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
|
||||||
WebKitNetworkRequest *req, WebKitNetworkResponse *resp,
|
WebKitNetworkRequest *req, WebKitNetworkResponse *resp,
|
||||||
gpointer d) {
|
gpointer d) {
|
||||||
const gchar *uri = webkit_network_request_get_uri(req);
|
const gchar *uri = webkit_network_request_get_uri(req);
|
||||||
|
|
||||||
if(g_str_has_suffix(uri, "/favicon.ico"))
|
if(g_str_has_suffix(uri, "/favicon.ico"))
|
||||||
webkit_network_request_set_uri(req, "about:blank");
|
webkit_network_request_set_uri(req, "about:blank");
|
||||||
}
|
}
|
||||||
|
@ -291,7 +292,8 @@ evalscript(JSContextRef js, char *script, char* scriptname) {
|
||||||
|
|
||||||
jsscript = JSStringCreateWithUTF8CString(script);
|
jsscript = JSStringCreateWithUTF8CString(script);
|
||||||
jsscriptname = JSStringCreateWithUTF8CString(scriptname);
|
jsscriptname = JSStringCreateWithUTF8CString(scriptname);
|
||||||
JSEvaluateScript(js, jsscript, JSContextGetGlobalObject(js), jsscriptname, 0, &exception);
|
JSEvaluateScript(js, jsscript, JSContextGetGlobalObject(js),
|
||||||
|
jsscriptname, 0, &exception);
|
||||||
JSStringRelease(jsscript);
|
JSStringRelease(jsscript);
|
||||||
JSStringRelease(jsscriptname);
|
JSStringRelease(jsscriptname);
|
||||||
}
|
}
|
||||||
|
@ -302,7 +304,8 @@ runscript(WebKitWebFrame *frame) {
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
if(g_file_get_contents(scriptfile, &script, NULL, &error)) {
|
if(g_file_get_contents(scriptfile, &script, NULL, &error)) {
|
||||||
evalscript(webkit_web_frame_get_global_context(frame), script, scriptfile);
|
evalscript(webkit_web_frame_get_global_context(frame),
|
||||||
|
script, scriptfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,10 +313,15 @@ static void
|
||||||
clipboard(Client *c, const Arg *arg) {
|
clipboard(Client *c, const Arg *arg) {
|
||||||
gboolean paste = *(gboolean *)arg;
|
gboolean paste = *(gboolean *)arg;
|
||||||
|
|
||||||
if(paste)
|
if(paste) {
|
||||||
gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteuri, c);
|
gtk_clipboard_request_text(
|
||||||
else
|
gtk_clipboard_get(GDK_SELECTION_PRIMARY),
|
||||||
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), c->linkhover ? c->linkhover : geturi(c), -1);
|
pasteuri, c);
|
||||||
|
} else {
|
||||||
|
gtk_clipboard_set_text(
|
||||||
|
gtk_clipboard_get(GDK_SELECTION_PRIMARY),
|
||||||
|
c->linkhover ? c->linkhover : geturi(c), -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -426,11 +434,13 @@ getatom(Client *c, int a) {
|
||||||
XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
|
XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
|
||||||
atoms[a], 0L, BUFSIZ, False, XA_STRING,
|
atoms[a], 0L, BUFSIZ, False, XA_STRING,
|
||||||
&adummy, &idummy, &ldummy, &ldummy, &p);
|
&adummy, &idummy, &ldummy, &ldummy, &p);
|
||||||
if(p)
|
if(p) {
|
||||||
strncpy(buf, (char *)p, LENGTH(buf)-1);
|
strncpy(buf, (char *)p, LENGTH(buf)-1);
|
||||||
else
|
} else {
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
|
}
|
||||||
XFree(p);
|
XFree(p);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,10 +888,11 @@ progresschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
|
||||||
static void
|
static void
|
||||||
reload(Client *c, const Arg *arg) {
|
reload(Client *c, const Arg *arg) {
|
||||||
gboolean nocache = *(gboolean *)arg;
|
gboolean nocache = *(gboolean *)arg;
|
||||||
if(nocache)
|
if(nocache) {
|
||||||
webkit_web_view_reload_bypass_cache(c->view);
|
webkit_web_view_reload_bypass_cache(c->view);
|
||||||
else
|
} else {
|
||||||
webkit_web_view_reload(c->view);
|
webkit_web_view_reload(c->view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1036,6 +1047,19 @@ toggle(Client *c, const Arg *arg) {
|
||||||
reload(c,&a);
|
reload(c,&a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gettogglestat(Client *c){
|
gettogglestat(Client *c){
|
||||||
gboolean value;
|
gboolean value;
|
||||||
|
@ -1188,15 +1212,3 @@ main(int argc, char *argv[]) {
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue