From 0127190e3bb1ee29a4772adf42055ca5c10e147b Mon Sep 17 00:00:00 2001 From: Marc-Andre Lureau Date: Tue, 3 Jun 2008 18:09:46 +0300 Subject: Rewrite the algorithms after Lennart implementation and cleverness --- spec/sound-theme-spec.xml | 61 +++++++++++------------------------------------ 1 file changed, 14 insertions(+), 47 deletions(-) (limited to 'spec') diff --git a/spec/sound-theme-spec.xml b/spec/sound-theme-spec.xml index ca9d8ea..376e50d 100644 --- a/spec/sound-theme-spec.xml +++ b/spec/sound-theme-spec.xml @@ -451,18 +451,6 @@ (if the implementation supports OGG) is: -FindSound(sound, locale) { - filename = FindSoundHelper(sound, locale, outputprofile, user selected theme); - if filename != none - return filename - - filename = FindSoundHelper(sound, locale, outputprofile, "freedesktop"); - if filename != none - return filename - - return LookupFallbackSound (sound) -} - FindSoundHelper(sound, locale, outputprofile, theme) { filename = LookupSound (sound, locale, outputprofile, theme) if filename != none @@ -472,7 +460,7 @@ FindSoundHelper(sound, locale, outputprofile, theme) { parents = theme.parents for parent in parents { - filename = FindSoundHelper (sound, locale, outputprofile, parent) + filename = LookupSound (sound, locale, outputprofile, parent) if filename != none return filename } @@ -483,47 +471,26 @@ FindSoundHelper(sound, locale, outputprofile, theme) { With the following helper functions: -LookupSound (sound, locale, outputprofile, theme) { +LookupSound (sound, locale, requestedoutputprofile, requestedtheme) { // lookup localized version - for each subdir in $(theme subdir list) { - for each directory in $(basename list) { - for profile in (outputprofile, "stereo") { - if DirectoryMatchesOutputProfile(subdir, profile) { - for extension in ("wav", "ogg") { - filename = directory/$(themename)/subdir/$locale/sound.extension - if exist filename - return filename + for theme in (requestedtheme, "freedesktop", "") { + for each locale in ($locale, truncate($locale, "@"), truncate($locale, "_"), "C", "") + for profile in (requestedoutputprofile, "stereo", "") { + for each subdir in $(theme subdir list) { + if DirectoryMatchesOutputProfile(subdir, profile) { + for each directory in $(basename list) { + for extension in ("wav", "ogg") { + filename = directory/$theme/subdir/locale/sound.extension + if exist filename + return filename + } + } } } } } } - // lookup unlocalized version - for each subdir in $(theme subdir list) { - for each directory in $(basename list) { - for profile in (outputprofile, "stereo") { - if DirectoryMatchesOutputProfile(subdir, profile) { - for extension in ("wav", "ogg") { - filename = directory/$(themename)/subdir/sound.extension - if exist filename - return filename - } - } - } - } - } - - return none -} - -LookupFallbackSound (sound) { - for each directory in $(basename list) { - for extension in ("wav", "ogg") { - if exists directory/sound.extension - return directory/sound.extension - } - } return none } -- cgit