The right click menu to copy the link URI will now work. Thanks to Carlos

Pita!
This commit is contained in:
Christoph Lohmann 2012-10-13 07:28:16 +02:00
parent 2e92060efc
commit 81d23cb76d
1 changed files with 42 additions and 0 deletions

42
surf.c
View File

@ -93,6 +93,8 @@ static Client *newclient(void);
static void newwindow(Client *c, const Arg *arg, gboolean noembed); static void newwindow(Client *c, const Arg *arg, gboolean noembed);
static void newrequest(SoupSession *s, SoupMessage *msg, gpointer v); static void newrequest(SoupSession *s, SoupMessage *msg, gpointer v);
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); 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 void print(Client *c, const Arg *arg);
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d); static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
static void progresschange(WebKitWebView *view, GParamSpec *pspec, Client *c); 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), "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), "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), "button-release-event", G_CALLBACK(buttonrelease), c);
g_signal_connect(G_OBJECT(c->view), "populate-popup", G_CALLBACK(populatepopup), c);
/* Indicator */ /* Indicator */
c->indicator = gtk_drawing_area_new(); c->indicator = gtk_drawing_area_new();
@ -615,6 +618,45 @@ newwindow(Client *c, const Arg *arg, gboolean noembed) {
spawn(NULL, &a); 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 void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) { pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
Arg arg = {.v = text }; Arg arg = {.v = text };