X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=476fd563dd0d11780cd551567452cc873d639c3d;hb=77fc27ef561c6777c2c05c394bf13183c1d74143;hp=4bbe95d4f4945f83c02846764a66ec0646b206a0;hpb=a122748ae79d46b841c221669cf6a33cb6641b30;p=surf.git diff --git a/surf.c b/surf.c index 4bbe95d..476fd56 100644 --- a/surf.c +++ b/surf.c @@ -53,6 +53,7 @@ static void loadfile(Client *c, const gchar *f); static void loaduri(Client *c, const gchar *uri); static Client *newclient(); static WebKitWebView *newwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c); +static void pasteurl(GtkClipboard *clipboard, const gchar *text, gpointer d); static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d); static void progresschange(WebKitWebView *view, gint p, Client *c); static void setup(void); @@ -108,9 +109,6 @@ download(WebKitDownload *o, GParamSpec *pspec, Client *c) { if(status == WEBKIT_DOWNLOAD_STATUS_STARTED || status == WEBKIT_DOWNLOAD_STATUS_CREATED) { c->progress = (int)(webkit_download_get_progress(c->download)*100); } - else { - stop(c); - } updatetitle(c, NULL); } @@ -198,6 +196,12 @@ keypress(GtkWidget* w, GdkEventKey *ev, Client *c) { } if(ev->state & GDK_CONTROL_MASK) { switch(ev->keyval) { + case GDK_p: + gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteurl, c); + return TRUE; + case GDK_y: + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), webkit_web_view_get_uri(c->view), -1); + return TRUE; case GDK_r: case GDK_R: if((ev->state & GDK_SHIFT_MASK)) @@ -270,8 +274,6 @@ loadcommit(WebKitWebView *view, WebKitWebFrame *f, Client *c) { void loadstart(WebKitWebView *view, WebKitWebFrame *f, Client *c) { - if(c->download) - stop(c); c->progress = 0; updatetitle(c, NULL); } @@ -310,7 +312,7 @@ loadfile(Client *c, const gchar *f) { void loaduri(Client *c, const gchar *uri) { gchar *u; - u = g_strrstr(uri, ":") ? g_strdup(uri) + u = g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("http://%s", uri); webkit_web_view_load_uri(c->view, u); c->progress = 0; @@ -399,6 +401,13 @@ newwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c) { return n->view; } + +void +pasteurl(GtkClipboard *clipboard, const gchar *text, gpointer d) { + if(text != NULL) + loaduri((Client *) d, text); +} + GdkFilterReturn processx(GdkXEvent *e, GdkEvent *event, gpointer d) { Client *c = (Client *)d; @@ -407,6 +416,7 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) { int idummy; unsigned long ldummy; unsigned char *buf = NULL; + if(((XEvent *)e)->type == PropertyNotify) { ev = &((XEvent *)e)->xproperty; if(ev->atom == urlprop && ev->state == PropertyNewValue) {