/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: Szilveszter Farkas (Phanatic)
  • Date: 2007-08-16 07:17:26 UTC
  • mfrom: (257 trunk)
  • mto: This revision was merged to the branch mainline in revision 258.
  • Revision ID: szilveszter.farkas@gmail.com-20070816071726-3d3y82e7v7qo4ytt
Merge the changes from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
from bzrlib.plugins.gtk.push import PushDialog
56
56
from bzrlib.plugins.gtk.revbrowser import RevisionBrowser
57
57
 
 
58
def about():
 
59
    """ Display the AboutDialog. """
 
60
    from bzrlib.plugins.gtk import __version__
 
61
    from bzrlib.plugins.gtk.olive.guifiles import GLADEFILENAME
 
62
 
 
63
    # Load AboutDialog description
 
64
    dglade = gtk.glade.XML(GLADEFILENAME, 'aboutdialog')
 
65
    dialog = dglade.get_widget('aboutdialog')
 
66
 
 
67
    # Set version
 
68
    dialog.set_version(__version__)
 
69
 
 
70
    dialog.run()
 
71
    # Destroy the dialog
 
72
    dialog.destroy()
 
73
 
58
74
class OliveGtk:
59
75
    """ The main Olive GTK frontend class. This is called when launching the
60
76
    program. """
354
370
                return self.remote_branch.base
355
371
   
356
372
    def on_about_activate(self, widget):
357
 
        from bzrlib.plugins.gtk.dialog import about
358
373
        about()
359
 
        
360
374
    
361
375
    def on_button_history_browse_clicked(self, widget):
362
376
        """ Browse for revision button handler. """
839
853
    def _load_right(self):
840
854
        """ Load data into the right panel. (Filelist) """
841
855
        # Create ListStore
842
 
        # 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 ]
843
857
        liststore = gtk.ListStore(gobject.TYPE_STRING,
844
858
                                  gobject.TYPE_BOOLEAN,
845
859
                                  gobject.TYPE_STRING,
846
860
                                  gobject.TYPE_STRING,
847
861
                                  gobject.TYPE_STRING,
848
 
                                  gobject.TYPE_INT,
 
862
                                  gobject.TYPE_STRING,
849
863
                                  gobject.TYPE_STRING,
850
864
                                  gobject.TYPE_INT,
851
865
                                  gobject.TYPE_STRING,
878
892
                               item,
879
893
                               '',
880
894
                               '',
881
 
                               statinfo.st_size,
882
 
                               self._format_size(statinfo.st_size),
 
895
                               "<DIR>",
 
896
                               "<DIR>",
883
897
                               statinfo.st_mtime,
884
898
                               self._format_date(statinfo.st_mtime),
885
899
                               ''])
939
953
                              item,
940
954
                              st,
941
955
                              status,
942
 
                              statinfo.st_size,
 
956
                              str(statinfo.st_size), # NOTE: if int used there it will fail for large files (size expressed as long int)
943
957
                              self._format_size(statinfo.st_size),
944
958
                              statinfo.st_mtime,
945
959
                              self._format_date(statinfo.st_mtime),
1165
1179
                                  item,
1166
1180
                                  '',
1167
1181
                                  '',
1168
 
                                  statinfo.st_size,
1169
 
                                  self._format_size(statinfo.st_size),
 
1182
                                  "<DIR>",
 
1183
                                  "<DIR>",
1170
1184
                                  statinfo.st_mtime,
1171
1185
                                  self._format_date(statinfo.st_mtime),
1172
1186
                                  ''])
1226
1240
                                  item,
1227
1241
                                  st,
1228
1242
                                  status,
1229
 
                                  statinfo.st_size,
 
1243
                                  str(statinfo.st_size),
1230
1244
                                  self._format_size(statinfo.st_size),
1231
1245
                                  statinfo.st_mtime,
1232
1246
                                  self._format_date(statinfo.st_mtime),
1283
1297
                                       item.name,
1284
1298
                                       '',
1285
1299
                                       '',
1286
 
                                       0,
1287
 
                                       self._format_size(0),
 
1300
                                       "<DIR>",
 
1301
                                       "<DIR>",
1288
1302
                                       rev.timestamp,
1289
1303
                                       self._format_date(rev.timestamp),
1290
1304
                                       ''
1300
1314
                                       item.name,
1301
1315
                                       '',
1302
1316
                                       '',
1303
 
                                       item.text_size,
 
1317
                                       str(item.text_size),
1304
1318
                                       self._format_size(item.text_size),
1305
1319
                                       rev.timestamp,
1306
1320
                                       self._format_date(rev.timestamp),
1402
1416
    
1403
1417
    def _format_size(self, size):
1404
1418
        """ Format size to a human readable format. """
1405
 
        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) 
1406
1428
    
1407
1429
    def _format_date(self, timestamp):
1408
1430
        """ Format the time (given in secs) to a human readable format. """