Changeset 8751


Ignore:
Timestamp:
Jun 27, 2009, 5:23:13 AM (13 years ago)
Author:
charles
Message:

(trunk gtk,qt) more o/c simplification of the prefs dialog

Location:
trunk
Files:
5 edited

Legend:

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

    r8738 r8751  
    377377/* prefs dialog is being destroyed, so stop listening to blocklist updates */
    378378static void
    379 peerPageDestroyed( gpointer gdata, GObject * dead UNUSED )
     379privacyPageDestroyed( gpointer gdata, GObject * dead UNUSED )
    380380{
    381381    struct blocklist_data * data = gdata;
     
    488488
    489489static GtkWidget*
    490 peerPage( GObject * core )
     490privacyPage( GObject * core )
    491491{
    492492    int                     row = 0;
     
    545545#endif
    546546
    547     hig_workarea_add_section_divider( t, &row );
    548     hig_workarea_add_section_title( t, &row, _( "Limits" ) );
    549 
    550     w = new_spin_button( TR_PREFS_KEY_PEER_LIMIT_TORRENT, core, 1, 300, 5 );
    551     hig_workarea_add_row( t, &row, _( "Maximum peers per _torrent:" ), w, NULL );
    552     w = new_spin_button( TR_PREFS_KEY_PEER_LIMIT_GLOBAL, core, 1, 3000, 5 );
    553     hig_workarea_add_row( t, &row, _( "Maximum peers _overall:" ), w, NULL );
    554 
    555547    hig_workarea_finish( t, &row );
    556     g_object_weak_ref( G_OBJECT( t ), peerPageDestroyed, data );
     548    g_object_weak_ref( G_OBJECT( t ), privacyPageDestroyed, data );
    557549    return t;
    558550}
     
    12821274
    12831275static void
    1284 networkPageDestroyed( gpointer gdata, GObject * dead UNUSED )
     1276peerPageDestroyed( gpointer gdata, GObject * dead UNUSED )
    12851277{
    12861278    struct network_page_data * data = gdata;
     
    13141306
    13151307static GtkWidget*
    1316 networkPage( GObject * core )
     1308peerPage( GObject * core )
    13171309{
    13181310    int                        row = 0;
     
    13401332    gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f );
    13411333    gtk_box_pack_start( GTK_BOX( h ), l, TRUE, TRUE, 0 );
    1342     w = data->portButton = gtk_button_new_with_mnemonic( _( "_Test Port" ) );
     1334    w = data->portButton = gtk_button_new_with_mnemonic( _( "Te_st Port" ) );
    13431335    gtk_box_pack_end( GTK_BOX( h ), w, FALSE, FALSE, 0 );
    13441336    g_signal_connect( w, "clicked", G_CALLBACK(onPortTest), data );
    13451337    hig_workarea_add_row( t, &row, NULL, h, NULL );
    13461338    data->prefsTag = g_signal_connect( TR_CORE( core ), "prefs-changed", G_CALLBACK( onCorePrefsChanged ), data );
    1347     g_object_weak_ref( G_OBJECT( t ), networkPageDestroyed, data );
     1339    g_object_weak_ref( G_OBJECT( t ), peerPageDestroyed, data );
    13481340
    13491341    s = _( "Use UPnP or NAT-PMP port _forwarding from my router" );
     
    13541346    w = new_check_button( s, TR_PREFS_KEY_PEER_PORT_RANDOM_ON_START, core );
    13551347    hig_workarea_add_wide_control( t, &row, w );
     1348
     1349    hig_workarea_add_section_divider( t, &row );
     1350    hig_workarea_add_section_title( t, &row, _( "Limits" ) );
     1351
     1352    w = new_spin_button( TR_PREFS_KEY_PEER_LIMIT_TORRENT, core, 1, 300, 5 );
     1353    hig_workarea_add_row( t, &row, _( "Maximum peers per _torrent:" ), w, NULL );
     1354    w = new_spin_button( TR_PREFS_KEY_PEER_LIMIT_GLOBAL, core, 1, 3000, 5 );
     1355    hig_workarea_add_row( t, &row, _( "Maximum peers _overall:" ), w, NULL );
    13561356
    13571357    hig_workarea_finish( t, &row );
     
    13881388                              gtk_label_new ( _( "Torrents" ) ) );
    13891389    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    1390                               peerPage( core ),
    1391                               gtk_label_new ( _( "Peers" ) ) );
    1392     gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    13931390                              bandwidthPage( core ),
    13941391                              gtk_label_new ( _( "Speed" ) ) );
    13951392    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    1396                               networkPage( core ),
    1397                               gtk_label_new ( _( "Network" ) ) );
     1393                              privacyPage( core ),
     1394                              gtk_label_new ( _( "Privacy" ) ) );
     1395    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
     1396                              peerPage( core ),
     1397                              gtk_label_new ( _( "Peers" ) ) );
    13981398    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    13991399                              desktopPage( core ),
  • trunk/gtk/tr-window.c

    r8729 r8751  
    271271        tr_window_update( (TrWindow*)wind );
    272272    }
    273     else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_ENABLED ) )
     273    else if( !strcmp( key, TR_PREFS_KEY_ALT_SPEED_ENABLED ) ||
     274             !strcmp( key, TR_PREFS_KEY_ALT_SPEED_UP ) ||
     275             !strcmp( key, TR_PREFS_KEY_ALT_SPEED_DOWN ) )
    274276    {
    275277        syncAltSpeedButton( p );
     
    325327syncAltSpeedButton( PrivateData * p )
    326328{
    327     const char * tip;
     329    char u[32];
     330    char d[32];
     331    char buf[128];
     332    const char * fmt;
    328333    const gboolean b = pref_flag_get( TR_PREFS_KEY_ALT_SPEED_ENABLED );
    329334    GtkWidget * w = p->alt_speed_button;
    330335
     336    tr_strlspeed( u, pref_int_get( TR_PREFS_KEY_ALT_SPEED_UP ), sizeof( u ) );
     337    tr_strlspeed( d, pref_int_get( TR_PREFS_KEY_ALT_SPEED_DOWN ), sizeof( d ) );
     338    fmt = b ? _( "Click to disable Temporary Speed Limits\n(%1$s down, %2$s up)" )
     339            : _( "Click to enable Temporary Speed Limits\n(%1$s down, %2$s up)" );
     340    g_snprintf( buf, sizeof( buf ), fmt, d, u );
     341
    331342    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), b );
    332 
    333343    gtk_button_set_image( GTK_BUTTON( w ), p->alt_speed_image[b?1:0] );
    334344    gtk_button_set_alignment( GTK_BUTTON( w ), 0.5, 0.5 );
    335 
    336     tip = b ? _( "Click to disable Temporary Speed Limits" )
    337             : _( "Click to enable Temporary Speed Limits" );
    338     gtr_widget_set_tooltip_text( w, tip );
     345    gtr_widget_set_tooltip_text( w, buf );
    339346}
    340347
  • trunk/qt/mainwin.cc

    r8729 r8751  
    10041004
    10051005        case Prefs :: ALT_SPEED_LIMIT_ENABLED:
     1006        case Prefs :: ALT_SPEED_LIMIT_UP:
     1007        case Prefs :: ALT_SPEED_LIMIT_DOWN: {
    10061008            b = myPrefs.getBool( key );
    10071009            myAltSpeedButton->setChecked( b );
    10081010            myAltSpeedButton->setIcon( b ? mySpeedModeOnIcon : mySpeedModeOffIcon );
    1009             myAltSpeedButton->setToolTip( b ? tr( "Click to disable Temporary Speed Limits" )
    1010                                             : tr( "Click to enable Temporary Speed Limits" ) );
    1011             break;
     1011            const QString fmt = b ? tr( "Click to disable Temporary Speed Limits\n(%1 down, %2 up)" )
     1012                                  : tr( "Click to enable Temporary Speed Limits\n(%1 down, %2 up)" );
     1013            const Speed d = Speed::fromKbps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_DOWN ) );
     1014            const Speed u = Speed::fromKbps( myPrefs.getInt( Prefs::ALT_SPEED_LIMIT_UP ) );
     1015            myAltSpeedButton->setToolTip( fmt.arg( Utils::speedToString( d ) )
     1016                                             .arg( Utils::speedToString( u ) ) );
     1017            break;
     1018        }
    10121019
    10131020        default:
  • trunk/qt/prefs-dialog.cc

    r8738 r8751  
    261261
    262262QWidget *
    263 PrefsDialog :: createBandwidthTab( )
     263PrefsDialog :: createSpeedTab( )
    264264{
    265265    QWidget *l, *r;
     
    361361
    362362QWidget *
    363 PrefsDialog :: createNetworkTab( )
     363PrefsDialog :: createPeersTab( )
    364364{
    365365    HIG * hig = new HIG( this );
    366366    hig->addSectionTitle( tr( "Incoming Peers" ) );
    367367
    368         QSpinBox * s = spinBoxNew( Prefs::PEER_PORT, 1, 65535, 1 );
    369         QHBoxLayout * h = new QHBoxLayout( );
    370         QPushButton * b = myPortButton = new QPushButton( tr( "&Test Port" ) );
    371         QLabel * l = myPortLabel = new QLabel( tr( "Status unknown" ) );
    372         h->addWidget( l );
    373         h->addSpacing( HIG :: PAD_BIG );
    374         h->addWidget( b );
    375         h->setStretchFactor( l, 1 );
    376         connect( b, SIGNAL(clicked(bool)), this, SLOT(onPortTest()));
    377         connect( &mySession, SIGNAL(portTested(bool)), this, SLOT(onPortTested(bool)));
    378 
    379         hig->addRow( tr( "&Port for incoming connections:" ), s );
    380         hig->addRow( "", h, 0 );
    381         hig->addWideControl( checkBoxNew( tr( "Use UPnP or NAT-PMP port &forwarding from my router" ), Prefs::PORT_FORWARDING ) );
    382         hig->addWideControl( checkBoxNew( tr( "Pick a &random port every time Transmission is started" ), Prefs :: PEER_PORT_RANDOM_ON_START ) );
     368    QSpinBox * s = spinBoxNew( Prefs::PEER_PORT, 1, 65535, 1 );
     369    QHBoxLayout * h = new QHBoxLayout( );
     370    QPushButton * b = myPortButton = new QPushButton( tr( "&Test Port" ) );
     371    QLabel * l = myPortLabel = new QLabel( tr( "Status unknown" ) );
     372    h->addWidget( l );
     373    h->addSpacing( HIG :: PAD_BIG );
     374    h->addWidget( b );
     375    h->setStretchFactor( l, 1 );
     376    connect( b, SIGNAL(clicked(bool)), this, SLOT(onPortTest()));
     377    connect( &mySession, SIGNAL(portTested(bool)), this, SLOT(onPortTested(bool)));
     378
     379    hig->addRow( tr( "&Port for incoming connections:" ), s );
     380    hig->addRow( "", h, 0 );
     381    hig->addWideControl( checkBoxNew( tr( "Use UPnP or NAT-PMP port &forwarding from my router" ), Prefs::PORT_FORWARDING ) );
     382    hig->addWideControl( checkBoxNew( tr( "Pick a &random port every time Transmission is started" ), Prefs :: PEER_PORT_RANDOM_ON_START ) );
     383
     384    hig->addSectionDivider( );
     385    hig->addSectionTitle( tr( "Limits" ) );
     386    hig->addRow( tr( "Maximum peers per &torrent:" ), spinBoxNew( Prefs::PEER_LIMIT_TORRENT, 1, 300, 5 ) );
     387    hig->addRow( tr( "Maximum peers &overall:" ), spinBoxNew( Prefs::PEER_LIMIT_GLOBAL, 1, 3000, 5 ) );
    383388
    384389    hig->finish( );
     
    440445
    441446QWidget *
    442 PrefsDialog :: createPeersTab( )
     447PrefsDialog :: createPrivacyTab( )
    443448{
    444449    HIG * hig = new HIG( this );
     
    471476    hig->addWideControl( checkBoxNew( tr( "Use &DHT to find more peers" ), Prefs::DHT_ENABLED ) );
    472477
    473     hig->addSectionDivider( );
    474     hig->addSectionTitle( tr( "Limits" ) );
    475     hig->addRow( tr( "Maximum peers per &torrent:" ), spinBoxNew( Prefs::PEER_LIMIT_TORRENT, 1, 300, 5 ) );
    476     hig->addRow( tr( "Maximum peers &overall:" ), spinBoxNew( Prefs::PEER_LIMIT_GLOBAL, 1, 3000, 5 ) );
    477 
    478478    hig->finish( );
    479479    updateBlocklistCheckBox( );
     
    576576
    577577    QTabWidget * t = new QTabWidget( this );
    578     t->addTab( createTorrentsTab( ),       tr( "Torrents" ) );
    579     t->addTab( createPeersTab( ),          tr( "Peers" ) );
    580     t->addTab( createBandwidthTab( ),      tr( "Speed" ) );
    581     t->addTab( createNetworkTab( ),        tr( "Network" ) );
    582     t->addTab( createWebTab( session ),    tr( "Web" ) );
    583     //t->addTab( createTrackerTab( ),        tr( "Trackers" ) );
     578    t->addTab( createTorrentsTab( ),     tr( "Torrents" ) );
     579    t->addTab( createSpeedTab( ),        tr( "Speed" ) );
     580    t->addTab( createPrivacyTab( ),      tr( "Privacy" ) );
     581    t->addTab( createPeersTab( ),        tr( "Peers" ) );
     582    t->addTab( createWebTab( session ),  tr( "Web" ) );
     583    //t->addTab( createTrackerTab( ),    tr( "Trackers" ) );
    584584    myLayout->addWidget( t );
    585585
  • trunk/qt/prefs-dialog.h

    r8570 r8751  
    8080        QWidget * createTorrentsTab( );
    8181        QWidget * createPeersTab( );
    82         QWidget * createNetworkTab( );
    83         QWidget * createBandwidthTab( );
     82        QWidget * createPrivacyTab( );
     83        QWidget * createSpeedTab( );
    8484        QWidget * createWebTab( Session& );
    8585        QWidget * createTrackerTab( );
Note: See TracChangeset for help on using the changeset viewer.