Author: andar

Revision: 5808

Log:
        Commit #1019 allow up to 4 MiB piece sizes

Diff:
Modified: trunk/deluge/ui/gtkui/createtorrentdialog.py
===================================================================
--- trunk/deluge/ui/gtkui/createtorrentdialog.py        2009-10-04 19:11:37 UTC 
(rev 5807)
+++ trunk/deluge/ui/gtkui/createtorrentdialog.py        2009-10-04 19:15:35 UTC 
(rev 5808)
@@ -111,13 +111,20 @@
 
         self.dialog.show()
 
+    def parse_piece_size_text(self, value):
+        psize, metric = value.split()
+        psize = int(psize) * 1024
+        if metric[0] == 'M':
+            psize *= 1024
+            
+        return psize
+
     def adjust_piece_size(self):
         """Adjusts the recommended piece based on the file/folder/path 
selected."""
         size = self.files_treestore[0][2]
         model = self.glade.get_widget("combo_piece_size").get_model()
-        psize = 0
         for index,value in enumerate(model):
-            psize = int(value[0].split()[0]) * 1024
+            psize = self.parse_piece_size_text(value[0])
             pieces = size / psize
             if pieces < 2048 or (index + 1) == len(model):
                 self.glade.get_widget("combo_piece_size").set_active(index)
@@ -284,7 +291,8 @@
                 webseeds.append(l)
         # Get the piece length in bytes
         combo = self.glade.get_widget("combo_piece_size")
-        piece_length = 
int(combo.get_model()[combo.get_active()][0].split()[0]) * 1024
+        piece_length = \
+            
self.parse_piece_size_text(combo.get_model()[combo.get_active()][0])
         num_pieces = self.files_treestore[0][2] / piece_length
 
         author = self.glade.get_widget("entry_author").get_text()

Modified: trunk/deluge/ui/gtkui/glade/create_torrent_dialog.glade
===================================================================
--- trunk/deluge/ui/gtkui/glade/create_torrent_dialog.glade     2009-10-04 
19:11:37 UTC (rev 5807)
+++ trunk/deluge/ui/gtkui/glade/create_torrent_dialog.glade     2009-10-04 
19:15:35 UTC (rev 5808)
@@ -553,7 +553,10 @@
 64 KiB
 128 KiB
 256 KiB
-512 KiB</property>
+512 KiB
+1 MiB
+2 MiB
+4 MiB</property>
                           </widget>
                           <packing>
                             <property name="expand">False</property>



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to