X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=7fa0eb6330ba50c50a27e9fd354c555a0e7d21f1;hb=a283fa4bc93167c0f59fcd32bd19a6729d8e057d;hp=07c689e57fe8a2a4efcc81ed9a426a244d8f26e4;hpb=1bfda445acda48a3df57414f1f5ce0a225da9588;p=surf.git diff --git a/surf.c b/surf.c index 07c689e..7fa0eb6 100644 --- a/surf.c +++ b/surf.c @@ -126,6 +126,7 @@ static void spawn(Client *c, const Arg *arg); static void eval(Client *c, const Arg *arg); static void stop(Client *c, const Arg *arg); static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c); +static void toggle(Client *c, const Arg *arg); static void update(Client *c); static void updatewinid(Client *c); static void usage(void); @@ -453,8 +454,7 @@ void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c) { if(l) { c->linkhover = copystr(&c->linkhover, l); - } - else if(c->linkhover) { + } else if(c->linkhover) { free(c->linkhover); c->linkhover = NULL; } @@ -504,8 +504,7 @@ loaduri(Client *c, const Arg *arg) { /* prevents endless loop */ if(c->uri && strcmp(u, c->uri) == 0) { reload(c, &a); - } - else { + } else { webkit_web_view_load_uri(c->view, u); c->progress = 0; c->title = copystr(&c->title, u); @@ -891,6 +890,20 @@ titlechange(WebKitWebView *v, WebKitWebFrame *f, const char *t, Client *c) { update(c); } +void +toggle(Client *c, const Arg *arg) { + WebKitWebSettings *settings; + char *name = (char *)arg->v; + gboolean value; + Arg a = { .b = FALSE }; + + settings = webkit_web_view_get_settings(c->view); + g_object_get(G_OBJECT(settings), name, &value, NULL); + g_object_set(G_OBJECT(settings), name, !value, NULL); + + reload(c,&a); +} + void update(Client *c) { char *t; @@ -905,6 +918,7 @@ update(Client *c) { gtk_widget_hide_all(c->indicator); t = g_strdup(c->title); } + gtk_window_set_title(GTK_WINDOW(c->win), t); g_free(t); } @@ -944,6 +958,8 @@ int main(int argc, char *argv[]) { Arg arg; + memset(&arg, 0, sizeof(arg)); + /* command line args */ ARGBEGIN { case 'c': @@ -985,6 +1001,7 @@ main(int argc, char *argv[]) { newclient(); if(arg.v) loaduri(clients, &arg); + gtk_main(); cleanup();