~bkrpr/bookliberator/trunk

« back to all changes in this revision

Viewing changes to GUI/bkrpr.py

  • Committer: James Vasile
  • Date: 2009-01-13 20:25:09 UTC
  • Revision ID: james@hackervisions.org-20090113202509-4gairbhb1csyiuot
user level implemented, verbose levels adjusted, comm.verbose propagated throughout code, pref fiddling

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import pygtk
5
5
pygtk.require('2.0')
6
6
try:
 
7
    import gobject
7
8
    import gtk
8
9
except:
9
10
    print "You need to install pyGTK or GTKv2 ",
10
11
    print "or set your PYTHONPATH correctly."
11
12
    sys.exit(1)
12
13
 
 
14
 
13
15
import webbrowser
14
16
 
15
17
import config
47
49
    </ui>'''
48
50
 
49
51
    path = None
50
 
            
 
52
    M = model.Model()
 
53
 
51
54
    def __init__(self):
52
55
 
53
56
        assert not gtk.check_version(2,6,0), gtk.check_version(2,6,0)
54
57
 
55
 
        self.M = model.Model()
56
 
 
57
58
        # Create toplevel window
58
59
        self.window = gtk.Window()
59
60
        self.window.connect('destroy', lambda w: gtk.main_quit())
129
130
            self.window, gtk.DIALOG_DESTROY_WITH_PARENT, 
130
131
            gtk.MESSAGE_INFO, gtk.BUTTONS_OK, text)
131
132
 
 
133
        ## Setup Preferences Signal
 
134
        gobject.signal_new("user_level_change", Preferences, gobject.SIGNAL_ACTION, gobject.TYPE_BOOLEAN, (gobject.TYPE_INT,))
 
135
 
 
136
 
132
137
    ## File Dialog
133
138
    def file_ok(self, action):
134
139
        'Handle file dialog ok button'
175
180
    def preferences_cb(self, action):
176
181
        'Launch preferences dialog.'
177
182
        p = Preferences()
 
183
        p.connect("user_level_change", self.user_level_cb)
 
184
 
 
185
    def user_level_cb(self, widget, int):
 
186
        '''Called when user experience level changes.  Kicks off
 
187
        whatever adjustments need to be made to the GUI when the user
 
188
        level changes.'''
 
189
        comm.debug("User level changed to %d" % config.user_level)
 
190
        self.window.emit("user_level_change", config.user_level)
 
191
        self.notebook.start.set_textbuffer()
178
192
 
179
193
    def quit_cb(self, act):
180
194
        'Quit callback'
183
197
 
184
198
    def main(self):
185
199
        'Main entry point for the GUI'
186
 
        comm.set_verbose(True) #DEBUG
187
200
        gtk.main()
188
201
 
189
202