3 # vim: sw=4 ts=4 expandtab ai
5 from os.path import abspath
9 #==============================================================================
11 class Cli_Presentation(object):
12 def __init__(self, filelist): ###
13 self.toplevel = self.print_results(filelist)
15 def print_results(self, filelist):
16 for bsize, path, size in filelist:
17 print '%10d' % bsize, path
19 #==============================================================================
21 class Gtk_Presentation(object):
22 def __init__(self, results): ###
26 self.filelist, self.start_path = results
33 self.liststore = gtk.ListStore(str, str, gobject.TYPE_INT64)
34 self._show_relpaths(None)
36 treeview = gtk.TreeView(self.liststore)
39 size_col = gtk.TreeViewColumn(_('Size'))
40 cell1 = gtk.CellRendererText()
41 cell1.set_property('width', 90)
42 size_col.pack_start(cell1, True)
43 size_col.add_attribute(cell1, 'text', 1)
44 treeview.append_column(size_col)
47 path_col = gtk.TreeViewColumn(_('Path'))
48 cell2 = gtk.CellRendererText()
49 path_col.pack_start(cell2, True)
50 #path_col.add_attribute(cell2, 'text', 0)
51 path_col.add_attribute(cell2, 'markup', 0)
52 treeview.append_column(path_col)
55 treeview.set_search_column(1)
56 path_col.set_sort_column_id(0)
57 size_col.set_sort_column_id(2)
59 # Add treeview to scrolled window
60 swin = gtk.ScrolledWindow()
61 swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
68 toolbar = gtk.Toolbar()
69 relpaths_tbtn = gtk.RadioToolButton(None)
70 abspaths_tbtn = gtk.RadioToolButton(relpaths_tbtn)
72 relpaths_tbtn.set_label(_('Relative paths'))
73 abspaths_tbtn.set_label(_('Absolute paths'))
75 relpaths_tbtn.connect('clicked', self._show_relpaths)
76 abspaths_tbtn.connect('clicked', self._show_abspaths)
78 toolbar.insert(relpaths_tbtn, -1)
79 toolbar.insert(abspaths_tbtn, -1)
85 vbox = gtk.VBox(False, 4)
86 vbox.pack_start(swin, True, True, 0)
87 vbox.pack_start(toolbar, False, False, 0)
91 #=== Functions ============================================================
93 def _show_relpaths(self, btn):
94 self.liststore.clear()
95 for bsize, path, size in self.filelist:
96 self.liststore.append([path.replace(self.start_path,'', 1),
99 def _show_abspaths(self, btn):
100 self.liststore.clear()
101 for bsize, path, size in self.filelist:
102 #self.liststore.append([abspath(path), size, bsize])
103 # Mark absolute part of path with color
104 self.liststore.append([
105 '<span background="lawngreen">' + abspath(self.start_path) + '</span>' +
106 path.replace(self.start_path,'', 1),
109 #==============================================================================
111 class Hildon_Presentation(object):
112 def __init__(self, filelist): ###
117 # На таблетке не отображаються заголовки столбцов по умолчанию -
118 # след строка заставляет их отображаться принудительно
119 treeview.set_headers_visible(1)