X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffiles%2Fout_table.py;h=ef59d46ee9810d675a1f40e0b75a173e2aed06f6;hb=490a7a786b5e989a1cd089be99a9b5439c4b2242;hp=52b5b9bb9e65862f3827373795d97a986475edbf;hpb=9d41de950eb735e2f86fcc8fb764b9e98e8889d7;p=findit
diff --git a/src/files/out_table.py b/src/files/out_table.py
index 52b5b9b..ef59d46 100755
--- a/src/files/out_table.py
+++ b/src/files/out_table.py
@@ -9,7 +9,8 @@ from misc import _
#==============================================================================
class Cli_Presentation(object):
- def __init__(self, filelist): ###
+ def __init__(self, results): ###
+ filelist, start_path = results
self.toplevel = self.print_results(filelist)
def print_results(self, filelist):
@@ -19,9 +20,35 @@ class Cli_Presentation(object):
#==============================================================================
class Gtk_Presentation(object):
+
+ def _create_toolbar(self):
+ toolbar = gtk.Toolbar()
+ toolbar.set_property('icon-size', 'small-toolbar')
+
+ abs_paths_tbtn = gtk.ToggleToolButton()
+ abs_paths_tbtn.set_label(_('Absolute paths'))
+ abs_paths_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)
+
+ copyresults_tbtn = gtk.ToolButton('gtk-copy')
+ copyresults_tbtn.connect('clicked', self.copy_results)
+
+ toolbar.insert(abs_paths_tbtn, -1)
+ toolbar.insert(bitesizes_tbtn, -1)
+ toolbar.insert(saveresults_tbtn, -1)
+ toolbar.insert(copyresults_tbtn, -1)
+
+ return toolbar
+
def __init__(self, results): ###
import gtk
- global gtk # for save_results
+ global gtk # for save_results and copy_results
import gobject
self.filelist, self.start_path = results
@@ -32,7 +59,10 @@ class Gtk_Presentation(object):
# Store results
self.liststore = gtk.ListStore(str, str, gobject.TYPE_INT64)
- self._show_relpaths(None)
+ for bsize, path, size in self.filelist:
+ self.liststore.append([size,
+ path.replace(self.start_path,'', 1),
+ bsize])
treeview = gtk.TreeView(self.liststore)
@@ -41,19 +71,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
@@ -62,33 +92,12 @@ class Gtk_Presentation(object):
swin.add(treeview)
#====================
- # Toolbar
+ # Packing
#====================
- toolbar = gtk.Toolbar()
-
- relpaths_tbtn = gtk.RadioToolButton(None)
- abspaths_tbtn = gtk.RadioToolButton(relpaths_tbtn)
+ toolbar = self._create_toolbar()
- relpaths_tbtn.set_label(_('Relative paths'))
- abspaths_tbtn.set_label(_('Absolute paths'))
-
- relpaths_tbtn.connect('clicked', self._show_relpaths)
- abspaths_tbtn.connect('clicked', self._show_abspaths)
-
- saveresults_tbtn = gtk.ToolButton()
- saveresults_tbtn.set_label(_('Save results'))
- saveresults_tbtn.connect('clicked', self.save_results)
-
- toolbar.insert(relpaths_tbtn, -1)
- toolbar.insert(abspaths_tbtn, -1)
- toolbar.insert(saveresults_tbtn, -1)
-
- #====================
- # Others
- #====================
-
- vbox = gtk.VBox(False, 4)
+ vbox = gtk.VBox(False, 0)
vbox.pack_start(swin, True, True, 0)
vbox.pack_start(toolbar, False, False, 0)
@@ -96,24 +105,28 @@ class Gtk_Presentation(object):
#=== Functions ============================================================
- 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])
-
def _show_abspaths(self, btn):
- self.liststore.clear()
- for bsize, path, size in self.filelist:
- #self.liststore.append([abspath(path), size, bsize])
+ # Toggled mean 'absolute paths'
+ if btn.get_active():
# Mark absolute part of path with color
- self.liststore.append([
- '' + abspath(self.start_path) + '' +
- path.replace(self.start_path,'', 1),
- size, bsize])
+ for i, (bsize, path, size) in enumerate(self.filelist):
+ self.liststore[i][1] = '' + \
+ abspath(self.start_path) + '' + \
+ path.replace(self.start_path,'', 1)
+ else:
+ for i, (bsize, path, size) in enumerate(self.filelist):
+ self.liststore[i][1] = path.replace(self.start_path,'', 1)
+
+ 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):
- # 'Save to file' dialog
+ """Show 'Save to file' dialog."""
dialog = gtk.FileChooserDialog(title='Save to...',
action='save',
buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
@@ -129,6 +142,18 @@ class Gtk_Presentation(object):
outfile.close()
dialog.destroy()
+ def copy_results(self, btn):
+ """Copy results to clipboard."""
+ # Form list
+ filelist = ''
+ for bsize, path, size in self.filelist:
+ filelist += `bsize` + '\t' + abspath(path) + '\n'
+
+ # Store in clipboard
+ cb = gtk.Clipboard()
+ cb.set_text(filelist)
+ cb.store()
+
#==============================================================================
class Hildon_Presentation(object):