1
'''a module to handle sound themes'''
2
# -*- coding: utf-8 -*-
4
# This file is part of emesene.
6
# emesene 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
# emesene 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 emesene; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
class SoundThemes(ThemesManager.ThemesManager):
25
'''a class to handle sound themes
30
ThemesManager.ThemesManager.__init__(self, ".AdiumSoundset")
32
def get(self, theme_path):
33
'''return a Theme object instance
34
returs True, theme_instance if the validation was ok
35
False, reason if some validation failed
37
status, message = self.validate(theme_path)
40
return status, message
42
return True, SoundTheme.SoundTheme(theme_path)
44
def get_sound_theme (self, sound_name):
45
''' return the instance of SoundThemes corresponding to the
46
sound_name or the default theme if isn't found
48
sound_path = os.path.join('themes', 'sounds', 'default.AdiumSoundset')
50
for elem in self.list():
51
if sound_name in elem:
54
return self.get(sound_path)[1]
56
def validate(self, theme_path):
57
'''validate a Theme directory structure
59
if not os.path.isdir(theme_path):
60
return False, _("%s is not a directory") % theme_path
62
sound_config_file = os.path.join(theme_path, "Sounds.plist")
63
if not os.path.isfile(sound_config_file):
64
return False, _("Sounds.plist not found")