summaryrefslogtreecommitdiff
path: root/surf.c
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2012-10-13 07:28:16 +0200
committerChristoph Lohmann <20h@r-36.net>2012-10-13 07:28:16 +0200
commit81d23cb76d40331656efd61338c0fb1ccc3422c2 (patch)
treedc2aa9ea590d02688207654b3b613a557df882c2 /surf.c
parent2e92060efcb672e44dfd3424a9dadffcdf9aa770 (diff)
downloadsurf-81d23cb76d40331656efd61338c0fb1ccc3422c2.tar.gz
surf-81d23cb76d40331656efd61338c0fb1ccc3422c2.tar.bz2
surf-81d23cb76d40331656efd61338c0fb1ccc3422c2.zip
The right click menu to copy the link URI will now work. Thanks to Carlos
Pita!
Diffstat (limited to 'surf.c')
-rw-r--r--surf.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/surf.c b/surf.c
index 097ecc9..3cf452f 100644
--- a/surf.c
+++ b/surf.c
@@ -93,6 +93,8 @@ static Client *newclient(void);
static void newwindow(Client *c, const Arg *arg, gboolean noembed);
static void newrequest(SoupSession *s, SoupMessage *msg, gpointer v);
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
+static void populatepopup(WebKitWebView *web, GtkMenu *menu, Client *c);
+static void popupactivate(GtkMenuItem *menu, Client *);
static void print(Client *c, const Arg *arg);
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
static void progresschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
@@ -513,6 +515,7 @@ newclient(void) {
g_signal_connect(G_OBJECT(c->view), "notify::progress", G_CALLBACK(progresschange), c);
g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
g_signal_connect(G_OBJECT(c->view), "button-release-event", G_CALLBACK(buttonrelease), c);
+ g_signal_connect(G_OBJECT(c->view), "populate-popup", G_CALLBACK(populatepopup), c);
/* Indicator */
c->indicator = gtk_drawing_area_new();
@@ -615,6 +618,45 @@ newwindow(Client *c, const Arg *arg, gboolean noembed) {
spawn(NULL, &a);
}
+static void
+populatepopup(WebKitWebView *web, GtkMenu *menu, Client *c) {
+ GList *items = gtk_container_get_children(GTK_CONTAINER(menu));
+
+ for(GList *l = items; l; l = l->next) {
+ g_signal_connect(l->data, "activate", G_CALLBACK(popupactivate), c);
+ }
+
+ g_list_free(items);
+}
+
+static void
+popupactivate(GtkMenuItem *menu, Client *c) {
+ /*
+ * context-menu-action-2000 open link
+ * context-menu-action-1 open link in window
+ * context-menu-action-2 download linked file
+ * context-menu-action-3 copy link location
+ * context-menu-action-13 reload
+ * context-menu-action-10 back
+ * context-menu-action-11 forward
+ * context-menu-action-12 stop
+ */
+
+ GtkAction *a = NULL;
+ const char *name;
+ GtkClipboard *prisel;
+
+ a = gtk_activatable_get_related_action(GTK_ACTIVATABLE(menu));
+ if(a == NULL)
+ return;
+
+ name = gtk_action_get_name(a);
+ if(!g_strcmp0(name, "context-menu-action-3")) {
+ prisel = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
+ gtk_clipboard_set_text(prisel, c->linkhover, -1);
+ }
+}
+
void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
Arg arg = {.v = text };