diff -rup a/surf-0.4.1/config.def.h b/surf-0.4.1/config.def.h --- a/surf-0.4.1/config.def.h 2010-11-18 12:22:58.000000000 -0800 +++ b/surf-0.4.1/config.def.h 2010-11-18 16:12:33.724409462 -0800 @@ -2,10 +2,12 @@ static char *useragent = "Surf/"VERSION" (X11; U; Unix; en-US) AppleWebKit/531.2+ Compatible (Safari)"; static char *progress = "#FF0000"; static char *progress_trust = "#00FF00"; +static char *progress_proxy = "#D059F4"; static char *stylefile = ".surf/style.css"; static char *scriptfile = ".surf/script.js"; static char *cookiefile = ".surf/cookies.txt"; static time_t sessiontime = 3600; +static int using_proxy = 0; #define NOBACKGROUND 0 #define SETPROP(p, q) { .v = (char *[]){ "/bin/sh", "-c", \ @@ -35,6 +37,8 @@ static Key keys[] = { { MODKEY, GDK_o, source, { 0 } }, { MODKEY, GDK_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, { MODKEY, GDK_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, + { MODKEY, GDK_t, togglesb, { 0 } }, + { MODKEY, GDK_x, toggleproxy,{ .b = FALSE } }, { MODKEY, GDK_n, find, { .b = TRUE } }, { MODKEY|GDK_SHIFT_MASK,GDK_n, find, { .b = FALSE } }, }; diff -rup a/surf-0.4.1/surf.c b/surf-0.4.1/surf.c --- a/surf-0.4.1/surf.c 2010-11-18 12:22:58.000000000 -0800 +++ b/surf-0.4.1/surf.c 2010-11-18 16:12:33.732397070 -0800 @@ -38,6 +38,7 @@ typedef struct Client { char *title, *linkhover; const char *uri, *needle; gint progress; + gint indicator_shown; struct Client *next; gboolean zoomed; } Client; @@ -105,6 +106,8 @@ static void source(Client *c, const Arg static void spawn(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 toggleproxy(Client *c, const Arg *arg); +static void togglesb(Client *c, const Arg *arg); static void update(Client *c); static void updatewinid(Client *c); static void usage(void); @@ -245,13 +248,22 @@ drawindicator(Client *c) { GtkWidget *w; GdkGC *gc; GdkColor fg; + char *color_string; uri = geturi(c); w = c->indicator; width = c->progress * w->allocation.width / 100; gc = gdk_gc_new(w->window); - gdk_color_parse(strstr(uri, "https://") == uri ? - progress_trust : progress, &fg); + + if((strstr(uri, "https://") == uri)) + color_string = g_strdup(progress_trust); + + if(using_proxy) + color_string = g_strdup(progress_proxy); + else + color_string = g_strdup(progress); + + gdk_color_parse(color_string, &fg); gdk_gc_set_rgb_fg_color(gc, &fg); gdk_draw_rectangle(w->window, w->style->bg_gc[GTK_WIDGET_STATE(w)], @@ -259,6 +271,7 @@ drawindicator(Client *c) { gdk_draw_rectangle(w->window, gc, TRUE, 0, 0, width, w->allocation.height); g_object_unref(gc); + g_free(color_string); } gboolean @@ -511,6 +524,7 @@ newclient(void) { c->title = NULL; c->next = clients; + c->indicator_shown = 0; clients = c; if(showxid) { gdk_display_sync(gtk_widget_get_display(c->win)); @@ -702,6 +716,7 @@ setup(void) { if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) { new_proxy = g_strrstr(proxy, "http://") ? g_strdup(proxy) : g_strdup_printf("http://%s", proxy); + using_proxy = 1; puri = soup_uri_new(new_proxy); g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL); soup_uri_free(puri); @@ -751,15 +766,62 @@ titlechange(WebKitWebView *v, WebKitWebF } void +toggleproxy(Client *c, const Arg *arg) { + SoupSession *s; + char *proxy; + SoupURI *puri; + + s = webkit_get_default_session(); + + if((proxy = getenv("http_proxy")) && strcmp(proxy, "") && !using_proxy) { + using_proxy = 1; + puri = soup_uri_new(proxy); + g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL); + soup_uri_free(puri); + } else { + using_proxy = 0; + g_object_set(G_OBJECT(s), "proxy-uri", (SoupURI *)NULL, NULL); + } + + reload(c, arg); + + return; +} + +void +togglesb(Client *c, const Arg *arg) { + + if(c->indicator_shown) { + gtk_widget_hide_all(c->indicator); + c->indicator_shown = 0; + } else { + gtk_widget_show(c->indicator); + c->indicator_shown = 1; + } + + return; + +} + + +void update(Client *c) { char *t; - if(c->progress != 100) + if(c->progress != 100) { + drawindicator(c); + gtk_widget_show(c->indicator); t = g_strdup_printf("[%i%%] %s", c->progress, c->title); - else if(c->linkhover) + } + else if(c->linkhover) { t = g_strdup(c->linkhover); - else + c->indicator_shown = 0; + } + else { + gtk_widget_hide_all(c->indicator); t = g_strdup(c->title); + c->indicator_shown = 0; + } drawindicator(c); gtk_window_set_title(GTK_WINDOW(c->win), t); g_free(t);