From 7fd39fa65d83845680bfeb123007d54a8839f068 Mon Sep 17 00:00:00 2001 From: Eugene Gagarin Date: Mon, 18 May 2009 15:13:14 +0400 Subject: [PATCH] Added 'Sizes in bytes' togglebutton to files.out_table --- src/files/out_table.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/files/out_table.py b/src/files/out_table.py index 6bd66eb..fa3d7a1 100755 --- a/src/files/out_table.py +++ b/src/files/out_table.py @@ -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, '' + abspath(self.start_path) + '' + 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.""" -- 1.7.9.5