Changes in application mvc
[findit] / src / mvc / controllers / application.py
1 from gtkmvc import Controller
2 import gtk
3
4 from filesearch import FilesearchCtrl
5
6 from about import AboutCtrl
7 from views.about import AboutView
8
9
10 class ApplicationCtrl(Controller):
11     """Controller of the top-level window (application)"""
12
13     def __init__(self, model):
14         Controller.__init__(self, model)
15
16         self.filesearch = FilesearchCtrl(model.filesearch)
17         return
18
19     def register_view(self, view):
20         """Creates subviews and connect signals"""
21         Controller.register_view(self, view)
22
23         self.view.create_sub_views(self.filesearch)
24
25         # connects the signals:
26         self.view['main_window'].connect('destroy', gtk.main_quit)
27         self.view['about_btn'].connect('clicked', self.on_about_btn_clicked)
28         self.view['quit_btn'].connect('clicked', self.on_quit_btn_clicked)
29         return
30
31     # -----------------------------------------------------
32     #                  user callbacks
33     # -----------------------------------------------------
34
35     def quit(self):
36         gtk.main_quit()
37         return
38
39     # -----------------------------------------------------
40     #                    gtk signals
41     # -----------------------------------------------------
42
43     def on_about_btn_clicked(self, tb):
44         c = AboutCtrl(self.model.about)
45         v = AboutView(c)
46         v.run() # this runs in modal mode
47         return
48
49     def on_quit_btn_clicked(self, bt):
50         self.quit()
51
52     # -----------------------------------------------------
53     #                observable properties
54     # -----------------------------------------------------
55
56     pass # end of class