/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/__init__.py

  • Committer: Mateusz Korniak
  • Date: 2007-07-21 14:55:44 UTC
  • mto: This revision was merged to the branch mainline in revision 248.
  • Revision ID: matkor@laptop-hp-20070721145544-4r58383ilp9ogqt3
Fixes crash when operating over files which are large enouth to have size represented by long int
Size of dir is <DIR> now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
853
853
    def _load_right(self):
854
854
        """ Load data into the right panel. (Filelist) """
855
855
        # Create ListStore
856
 
        # Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid]
 
856
        # Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
857
857
        liststore = gtk.ListStore(gobject.TYPE_STRING,
858
858
                                  gobject.TYPE_BOOLEAN,
859
859
                                  gobject.TYPE_STRING,
860
860
                                  gobject.TYPE_STRING,
861
861
                                  gobject.TYPE_STRING,
862
 
                                  gobject.TYPE_INT,
 
862
                                  gobject.TYPE_STRING,
863
863
                                  gobject.TYPE_STRING,
864
864
                                  gobject.TYPE_INT,
865
865
                                  gobject.TYPE_STRING,
892
892
                               item,
893
893
                               '',
894
894
                               '',
895
 
                               statinfo.st_size,
896
 
                               self._format_size(statinfo.st_size),
 
895
                               "<DIR>",
 
896
                               "<DIR>",
897
897
                               statinfo.st_mtime,
898
898
                               self._format_date(statinfo.st_mtime),
899
899
                               ''])
953
953
                              item,
954
954
                              st,
955
955
                              status,
956
 
                              statinfo.st_size,
 
956
                              str(statinfo.st_size), # NOTE: if int used there it will fail for large files (size expressed as long int)
957
957
                              self._format_size(statinfo.st_size),
958
958
                              statinfo.st_mtime,
959
959
                              self._format_date(statinfo.st_mtime),
1179
1179
                                  item,
1180
1180
                                  '',
1181
1181
                                  '',
1182
 
                                  statinfo.st_size,
1183
 
                                  self._format_size(statinfo.st_size),
 
1182
                                  "<DIR>",
 
1183
                                  "<DIR>",
1184
1184
                                  statinfo.st_mtime,
1185
1185
                                  self._format_date(statinfo.st_mtime),
1186
1186
                                  ''])
1240
1240
                                  item,
1241
1241
                                  st,
1242
1242
                                  status,
1243
 
                                  statinfo.st_size,
 
1243
                                  str(statinfo.st_size),
1244
1244
                                  self._format_size(statinfo.st_size),
1245
1245
                                  statinfo.st_mtime,
1246
1246
                                  self._format_date(statinfo.st_mtime),
1297
1297
                                       item.name,
1298
1298
                                       '',
1299
1299
                                       '',
1300
 
                                       0,
1301
 
                                       self._format_size(0),
 
1300
                                       "<DIR>",
 
1301
                                       "<DIR>",
1302
1302
                                       rev.timestamp,
1303
1303
                                       self._format_date(rev.timestamp),
1304
1304
                                       ''
1314
1314
                                       item.name,
1315
1315
                                       '',
1316
1316
                                       '',
1317
 
                                       item.text_size,
 
1317
                                       str(item.text_size),
1318
1318
                                       self._format_size(item.text_size),
1319
1319
                                       rev.timestamp,
1320
1320
                                       self._format_date(rev.timestamp),
1416
1416
    
1417
1417
    def _format_size(self, size):
1418
1418
        """ Format size to a human readable format. """
1419
 
        return size
 
1419
        if size < 1000:
 
1420
            return "%d[B]" % (size,)
 
1421
        size = size / 1000.0
 
1422
        
 
1423
        for metric in ["kB","MB","GB","TB"]:
 
1424
            if size < 1000:
 
1425
                break
 
1426
            size = size / 1000.0
 
1427
        return "%.1f[%s]" % (size,metric) 
1420
1428
    
1421
1429
    def _format_date(self, timestamp):
1422
1430
        """ Format the time (given in secs) to a human readable format. """