Added filesearch mvc
[findit] / src / mvc / views / filesearch.py
diff --git a/src/mvc/views/filesearch.py b/src/mvc/views/filesearch.py
new file mode 100755 (executable)
index 0000000..e516989
--- /dev/null
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*-coding: utf-8 -*-
+# vim: sw=4 ts=4 expandtab ai
+# pylint: disable-msg=C0301
+
+from gtkmvc import View
+import os.path
+import gtk, pango
+
+
+class FilesearchView(View):
+    """A view for the files search plugin"""
+
+    def __init__(self, ctrl):
+        View.__init__(self, ctrl, register=False)
+        self.__build_widgets()
+        ctrl.register_view(self)
+        return
+
+    def __build_widgets(self):
+
+        # "Start path" entry
+        self['path_entry'] = gtk.Entry()
+
+        hbox = gtk.HBox(False, 4)
+
+        # "Files quantity" label
+        qty_label = gtk.Label('Files quantity')
+
+        # "Files quantity" spin
+        self['qty_spin'] = gtk.SpinButton()
+        self['qty_spin'].set_numeric(True)
+        self['qty_spin'].set_range(0, 65536)
+        self['qty_spin'].set_increments(1, 10)
+
+        # "Go" button
+        self['start_btn'] = gtk.Button('Go')
+
+        # "Stop" button
+        self['stop_btn'] = gtk.Button('Stop')
+        self['stop_btn'].set_sensitive(False)
+
+        hbox.pack_start(qty_label, False, False, 0)
+        hbox.pack_start(self['qty_spin'], False, False, 0)
+        hbox.pack_start(self['start_btn'])
+        hbox.pack_start(self['stop_btn'])
+
+        # Files list
+        swin = gtk.ScrolledWindow()
+        swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+
+        self['liststore'] = gtk.ListStore(str, str, long)
+        self['liststore'].append(['', '', 0])
+
+        self['treeview'] = gtk.TreeView(self['liststore'])
+        self['treeview'].set_headers_visible(1)
+
+        # Size column
+        size_col = gtk.TreeViewColumn('Size')
+        cell1 = gtk.CellRendererText()
+        cell1.set_property('width', 90)
+        size_col.pack_start(cell1, True)
+        size_col.add_attribute(cell1, 'text', 1)
+        self['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, 'text', 0)
+        self['treeview'].append_column(path_col)
+
+        # Column sorting
+        self['treeview'].set_search_column(1)
+        path_col.set_sort_column_id(0)
+        size_col.set_sort_column_id(2)
+
+        # Current file status line
+        self['currfile_lbl'] = gtk.Label()
+        self['currfile_lbl'].set_alignment(0, 0.5)
+        self['currfile_lbl'].set_ellipsize(pango.ELLIPSIZE_MIDDLE)
+        self['currfile_lbl'].set_padding(2, 2)
+        currfile_frm = gtk.Frame()
+        currfile_frm.add(self['currfile_lbl'])
+
+        self['vbox'] = gtk.VBox(False, 4)
+        self['vbox'].pack_start(self['path_entry'], False, False, 0)
+        self['vbox'].pack_start(hbox, False, False, 0)
+        self['vbox'].pack_start(self['treeview'])
+        self['vbox'].pack_start(currfile_frm, False, False, 0)
+        self['vbox'].show_all()
+
+        return
+
+    def set_quantity_value(self, val):
+        self['qty_spin'].set_value(val)
+        return
+
+    def set_start_path_value(self, val):
+        self['path_entry'].set_text(val)
+        return
+
+    def set_stopit_value(self, val):
+        return
+
+    pass # end of class