// Apply per-site settings when going to new sites static void persite(webview * const view, const char * const url) { tab * const cur = findtab(view); if (!cur || cur->state != TS_WEB) return; char site[120]; url2site(url, site, 120, true); setting *s = NULL; if (cur->js == TRI_AUTO) { s = getSetting("general.javascript", site); view->setBool(WK_SETTING_JS, s->val.u); } if (cur->css == TRI_AUTO) { s = getSetting("general.css", site); view->setBool(WK_SETTING_CSS, s->val.u); } if (cur->img == TRI_AUTO) { s = getSetting("general.images", site); view->setBool(WK_SETTING_IMG, s->val.u); } s = getSetting("general.localstorage", site); view->setBool(WK_SETTING_LOCALSTORAGE, s->val.u); s = getSetting("user.css", site); view->setChar(WK_SETTING_USER_CSS, s->val.c); }
static void statuscb(webview * const view) { tab * const cur = findtab(view); if (!cur || cur->state != TS_WEB) return; g->status->redraw(); }
static void progresscb(webview * const view, float val) { tab * const cur = findtab(view); if (!cur || cur->state != TS_WEB) return; val *= 100; cur->progress = val; if (cur == &g->tabs[g->curtab]) g->url->redraw(); // If this is a new one, reset the favicon if (val < 15) { if (cur->icon) delete cur->icon; cur->icon = NULL; g->url->url->input().image(NULL); } // Is it a finished about:config? A more generic mechanism may be worth it later. if (val > 99 && cur->url && !strcmp(cur->url, "about:config")) { cur->web->bindEvent("input", "button", "click", configchange); } }
static void faviconcb(webview * const view) { tab * const cur = findtab(view); if (!cur || cur->state != TS_WEB) return; if (cur->icon) delete cur->icon; cur->icon = wk_get_favicon(cur->url); g->url->url->input().image(NULL); if (!cur->icon) return; // It may be in a wrong resolution - resize in that case if (cur->icon->w() != 16 || cur->icon->h() != 16) { Fl_RGB_Image *old = cur->icon; cur->icon = (Fl_RGB_Image *) old->copy(16, 16); delete old; } if (g->tabs[g->curtab].web == view) { g->url->url->input().image(cur->icon); g->url->redraw(); } g->tabwidget->redraw(); }
static char* fswalk1(Fid *fid, char *name, void*) { int i; Tab *t; vlong h; if(fid->qid.path != 0){ /* nothing in child directory */ if(strcmp(name, "..") == 0){ if((t = findtab(fid->qid.path)) != nil) t->ref--; fid->qid.path = 0; return nil; } return "path not found"; } /* root */ if(strcmp(name, "..") == 0) return nil; for(i=0; i<ntab; i++) if(strcmp(tab[i].name, name) == 0){ tab[i].ref++; fid->qid.path = tab[i].qid; return nil; } h = hash(name); if(findtab(h) != nil) return "hash collision"; /* create it */ if(ntab == mtab){ if(mtab == 0) mtab = 16; else mtab *= 2; tab = erealloc9p(tab, sizeof(tab[0])*mtab); } tab[ntab].qid = h; fid->qid.path = tab[ntab].qid; tab[ntab].name = estrdup9p(name); tab[ntab].time = time(0); tab[ntab].ref = 1; ntab++; return nil; }
static void errorcb(webview * const view, const char *err) { tab * const cur = findtab(view); if (!cur || cur->state != TS_WEB) return; cur->errors->add(err, 0); refresherr(cur->errors); }
static char* fsclone(Fid *fid, Fid*, void*) { Tab *t; if((t = findtab(fid->qid.path)) != nil) t->ref++; return nil; }
static void fsstat(Req *r) { Tab *t; vlong qid; qid = r->fid->qid.path; if(qid == 0) dirgen(-1, &r->d, nil); else{ if((t = findtab(qid)) == nil){ respond(r, "path not found (???)"); return; } dirgen(t-tab, &r->d, nil); } respond(r, nil); }
static void fsclunk(Fid *fid) { Tab *t; vlong qid; qid = fid->qid.path; if(qid == 0) return; if((t = findtab(qid)) == nil){ fprint(2, "warning: cannot find %llux\n", qid); return; } if(--t->ref == 0){ free(t->name); tab[t-tab] = tab[--ntab]; }else if(t->ref < 0) fprint(2, "warning: negative ref count for %s\n", t->name); }