Removed progress indicator
This removes the progress indicator and replaces it with letters in the window title. T/U: Trusted, Untrusted P/-: Proxy, No proxy Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
parent
27dac4a157
commit
3c1ed5d56a
2 changed files with 13 additions and 72 deletions
|
@ -2,19 +2,12 @@
|
||||||
static char *useragent = "Mozilla/5.0 (X11; U; Unix; en-US) "
|
static char *useragent = "Mozilla/5.0 (X11; U; Unix; en-US) "
|
||||||
"AppleWebKit/537.15 (KHTML, like Gecko) Chrome/24.0.1295.0 "
|
"AppleWebKit/537.15 (KHTML, like Gecko) Chrome/24.0.1295.0 "
|
||||||
"Safari/537.15 Surf/"VERSION;
|
"Safari/537.15 Surf/"VERSION;
|
||||||
static char *progress = "#0000FF";
|
|
||||||
static char *progress_untrust = "#FF0000";
|
|
||||||
static char *progress_trust = "#00FF00";
|
|
||||||
static char *progress_proxy = "#FFFF00";
|
|
||||||
static char *progress_proxy_trust = "#66FF00";
|
|
||||||
static char *progress_proxy_untrust = "#FF6600";
|
|
||||||
static char *stylefile = "~/.surf/style.css";
|
static char *stylefile = "~/.surf/style.css";
|
||||||
static char *scriptfile = "~/.surf/script.js";
|
static char *scriptfile = "~/.surf/script.js";
|
||||||
static char *cookiefile = "~/.surf/cookies.txt";
|
static char *cookiefile = "~/.surf/cookies.txt";
|
||||||
static time_t sessiontime = 3600;
|
static time_t sessiontime = 3600;
|
||||||
static char *cafile = "/etc/ssl/certs/ca-certificates.crt";
|
static char *cafile = "/etc/ssl/certs/ca-certificates.crt";
|
||||||
static char *strictssl = FALSE; /* Refuse untrusted SSL connections */
|
static char *strictssl = FALSE; /* Refuse untrusted SSL connections */
|
||||||
static int indicator_thickness = 2;
|
|
||||||
|
|
||||||
/* Webkit default features */
|
/* Webkit default features */
|
||||||
static Bool enablespatialbrowsing = TRUE;
|
static Bool enablespatialbrowsing = TRUE;
|
||||||
|
|
78
surf.c
78
surf.c
|
@ -42,7 +42,7 @@ union Arg {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Client {
|
typedef struct Client {
|
||||||
GtkWidget *win, *scroll, *vbox, *indicator, *pane;
|
GtkWidget *win, *scroll, *vbox, *pane;
|
||||||
WebKitWebView *view;
|
WebKitWebView *view;
|
||||||
WebKitWebInspector *inspector;
|
WebKitWebInspector *inspector;
|
||||||
char *title, *linkhover;
|
char *title, *linkhover;
|
||||||
|
@ -84,6 +84,7 @@ static gboolean showxid = FALSE;
|
||||||
static char winid[64];
|
static char winid[64];
|
||||||
static gboolean usingproxy = 0;
|
static gboolean usingproxy = 0;
|
||||||
static char togglestat[5];
|
static char togglestat[5];
|
||||||
|
static char pagestat[2];
|
||||||
|
|
||||||
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
|
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
|
||||||
WebKitWebResource *r, WebKitNetworkRequest *req,
|
WebKitWebResource *r, WebKitNetworkRequest *req,
|
||||||
|
@ -113,13 +114,12 @@ static gboolean decidewindow(WebKitWebView *v, WebKitWebFrame *f,
|
||||||
static void destroyclient(Client *c);
|
static void destroyclient(Client *c);
|
||||||
static void destroywin(GtkWidget* w, Client *c);
|
static void destroywin(GtkWidget* w, Client *c);
|
||||||
static void die(const char *errstr, ...);
|
static void die(const char *errstr, ...);
|
||||||
static void drawindicator(Client *c);
|
|
||||||
static void eval(Client *c, const Arg *arg);
|
static void eval(Client *c, const Arg *arg);
|
||||||
static gboolean exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c);
|
|
||||||
static void find(Client *c, const Arg *arg);
|
static void find(Client *c, const Arg *arg);
|
||||||
static void fullscreen(Client *c, const Arg *arg);
|
static void fullscreen(Client *c, const Arg *arg);
|
||||||
static const char *getatom(Client *c, int a);
|
static const char *getatom(Client *c, int a);
|
||||||
static void gettogglestat(Client *c);
|
static void gettogglestat(Client *c);
|
||||||
|
static void getpagestat(Client *c);
|
||||||
static char *geturi(Client *c);
|
static char *geturi(Client *c);
|
||||||
static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c);
|
static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c);
|
||||||
|
|
||||||
|
@ -370,7 +370,6 @@ destroyclient(Client *c) {
|
||||||
Client *p;
|
Client *p;
|
||||||
|
|
||||||
webkit_web_view_stop_loading(c->view);
|
webkit_web_view_stop_loading(c->view);
|
||||||
gtk_widget_destroy(c->indicator);
|
|
||||||
gtk_widget_destroy(GTK_WIDGET(c->view));
|
gtk_widget_destroy(GTK_WIDGET(c->view));
|
||||||
gtk_widget_destroy(c->scroll);
|
gtk_widget_destroy(c->scroll);
|
||||||
gtk_widget_destroy(c->vbox);
|
gtk_widget_destroy(c->vbox);
|
||||||
|
@ -402,51 +401,6 @@ die(const char *errstr, ...) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
drawindicator(Client *c) {
|
|
||||||
gint width;
|
|
||||||
const char *uri;
|
|
||||||
char *colorname;
|
|
||||||
GtkWidget *w;
|
|
||||||
GdkGC *gc;
|
|
||||||
GdkColor fg;
|
|
||||||
|
|
||||||
uri = geturi(c);
|
|
||||||
w = c->indicator;
|
|
||||||
width = c->progress * w->allocation.width / 100;
|
|
||||||
gc = gdk_gc_new(w->window);
|
|
||||||
if(strstr(uri, "https://") == uri) {
|
|
||||||
if(usingproxy) {
|
|
||||||
colorname = c->sslfailed? progress_proxy_untrust :
|
|
||||||
progress_proxy_trust;
|
|
||||||
} else {
|
|
||||||
colorname = c->sslfailed? progress_untrust :
|
|
||||||
progress_trust;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(usingproxy) {
|
|
||||||
colorname = progress_proxy;
|
|
||||||
} else {
|
|
||||||
colorname = progress;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gdk_color_parse(colorname, &fg);
|
|
||||||
gdk_gc_set_rgb_fg_color(gc, &fg);
|
|
||||||
gdk_draw_rectangle(w->window,
|
|
||||||
w->style->bg_gc[GTK_WIDGET_STATE(w)],
|
|
||||||
TRUE, 0, 0, w->allocation.width, w->allocation.height);
|
|
||||||
gdk_draw_rectangle(w->window, gc, TRUE, 0, 0, width,
|
|
||||||
w->allocation.height);
|
|
||||||
g_object_unref(gc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c) {
|
|
||||||
drawindicator(c);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
find(Client *c, const Arg *arg) {
|
find(Client *c, const Arg *arg) {
|
||||||
const char *s;
|
const char *s;
|
||||||
|
@ -739,21 +693,12 @@ newclient(void) {
|
||||||
"resource-request-starting",
|
"resource-request-starting",
|
||||||
G_CALLBACK(beforerequest), c);
|
G_CALLBACK(beforerequest), c);
|
||||||
|
|
||||||
/* Indicator */
|
|
||||||
c->indicator = gtk_drawing_area_new();
|
|
||||||
gtk_widget_set_size_request(c->indicator, 0, indicator_thickness);
|
|
||||||
g_signal_connect (G_OBJECT (c->indicator), "expose_event",
|
|
||||||
G_CALLBACK (exposeindicator), c);
|
|
||||||
|
|
||||||
/* Arranging */
|
/* Arranging */
|
||||||
gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
|
gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
|
||||||
gtk_container_add(GTK_CONTAINER(c->win), c->pane);
|
gtk_container_add(GTK_CONTAINER(c->win), c->pane);
|
||||||
gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
|
gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
|
||||||
gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator);
|
|
||||||
|
|
||||||
/* Setup */
|
/* Setup */
|
||||||
gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE,
|
|
||||||
FALSE, 0, GTK_PACK_START);
|
|
||||||
gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE,
|
gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE,
|
||||||
TRUE, 0, GTK_PACK_START);
|
TRUE, 0, GTK_PACK_START);
|
||||||
gtk_widget_grab_focus(GTK_WIDGET(c->view));
|
gtk_widget_grab_focus(GTK_WIDGET(c->view));
|
||||||
|
@ -1117,23 +1062,26 @@ gettogglestat(Client *c){
|
||||||
togglestat[4] = '\0';
|
togglestat[4] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
getpagestat(Client *c) {
|
||||||
|
pagestat[0] = c->sslfailed ? 'U' : 'T';
|
||||||
|
pagestat[1] = usingproxy ? 'P' : '-';
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update(Client *c) {
|
update(Client *c) {
|
||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
gettogglestat(c);
|
gettogglestat(c);
|
||||||
|
getpagestat(c);
|
||||||
|
|
||||||
if(c->linkhover) {
|
if(c->linkhover) {
|
||||||
t = g_strdup_printf("%s| %s", togglestat, c->linkhover);
|
t = g_strdup_printf("%s:%s | %s", togglestat, pagestat, c->linkhover);
|
||||||
} else if(c->progress != 100) {
|
} else if(c->progress != 100) {
|
||||||
drawindicator(c);
|
t = g_strdup_printf("[%i%%] %s:%s | %s", c->progress, togglestat,
|
||||||
gtk_widget_show(c->indicator);
|
pagestat, c->title);
|
||||||
t = g_strdup_printf("[%i%%] %s| %s", c->progress, togglestat,
|
|
||||||
c->title);
|
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_hide_all(c->indicator);
|
t = g_strdup_printf("%s:%s | %s", togglestat, pagestat, c->title);
|
||||||
t = g_strdup_printf("%s| %s", togglestat, c->title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_set_title(GTK_WINDOW(c->win), t);
|
gtk_window_set_title(GTK_WINDOW(c->win), t);
|
||||||
|
|
Loading…
Reference in a new issue