{ "sort-menu", NULL, N_( "_Sort Torrents By" ), NULL, NULL, NULL },
{ "edit-menu", NULL, N_( "_Edit" ), NULL, NULL, NULL },
{ "help-menu", NULL, N_( "_Help" ), NULL, NULL, NULL },
+ { "copy-magnet-link-to-clipboard", GTK_STOCK_COPY, N_("Copy _Magnet Link to Clipboard" ), "<control>M", NULL, G_CALLBACK( action_cb ) },
{ "add-torrent-from-url", GTK_STOCK_ADD, N_("Add _URL..." ), NULL, N_( "Add URL..." ), G_CALLBACK( action_cb ) },
{ "add-torrent-toolbar", GTK_STOCK_ADD, NULL, NULL, N_( "Add a torrent" ), G_CALLBACK( action_cb ) },
{ "add-torrent-menu", GTK_STOCK_ADD, N_( "_Add File..." ), "<control>D", N_( "Add a torrent" ), G_CALLBACK( action_cb ) },
{ "start-torrent", GTK_STOCK_MEDIA_PLAY, N_( "_Start" ), "<control>S", N_( "Start torrent" ), G_CALLBACK( action_cb ) },
{ "show-stats", NULL, N_( "_Statistics" ), NULL, NULL, G_CALLBACK( action_cb ) },
{ "donate", NULL, N_( "_Donate" ), NULL, NULL, G_CALLBACK( action_cb ) },
- { "verify-torrent", NULL, N_( "_Verify Local Data" ), NULL, NULL, G_CALLBACK( action_cb ) },
+ { "verify-torrent", NULL, N_( "_Verify Local Data" ), "<control>V", NULL, G_CALLBACK( action_cb ) },
{ "pause-torrent", GTK_STOCK_MEDIA_PAUSE, N_( "_Pause" ), "<control>P", N_( "Pause torrent" ), G_CALLBACK( action_cb ) },
{ "pause-all-torrents", GTK_STOCK_MEDIA_PAUSE, N_( "_Pause All" ), NULL, N_( "Pause all torrents" ), G_CALLBACK( action_cb ) },
{ "start-all-torrents", GTK_STOCK_MEDIA_PLAY, N_( "_Start All" ), NULL, N_( "Start all torrents" ), G_CALLBACK( action_cb ) },
GtkWidget * last_activity_lb;
GtkWidget * hash_lb;
- GtkWidget * magnet_lb;
GtkWidget * privacy_lb;
GtkWidget * origin_lb;
GtkWidget * destination_lb;
refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n )
{
int i;
- char * freeme;
const char * str;
const char * none = _( "None" );
const char * mixed = _( "Mixed" );
str = mixed;
gtr_label_set_text( GTK_LABEL( di->hash_lb ), str );
- /* magnet lb */
- freeme = NULL;
- if( n<=0 )
- str = none;
- else if ( n>1 )
- str = mixed;
- else if( infos[0]->isPrivate )
- str = _( "Private Torrent" );
- else
- str = freeme = tr_torrentGetMagnetLink( torrents[0] );
- gtr_label_set_text( GTK_LABEL( di->magnet_lb ), str );
- tr_free( freeme );
-
/* error */
if( n <= 0 )
str = none;
hig_workarea_add_row( t, &row, _( "Hash:" ), l, NULL );
di->hash_lb = l;
- /* magnet url */
- l = g_object_new( GTK_TYPE_LABEL, "selectable", TRUE,
- "ellipsize", PANGO_ELLIPSIZE_END,
- NULL );
- hig_workarea_add_row( t, &row, _( "Magnet link:" ), l, NULL );
- di->magnet_lb = l;
-
/* privacy */
l = gtk_label_new( NULL );
hig_workarea_add_row( t, &row, _( "Privacy:" ), l, NULL );
action_sensitize( "show-torrent-properties", counts.totalCount != 0 );
action_sensitize( "open-torrent-folder", counts.totalCount == 1 );
action_sensitize( "relocate-torrent", counts.totalCount == 1 );
+ action_sensitize( "copy-magnet-link-to-clipboard", counts.totalCount == 1 );
canUpdate = 0;
gtk_tree_selection_selected_foreach( s, accumulateCanUpdateForeach, &canUpdate );
data->details = g_slist_remove( data->details, dead );
}
+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 );
+}
+
void
doAction( const char * action_name, gpointer user_data )
{
{
startAllTorrents( data );
}
+ else if( !strcmp( action_name, "copy-magnet-link-to-clipboard" ) )
+ {
+ tr_torrent * tor = getFirstSelectedTorrent( data );
+ if( tor != NULL )
+ {
+ copyMagnetLinkToClipboard( GTK_WIDGET( data->wind ), tor );
+ }
+ }
else if( !strcmp( action_name, "relocate-torrent" ) )
{
tr_torrent * tor = getFirstSelectedTorrent( data );
- if( tor )
+ if( tor != NULL )
{
GtkWindow * parent = GTK_WINDOW( data->wind );
GtkWidget * w = gtr_relocate_dialog_new( parent, tor );
" </menu>\n"
" <menu action='torrent-menu'>\n"
" <menuitem action='show-torrent-properties'/>\n"
- " <menuitem action='open-torrent-folder'/>\n"
- " <menuitem action='relocate-torrent'/>\n"
" <separator/>\n"
" <menuitem action='start-torrent'/>\n"
" <menuitem action='update-tracker'/>\n"
" <menuitem action='pause-torrent'/>\n"
+ " <menuitem action='copy-magnet-link-to-clipboard'/>\n"
+ " <separator/>\n"
+ " <menuitem action='open-torrent-folder'/>\n"
+ " <menuitem action='relocate-torrent'/>\n"
" <menuitem action='verify-torrent'/>\n"
" <separator/>\n"
" <menuitem action='remove-torrent'/>\n"
"\n"
" <popup name='main-window-popup'>\n"
" <menuitem action='show-torrent-properties'/>\n"
- " <menuitem action='open-torrent-folder'/>\n"
- " <separator/>\n"
- " <menuitem action='start-torrent'/>\n"
- " <menuitem action='update-tracker'/>\n"
- " <menuitem action='pause-torrent'/>\n"
- " <menuitem action='verify-torrent'/>\n"
" <separator/>\n"
" <menu action='sort-menu'>\n"
" <menuitem action='sort-by-activity'/>\n"
" <menuitem action='sort-reversed'/>\n"
" </menu>\n"
" <separator/>\n"
+ " <menuitem action='start-torrent'/>\n"
+ " <menuitem action='update-tracker'/>\n"
+ " <menuitem action='pause-torrent'/>\n"
+ " <menuitem action='copy-magnet-link-to-clipboard'/>\n"
+ " <separator/>\n"
+ " <menuitem action='open-torrent-folder'/>\n"
+ " <menuitem action='verify-torrent'/>\n"
" <menuitem action='relocate-torrent'/>\n"
" <separator/>\n"
" <menuitem action='remove-torrent'/>\n"