creating one window with toolbar presentation
[findit] / src / core.py
index 586e5d2..98074a8 100644 (file)
@@ -3,53 +3,58 @@
 # 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()
 
-        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()
+        core_present = Core_Presentation(self.cfg.get('window_width'), self.cfg.get('window_height'))
         
-        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)
+        from pkgsearch import Search_Pkg_Control
+        searchpkg = Search_Pkg_Control(self.cfg, core_present.show_work_widget)
         
-        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()
-                
+        core_present.run(searchpkg.get_ui(), searchpkg.get_ui(), searchpkg.get_ui())
+
 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):
         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')
+        
+        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)
 
-        main_vbox = gtk.VBox(False, 4)
-        for elem, packtype in elem_list:
-            main_vbox.pack_start(elem, packtype, packtype, 5)
+        self.widget_vbox = gtk.VBox(False, 0)
 
+        main_vbox = gtk.VBox(False, 4)
+        main_vbox.pack_start(hbox, False, False, 10)
+        main_vbox.pack_start(self.widget_vbox, False, False, 2)
         self.add(main_vbox)
 
-    def show_mw(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 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()