Beispiel #1
0
class MainController(BaseMainController):
    
    def __init__(self, main_script):
        font = wx.NORMAL_FONT
        BaseMainController.__init__(self, main_script, meta, config)
        
        self.view = MainWindow()
        self.settings = BaseSettings(self.settings_path, SETTINGS_DEFAULTS)
        self.model = App(self.settings)
        self.notes = NotesController(self.model, self.settings, self.view, self.settings_path.parent)
        self.commands = CommandController(self, self.settings)
        
        self.view.load_position(self.settings)
        
        pub.subscribe(self.on_program_closed, 'program.closed')
        pub.subscribe(self.on_page_key_down, 'page.key_down')
        pub.subscribe(self.on_options_changing, 'options.changing')
        
        #TODO: use call after? handle exceptions
        self.notes.open_initial()
        
    def quit(self):
        self.view.Close()
        
    def open_options(self):
        opt = Options()
        opt.read(self.settings)
        self.view.open_options(opt)
    
    def hide(self):
        self.notes.save(self.view.pages)
        self.notes.save_opened(self.view.pages)
        self.view.hide()
        
    def find(self):
        self.view.find()
        
    def delete_line(self):
        pub.sendMessage('note.edit.delete_line')
        
    def on_program_closed(self, pages):
        self.view.save_position(self.settings)
        self.notes.save_opened(pages)
        self.settings.save()
        logging.shutdown()
        
    def on_page_key_down(self, key_code, flags):
        if key_code == wx.WXK_ESCAPE:
            self.hide()
            
    def on_options_changing(self, options):
        if options.modifiers is None or options.key_code is None:
            hotkey = ''
        else:
            hotkey = '%d,%d' % (options.modifiers, options.key_code)
        self.settings.set('Options', 'HotKey', hotkey)
        self.settings.set('Options', 'Font', options.font)
Beispiel #2
0
 def __init__(self, main_script):
     font = wx.NORMAL_FONT
     BaseMainController.__init__(self, main_script, meta, config)
     
     self.view = MainWindow()
     self.settings = BaseSettings(self.settings_path, SETTINGS_DEFAULTS)
     self.model = App(self.settings)
     self.notes = NotesController(self.model, self.settings, self.view, self.settings_path.parent)
     self.commands = CommandController(self, self.settings)
     
     self.view.load_position(self.settings)
     
     pub.subscribe(self.on_program_closed, 'program.closed')
     pub.subscribe(self.on_page_key_down, 'page.key_down')
     pub.subscribe(self.on_options_changing, 'options.changing')
     
     #TODO: use call after? handle exceptions
     self.notes.open_initial()