1 # (c) 2006 Stephan Reichholf
2 # 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!
5 from Screens.Screen import Screen
6 from Screens.MessageBox import MessageBox
7 from Components.ActionMap import NumberActionMap
8 from Components.Pixmap import Pixmap
9 from Components.GUIComponent import *
10 from Components.MenuList import MenuList
11 from Plugins.Plugin import PluginDescriptor
13 from Components.config import config
14 from Tools.Directories import SCOPE_SKIN
16 from Components.config import config
20 class SkinSelector(Screen):
22 <screen position="75,138" size="600,300" title="Choose your Skin" >
23 <widget name="SkinList" position="10,10" size="275,280" scrollbarMode="showOnDemand" />
24 <widget name="Preview" position="305,45" size="280,210" alphatest="on"/>
29 root = "/usr/share/enigma2/"
31 def __init__(self, session, args = None):
33 self.skin = SkinSelector.skin
34 Screen.__init__(self, session)
37 self.session = session
40 os.path.walk(self.root, self.find, "")
43 self["SkinList"] = MenuList(self.skinlist)
44 self["Preview"] = Pixmap()
46 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
57 self.onLayoutFinish.append(self.loadPreview)
64 self["SkinList"].down()
68 self["SkinList"].pageUp()
72 self["SkinList"].pageDown()
76 aboutbox = self.session.open(MessageBox,_("Enigma2 Skinselector v0.5 BETA\n\nIf you experience any problems please contact\nstephan@reichholf.net\n\n\xA9 2006 - Stephan Reichholf"), MessageBox.TYPE_INFO)
77 aboutbox.setTitle(_("About..."))
79 def find(self, arg, dirname, names):
82 if dirname <> self.root:
84 self.skinlist.append(subdir)
86 subdir = "Default Skin"
87 self.skinlist.append(subdir)
90 if self["SkinList"].getCurrent() == "Default Skin":
93 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
95 print "Skinselector: Selected Skin: "+self.root+skinfile
96 config.skin.primary_skin.value = skinfile
97 config.skin.primary_skin.save()
98 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)
99 restartbox.setTitle(_("Restart GUI now?"))
101 def loadPreview(self):
102 if self["SkinList"].getCurrent() == "Default Skin":
103 pngpath = self.root+"/prev.png"
105 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
107 if not os.path.exists(pngpath):
108 # FIXME: don't use hardcoded path
109 pngpath = "/usr/lib/enigma2/python/Plugins/SystemPlugins/SkinSelector/noprev.png"
111 if self.previewPath != pngpath:
112 self.previewPath = pngpath
114 self["Preview"].instance.setPixmapFromFile(self.previewPath)
116 def restartGUI(self, answer):
120 def SkinSelMain(session, **kwargs):
121 session.open(SkinSelector)
123 def SkinSelSetup(menuid):
124 if menuid == "system":
125 return [("Skin...", SkinSelMain)]
129 def Plugins(**kwargs):
130 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_SETUP, fnc=SkinSelSetup)