Changeset 8021 for trunk/gtk/details.c


Ignore:
Timestamp:
Mar 4, 2009, 7:52:57 PM (13 years ago)
Author:
charles
Message:

(trunk) libT and gtk+ parts for #1889: per-torrent vs. global speed limit confusion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r8001 r8021  
    11531153
    11541154static void
    1155 speed_toggled_cb( GtkToggleButton * tb,
    1156                   gpointer          gtor,
    1157                   int               up_or_down )
     1155up_speed_toggled_cb( GtkToggleButton *tb,
     1156                     gpointer         gtor )
    11581157{
    11591158    tr_torrent * tor = tr_torrent_handle ( gtor );
    1160     gboolean     b = gtk_toggle_button_get_active( tb );
    1161 
    1162     tr_torrentSetSpeedMode( tor, up_or_down, b ? TR_SPEEDLIMIT_SINGLE
    1163                             : TR_SPEEDLIMIT_GLOBAL );
    1164 }
    1165 
    1166 static void
    1167 ul_speed_toggled_cb( GtkToggleButton *tb,
    1168                      gpointer         gtor )
    1169 {
    1170     speed_toggled_cb( tb, gtor, TR_UP );
    1171 }
    1172 
    1173 static void
    1174 dl_speed_toggled_cb( GtkToggleButton *tb,
    1175                      gpointer         gtor )
    1176 {
    1177     speed_toggled_cb( tb, gtor, TR_DOWN );
     1159    const gboolean b = gtk_toggle_button_get_active( tb );
     1160
     1161    tr_torrentUseSpeedLimit( tor, TR_UP, b );
     1162}
     1163
     1164static void
     1165down_speed_toggled_cb( GtkToggleButton *tb,
     1166                       gpointer         gtor )
     1167{
     1168    tr_torrent * tor = tr_torrent_handle ( gtor );
     1169    const gboolean b = gtk_toggle_button_get_active( tb );
     1170
     1171    tr_torrentUseSpeedLimit( tor, TR_DOWN, b );
     1172}
     1173
     1174static void
     1175global_speed_toggled_cb( GtkToggleButton * tb, gpointer gtor )
     1176{
     1177    tr_torrent * tor = tr_torrent_handle ( gtor );
     1178    const gboolean b = gtk_toggle_button_get_active( tb );
     1179
     1180    tr_torrentUseGlobalSpeedLimit( tor, TR_UP, b );
     1181    tr_torrentUseGlobalSpeedLimit( tor, TR_DOWN, b );
    11781182}
    11791183
     
    11921196
    11931197static void
    1194 sensitize_from_check_cb( GtkToggleButton *toggle,
    1195                          gpointer         w )
     1198sensitize_from_check_cb( GtkToggleButton * toggle, gpointer w )
    11961199{
    11971200    gtk_widget_set_sensitive ( GTK_WIDGET( w ),
    1198                               gtk_toggle_button_get_active( toggle ) );
    1199 }
    1200 
    1201 static void
    1202 setSpeedLimit( GtkSpinButton* spin,
    1203                gpointer       gtor,
    1204                int            up_or_down )
     1201                               gtk_toggle_button_get_active( toggle ) );
     1202}
     1203
     1204static void
     1205setSpeedLimit( GtkSpinButton* spin, gpointer gtor, int up_or_down )
    12051206{
    12061207    tr_torrent * tor = tr_torrent_handle ( gtor );
    1207     int          kb_sec = gtk_spin_button_get_value_as_int ( spin );
     1208    const int kb_sec = gtk_spin_button_get_value_as_int ( spin );
    12081209
    12091210    tr_torrentSetSpeedLimit( tor, up_or_down, kb_sec );
     
    12111212
    12121213static void
    1213 ul_speed_spun_cb( GtkSpinButton *spin,
    1214                   gpointer       gtor )
     1214up_speed_spun_cb( GtkSpinButton * spin, gpointer gtor )
    12151215{
    12161216    setSpeedLimit( spin, gtor, TR_UP );
     
    12181218
    12191219static void
    1220 dl_speed_spun_cb( GtkSpinButton *spin,
    1221                   gpointer       gtor )
     1220down_speed_spun_cb( GtkSpinButton * spin, gpointer gtor )
    12221221{
    12231222    setSpeedLimit( spin, gtor, TR_DOWN );
     
    12251224
    12261225static void
    1227 ratio_spun_cb( GtkSpinButton *spin,
    1228                gpointer       gtor )
     1226ratio_spun_cb( GtkSpinButton * spin, gpointer gtor )
    12291227{
    12301228    tr_torrent * tor = tr_torrent_handle ( gtor );
     
    12351233
    12361234static void
    1237 max_peers_spun_cb( GtkSpinButton * spin,
    1238                    gpointer        gtor )
     1235max_peers_spun_cb( GtkSpinButton * spin, gpointer gtor )
    12391236{
    12401237    const uint16_t n = gtk_spin_button_get_value( spin );
     
    12861283    row = 0;
    12871284    t = hig_workarea_create ( );
    1288     hig_workarea_add_section_title ( t, &row, _( "Limits" ) );
    1289 
    1290     tb =
    1291         gtk_check_button_new_with_mnemonic ( _(
    1292                                                 "Limit _download speed (KB/s):" ) );
    1293     b = tr_torrentGetSpeedMode( tor, TR_DOWN ) == TR_SPEEDLIMIT_SINGLE;
    1294     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON( tb ), b );
    1295     g_signal_connect ( tb, "toggled", G_CALLBACK(
    1296                            dl_speed_toggled_cb ), gtor );
    1297 
    1298     i = tr_torrentGetSpeedLimit( tor, TR_DOWN );
    1299     w = gtk_spin_button_new_with_range( 1, INT_MAX, 5 );
    1300     gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), i );
    1301 
    1302     g_signal_connect ( w, "value-changed", G_CALLBACK(
    1303                            dl_speed_spun_cb ), gtor );
    1304     g_signal_connect ( tb, "toggled", G_CALLBACK(
    1305                            sensitize_from_check_cb ), w );
    1306     sensitize_from_check_cb ( GTK_TOGGLE_BUTTON( tb ), w );
    1307     hig_workarea_add_row_w ( t, &row, tb, w, NULL );
    1308 
    1309     tb =
    1310         gtk_check_button_new_with_mnemonic ( _(
    1311                                                 "Limit _upload speed (KB/s):" ) );
    1312     b = tr_torrentGetSpeedMode( tor, TR_UP ) == TR_SPEEDLIMIT_SINGLE;
    1313     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON( tb ), b );
    1314     g_signal_connect ( tb, "toggled", G_CALLBACK(
    1315                            ul_speed_toggled_cb ), gtor );
    1316 
    1317     i = tr_torrentGetSpeedLimit( tor, TR_UP );
    1318     w = gtk_spin_button_new_with_range( 1, INT_MAX, 5 );
    1319     gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), i );
    1320 
    1321     g_signal_connect ( w, "value-changed", G_CALLBACK(
    1322                            ul_speed_spun_cb ), gtor );
    1323     g_signal_connect ( tb, "toggled", G_CALLBACK(
    1324                            sensitize_from_check_cb ), w );
    1325     sensitize_from_check_cb ( GTK_TOGGLE_BUTTON( tb ), w );
    1326     hig_workarea_add_row_w ( t, &row, tb, w, NULL );
     1285    hig_workarea_add_section_title ( t, &row, _( "Speed Limits" ) );
     1286
     1287        b = tr_torrentIsUsingGlobalSpeedLimit( tor, TR_UP );
     1288        tb = hig_workarea_add_wide_checkbutton( t, &row, _( "Honor global _limits" ), b );
     1289        g_signal_connect( tb, "toggled", G_CALLBACK( global_speed_toggled_cb ), gtor );
     1290
     1291        tb = gtk_check_button_new_with_mnemonic ( _( "Limit _download speed (KB/s):" ) );
     1292        b = tr_torrentIsUsingSpeedLimit( tor, TR_DOWN );
     1293        gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON( tb ), b );
     1294        g_signal_connect ( tb, "toggled", G_CALLBACK( down_speed_toggled_cb ), gtor );
     1295
     1296        i = tr_torrentGetSpeedLimit( tor, TR_DOWN );
     1297        w = gtk_spin_button_new_with_range( 1, INT_MAX, 5 );
     1298        gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), i );
     1299        g_signal_connect ( w, "value-changed", G_CALLBACK( down_speed_spun_cb ), gtor );
     1300        g_signal_connect ( tb, "toggled", G_CALLBACK( sensitize_from_check_cb ), w );
     1301        sensitize_from_check_cb ( GTK_TOGGLE_BUTTON( tb ), w );
     1302        hig_workarea_add_row_w ( t, &row, tb, w, NULL );
     1303
     1304        tb = gtk_check_button_new_with_mnemonic ( _( "Limit _upload speed (KB/s):" ) );
     1305        b = tr_torrentIsUsingSpeedLimit( tor, TR_UP );
     1306        gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON( tb ), b );
     1307        g_signal_connect ( tb, "toggled", G_CALLBACK( up_speed_toggled_cb ), gtor );
     1308
     1309        i = tr_torrentGetSpeedLimit( tor, TR_UP );
     1310        w = gtk_spin_button_new_with_range( 1, INT_MAX, 5 );
     1311        gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), i );
     1312        g_signal_connect ( w, "value-changed", G_CALLBACK( up_speed_spun_cb ), gtor );
     1313        g_signal_connect ( tb, "toggled", G_CALLBACK( sensitize_from_check_cb ), w );
     1314        sensitize_from_check_cb ( GTK_TOGGLE_BUTTON( tb ), w );
     1315        hig_workarea_add_row_w ( t, &row, tb, w, NULL );
    13271316
    13281317    hig_workarea_add_section_divider ( t, &row );
    13291318    hig_workarea_add_section_title ( t, &row, _( "Seed-Until Ratio" ) );
    1330 
    13311319
    13321320        group = NULL;
Note: See TracChangeset for help on using the changeset viewer.