1 # -*- coding: iso-8859-1 -*-
2 # (c) 2006 Stephan Reichholf
3 # This Software is Free, use it where you want, when you want for whatever you want and modify it if you want but don't remove my copyright!
4 from Screens.Screen import Screen
5 from Screens.Standby import TryQuitMainloop
6 from Screens.MessageBox import MessageBox
7 from Components.ActionMap import NumberActionMap
8 from Components.Pixmap import Pixmap
9 from Components.Sources.StaticText import StaticText
10 from Components.MenuList import MenuList
11 from Plugins.Plugin import PluginDescriptor
12 from Components.config import config
13 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
14 from os import path, walk
15 from enigma import eEnv
17 class SkinSelector(Screen):
19 # _("Choose your Skin")
21 root = eEnv.resolve("${datadir}/enigma2/")
23 def __init__(self, session, args = None):
25 Screen.__init__(self, session)
29 path.walk(self.root, self.find, "")
31 self["key_red"] = StaticText(_("Close"))
32 self["introduction"] = StaticText(_("Press OK to activate the selected skin."))
34 self["SkinList"] = MenuList(self.skinlist)
35 self["Preview"] = Pixmap()
37 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
49 self.onLayoutFinish.append(self.layoutFinished)
51 def layoutFinished(self):
52 tmp = config.skin.primary_skin.value.find('/skin.xml')
54 tmp = config.skin.primary_skin.value[:tmp]
56 for skin in self.skinlist:
60 if idx < len(self.skinlist):
61 self["SkinList"].moveToIndex(idx)
69 self["SkinList"].down()
73 self["SkinList"].pageUp()
77 self["SkinList"].pageDown()
81 aboutbox = self.session.open(MessageBox,_("Enigma2 Skinselector\n\nIf you experience any problems please contact\nstephan@reichholf.net\n\n\xA9 2006 - Stephan Reichholf"), MessageBox.TYPE_INFO)
82 aboutbox.setTitle(_("About..."))
84 def find(self, arg, dirname, names):
87 if dirname <> self.root:
89 self.skinlist.append(subdir)
91 subdir = "Default Skin"
92 self.skinlist.append(subdir)
95 if self["SkinList"].getCurrent() == "Default Skin":
98 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
100 print "Skinselector: Selected Skin: "+self.root+skinfile
101 config.skin.primary_skin.value = skinfile
102 config.skin.primary_skin.save()
103 restartbox = self.session.openWithCallback(self.restartGUI,MessageBox,_("GUI needs a restart to apply a new skin\nDo you want to Restart the GUI now?"), MessageBox.TYPE_YESNO)
104 restartbox.setTitle(_("Restart GUI now?"))
106 def loadPreview(self):
107 if self["SkinList"].getCurrent() == "Default Skin":
108 pngpath = self.root+"/prev.png"
110 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
112 if not path.exists(pngpath):
113 pngpath = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SkinSelector/noprev.png")
115 if self.previewPath != pngpath:
116 self.previewPath = pngpath
118 self["Preview"].instance.setPixmapFromFile(self.previewPath)
120 def restartGUI(self, answer):
122 self.session.open(TryQuitMainloop, 3)
124 def SkinSelMain(session, **kwargs):
125 session.open(SkinSelector)
127 def SkinSelSetup(menuid, **kwargs):
128 if menuid == "system":
129 return [(_("Skin"), SkinSelMain, "skin_selector", None)]
133 def Plugins(**kwargs):
134 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_MENU, fnc=SkinSelSetup)