Added 'Sizes in bytes' togglebutton to files.out_table
authorEugene Gagarin <mosfet07@ya.ru>
Mon, 18 May 2009 11:13:14 +0000 (15:13 +0400)
committerEugene Gagarin <mosfet07@ya.ru>
Mon, 18 May 2009 11:13:14 +0000 (15:13 +0400)
src/files/out_table.py

index 6bd66eb..fa3d7a1 100755 (executable)
@@ -41,19 +41,19 @@ class Gtk_Presentation(object):
         cell1 = gtk.CellRendererText()
         cell1.set_property('width', 90)
         size_col.pack_start(cell1, True)
-        size_col.add_attribute(cell1, 'text', 1)
+        size_col.add_attribute(cell1, 'text', 0)
         treeview.append_column(size_col)
 
         # 'Path' column
         path_col = gtk.TreeViewColumn(_('Path'))
         cell2 = gtk.CellRendererText()
         path_col.pack_start(cell2, True)
-        path_col.add_attribute(cell2, 'markup', 0)
+        path_col.add_attribute(cell2, 'markup', 1)
         treeview.append_column(path_col)
 
         # Column sorting
         treeview.set_search_column(1)
-        path_col.set_sort_column_id(0)
+        path_col.set_sort_column_id(1)
         size_col.set_sort_column_id(2)
 
         # Add treeview to scrolled window
@@ -77,6 +77,10 @@ class Gtk_Presentation(object):
         relpaths_tbtn.connect('clicked', self._show_relpaths)
         abspaths_tbtn.connect('clicked', self._show_abspaths)
 
+        bitesizes_tbtn = gtk.ToggleToolButton()
+        bitesizes_tbtn.set_label(_('Sizes in bytes'))
+        bitesizes_tbtn.connect('clicked', self._show_bitesizes)
+
         saveresults_tbtn = gtk.ToolButton('gtk-save')
         saveresults_tbtn.connect('clicked', self.save_results)
 
@@ -85,6 +89,7 @@ class Gtk_Presentation(object):
 
         toolbar.insert(relpaths_tbtn, -1)
         toolbar.insert(abspaths_tbtn, -1)
+        toolbar.insert(bitesizes_tbtn, -1)
         toolbar.insert(saveresults_tbtn, -1)
         toolbar.insert(copyresults_tbtn, -1)
 
@@ -103,18 +108,26 @@ class Gtk_Presentation(object):
     def _show_relpaths(self, btn):
         self.liststore.clear()
         for bsize, path, size in self.filelist:
-            self.liststore.append([path.replace(self.start_path,'', 1),
-                                   size, bsize])
+            self.liststore.append([size, path.replace(self.start_path,'', 1),
+                                   bsize])
 
     def _show_abspaths(self, btn):
         self.liststore.clear()
         for bsize, path, size in self.filelist:
             #self.liststore.append([abspath(path), size, bsize])
             # Mark absolute part of path with color 
-            self.liststore.append([
+            self.liststore.append([size,
                 '<span background="lawngreen">' + abspath(self.start_path) + '</span>' +
                 path.replace(self.start_path,'', 1),
-                size, bsize])
+                bsize])
+
+    def _show_bitesizes(self, btn):
+        if btn.get_active():
+            for i, (bsize, path, size) in enumerate(self.filelist):
+                self.liststore[i][0] = bsize
+        else:
+            for i, (bsize, path, size) in enumerate(self.filelist):
+                self.liststore[i][0] = size
 
     def save_results(self, btn):
         """Show 'Save to file' dialog."""