Opened 12 years ago

Closed 12 years ago

#2625 closed Enhancement (fixed)

Ability to create a magnet link

Reported by: User294 Owned by: charles
Priority: Normal Milestone: 1.80
Component: Transmission Version: 1.76
Severity: Normal Keywords:
Cc:

Description

I have idea: simplify magnet links creation/usage. Transmission always knows infohash so it would be nice to have say, menu option like "copy magnet link to clipboard" for downloads or so. It can also be a good idea to display magnet link in torrent's properties dialog and/or have option to obtain magnet uri when creating torrent.

Change History (17)

comment:1 Changed 12 years ago by livings124

  • Summary changed from Idea: simplifu magnet links creation. to Ability to create a magnet link

comment:2 Changed 12 years ago by charles

I kind of like this idea

comment:3 Changed 12 years ago by User294

Thanks for fixing my lame typo in title, btw :).

comment:4 Changed 12 years ago by livings124

This is a really good idea - it essentially eliminates any need for a website for friends to share their own content.

comment:5 Changed 12 years ago by charles

charles * r9627 /trunk/ (3 files in 2 dirs): (trunk libT, gtk) #2625 "ability to create a magnet link" -- add hook for generating a magnet link from a tr_torrent, and use it in the Torrent Properties dialog in the GTK+ client

comment:6 Changed 12 years ago by charles

  • Milestone changed from None Set to 1.80
  • Owner set to charles
  • Status changed from new to assigned
  • Version changed from 1.76+ to 1.76

comment:7 Changed 12 years ago by Rolcol

What if we slightly advance this further and add the ability to copy the magnet link of a public torrent through the right-click context menu?

comment:8 Changed 12 years ago by charles

charles * r9631 gtk/ (actions.c details.c main.c ui.h): (trunk gtk) #2625: "ability to create a manget link" -- remove the magnet link from the properties dialog; add a "Copy _Magnet Link to Clipboard" menu & context menu item instead

comment:9 Changed 12 years ago by jch

r9631 doesn't work for me. Transmission is not claiming the X selection.

I'm not running a "clipboard" or whatever, just a plain window manager. Is your code supposed to work with X selections?

--Juliusz

comment:10 Changed 12 years ago by charles

It uses this code:

static void
copyMagnetLinkToClipboard( GtkWidget * w, tr_torrent * tor )
{
    char * magnet = tr_torrentGetMagnetLink( tor );
    GdkDisplay * display = gtk_widget_get_display( w );
    GdkAtom selection = GDK_SELECTION_CLIPBOARD;
    GtkClipboard * clipboard = gtk_clipboard_get_for_display( display, selection );
    gtk_clipboard_set_text( clipboard, magnet, -1 );
    tr_free( magnet );
}

..if it's not working for you, you might want to file a gtk+ ticket at bugzilla.gnome.org

comment:11 Changed 12 years ago by livings124

r9667 adds a menu item to the Mac client to copy the magnet link to the clipboard.

comment:12 Changed 12 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

r9662 adds a menu item to the Qt client to copy the magnet link to the clipboard.

comment:13 Changed 12 years ago by jch

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening this bug. As mentioned above, it doesn't do anything if you're not running a clipboard manager, just plain X.

--Juliusz

comment:14 Changed 12 years ago by charles

jch: after reading http://www.freedesktop.org/wiki/Specifications/ClipboardsWiki it sounds like maybe your environment would support using X's PRIMARY selection rather than CLIPBOARD.

If you change "GdkAtom? selection = GDK_SELECTION_CLIPBOARD;" to "GdkAtom? selection = GDK_SELECTION_PRIMARY;" in main.c, does that help things any?

comment:15 Changed 12 years ago by jch

Yep, that did the trick. Thanks.

--Juliusz

--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1407,7 +1407,7 @@ copyMagnetLinkToClipboard( GtkWidget * w, tr_torrent * tor )
 {
     char * magnet = tr_torrentGetMagnetLink( tor );
     GdkDisplay * display = gtk_widget_get_display( w );
-    GdkAtom selection = GDK_SELECTION_CLIPBOARD;
+    GdkAtom selection = GDK_SELECTION_PRIMARY;
     GtkClipboard * clipboard = gtk_clipboard_get_for_display( display, selection );
     gtk_clipboard_set_text( clipboard, magnet, -1 );
     tr_free( magnet );

comment:16 Changed 12 years ago by charles

jch: the opendesktop guide is pretty explicit that "well-behaved" apps should use GDK_SELECTION_CLIPBOARD rather than GDK_SELECTION_PRIMARY. After some cursory Googling, it appears that some apps split the difference and use both.

comment:17 Changed 12 years ago by charles

  • Resolution set to fixed
  • Status changed from reopened to closed

r9688 gtk/main.c: (trunk gtk) #2625 "ability to create a magnet link" -- fix "Copy Magnet Link to Clipboard" for X users who aren't using KDE or GNOME. Reported by jch

Note: See TracTickets for help on using tickets.