7fc52ad16d94922c9766f7d77606ec758c2d3b5d
[findit] / src / files / outtable.py
1 #!/usr/bin/env python
2 # -*-coding: utf-8 -*-
3 # vim: sw=4 ts=4 expandtab ai
4
5 #==============================================================================
6
7 # class OutTable_Control(object):
8 #     def __init__(self):
9 #         self.table_present = Gtk_Presentation()
10
11 #     def show(self, filelist, flsize):
12 #         self.table_present.show_result(filelist, flsize)
13
14 #     def get_ui(self):
15 #         return self.table_present.get_toplevel()
16
17
18 # #==============================================================================
19
20 # class OutTable_Abstraction(object):
21 #     pass
22
23 #==============================================================================
24
25 class Cli_Presentation(object):
26     pass
27
28 #==============================================================================
29
30 class Gtk_Presentation(object):
31     def __init__(self, filelist):   ###
32         import gtk
33         import gobject
34
35         # Определяем переменную в которой будет храниться выводимый список
36         self.liststore = gtk.ListStore(str, str, gobject.TYPE_INT64)
37
38         for bsize, path, size in filelist:
39             self.liststore.append([path, size, bsize])
40
41         treeview = gtk.TreeView(self.liststore)
42
43         # На таблетке не отображаються заголовки столбцов по умолчанию -
44         # след строка заставляет их отображаться принудительно
45         treeview.set_headers_visible(1)
46
47         # Создаем и настраиваем колонку с размером файла
48         size_col = gtk.TreeViewColumn( 'Size')
49         cell1 = gtk.CellRendererText()
50         cell1.set_property('width', 90)
51         size_col.pack_start(cell1, True)
52         size_col.add_attribute(cell1, 'text', 1)
53         treeview.append_column(size_col)
54         # Создаем и настраиваем колонку с именем файла
55         path_col = gtk.TreeViewColumn( 'Path')
56         cell2 = gtk.CellRendererText()
57         path_col.pack_start(cell2, True)
58         path_col.add_attribute(cell2, 'text', 0)
59         treeview.append_column(path_col)
60
61         # Добавляем сортировку для колонок
62         treeview.set_search_column(1)
63         path_col.set_sort_column_id(0)
64         size_col.set_sort_column_id(2)
65
66         self.swin = gtk.ScrolledWindow()
67         self.swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
68         self.swin.add(treeview)
69 ###        self.swin.show_all()
70         self.toplevel = self.swin
71
72 #     #=== Functions ============================================================
73 #     def show_results(self, filelist):
74 #         self.liststore.clear()
75 #         for path, size, bsize in filelist:
76 #             print path, size, bsize
77 #             self.liststore.append([path, size, bsize])