- static char buf[BUFSIZ];
- Atom adummy;
- int idummy;
- unsigned long ldummy;
- unsigned char *p = NULL;
-
- XGetWindowProperty(dpy, c->xid,
- atoms[a], 0L, BUFSIZ, False, XA_STRING,
- &adummy, &idummy, &ldummy, &ldummy, &p);
- if (p)
- strncpy(buf, (char *)p, LENGTH(buf)-1);
- else
- buf[0] = '\0';
- XFree(p);
-
- return buf;
-}
-
-char *
-geturi(Client *c)
-{
- char *uri;
-
- if (!(uri = (char *)webkit_web_view_get_uri(c->view)))
- uri = "about:blank";
- return uri;
-}
-
-const gchar *
-getstyle(const char *uri)
-{
- int i;
-
- if (stylefile != NULL)
- return stylefile;
-
- for (i = 0; i < LENGTH(styles); i++) {
- if (styles[i].regex && !regexec(&(styles[i].re), uri, 0,
- NULL, 0))
- return styles[i].style;
- }
-
- 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)
-{
- Arg arg;
-
- webkit_web_view_stop_loading(w);
- arg = (Arg)PLUMB((char *)uri);
- spawn(c, &arg);
-}
-
-gboolean
-initdownload(WebKitWebView *view, WebKitDownload *o, Client *c)
-{
- Arg arg;
-
- updatewinid(c);
- arg = (Arg)DOWNLOAD((char *)webkit_download_get_uri(o), geturi(c));
- spawn(c, &arg);
- return FALSE;
-}
-
-void
-inspector(Client *c, const Arg *arg)
-{
- if (enableinspector) {
- if (c->isinspecting)
- webkit_web_inspector_close(c->inspector);
- else
- webkit_web_inspector_show(c->inspector);
- }
-}
-
-WebKitWebView *
-inspector_new(WebKitWebInspector *i, WebKitWebView *v, Client *c)
-{
- return WEBKIT_WEB_VIEW(webkit_web_view_new());
-}
-
-gboolean
-inspector_show(WebKitWebInspector *i, Client *c)
-{
- WebKitWebView *w;
-
- if (c->isinspecting)
- return false;
-
- w = webkit_web_inspector_get_web_view(i);
- gtk_paned_pack2(GTK_PANED(c->pane), GTK_WIDGET(w), TRUE, TRUE);
- gtk_widget_show(GTK_WIDGET(w));
- c->isinspecting = true;
-
- return true;
-}
-
-gboolean
-inspector_close(WebKitWebInspector *i, Client *c)
-{
- GtkWidget *w;
-
- if (!c->isinspecting)
- return false;
-
- w = GTK_WIDGET(webkit_web_inspector_get_web_view(i));
- gtk_widget_hide(w);
- gtk_widget_destroy(w);
- c->isinspecting = false;
-
- return true;
-}
-
-void
-inspector_finished(WebKitWebInspector *i, Client *c)
-{
- g_free(c->inspector);
-}
-
-gboolean
-keypress(GtkAccelGroup *group, GObject *obj, guint key, GdkModifierType mods,
- Client *c)
-{
- guint i;
- gboolean processed = FALSE;
-
- mods = CLEANMASK(mods);
- key = gdk_keyval_to_lower(key);
- updatewinid(c);
- for (i = 0; i < LENGTH(keys); i++) {
- if (key == keys[i].keyval
- && mods == keys[i].mod
- && keys[i].func) {
- keys[i].func(c, &(keys[i].arg));
- processed = TRUE;
- }