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
28 LAST_FOLDER_DEFAULT
= os
.path
.join(os
.path
.expanduser('~'), 'MyDocs')
30 if not os
.path
.exists(LAST_FOLDER_DEFAULT
):
31 LAST_FOLDER_DEFAULT
= os
.path
.expanduser('~')
34 'dual_action_button_delay' : 0.5,
35 'enable_dual_action_btn' : True,
36 'last_folder' : LAST_FOLDER_DEFAULT
,
37 'max_recent_files' : 10,
38 'progress_locked' : False,
39 'scrolling_labels' : True,
44 class Settings(object):
46 self
.__log
= logging
.getLogger('panucci.settings.Settings')
48 def __getattr__(self
, key
):
49 if DEFAULTS
.has_key(key
):
50 # FIXME: Load settings from somewhere
53 self
.__log
.warning('Setting "%s" doesn\'t exist.' % key
)
56 def __setattr__(self
, key
, value
):
57 if DEFAULTS
.has_key(key
):
58 if type(value
) == type(DEFAULTS
[key
]):
59 # Don't set the value if it's the same as it used to be
60 #if getattr(self, key) != value:
61 # FIXME: Save setting somewhere
66 'Type of "%s" (%s) does not match default type (%s)',
67 key
, type(value
).__name
__,
68 type(DEFAULTS
[key
]).__name
__ )
70 object.__setattr
__( self
, key
, value
)
71 self
.__log
.warning('Setting "%s" doesn\'t exist.', key
)
75 def attach_checkbutton(self
, button
, setting
):
77 'toggled', lambda w
: setattr( self
, setting
, w
.get_active()) )
79 # setting + SIGNAL_NAME_SUFFIX, lambda v: button.set_active(v) )
80 button
.set_active( getattr(self
, setting
) )