2 Copyright 2008 Free Software Foundation, Inc.
3 This file is part of GNU Radio
5 GNU Radio Companion is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 GNU Radio Companion 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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 _config_parser = ConfigParser.ConfigParser()
26 def file_extension(): return '.'+_platform.get_key()
27 def _prefs_file(): return os.path.join(os.path.expanduser('~'), file_extension())
33 _config_parser.add_section('main')
34 _config_parser.add_section('files_open')
35 try: _config_parser.read(_prefs_file())
38 try: _config_parser.write(open(_prefs_file(), 'w'))
41 ###########################################################################
42 # Special methods for specific program functionalities
43 ###########################################################################
45 def main_window_size(size=None):
47 _config_parser.set('main', 'main_window_width', size[0])
48 _config_parser.set('main', 'main_window_height', size[1])
51 _config_parser.getint('main', 'main_window_width'),
52 _config_parser.getint('main', 'main_window_height'),
56 def file_open(file=None):
57 if file is not None: _config_parser.set('main', 'file_open', file)
59 try: return _config_parser.get('main', 'file_open')
62 def files_open(files=None):
64 _config_parser.remove_section('files_open') #clear section
65 _config_parser.add_section('files_open')
66 for i, file in enumerate(files):
67 _config_parser.set('files_open', 'file_open_%d'%i, file)
72 try: files.append(_config_parser.get('files_open', 'file_open_%d'%i))
76 def reports_window_position(pos=None):
77 if pos is not None: _config_parser.set('main', 'reports_window_position', pos)
79 try: return _config_parser.getint('main', 'reports_window_position') or 1 #greater than 0
82 def blocks_window_position(pos=None):
83 if pos is not None: _config_parser.set('main', 'blocks_window_position', pos)
85 try: return _config_parser.getint('main', 'blocks_window_position') or 1 #greater than 0