X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=fc613815a295142994e2bc16d8e6d1068a197794;hb=bd5bbb7fc352a4f1f5c54731e6c8ef01ff91d002;hp=1c999dd09097e15847b60926b03c88af843766d1;hpb=3c1ed5d56af13f09a81beb00c59464972c36b2f0;p=surf.git diff --git a/surf.c b/surf.c index 1c999dd..fc61381 100644 --- a/surf.c +++ b/surf.c @@ -52,12 +52,6 @@ typedef struct Client { gboolean zoomed, fullscreen, isinspecting, sslfailed; } Client; -typedef struct { - char *label; - void (*func)(Client *c, const Arg *arg); - const Arg arg; -} Item; - typedef struct { guint mod; guint keyval; @@ -83,8 +77,8 @@ static GdkNativeWindow embed = 0; static gboolean showxid = FALSE; static char winid[64]; static gboolean usingproxy = 0; -static char togglestat[5]; -static char pagestat[2]; +static char togglestat[6]; +static char pagestat[3]; static void beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r, WebKitNetworkRequest *req, @@ -159,6 +153,7 @@ 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 togglestyle(Client *c, const Arg *arg); static void update(Client *c); static void updatewinid(Client *c); static void usage(void); @@ -1044,6 +1039,7 @@ toggle(Client *c, const Arg *arg) { static void gettogglestat(Client *c){ gboolean value; + char *uri; WebKitWebSettings *settings = webkit_web_view_get_settings(c->view); g_object_get(G_OBJECT(settings), "enable-caret-browsing", @@ -1059,13 +1055,25 @@ gettogglestat(Client *c){ g_object_get(G_OBJECT(settings), "enable-plugins", &value, NULL); togglestat[3] = value? 'V': 'v'; - togglestat[4] = '\0'; + g_object_get(G_OBJECT(settings), "user-stylesheet-uri", &uri, NULL); + togglestat[4] = uri[0] ? 'M': 'm'; + + togglestat[5] = '\0'; } static void getpagestat(Client *c) { - pagestat[0] = c->sslfailed ? 'U' : 'T'; + const char *uri = geturi(c); + + if(strstr(uri, "https://") == uri) { + pagestat[0] = c->sslfailed ? 'U' : 'T'; + } else { + pagestat[0] = '-'; + } + pagestat[1] = usingproxy ? 'P' : '-'; + pagestat[2] = '\0'; + } static void @@ -1180,3 +1188,15 @@ main(int argc, char *argv[]) { 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); +}