summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiguel <miguel@localhost>2018-03-19 18:08:18 +0100
committermiguel <miguel@localhost>2018-03-19 18:08:18 +0100
commit47757191f41251b5de0c84abe891624bde02aa72 (patch)
treec50b814018c665570f2265a7ca78565ddca48d82
parent45b074d24577b7ba2aa7b0e5e0d799b3ddcd5cbb (diff)
paste uri and open in new window
-rw-r--r--config.h1
-rw-r--r--surf.c27
2 files changed, 24 insertions, 4 deletions
diff --git a/config.h b/config.h
index 4744cec..264727a 100644
--- a/config.h
+++ b/config.h
@@ -178,6 +178,7 @@ static Key keys[] = {
{ 0, GDK_KEY_minus, zoom, { .i = -1 } },
{ 0, GDK_KEY_equal, zoom, { .i = +1 } },
+ { GDK_SHIFT_MASK, GDK_KEY_p, clipboard, { .i = 2 } },
{ 0, GDK_KEY_p, clipboard, { .i = 1 } },
{ 0, GDK_KEY_y, clipboard, { .i = 0 } },
diff --git a/surf.c b/surf.c
index 68a1930..e1420b0 100644
--- a/surf.c
+++ b/surf.c
@@ -214,6 +214,7 @@ static void destroywin(GtkWidget* w, Client *c);
/* Hotkeys */
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
+static void pasteurinew(GtkClipboard *clipboard, const char *text, gpointer d);
static void reload(Client *c, const Arg *a);
static void print(Client *c, const Arg *a);
static void showcert(Client *c, const Arg *a);
@@ -1707,7 +1708,22 @@ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
}
loaduri((Client *) d, &a);
}
+}
+void
+pasteurinew(GtkClipboard *clipboard, const char *text, gpointer d)
+{
+ char buf[1024];
+ Arg a = {.v = text };
+ if (text)
+ {
+ if (strstr(text, ".") == NULL) {
+ snprintf(buf,1024,"https://duckduckgo.com/?q=%s",text);
+ a.v = buf;
+ printf("%s\n",buf);
+ }
+ piper_recv(buf);
+ }
}
void
@@ -1753,10 +1769,15 @@ showcert(Client *c, const Arg *a)
void
clipboard(Client *c, const Arg *a)
{
- if (a->i) { /* load clipboard uri */
+ if (a->i==1) { /* load clipboard uri */
gtk_clipboard_request_text(gtk_clipboard_get(
GDK_SELECTION_PRIMARY),
pasteuri, c);
+ }else if (a->i==2) { /* load clipboard uri */
+ gtk_clipboard_request_text(gtk_clipboard_get(
+ GDK_SELECTION_PRIMARY),
+ pasteurinew, c);
+
} else { /* copy uri */
gtk_clipboard_set_text(gtk_clipboard_get(
GDK_SELECTION_PRIMARY), c->targeturi
@@ -1931,7 +1952,7 @@ clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h)
void
piper_recv(char *msg)
{
- g_print("message from extension: [%s]\n",msg);
+ g_print("message receieved [%s]\n",msg);
Arg a;
a.v=msg;
@@ -1940,8 +1961,6 @@ piper_recv(char *msg)
loaduri(c, &a);
updatetitle(c);
-
-
}
int