~ubuntu-branches/ubuntu/oneiric/emesene/oneiric

« back to all changes in this revision

Viewing changes to emesene/gui/base/SoundThemes.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski, Fabrizio Regalli
  • Date: 2011-08-22 20:48:17 UTC
  • mfrom: (1.1.12 upstream) (5.2.11 sid)
  • Revision ID: package-import@ubuntu.com-20110822204817-ctdvj2g7byl7icpd
Tags: 2.11.7+dfsg-1
* Team upload.

[ Fabrizio Regalli ]
* New upstream release (Closes: #633614)
* Added 01-fix-spelling-error.diff patch
* Fix spelling-error-in-description lintian message
* Removed libclearlooks.dll file also in d/rules
* Added imagemagick as B-D to resize icon via d/rules
* Fixed typo in description (Closes: #633483)
* Added override for dh_install, dh_installdir and dh_clean rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''a module to handle sound themes'''
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
#    This file is part of emesene.
 
5
#
 
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.
 
10
#
 
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.
 
15
#
 
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
 
19
 
 
20
import os
 
21
import ThemesManager
 
22
import SoundTheme
 
23
 
 
24
class SoundThemes(ThemesManager.ThemesManager):
 
25
    '''a class to handle sound themes
 
26
    '''
 
27
 
 
28
    def __init__(self):
 
29
        '''constructor'''
 
30
        ThemesManager.ThemesManager.__init__(self, ".AdiumSoundset")
 
31
 
 
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
 
36
        '''
 
37
        status, message = self.validate(theme_path)
 
38
 
 
39
        if not status:
 
40
            return status, message
 
41
 
 
42
        return True, SoundTheme.SoundTheme(theme_path)
 
43
 
 
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
 
47
        '''
 
48
        sound_path = os.path.join('themes', 'sounds', 'default.AdiumSoundset')
 
49
 
 
50
        for elem in self.list():
 
51
            if sound_name in elem:
 
52
                sound_path = elem
 
53
 
 
54
        return self.get(sound_path)[1]
 
55
 
 
56
    def validate(self, theme_path):
 
57
        '''validate a Theme directory structure
 
58
        '''
 
59
        if not os.path.isdir(theme_path):
 
60
            return False, _("%s is not a directory") % theme_path
 
61
 
 
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")
 
65
        return True, "ok"