Remove Maemo-specific anti-blanking code
[panucci.git] / src / panucci / settings.py
blobae5d73dfea0a3373e6803e947ecd4a00b3998e80
1 #!/usr/bin/python
3 # This file is part of Panucci.
4 # Copyright (c) 2008-2010 The Panucci Audiobook and Podcast Player Project
6 # Panucci is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Panucci is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Panucci. If not, see <http://www.gnu.org/licenses/>.
20 from __future__ import absolute_import
22 import logging
24 import panucci
26 DEFAULTS = {
27 'dual_action_button_delay' : 0.5,
28 'enable_dual_action_btn' : True,
29 'last_folder' : '~',
30 'max_recent_files' : 10,
31 'progress_locked' : False,
32 'scrolling_labels' : True,
33 'seek_long' : 60,
34 'seek_short' : 10,
35 'volume' : 0.3,
38 class Settings(object):
39 def __init__(self):
40 self.__log = logging.getLogger('panucci.settings.Settings')
42 def __getattr__(self, key):
43 if DEFAULTS.has_key(key):
44 # FIXME: Load settings from somewhere
45 return DEFAULTS[key]
46 else:
47 self.__log.warning('Setting "%s" doesn\'t exist.' % key)
48 raise AttributeError
50 def __setattr__(self, key, value):
51 if DEFAULTS.has_key(key):
52 if type(value) == type(DEFAULTS[key]):
53 # Don't set the value if it's the same as it used to be
54 #if getattr(self, key) != value:
55 # FIXME: Save setting somewhere
57 return True
58 else:
59 self.__log.warning(
60 'Type of "%s" (%s) does not match default type (%s)',
61 key, type(value).__name__,
62 type(DEFAULTS[key]).__name__ )
63 else:
64 object.__setattr__( self, key, value )
65 self.__log.warning('Setting "%s" doesn\'t exist.', key)
67 return False
69 def attach_checkbutton(self, button, setting):
70 button.connect(
71 'toggled', lambda w: setattr( self, setting, w.get_active()) )
72 self.register(
73 setting + SIGNAL_NAME_SUFFIX, lambda v: button.set_active(v) )
74 button.set_active( getattr(self, setting) )
76 settings = Settings()