54737cf4efe058e2a3c341d4e95dc7f10d26f3a4
[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 searchfile import Search_File_Control
22         elif search_type is 'large_pkg':
23             from pkgsearch import Search_Pkg_Control
24             search = Search_Pkg_Control(self.cfg, out)
25
26         search.run()
27
28
29 class Core_Abstraction(object):
30     pass
31
32
33 class Core_Presentation(gtk.Window):
34     """Main window class."""
35     def __init__(self, win_width, win_height, func_chooser):
36         gtk.Window.__init__(self)
37         self.set_default_size(win_width, win_height)
38         self.set_border_width(4)
39         self.connect('delete_event', gtk.main_quit)
40         self.set_wmclass('GtkWindow', 'FindIT')
41         
42         label1 = gtk.Label('Choice search type')
43         srch_butt1 = gtk.RadioButton(None, 'Search Largest File')
44         srch_butt1.connect('toggled', self.srch_type, 'large_file')
45         srch_butt1.set_active(True)
46         srch_butt2 = gtk.RadioButton(srch_butt1, 'Search Largest Package')
47         srch_butt2.connect('toggled', self.srch_type, 'large_pkg')
48         self.search = 'large_file'
49         separator1 = gtk.HSeparator()
50
51         label2 = gtk.Label('Choice show type')
52         show_butt1 = gtk.RadioButton(None, 'Show in Table view')
53         show_butt1.connect('toggled', self.show_type, 'table_view')
54         show_butt1.set_active(True)
55         show_butt2 = gtk.RadioButton(show_butt1, 'Show in Diagram view')
56         show_butt2.connect('toggled', self.show_type, 'table_view')
57         self.show = 'table_view'
58         separator2 = gtk.HSeparator()
59
60         self.butt_next = gtk.Button('Next >')
61         self.butt_next.connect('released', self.next_wind, func_chooser)
62
63         main_vbox = gtk.VBox(False, 4)
64         main_vbox.pack_start(label1, False, False, 10)
65         main_vbox.pack_start(srch_butt1, False, False, 2)
66         main_vbox.pack_start(srch_butt2, False, False, 2)
67         main_vbox.pack_start(separator1, False, False, 2)
68         main_vbox.pack_start(label2, False, False, 10)
69         main_vbox.pack_start(show_butt1, False, False, 2)
70         main_vbox.pack_start(show_butt2, False, False, 2)
71         main_vbox.pack_start(separator2, False, False, 2)
72         main_vbox.pack_start(self.butt_next, False, False, 20)
73         self.add(main_vbox)
74
75     def run(self):
76         self.show_all()
77         gtk.main()
78     
79     def srch_type(self, widget, data):
80         self.search = data
81
82     def show_type(self, widget, data):
83         self.show = data
84
85     def next_wind(self, widget, func_chooser):
86         self.destroy()
87         gtk.main_quit()
88         func_chooser(self.search, self.show)
89
90 if __name__ == '__main__':
91     Core_Control()