Changeset 9631


Ignore:
Timestamp:
Nov 29, 2009, 6:23:06 PM (12 years ago)
Author:
charles
Message:

(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

Location:
trunk/gtk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/actions.c

    r9624 r9631  
    109109    { "edit-menu", NULL, N_( "_Edit" ), NULL, NULL, NULL },
    110110    { "help-menu", NULL, N_( "_Help" ), NULL, NULL, NULL },
     111    { "copy-magnet-link-to-clipboard",  GTK_STOCK_COPY, N_("Copy _Magnet Link to Clipboard" ), "<control>M", NULL,  G_CALLBACK( action_cb ) },
    111112    { "add-torrent-from-url",  GTK_STOCK_ADD, N_("Add _URL..." ), NULL, N_( "Add URL..." ),  G_CALLBACK( action_cb ) },
    112113    { "add-torrent-toolbar",  GTK_STOCK_ADD, NULL, NULL, N_( "Add a torrent" ),  G_CALLBACK( action_cb ) },
     
    115116    { "show-stats", NULL, N_( "_Statistics" ), NULL, NULL, G_CALLBACK( action_cb ) },
    116117    { "donate", NULL, N_( "_Donate" ), NULL, NULL, G_CALLBACK( action_cb ) },
    117     { "verify-torrent", NULL, N_( "_Verify Local Data" ), NULL, NULL, G_CALLBACK( action_cb ) },
     118    { "verify-torrent", NULL, N_( "_Verify Local Data" ), "<control>V", NULL, G_CALLBACK( action_cb ) },
    118119    { "pause-torrent", GTK_STOCK_MEDIA_PAUSE, N_( "_Pause" ), "<control>P", N_( "Pause torrent" ), G_CALLBACK( action_cb ) },
    119120    { "pause-all-torrents", GTK_STOCK_MEDIA_PAUSE, N_( "_Pause All" ), NULL, N_( "Pause all torrents" ), G_CALLBACK( action_cb ) },
  • trunk/gtk/details.c

    r9627 r9631  
    7777
    7878    GtkWidget * hash_lb;
    79     GtkWidget * magnet_lb;
    8079    GtkWidget * privacy_lb;
    8180    GtkWidget * origin_lb;
     
    621620{
    622621    int i;
    623     char * freeme;
    624622    const char * str;
    625623    const char * none = _( "None" );
     
    887885        str = mixed;
    888886    gtr_label_set_text( GTK_LABEL( di->hash_lb ), str );
    889 
    890     /* magnet lb */
    891     freeme = NULL;
    892     if( n<=0 )
    893         str = none;
    894     else if ( n>1 )
    895         str = mixed;
    896     else if( infos[0]->isPrivate )
    897         str = _( "Private Torrent" );
    898     else
    899         str = freeme = tr_torrentGetMagnetLink( torrents[0] );
    900     gtr_label_set_text( GTK_LABEL( di->magnet_lb ), str );
    901     tr_free( freeme );
    902887
    903888    /* error */
     
    1014999        hig_workarea_add_row( t, &row, _( "Hash:" ), l, NULL );
    10151000        di->hash_lb = l;
    1016 
    1017         /* magnet url */
    1018         l = g_object_new( GTK_TYPE_LABEL, "selectable", TRUE,
    1019                                           "ellipsize", PANGO_ELLIPSIZE_END,
    1020                                            NULL );
    1021         hig_workarea_add_row( t, &row, _( "Magnet link:" ), l, NULL );
    1022         di->magnet_lb = l;
    10231001
    10241002        /* privacy */
  • trunk/gtk/main.c

    r9581 r9631  
    180180    action_sensitize( "open-torrent-folder", counts.totalCount == 1 );
    181181    action_sensitize( "relocate-torrent", counts.totalCount == 1 );
     182    action_sensitize( "copy-magnet-link-to-clipboard", counts.totalCount == 1 );
    182183
    183184    canUpdate = 0;
     
    13441345}
    13451346
     1347static void
     1348copyMagnetLinkToClipboard( GtkWidget * w, tr_torrent * tor )
     1349{
     1350    char * magnet = tr_torrentGetMagnetLink( tor );
     1351    GdkDisplay * display = gtk_widget_get_display( w );
     1352    GdkAtom selection = GDK_SELECTION_CLIPBOARD;
     1353    GtkClipboard * clipboard = gtk_clipboard_get_for_display( display, selection );
     1354    gtk_clipboard_set_text( clipboard, magnet, -1 );
     1355    tr_free( magnet );
     1356}
     1357
    13461358void
    13471359doAction( const char * action_name, gpointer user_data )
     
    13821394        startAllTorrents( data );
    13831395    }
     1396    else if( !strcmp( action_name, "copy-magnet-link-to-clipboard" ) )
     1397    {
     1398        tr_torrent * tor = getFirstSelectedTorrent( data );
     1399        if( tor != NULL )
     1400        {
     1401            copyMagnetLinkToClipboard( GTK_WIDGET( data->wind ), tor );
     1402        }
     1403    }
    13841404    else if( !strcmp( action_name, "relocate-torrent" ) )
    13851405    {
    13861406        tr_torrent * tor = getFirstSelectedTorrent( data );
    1387         if( tor )
     1407        if( tor != NULL )
    13881408        {
    13891409            GtkWindow * parent = GTK_WINDOW( data->wind );
  • trunk/gtk/ui.h

    r9624 r9631  
    2020    "    <menu action='torrent-menu'>\n"
    2121    "      <menuitem action='show-torrent-properties'/>\n"
    22     "      <menuitem action='open-torrent-folder'/>\n"
    23     "      <menuitem action='relocate-torrent'/>\n"
    2422    "      <separator/>\n"
    2523    "      <menuitem action='start-torrent'/>\n"
    2624    "      <menuitem action='update-tracker'/>\n"
    2725    "      <menuitem action='pause-torrent'/>\n"
     26    "      <menuitem action='copy-magnet-link-to-clipboard'/>\n"
     27    "      <separator/>\n"
     28    "      <menuitem action='open-torrent-folder'/>\n"
     29    "      <menuitem action='relocate-torrent'/>\n"
    2830    "      <menuitem action='verify-torrent'/>\n"
    2931    "      <separator/>\n"
     
    7274    "  <popup name='main-window-popup'>\n"
    7375    "    <menuitem action='show-torrent-properties'/>\n"
    74     "    <menuitem action='open-torrent-folder'/>\n"
    75     "    <separator/>\n"
    76     "    <menuitem action='start-torrent'/>\n"
    77     "    <menuitem action='update-tracker'/>\n"
    78     "    <menuitem action='pause-torrent'/>\n"
    79     "    <menuitem action='verify-torrent'/>\n"
    8076    "    <separator/>\n"
    8177    "    <menu action='sort-menu'>\n"
     
    9389    "    </menu>\n"
    9490    "    <separator/>\n"
     91    "    <menuitem action='start-torrent'/>\n"
     92    "    <menuitem action='update-tracker'/>\n"
     93    "    <menuitem action='pause-torrent'/>\n"
     94    "    <menuitem action='copy-magnet-link-to-clipboard'/>\n"
     95    "    <separator/>\n"
     96    "    <menuitem action='open-torrent-folder'/>\n"
     97    "    <menuitem action='verify-torrent'/>\n"
    9598    "    <menuitem action='relocate-torrent'/>\n"
    9699    "    <separator/>\n"
Note: See TracChangeset for help on using the changeset viewer.