creating one window with toolbar presentation
[findit] / src / core.py
index e8728f4..98074a8 100644 (file)
@@ -8,29 +8,13 @@ class Core_Control(object):
     def __init__(self):
         from config import Config_Control
         self.cfg = Config_Control()
-               
-        core_present = Core_Presentation(self.cfg.get('window_width'), \
-                self.cfg.get('window_height'), 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)
-        elif show_type is 'diag_view':
-            from outdiag import Out_Diag_Control
-            out = Out_Diag_Control(self.cfg)
-            
-        if search_type is 'large_file':
-            from filesearch import Search_File_Control
-            search = Search_File_Control(self.cfg, out)
-
-        elif search_type is 'large_pkg':
-            from pkgsearch import Search_Pkg_Control
-            search = Search_Pkg_Control(self.cfg, out)
-
-        search.run()
 
+        core_present = Core_Presentation(self.cfg.get('window_width'), self.cfg.get('window_height'))
+        
+        from pkgsearch import Search_Pkg_Control
+        searchpkg = Search_Pkg_Control(self.cfg, core_present.show_work_widget)
+        
+        core_present.run(searchpkg.get_ui(), searchpkg.get_ui(), searchpkg.get_ui())
 
 class Core_Abstraction(object):
     pass
@@ -38,60 +22,39 @@ class Core_Abstraction(object):
 
 class Core_Presentation(gtk.Window):
     """Main window class."""
-    def __init__(self, win_width, win_height, func_chooser):
+    def __init__(self, win_width, win_height):
         gtk.Window.__init__(self)
         self.set_default_size(win_width, win_height)
         self.set_border_width(4)
         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()
+        hbox = gtk.HBox(False, 4)
+        self.srch_butt1 = gtk.Button('file')
+        self.srch_butt2 = gtk.Button('pkg')
+        hbox.pack_start(self.srch_butt1, False, False, 2)
+        hbox.pack_start(self.srch_butt2, False, False, 2)
 
-        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, 'diag_view')
-        self.show = 'table_view'
-        separator2 = gtk.HSeparator()
-
-        self.butt_next = gtk.Button('Next >')
-        self.butt_next.connect('released', self.next_wind, func_chooser)
+        self.widget_vbox = gtk.VBox(False, 0)
 
         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)
+        main_vbox.pack_start(hbox, False, False, 10)
+        main_vbox.pack_start(self.widget_vbox, False, False, 2)
         self.add(main_vbox)
 
-    def run(self):
+    def run(self, init_srch, srch1, srch2):
+        self.srch_butt1.connect('released', self.show_work_widget, srch1)
+        self.srch_butt2.connect('released', self.show_work_widget, srch2)
+        self.widget_vbox.add(init_srch)
         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)
+    def show_work_widget(self, widget, new_widget):
+        if self.widget_vbox.get_children()[0]:
+            self.widget_vbox.remove(self.widget_vbox.get_children()[0])
+        self.widget_vbox.add(new_widget)
+        self.show_all()
+        print 'redraw'
 
 if __name__ == '__main__':
     Core_Control()