diff options
author | Josh Rickmar <jrick@devio.us> | 2012-06-07 13:52:07 -0400 |
---|---|---|
committer | Josh Rickmar <jrick@devio.us> | 2012-06-15 11:00:55 -0400 |
commit | 260f314f514dbd80ba00359a8d8317693553537e (patch) | |
tree | e7427333c2522434163591e1147d945636523ca1 | |
parent | 515f2ee756a374469626870a23ffac2f07932994 (diff) | |
download | xombrero-260f314f514dbd80ba00359a8d8317693553537e.tar.gz |
Make the Copy Link Location, Copy Image Address, and Copy Video Link
items of the context menu also copy to the PRIMARY clipboard. Slightly modified from a Patch by Lazaros Koromilas <lostd@2f30.org>.
-rw-r--r-- | xombrero.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/xombrero.c b/xombrero.c index 3d3d19e..743fd3f 100644 --- a/xombrero.c +++ b/xombrero.c @@ -6280,9 +6280,51 @@ done: } void -wv_popup_cb(GtkEntry *entry, GtkMenu *menu, struct tab *t) +wv_popup_activ_cb(GtkMenuItem *menu, struct tab *t) { + GtkAction *a = NULL; + GtkClipboard *clipboard, *primary; + const gchar *name, *uri; + + a = gtk_activatable_get_related_action(GTK_ACTIVATABLE(menu)); + if (a == NULL) + return; + name = gtk_action_get_name(a); + + DNPRINTF(XT_D_CMD, "wv_popup_activ_cb: tab %d action %s\n", + t->tab_id, name); + + /* + * context-menu-action-3 copy link location + * context-menu-action-7 copy image address + * context-menu-action-2030 copy video link location + */ + + /* copy actions */ + if ((g_strcmp0(name, "context-menu-action-3") == 0) || + (g_strcmp0(name, "context-menu-action-7") == 0) || + (g_strcmp0(name, "context-menu-action-2030") == 0)) { + clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); + primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY); + uri = gtk_clipboard_wait_for_text(clipboard); + if (uri == NULL) + return; + gtk_clipboard_set_text(primary, uri, -1); + } +} + +void +wv_popup_cb(WebKitWebView *wview, GtkMenu *menu, struct tab *t) +{ + GList *items, *l; + DNPRINTF(XT_D_CMD, "wv_popup_cb: tab %d\n", t->tab_id); + + items = gtk_container_get_children(GTK_CONTAINER(menu)); + for (l = items; l; l = l->next) + g_signal_connect(l->data, "activate", + G_CALLBACK(wv_popup_activ_cb), t); + g_list_free(items); } void |