#define LENGTH(x) (sizeof x / sizeof x[0])
#define CLEANMASK(mask) (mask & ~(GDK_MOD2_MASK))
-enum { AtomFind, AtomGo, AtomUri, AtomHiLight, AtomLast };
+enum { AtomFind, AtomGo, AtomUri, AtomLast };
typedef union Arg Arg;
union Arg {
static const char *getcookies(SoupURI *uri);
static char *geturi(Client *c);
void gotheaders(SoupMessage *msg, gpointer user_data);
+static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c);
static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c);
static void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c);
static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
static void loaduri(Client *c, const Arg *arg);
-static void mousemove(GtkWidget *w, GdkEventMotion *e, Client *c);
static void navigate(Client *c, const Arg *arg);
static Client *newclient(void);
static void newwindow(Client *c, const Arg *arg);
gboolean
decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, gchar *m, WebKitWebPolicyDecision *p, Client *c) {
if(!webkit_web_view_can_show_mime_type(v, m)) {
- webkit_web_policy_decision_ignore(p);
- webkit_web_view_load_html_string(c->view,
- "Can't display content.",
- webkit_network_request_get_uri(r));
+ webkit_web_policy_decision_download(p);
return TRUE;
}
return FALSE;
destroyclient(Client *c) {
Client *p;
+ webkit_web_view_stop_loading(c->view);
gtk_widget_destroy(c->indicator);
gtk_widget_destroy(GTK_WIDGET(c->view));
gtk_widget_destroy(c->scroll);
soup_cookies_free(l);
}
+gboolean
+initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
+ Arg arg;
+
+ updatewinid(c);
+ arg = (Arg)DOWNLOAD((char *)webkit_download_get_uri(o));
+ spawn(c, &arg);
+ return FALSE;
+}
+
gboolean
keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
guint i;
}
}
-void
-mousemove(GtkWidget *w, GdkEventMotion *e, Client *c) {
- int result;
- GdkEventButton coord;
- WebKitHitTestResult *hit;
-
- coord.x = e->x;
- coord.y = e->y;
- hit = webkit_web_view_get_hit_test_result(c->view, &coord);
- g_object_get(hit, "context", &result, NULL);
- if(result & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE && !c->linkhover) {
- puts("Picture");
- }
-}
-
void
navigate(Client *c, const Arg *arg) {
int steps = *(int *)arg;
g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c);
g_signal_connect(G_OBJECT(c->view), "notify::load-status", G_CALLBACK(loadstatuschange), c);
g_signal_connect(G_OBJECT(c->view), "notify::progress", G_CALLBACK(progresschange), c);
- g_signal_connect(G_OBJECT(c->view), "motion-notify-event", G_CALLBACK(mousemove), c);
+ g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
/* Indicator */
c->indicator = gtk_drawing_area_new();
g_object_set(G_OBJECT(settings), "auto-load-images", loadimage, NULL);
g_object_set(G_OBJECT(settings), "enable-plugins", plugin, NULL);
g_object_set(G_OBJECT(settings), "enable-scripts", script, NULL);
+ g_object_set(G_OBJECT(settings), "enable-spatial-navigation", true, NULL);
+
g_free(uri);
setatom(c, AtomFind, "");
setatom(c, AtomUri, "about:blank");
- setatom(c, AtomHiLight, "about:blank");
- if(NOBACKGROUND)
+ if(HIDE_BACKGROUND)
webkit_web_view_set_transparent(c->view, TRUE);
c->title = NULL;
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);
- atoms[AtomHiLight] = XInternAtom(dpy, "_SURF_HILIGHT", False);
/* dirs and files */
cookiefile = buildpath(cookiefile);
update(Client *c) {
char *t;
- if(c->progress != 100) {
+ if(c->progress != 100)
t = g_strdup_printf("[%i%%] %s", c->progress, c->title);
- }
else if(c->linkhover)
t = g_strdup(c->linkhover);
else
t = g_strdup(c->title);
- setatom(c, AtomHiLight, c->linkhover ? c->linkhover : geturi(c));
drawindicator(c);
gtk_window_set_title(GTK_WINDOW(c->win), t);
g_free(t);