creating wizard view - changes in src/core.py
author“Alexandr <“popov2al@gmail.com”>
Fri, 3 Apr 2009 15:36:56 +0000 (19:36 +0400)
committer“Alexandr <“popov2al@gmail.com”>
Fri, 3 Apr 2009 15:36:56 +0000 (19:36 +0400)
src/core.py

index 586e5d2..54737cf 100644 (file)
@@ -3,53 +3,89 @@
 # vim: sw=4 ts=4 expandtab ai
 
 import gtk
-import gobject
 
 class Core_Control(object):
     def __init__(self):
         from config import Config_Control
-        cfg = Config_Control()
+        self.cfg = Config_Control()
+               
+        core_present = Core_Presentation(575, 345, self.chooser)
+        core_present.run()
+
+    def chooser(self, search_type, show_type):
+        if show_type is 'table_view':
+            from outtable import Out_Table_Control
+            out = Out_Table_Control(self.cfg)
+            
+        if search_type is 'large_file':
+            from searchfile import Search_File_Control
+        elif search_type is 'large_pkg':
+            from pkgsearch import Search_Pkg_Control
+            search = Search_Pkg_Control(self.cfg, out)
+
+        search.run()
 
-        from vvod import Gtk_Inp_Control
-        vvod = Gtk_Inp_Control(cfg.get('default_start_dir'), cfg.get('default_count'))
 
-        from output import Output_Control
-        out = Output_Control()
-        
-        from searchfile import Search_File_Control
-        #start_dir, count = vvod.get_data()
-        search = Search_File_Control(vvod.get_data, cfg.get('ignore_dir_list'), out.show)
-        
-        elem_list = []
-        elem_list.append([vvod.get_ui(), False])
-        elem_list.append([search.get_ui(), False])
-        elem_list.append([out.get_ui(), True])
-        core_present = Core_Presentation(575, 345, elem_list)
-        core_present.show_mw()
-                
 class Core_Abstraction(object):
     pass
 
 
 class Core_Presentation(gtk.Window):
     """Main window class."""
-    def __init__(self, win_width, win_height, elem_list):
+    def __init__(self, win_width, win_height, func_chooser):
         gtk.Window.__init__(self)
         self.set_default_size(win_width, win_height)
         self.set_border_width(4)
-        self.fullscreen = False
         self.connect('delete_event', gtk.main_quit)
         self.set_wmclass('GtkWindow', 'FindIT')
+        
+        label1 = gtk.Label('Choice search type')
+        srch_butt1 = gtk.RadioButton(None, 'Search Largest File')
+        srch_butt1.connect('toggled', self.srch_type, 'large_file')
+        srch_butt1.set_active(True)
+        srch_butt2 = gtk.RadioButton(srch_butt1, 'Search Largest Package')
+        srch_butt2.connect('toggled', self.srch_type, 'large_pkg')
+        self.search = 'large_file'
+        separator1 = gtk.HSeparator()
 
-        main_vbox = gtk.VBox(False, 4)
-        for elem, packtype in elem_list:
-            main_vbox.pack_start(elem, packtype, packtype, 5)
+        label2 = gtk.Label('Choice show type')
+        show_butt1 = gtk.RadioButton(None, 'Show in Table view')
+        show_butt1.connect('toggled', self.show_type, 'table_view')
+        show_butt1.set_active(True)
+        show_butt2 = gtk.RadioButton(show_butt1, 'Show in Diagram view')
+        show_butt2.connect('toggled', self.show_type, 'table_view')
+        self.show = 'table_view'
+        separator2 = gtk.HSeparator()
+
+        self.butt_next = gtk.Button('Next >')
+        self.butt_next.connect('released', self.next_wind, func_chooser)
 
+        main_vbox = gtk.VBox(False, 4)
+        main_vbox.pack_start(label1, False, False, 10)
+        main_vbox.pack_start(srch_butt1, False, False, 2)
+        main_vbox.pack_start(srch_butt2, False, False, 2)
+        main_vbox.pack_start(separator1, False, False, 2)
+        main_vbox.pack_start(label2, False, False, 10)
+        main_vbox.pack_start(show_butt1, False, False, 2)
+        main_vbox.pack_start(show_butt2, False, False, 2)
+        main_vbox.pack_start(separator2, False, False, 2)
+        main_vbox.pack_start(self.butt_next, False, False, 20)
         self.add(main_vbox)
 
-    def show_mw(self):
+    def run(self):
         self.show_all()
         gtk.main()
+    
+    def srch_type(self, widget, data):
+        self.search = data
+
+    def show_type(self, widget, data):
+        self.show = data
+
+    def next_wind(self, widget, func_chooser):
+        self.destroy()
+        gtk.main_quit()
+        func_chooser(self.search, self.show)
 
 if __name__ == '__main__':
     Core_Control()