3 # vim: sw=4 ts=4 expandtab ai
4 # pylint: disable-msg=C0301
6 from gtkmvc import View
11 class FilesearchView(View):
12 """A view for the files search plugin"""
14 def __init__(self, ctrl):
15 View.__init__(self, ctrl, register=False)
16 self.__build_widgets()
17 ctrl.register_view(self)
20 def __build_widgets(self):
23 self['path_entry'] = gtk.Entry()
25 hbox = gtk.HBox(False, 4)
27 # "Files quantity" label
28 qty_label = gtk.Label('Files quantity')
30 # "Files quantity" spin
31 self['qty_spin'] = gtk.SpinButton()
32 self['qty_spin'].set_numeric(True)
33 self['qty_spin'].set_range(0, 65536)
34 self['qty_spin'].set_increments(1, 10)
37 self['start_btn'] = gtk.Button('Go')
40 self['stop_btn'] = gtk.Button('Stop')
41 self['stop_btn'].set_sensitive(False)
43 hbox.pack_start(qty_label, False, False, 0)
44 hbox.pack_start(self['qty_spin'], False, False, 0)
45 hbox.pack_start(self['start_btn'])
46 hbox.pack_start(self['stop_btn'])
49 swin = gtk.ScrolledWindow()
50 swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
52 self['liststore'] = gtk.ListStore(str, str, long)
53 self['liststore'].append(['', '', 0])
55 self['treeview'] = gtk.TreeView(self['liststore'])
56 self['treeview'].set_headers_visible(1)
59 size_col = gtk.TreeViewColumn('Size')
60 cell1 = gtk.CellRendererText()
61 cell1.set_property('width', 90)
62 size_col.pack_start(cell1, True)
63 size_col.add_attribute(cell1, 'text', 1)
64 self['treeview'].append_column(size_col)
67 path_col = gtk.TreeViewColumn('Path')
68 cell2 = gtk.CellRendererText()
69 path_col.pack_start(cell2, True)
70 path_col.add_attribute(cell2, 'text', 0)
71 self['treeview'].append_column(path_col)
74 self['treeview'].set_search_column(1)
75 path_col.set_sort_column_id(0)
76 size_col.set_sort_column_id(2)
78 # Current file status line
79 self['currfile_lbl'] = gtk.Label()
80 self['currfile_lbl'].set_alignment(0, 0.5)
81 self['currfile_lbl'].set_ellipsize(pango.ELLIPSIZE_MIDDLE)
82 self['currfile_lbl'].set_padding(2, 2)
83 currfile_frm = gtk.Frame()
84 currfile_frm.add(self['currfile_lbl'])
86 self['vbox'] = gtk.VBox(False, 4)
87 self['vbox'].pack_start(self['path_entry'], False, False, 0)
88 self['vbox'].pack_start(hbox, False, False, 0)
89 self['vbox'].pack_start(self['treeview'])
90 self['vbox'].pack_start(currfile_frm, False, False, 0)
91 self['vbox'].show_all()
95 def set_quantity_value(self, val):
96 self['qty_spin'].set_value(val)
99 def set_start_path_value(self, val):
100 self['path_entry'].set_text(val)
103 def set_stopit_value(self, val):