Package Gnumed :: Package timelinelib :: Module application
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.application

 1  # Copyright (C) 2009, 2010, 2011  Rickard Lindberg, Roger Lindberg 
 2  # 
 3  # This file is part of Timeline. 
 4  # 
 5  # Timeline is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation, either version 3 of the License, or 
 8  # (at your option) any later version. 
 9  # 
10  # Timeline is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License 
16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
17   
18   
19  from timelinelib.db.exceptions import TimelineIOError 
20   
21   
22 -class TimelineApplication(object):
23
24 - def __init__(self, main_frame, db_open_fn, config):
25 self.main_frame = main_frame 26 self.db_open_fn = db_open_fn 27 self.config = config 28 self.timeline = None
29
30 - def on_started(self, application_arguments):
31 input_files = application_arguments.get_files() 32 if len(input_files) == 0: 33 ro = self.config.get_recently_opened() 34 if self.config.get_open_recent_at_startup() and len(ro) > 0: 35 self.main_frame.open_timeline_if_exists(ro[0]) 36 else: 37 for input_file in input_files: 38 self.main_frame.open_timeline(input_file)
39
40 - def open_timeline(self, path):
41 try: 42 self.timeline = self.db_open_fn(path, self.config.get_use_wide_date_range()) 43 except TimelineIOError, e: 44 self.main_frame.handle_db_error(e) 45 else: 46 self.config.append_recently_opened(path) 47 self.main_frame._update_open_recent_submenu() 48 self.main_frame._display_timeline(self.timeline)
49
50 - def set_no_timeline(self):
51 self.timeline = None 52 self.main_frame._display_timeline(None)
53
54 - def on_play_clicked(self):
55 self.main_frame.open_play_frame(self.timeline)
56