int main(int argc, char *argv[]) { gchar *uri = NULL, *file = NULL; SoupSession *s; Client *c; int o; const gchar *home, *filename; gtk_init(NULL, NULL); if (!g_thread_supported()) g_thread_init(NULL); setup(); while((o = getopt(argc, argv, "vhxeu:f:")) != -1) switch(o) { case 'x': showxid = TRUE; break; case 'e': showxid = TRUE; embed = TRUE; break; case 'u': if(!(uri = optarg)) goto argerr; c = newclient(); loaduri(c, uri); updatetitle(c); break; case 'f': if(!(file = optarg)) goto argerr; c = newclient(); loadfile(c, file); updatetitle(c); break; case 'v': die("surf-"VERSION", © 2009 surf engineers, see LICENSE for details\n"); break; argerr: default: puts("surf - simple browser"); die("usage: surf [-e] [-x] [-u uri] [-f file]\n"); return EXIT_FAILURE; } if(optind != argc) goto argerr; if(!clients) newclient(); /* cookie persistance */ s = webkit_get_default_session(); home = g_get_home_dir(); filename = g_build_filename(home, ".surf-cookies", NULL); cookiejar = soup_cookie_jar_text_new(filename, FALSE); soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar)); gtk_main(); cleanup(); return EXIT_SUCCESS; }
void progresschange(WebKitWebView* view, gint p, gpointer d) { Client *c = (Client *)d; c->progress = p; updatetitle(c); }
void titlechange(WebKitWebView *v, WebKitWebFrame *f, const gchar *t, gpointer d) { Client *c = (Client *)d; if(c->title) g_free(c->title); c->title = g_strdup(t); updatetitle(c); }
void linkhover(WebKitWebView* page, const gchar* t, const gchar* l, gpointer d) { Client *c = (Client *)d; if(l) gtk_window_set_title(GTK_WINDOW(c->win), l); else updatetitle(c); }
void manage(Window w, XWindowAttributes *wa) { Client *c, *t; Window trans; c = emallocz(sizeof(Client)); c->win = w; c->x = wa->x; c->y = wa->y; c->w = wa->width; c->h = wa->height; if(c->w == sw && c->h == sh) { c->border = 0; c->x = sx; c->y = sy; } else { c->border = BORDERPX; if(c->x + c->w + 2 * c->border > sx + sw) c->x = sx + sw - c->w - 2 * c->border; if(c->y + c->h + 2 * c->border > sy + sh) c->y = sy + sh - c->h - 2 * c->border; if(c->x < sx) c->x = sx; if(c->y < sy) c->y = sy; } updatesizehints(c); XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XGetTransientForHint(dpy, c->win, &trans); XSetWindowBorder(dpy, c->win, normcol); updatetitle(c); if((t = getclient(trans))) c->view = t->view; else c->view = view; if(clients) clients->prev = c; c->next = clients; c->snext = stack; stack = clients = c; XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); XMapWindow(dpy, c->win); setclientstate(c, NormalState); if(c->view == view) focus(c); arrange(); }
webview::webview(QWidget *parent) : QWebView(parent) { setAttribute(Qt::WA_DeleteOnClose); settings()->setAttribute(QWebSettings::DnsPrefetchEnabled , true); settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows , true); settings()->setAttribute(QWebSettings::JavascriptCanCloseWindows , true); settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard , true); settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled , true); settings()->setAttribute(QWebSettings::LocalStorageEnabled , true); settings()->setAttribute(QWebSettings::JavaEnabled , true); settings()->setAttribute(QWebSettings::LocalStorageEnabled , true); settings()->enablePersistentStorage(QApplication::applicationDirPath()); QObject::connect(this , SIGNAL(urlChanged(QUrl)) , this , SLOT(addhistory(QUrl))); QObject::connect(this , SIGNAL(titleChanged(QString)) , this , SLOT(updatetitle(QString))); }