creating one window with toolbar presentation
[findit] / src / core.py
index ac84f39..98074a8 100644 (file)
@@ -2,4 +2,59 @@
 # -*-coding: utf-8 -*-
 # vim: sw=4 ts=4 expandtab ai
 
+import gtk
 
+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'))
+        
+        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
+
+
+class Core_Presentation(gtk.Window):
+    """Main window class."""
+    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')
+        
+        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)
+
+        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 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()