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);
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);
}
}
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))
void
loadstart(WebKitWebView *view, WebKitWebFrame *f, Client *c) {
- if(c->download)
- stop(c);
c->progress = 0;
updatetitle(c, NULL);
}
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;
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;
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) {