From: Alexandre H <ham...@co...> - 2003-08-29 01:58:36
|
Hello, Attached is a patch which makes file transfer windows display the transfer speed in K/s. A few changes to the file gui.tcl have been made. A common body is now shared between the r{} and s{} conditionals in the switch{} statement found in the FTProgress procedure. The extra lines are responsible for calculating the new speeds based upon the number of bytes received within a given interval (a variable is defined for the interval length in milliseconds so this can be easily changed). The transfer rate works when there are multiple file transfer windows opened as well. Some comment lines in the source code explains the details of the implementation. There might be other ways to implement it that are more or less complex and/or structured. I'd love to hear about alternatives. I thought that using the command "after" would have been rather complex to implement, while isolating the code into a separate procedure would yield in much code added as a lot of the variables would have had to be transfered from one procedure to another. To me, the latter approach also suffered from the difficulty of dividing the layers in a clean manner. (FTProgress does update the label for the number of bytes transfered so far and that, at every packet transfered; but the speed is only updated currently at every second. That posed a problem as to what procedure does the 1-second updates belong to: FTProgress or a new one. I chose to put everything into FTProgress.) Comments are welcomed. Alexandre Hamelin |