summaryrefslogtreecommitdiffstats
path: root/os-plugins
diff options
context:
space:
mode:
authorOliver Tappe2008-05-26 23:14:51 +0200
committerOliver Tappe2008-05-26 23:14:51 +0200
commit47afe5f52a06af49a9aad02e62bf13e303601489 (patch)
tree788d2c4bd3529803f442d3abce9f010430f6ff51 /os-plugins
parent* reworked plugin-API concerning the way the parameters are passed into (diff)
downloadcore-47afe5f52a06af49a9aad02e62bf13e303601489.tar.gz
core-47afe5f52a06af49a9aad02e62bf13e303601489.tar.xz
core-47afe5f52a06af49a9aad02e62bf13e303601489.zip
* added support to user provided themes (should live in /etc/opt/openslx/desktop/themes)
* implemented automatic detection of available themes if desktop::supported_themes is unset (which is now the default) git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1804 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins')
-rw-r--r--os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm57
1 files changed, 46 insertions, 11 deletions
diff --git a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm
index 7f20f852..ed8a7508 100644
--- a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm
+++ b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm
@@ -428,7 +428,7 @@ sub _fillUnsetStage1Attrs
$self->{'xdm'} = $self->{distro}->isXDMInstalled();
}
if (!defined $self->{'supported_themes'}) {
-# $self->{'supported_themes'} = $self->{distro}->getSupportedThemes();
+ $self->{'supported_themes'} = join ",", $self->_getAvailableThemes();
}
return 1;
@@ -582,6 +582,8 @@ sub _writeConfigHash
$content .= "\n";
}
spitFile($file, $content);
+
+ return;
}
sub _setupSupportedThemes
@@ -592,20 +594,53 @@ sub _setupSupportedThemes
my @supportedThemes = split m{\s*,\s*}, $supportedThemes;
return if !@supportedThemes;
- my $themeBaseDir = "$self->{openslxBasePath}/lib/plugins/desktop/themes";
+ # Every theme is copied from the folder where it is found first, such that
+ # themes in the config folder will be preferred to a theme with the same
+ # name living in the base folder
+ my @themeBaseDirs = (
+ "$self->{openslxConfigPath}/plugins/desktop/themes",
+ "$self->{openslxBasePath}/lib/plugins/desktop/themes",
+ );
THEME:
for my $theme (@supportedThemes) {
- my $themeDir = "$themeBaseDir/$theme";
- if (!-e $themeDir) {
- warn _tr('theme "%s" not found - skipped!', $theme);
- next;
+ THEME_DIR:
+ foreach my $themeBaseDir (@themeBaseDirs) {
+ my $themeDir = "$themeBaseDir/$theme";
+ next THEME_DIR if !-d $themeDir;
+
+ # copy theme into plugin-repo folder
+ my $themeTargetPath = "$self->{pluginRepositoryPath}/themes";
+ mkpath($themeTargetPath);
+ vlog(1, "installing theme '$theme'...");
+ slxsystem("cp -a $themeDir $themeTargetPath/$theme") == 0
+ or die _tr('unable to copy theme %s (%s)', $theme, $!);
+ next THEME;
}
- my $themeTargetPath = "$self->{pluginRepositoryPath}/themes";
- mkpath($themeTargetPath);
- vlog(1, "installing theme '$theme'...");
- slxsystem("cp -a $themeDir $themeTargetPath/$theme") == 0
- or die _tr('unable to copy theme %s (%s)', $theme, $!);
+ warn _tr('theme "%s" not found - skipped!', $theme);
}
+
+ return;
+}
+
+sub _getAvailableThemes
+{
+ my $self = shift;
+
+ my @availableThemes;
+
+ # return all themes found in any of these two folders
+ my @themeBaseDirs = (
+ "$self->{openslxConfigPath}/plugins/desktop/themes",
+ "$self->{openslxBasePath}/lib/plugins/desktop/themes",
+ );
+ for my $themeBaseDir (@themeBaseDirs) {
+ push @availableThemes,
+ map { basename $_ } grep { -d $_ } glob("$themeBaseDir/*");
+ }
+
+ vlog(1, _tr("available themes: %s", join ",", @availableThemes));
+
+ return @availableThemes;
}
1;