]> granicus.if.org Git - transmission/commitdiff
(trunk gtk) #2625: "ability to create a manget link" -- remove the magnet link from...
authorCharles Kerr <charles@transmissionbt.com>
Sun, 29 Nov 2009 18:23:06 +0000 (18:23 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sun, 29 Nov 2009 18:23:06 +0000 (18:23 +0000)
gtk/actions.c
gtk/details.c
gtk/main.c
gtk/ui.h

index bb03e01f13ed249b9c146053ef22ac0fe868a1ad..32f0deb32c2f1df97f5e0b9702dadd03a54ae3d5 100644 (file)
@@ -108,13 +108,14 @@ static GtkActionEntry entries[] =
     { "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 ) },
index d6704b279387e0d4a89ce3b3208282c79bd2d077..848c0c47d3a1b361da8643fbdeea766bb437eb83 100644 (file)
@@ -76,7 +76,6 @@ struct DetailsImpl
     GtkWidget * last_activity_lb;
 
     GtkWidget * hash_lb;
-    GtkWidget * magnet_lb;
     GtkWidget * privacy_lb;
     GtkWidget * origin_lb;
     GtkWidget * destination_lb;
@@ -620,7 +619,6 @@ static void
 refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n )
 {
     int i;
-    char * freeme;
     const char * str;
     const char * none = _( "None" );
     const char * mixed = _( "Mixed" );
@@ -887,19 +885,6 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n )
         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;
@@ -1014,13 +999,6 @@ info_page_new( struct DetailsImpl * di )
         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 );
index 0065b61ae43dc998ac8c17f7fa5a032998c8dac3..bb227216b24a43b3f1a7b9f4a5e953374bf3d0d9 100644 (file)
@@ -179,6 +179,7 @@ refreshActions( struct cbdata * data )
     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 );
@@ -1343,6 +1344,17 @@ detailsClosed( gpointer gdata, GObject * dead )
     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 )
 {
@@ -1381,10 +1393,18 @@ 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 );
index fd3c55dd5a716b8264daa58e9f358841a6c6aa02..4e133cf514ee2411386e8f6a88570d3374f572ad 100644 (file)
--- a/gtk/ui.h
+++ b/gtk/ui.h
@@ -19,12 +19,14 @@ static const char * fallback_ui_file =
     "    </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"
@@ -71,12 +73,6 @@ static const char * fallback_ui_file =
     "\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"
@@ -92,6 +88,13 @@ static const char * fallback_ui_file =
     "      <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"