diff options
author | Josh Rickmar <jrick@devio.us> | 2012-11-28 09:14:28 -0500 |
---|---|---|
committer | Josh Rickmar <jrick@devio.us> | 2012-11-28 09:14:28 -0500 |
commit | 62e3b73bf508dfe5d5ca65f6dc9c50d6aa461d7d (patch) | |
tree | 943730a77d62fe5c66a82392da6100103e204dd4 | |
parent | f43a052dee51a3269372782bb53b8fa3dadd7e95 (diff) | |
download | xombrero-62e3b73bf508dfe5d5ca65f6dc9c50d6aa461d7d.tar.gz |
Add a button to the toolbar to toggle the proxy
-rw-r--r-- | settings.c | 6 | ||||
-rw-r--r-- | xombrero.c | 29 | ||||
-rw-r--r-- | xombrero.h | 1 |
3 files changed, 35 insertions, 1 deletions
diff --git a/settings.c b/settings.c index 3c69c3c..0fcc262 100644 --- a/settings.c +++ b/settings.c @@ -3023,9 +3023,13 @@ setup_proxy(char *uri) if (proxy_uri != NULL && SOUP_URI_VALID_FOR_HTTP(proxy_uri)) { g_object_set(session, "proxy-uri", proxy_uri, (char *)NULL); - TAILQ_FOREACH(t, &tabs, entry) + TAILQ_FOREACH(t, &tabs, entry) { gtk_label_set_text(GTK_LABEL(t->sbe.proxy), "proxy"); + gtk_widget_show(t->proxy_toggle); + button_set_stockid(t->proxy_toggle, + GTK_STOCK_CONNECT); + } } } } diff --git a/xombrero.c b/xombrero.c index caea6aa..7e3003a 100644 --- a/xombrero.c +++ b/xombrero.c @@ -1600,6 +1600,15 @@ js_toggle_cb(GtkWidget *w, struct tab *t) toggle_js(t, &a); } +void +proxy_toggle_cb(GtkWidget *w, struct tab *t) +{ + struct karg args = {0}; + + args.i = XT_PRXY_TOGGLE; + proxy_cmd(t, &args); +} + int toggle_src(struct tab *t, struct karg *args) { @@ -3286,6 +3295,8 @@ char *http_proxy_save; /* not a setting, used to toggle */ int proxy_cmd(struct tab *t, struct karg *args) { + struct tab *tt; + DNPRINTF(XT_D_CMD, "%s: tab %d\n", __func__, t->tab_id); if (t == NULL) @@ -3293,6 +3304,8 @@ proxy_cmd(struct tab *t, struct karg *args) /* setup */ if (http_proxy) { + TAILQ_FOREACH(tt, &tabs, entry) + gtk_widget_show(t->proxy_toggle); if (http_proxy_save) g_free(http_proxy_save); http_proxy_save = g_strdup(http_proxy); @@ -3304,6 +3317,8 @@ proxy_cmd(struct tab *t, struct karg *args) else show_oops(t, "proxy is currently disabled"); } else if (args->i & XT_PRXY_TOGGLE) { + TAILQ_FOREACH(tt, &tabs, entry) + gtk_widget_show(t->proxy_toggle); if (http_proxy_save == NULL && http_proxy == NULL) { show_oops(t, "can't toggle proxy"); goto done; @@ -3311,9 +3326,13 @@ proxy_cmd(struct tab *t, struct karg *args) if (http_proxy) { setup_proxy(NULL); show_oops(t, "http proxy disabled"); + button_set_stockid(t->proxy_toggle, + GTK_STOCK_DISCONNECT); } else { setup_proxy(http_proxy_save); show_oops(t, "http_proxy = %s", http_proxy); + button_set_stockid(t->proxy_toggle, + GTK_STOCK_CONNECT); } } done: @@ -7240,6 +7259,14 @@ create_toolbar(struct tab *t) G_CALLBACK(js_toggle_cb), t); gtk_box_pack_start(GTK_BOX(b), t->js_toggle, FALSE, FALSE, 0); + /* toggle proxy button */ + t->proxy_toggle = create_button("Proxy-Toggle", proxy_uri ? + GTK_STOCK_CONNECT : GTK_STOCK_DISCONNECT, 0); + gtk_widget_set_sensitive(t->proxy_toggle, TRUE); + g_signal_connect(G_OBJECT(t->proxy_toggle), "clicked", + G_CALLBACK(proxy_toggle_cb), t); + gtk_box_pack_start(GTK_BOX(b), t->proxy_toggle, FALSE, FALSE, 0); + t->uri_entry = gtk_entry_new(); g_signal_connect(G_OBJECT(t->uri_entry), "activate", G_CALLBACK(activate_uri_entry_cb), t); @@ -7881,6 +7908,8 @@ create_new_tab(char *title, struct undo *u, int focus, int position) } if (!fancy_bar || (search_string == NULL || strlen(search_string) == 0)) gtk_widget_hide(t->search_entry); + if (!proxy_uri) + gtk_widget_hide(t->proxy_toggle); /* compact tab bar */ t->tab_elems.label = gtk_label_new(title); diff --git a/xombrero.h b/xombrero.h index 42bb8e5..1b36bf5 100644 --- a/xombrero.h +++ b/xombrero.h @@ -239,6 +239,7 @@ struct tab { GtkWidget *stop; GtkWidget *gohome; GtkWidget *js_toggle; + GtkWidget *proxy_toggle; GtkEntryCompletion *completion; guint tab_id; WebKitWebView *wv; |