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
27 'dual_action_button_delay' : 0.5,
28 'enable_dual_action_btn' : True,
30 'max_recent_files' : 10,
31 'progress_locked' : False,
32 'scrolling_labels' : True,
38 class Settings(object):
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
47 self
.__log
.warning('Setting "%s" doesn\'t exist.' % key
)
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
60 'Type of "%s" (%s) does not match default type (%s)',
61 key
, type(value
).__name
__,
62 type(DEFAULTS
[key
]).__name
__ )
64 object.__setattr
__( self
, key
, value
)
65 self
.__log
.warning('Setting "%s" doesn\'t exist.', key
)
69 def attach_checkbutton(self
, button
, setting
):
71 'toggled', lambda w
: setattr( self
, setting
, w
.get_active()) )
73 setting
+ SIGNAL_NAME_SUFFIX
, lambda v
: button
.set_active(v
) )
74 button
.set_active( getattr(self
, setting
) )