Commits

Gabriele Lanaro  committed 3510987

Cleaning tasks, debugging the transfers GUI

  • Participants
  • Parent commits bf62534

Comments (0)

Files changed (2)

 * Short Term
-** First Iterate
-*** DONE Fixing the various imports, maybe through packaging
-    - State "DONE"       [2010-06-01 mar 11:02]
-*** DONE Removing menu, using actions instead of menuitems and activate. all in the main_win
-    - State "DONE"       [2010-06-01 mar 16:47]
-*** DONE Fixing send_folder dialog (maybe prepare a patch for pygtkhelpers)
-    - State "DONE"       [2010-06-01 mar 19:41]
-*** DONE no toplevel folder when launching main_folder
-    - State "DONE"       [2010-06-01 mar 19:58]
-*** DONE pygtkhelpers dialogs fixed, update code
+** Papercuts (Third iterate)
+*** TODO Trasfer file dialog is ugly [1/6]
 
-    - State "DONE"       from "TODO"       [2010-06-02 mer 13
-*** DONE directory transfer pass filenames (using protocol and RESOURCE)
-    - State "DONE"       from "TODO"       [2010-06-02 mer 19:08]
-*** CANCELED the dirs are not made really(just a print statement), handling of duplicated names (sufficient on the server side)
-    - State "CANCELED"   from "TODO"       [2010-06-03 gio 00:47] \\
-      too much difficult
-
-*** DONE Fixing the dialog (not start/stop/remove toolbar)
-    - State "DONE"       from "TODO"       [2010-06-03 gio 14:54]
-*** DONE preferences dialog for default dir
-*** DONE fixing strange cases
-    - State "DONE"       from "TODO"       [2010-06-03 gio 17:58]
-    - State "DONE"       from "TODO"       [2010-06-03 gio 17:21]
-    - State "DONE"       from "TODO"       [2010-06-03 gio 14:59]
-    - empty directory
-    - 0 length files
-
-*** DONE Find a way to avoid the blocking of the GUI
-
-*** DONE Sumbit a bug to twisted about blocking
-    - State "DONE"       [2010-06-10 gio 22:29]
-    - State "DONE"       [2010-06-10 gio 22:29]
-*** DONE Overriding directory, find a way to send an alert to the client
-    - State "DONE"       [2010-06-10 gio 22:29]
-
-
-
-** Second Iterate
-*** DONE Better packaging of pygtkhelpers
-    - State "DONE"       [2010-06-22 mar 23:21]
-*** CANCELED Cleaning of the file structure
-    - State "CANCELED"   [2010-06-22 mar 23:32] \\
-      Remainded in future under cleaning
-*** DONE Cleaning of the imports
-    - State "DONE"       [2010-06-22 mar 23:31]
-    CLOCK: [2010-06-22 mar 23:22]--[2010-06-22 mar 23:31] =>  0:09
-    
-*** DONE Packaging
-    - State "DONE"       [2010-06-22 mar 23:21]
-*** DONE Two computers with the same name conflicting
-    - State "DONE"       [2010-06-22 mar 23:21]
-
-
-
-** Papercuts (Third iterate)
-*** TODO Trasfer file dialog is ugly
-- [ ] bad speed representation
-- [ ] bad size
-- [ ] status not always updated
-- [ ] ETA not displayed
-- [ ] No icon
-- [ ] Menu hasn't any functionality
+    - [X] bad speed representation
+    - [ ] bad size
+    - [ ] status not always updated
+    - [ ] ETA not displayed
+    - [ ] No icon
+    - [ ] Menu hasn't any functionality
 
 *** TODO Design icon 22x22, refine 16x16
 *** TODO Statusbar not updating when finished
 
+
 ** Windows Packaging
 ** Release
 

File filesnake/gui/transfers.py

-from ..pygtkhelpers.ui.objectlist import ObjectList, Column, Cell
+from ..pygtkhelpers.ui.objectlist import ObjectList, Column
 from ..pygtkhelpers.delegates import SlaveView,ToplevelView
-from ..pygtkhelpers.utils import gsignal
+from ..pygtkhelpers.utils import gsignal,refresh_gui
+
 from gobject import GObject
 import time
 
 class TransferList(SlaveView):
     '''
-    Good candidate to be the transfer controller, at least it can be
-    adapted to it
+    The widget that displays the filesnake transfers
     '''
+
     def create_ui(self):        
         listing = ObjectList([
                 Column("filename", str, resizable = True),
                 Column("ETA",str),
                 Column("peer", str)
                 ])
+
         self.objectlist = listing
         self.widget.add(listing)
 
         if value < 1024:
             return "{0} b/s".format(value)
         elif value > 1024 and value <  1048576:
-            return "{0:.2} Kb/s".format(value/1024.0)
+            return "{0:.1f} Kb/s".format(value/1024.0)
         elif value > 1048576:
-            return "{0:.2} Mb/s".format(value/1048576.0)  
+            return "{0:.1f} Mb/s".format(value/1048576.0)  
     
     @speed.setter
     def speed(self, value):
         '''
         self.emit("changed")
         self.status = "finish"
-        
+
+
 def test():
     a = TransfersDialog()
     a.show()
-    import gtk
 
     for i in range(3):
         mon = a.add_transfer("galois", "filename%d"%i, 1024)
+        refresh_gui()
     for i in range(100):
         mon.producing("hello")
-        
-    gtk.main()
+        refresh_gui()
 
+def test_monitor():
+    tm = TransferMonitor("hello.pdf", 1400)
+    
+    tm.speed = 15
+    res = tm.speed 
+    assert (res == "15 b/s")
+    
+    tm.speed = 0
+    res = tm.speed
+    assert (res == "0 b/s")
+    
+    tm.speed = 10000
+    res = tm.speed
+    assert (res== "9.8 Kb/s")
 
-if __name__ == '__main__':
-    test()