Changeset 8763


Ignore:
Timestamp:
Jun 30, 2009, 6:08:50 PM (13 years ago)
Author:
charles
Message:

(trunk, gtk/qt) use Monsoon's strings for encryption preferences and Deluge's system tray tooltip.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core.c

    r8757 r8763  
    719719}
    720720
    721 static gboolean
    722 statsForeach( GtkTreeModel * model,
    723               GtkTreePath  * path UNUSED,
    724               GtkTreeIter  * iter,
    725               gpointer       gstats )
    726 {
    727     tr_torrent *        tor;
    728     struct core_stats * stats = gstats;
    729     int                 activity;
    730 
    731     gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 );
    732     activity = tr_torrentGetActivity( tor );
    733 
    734     if( activity == TR_STATUS_DOWNLOAD )
    735         ++stats->downloadCount;
    736     else if( activity == TR_STATUS_SEED )
    737         ++stats->seedingCount;
    738 
    739     return FALSE;
    740 }
    741 
    742 void
    743 tr_core_get_stats( const TrCore *      core,
    744                    struct core_stats * setme )
    745 {
    746     memset( setme, 0, sizeof( struct core_stats ) );
    747 
    748     if( !isDisposed( core ) )
    749     {
    750         tr_session * session = core->priv->session;
    751 
    752         setme->clientDownloadSpeed = tr_sessionGetPieceSpeed( session, TR_DOWN );
    753 
    754         setme->clientUploadSpeed = tr_sessionGetPieceSpeed( session, TR_UP );
    755 
    756         gtk_tree_model_foreach( core->priv->model, statsForeach, setme );
    757     }
    758 }
    759 
    760721static char*
    761722doCollate( const char * in )
  • trunk/gtk/tr-core.h

    r8671 r8763  
    4646                                                         TrCoreClass )
    4747
    48 struct core_stats
    49 {
    50     int      downloadCount;
    51     int      seedingCount;
    52     float    clientDownloadSpeed;
    53     float    clientUploadSpeed;
    54 };
    55 
    5648typedef struct TrCore
    5749{
     
    110102
    111103tr_session *   tr_core_session( TrCore * self );
    112 
    113 void           tr_core_get_stats( const TrCore *      core,
    114                                   struct core_stats * setme );
    115104
    116105/******
  • trunk/gtk/tr-icon.c

    r8724 r8763  
    5252refresh_tooltip_cb( gpointer data )
    5353{
    54     GtkStatusIcon *   icon = GTK_STATUS_ICON( data );
    55     TrCore *          core = g_object_get_data( G_OBJECT( icon ), "tr-core" );
    56     struct core_stats stats;
    57     char              downStr[32], upStr[32];
    58     char              tip[256];
     54    double d;
     55    int limit;
     56    char up[64];
     57    char upLimit[64];
     58    char down[64];
     59    char downLimit[64];
     60    char tip[1024];
     61    const char * idle = _( "Idle" );
     62    GtkStatusIcon * icon = GTK_STATUS_ICON( data );
     63    tr_session * session = tr_core_session( g_object_get_data( G_OBJECT( icon ), "tr-core" ) );
    5964
    60     tr_core_get_stats( core, &stats );
     65    /* up */
     66    if(((d = tr_sessionGetRawSpeed( session, TR_UP ))) < 0.1 )
     67        g_strlcpy( up, idle, sizeof( up ) );
     68    else
     69        tr_strlspeed( up, d, sizeof( up ) );
    6170
    62     tr_strlspeed( downStr, stats.clientDownloadSpeed, sizeof( downStr ) );
    63     tr_strlspeed( upStr, stats.clientUploadSpeed, sizeof( upStr ) );
    64     g_snprintf( tip, sizeof( tip ),
    65                 /* %1$'d is the number of torrents we're seeding,
    66                    %2$'d is the number of torrents we're downloading,
    67                    %3$s is our download speed,
    68                    %4$s is our upload speed */
    69                 _( "%1$'d Seeding, %2$'d Downloading\nDown: %3$s, Up: %4$s" ),
    70                 stats.seedingCount,
    71                 stats.downloadCount,
    72                 downStr, upStr );
     71    /* up limit */
     72    if( !tr_sessionGetActiveSpeedLimit( session, TR_UP, &limit ) )
     73        *upLimit = '\0';
     74    else {
     75        char buf[64];
     76        tr_strlspeed( buf, limit, sizeof( buf ) );
     77        g_snprintf( upLimit, sizeof( upLimit ), _( "(Limit: %s)" ), buf );
     78    }
     79
     80    /* down */
     81    if(((d = tr_sessionGetRawSpeed( session, TR_DOWN ))) < 0.1 )
     82        g_strlcpy( down, idle, sizeof( down ) );
     83    else
     84        tr_strlspeed( down, d, sizeof( down ) );
     85
     86    /* down limit */   
     87    if( !tr_sessionGetActiveSpeedLimit( session, TR_DOWN, &limit ) )
     88        *downLimit = '\0';
     89    else {
     90        char buf[64];
     91        tr_strlspeed( buf, limit, sizeof( buf ) );
     92        g_snprintf( downLimit, sizeof( downLimit ), _( "(Limit: %s)" ), buf );
     93    }
     94
     95    /* %1$s: current upload speed
     96     * %2$s: current upload limit, if any
     97     * %3$s: current download speed
     98     * %4$s: current download limit, if any */
     99    g_snprintf( tip, sizeof( tip ), _( "Transmission\nUp: %1$s %2$s\nDown: %3$s %4$s" ), up, upLimit, down, downLimit );
     100
    73101#if GTK_CHECK_VERSION( 2,16,0 )
    74102    gtk_status_icon_set_tooltip_text( GTK_STATUS_ICON( icon ), tip );
  • trunk/gtk/tr-prefs.c

    r8757 r8763  
    456456        const char * text;
    457457    } items[] = {
    458         { TR_CLEAR_PREFERRED,      N_( "Plaintext preferred" )  },
    459         { TR_ENCRYPTION_PREFERRED, N_( "Encryption preferred" ) },
    460         { TR_ENCRYPTION_REQUIRED,  N_( "Encryption required" )  }
     458        { TR_CLEAR_PREFERRED,      N_( "Allow encryption" )  },
     459        { TR_ENCRYPTION_PREFERRED, N_( "Prefer encryption" ) },
     460        { TR_ENCRYPTION_REQUIRED,  N_( "Require encryption" )  }
    461461    };
    462462
     
    13991399    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    14001400                              peerPage( core ),
    1401                               gtk_label_new ( _( "Peers" ) ) );
     1401                              gtk_label_new ( _( "Network" ) ) );
    14021402    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    14031403                              desktopPage( core ),
  • trunk/gtk/tr-window.c

    r8757 r8763  
    285285
    286286    g_signal_handler_disconnect( p->core, p->pref_handler_id );
     287    g_object_unref( G_OBJECT( p->alt_speed_image[1] ) );
     288    g_object_unref( G_OBJECT( p->alt_speed_image[0] ) );
    287289    g_free( p->filter_text );
    288290    g_free( p );
  • trunk/libtransmission/session.c

    r8745 r8763  
    10271027    int isLimited = TRUE;
    10281028
     1029    if( !tr_isSession( session ) )
     1030        return FALSE;
     1031
    10291032    if( tr_sessionUsesAltSpeed( session ) )
    10301033        *setme = tr_sessionGetAltSpeed( session, dir );
  • trunk/libtransmission/session.h

    r8727 r8763  
    141141tr_bool      tr_sessionAllowsDHT( const tr_session * session );
    142142
    143 tr_bool      tr_sessionGetActiveSpeedLimit( const tr_session  * session,
    144                                             tr_direction        dir,
    145                                             int               * setme );
    146 
    147143const char * tr_sessionFindTorrentFile( const tr_session * session,
    148144                                        const char *       hashString );
  • trunk/libtransmission/transmission.h

    r8741 r8763  
    630630void     tr_sessionSetAltSpeedFunc    ( tr_session *, tr_altSpeedFunc *, void * );
    631631
     632
     633tr_bool      tr_sessionGetActiveSpeedLimit( const tr_session  * session,
     634                                            tr_direction        dir,
     635                                            int               * setme );
     636
     637
    632638/***
    633639****
  • trunk/qt/prefs-dialog.cc

    r8751 r8763  
    361361
    362362QWidget *
    363 PrefsDialog :: createPeersTab( )
     363PrefsDialog :: createNetworkTab( )
    364364{
    365365    HIG * hig = new HIG( this );
     
    464464
    465465    QComboBox * box = new QComboBox( );
    466     box->addItem( tr( "Plaintext preferred" ), 0 );
    467     box->addItem( tr( "Encryption preferred" ), 1 );
    468     box->addItem( tr( "Encryption required" ), 2 );
     466    box->addItem( tr( "Allow encryption" ), 0 );
     467    box->addItem( tr( "Prefer encryption" ), 1 );
     468    box->addItem( tr( "Require encryption" ), 2 );
    469469    myWidgets.insert( Prefs :: ENCRYPTION, box );
    470470    connect( box, SIGNAL(activated(int)), this, SLOT(encryptionEdited(int)));
     
    579579    t->addTab( createSpeedTab( ),        tr( "Speed" ) );
    580580    t->addTab( createPrivacyTab( ),      tr( "Privacy" ) );
    581     t->addTab( createPeersTab( ),        tr( "Peers" ) );
     581    t->addTab( createNetworkTab( ),      tr( "Network" ) );
    582582    t->addTab( createWebTab( session ),  tr( "Web" ) );
    583583    //t->addTab( createTrackerTab( ),    tr( "Trackers" ) );
  • trunk/qt/prefs-dialog.h

    r8751 r8763  
    7979        bool isAllowed( int key ) const;
    8080        QWidget * createTorrentsTab( );
    81         QWidget * createPeersTab( );
     81        QWidget * createNetworkTab( );
    8282        QWidget * createPrivacyTab( );
    8383        QWidget * createSpeedTab( );
Note: See TracChangeset for help on using the changeset viewer.