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 # _("Choose your Skin")
24 <screen position="75,138" size="600,320" title="Choose your Skin" >
25 <widget name="SkinList" position="10,10" size="275,300" scrollbarMode="showOnDemand" />
26 <widget name="Preview" position="305,45" size="280,210" alphatest="on"/>
31 root = "/usr/share/enigma2/"
33 def __init__(self, session, args = None):
35 self.skin = SkinSelector.skin
36 Screen.__init__(self, session)
39 self.session = session
42 os.path.walk(self.root, self.find, "")
45 self["SkinList"] = MenuList(self.skinlist)
46 self["Preview"] = Pixmap()
48 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
59 self.onLayoutFinish.append(self.loadPreview)
66 self["SkinList"].down()
70 self["SkinList"].pageUp()
74 self["SkinList"].pageDown()
78 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)
79 aboutbox.setTitle(_("About..."))
81 def find(self, arg, dirname, names):
84 if dirname <> self.root:
86 self.skinlist.append(subdir)
88 subdir = "Default Skin"
89 self.skinlist.append(subdir)
92 if self["SkinList"].getCurrent() == "Default Skin":
95 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
97 print "Skinselector: Selected Skin: "+self.root+skinfile
98 config.skin.primary_skin.value = skinfile
99 config.skin.primary_skin.save()
100 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)
101 restartbox.setTitle(_("Restart GUI now?"))
103 def loadPreview(self):
104 if self["SkinList"].getCurrent() == "Default Skin":
105 pngpath = self.root+"/prev.png"
107 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
109 if not os.path.exists(pngpath):
110 # FIXME: don't use hardcoded path
111 pngpath = "/usr/lib/enigma2/python/Plugins/SystemPlugins/SkinSelector/noprev.png"
113 if self.previewPath != pngpath:
114 self.previewPath = pngpath
116 self["Preview"].instance.setPixmapFromFile(self.previewPath)
118 def restartGUI(self, answer):
122 def SkinSelMain(session, **kwargs):
123 session.open(SkinSelector)
125 def SkinSelSetup(menuid):
126 if menuid == "system":
127 return [("Skin...", SkinSelMain)]
131 def Plugins(**kwargs):
132 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_SETUP, fnc=SkinSelSetup)