fixing proglem - TypeError: value is of wrong type for this column in self.liststore...
[findit] / src / core.py
1 #!/usr/bin/env python
2 # -*-coding: utf-8 -*-
3 # vim: sw=4 ts=4 expandtab ai
4
5 import gtk
6
7 class Core_Control(object):
8     def __init__(self):
9         from config import Config_Control
10         self.cfg = Config_Control()
11                
12         core_present = Core_Presentation(575, 345, self.chooser)
13         core_present.run()
14
15     def chooser(self, search_type, show_type):
16         if show_type is 'table_view':
17             from outtable import Out_Table_Control
18             out = Out_Table_Control(self.cfg)
19             
20         if search_type is 'large_file':
21             from filesearch import Search_File_Control
22             search = Search_File_Control(self.cfg, out)
23
24         elif search_type is 'large_pkg':
25             from pkgsearch import Search_Pkg_Control
26             search = Search_Pkg_Control(self.cfg, out)
27
28         search.run()
29
30
31 class Core_Abstraction(object):
32     pass
33
34
35 class Core_Presentation(gtk.Window):
36     """Main window class."""
37     def __init__(self, win_width, win_height, func_chooser):
38         gtk.Window.__init__(self)
39         self.set_default_size(win_width, win_height)
40         self.set_border_width(4)
41         self.connect('delete_event', gtk.main_quit)
42         self.set_wmclass('GtkWindow', 'FindIT')
43         
44         label1 = gtk.Label('Choice search type')
45         srch_butt1 = gtk.RadioButton(None, 'Search Largest File')
46         srch_butt1.connect('toggled', self.srch_type, 'large_file')
47         srch_butt1.set_active(True)
48         srch_butt2 = gtk.RadioButton(srch_butt1, 'Search Largest Package')
49         srch_butt2.connect('toggled', self.srch_type, 'large_pkg')
50         self.search = 'large_file'
51         separator1 = gtk.HSeparator()
52
53         label2 = gtk.Label('Choice show type')
54         show_butt1 = gtk.RadioButton(None, 'Show in Table view')
55         show_butt1.connect('toggled', self.show_type, 'table_view')
56         show_butt1.set_active(True)
57         show_butt2 = gtk.RadioButton(show_butt1, 'Show in Diagram view')
58         show_butt2.connect('toggled', self.show_type, 'table_view')
59         self.show = 'table_view'
60         separator2 = gtk.HSeparator()
61
62         self.butt_next = gtk.Button('Next >')
63         self.butt_next.connect('released', self.next_wind, func_chooser)
64
65         main_vbox = gtk.VBox(False, 4)
66         main_vbox.pack_start(label1, False, False, 10)
67         main_vbox.pack_start(srch_butt1, False, False, 2)
68         main_vbox.pack_start(srch_butt2, False, False, 2)
69         main_vbox.pack_start(separator1, False, False, 2)
70         main_vbox.pack_start(label2, False, False, 10)
71         main_vbox.pack_start(show_butt1, False, False, 2)
72         main_vbox.pack_start(show_butt2, False, False, 2)
73         main_vbox.pack_start(separator2, False, False, 2)
74         main_vbox.pack_start(self.butt_next, False, False, 20)
75         self.add(main_vbox)
76
77     def run(self):
78         self.show_all()
79         gtk.main()
80     
81     def srch_type(self, widget, data):
82         self.search = data
83
84     def show_type(self, widget, data):
85         self.show = data
86
87     def next_wind(self, widget, func_chooser):
88         self.destroy()
89         gtk.main_quit()
90         func_chooser(self.search, self.show)
91
92 if __name__ == '__main__':
93     Core_Control()