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!
6 from Screens.Screen import Screen
7 from Screens.MessageBox import MessageBox
8 from Components.ActionMap import NumberActionMap
9 from Components.Pixmap import Pixmap
10 from Components.GUIComponent import *
11 from Components.MenuList import MenuList
12 from Plugins.Plugin import PluginDescriptor
14 from Components.config import config
15 from Tools.Directories import SCOPE_SKIN
17 from Components.config import config
21 class SkinSelector(Screen):
23 # _("Choose your Skin")
25 <screen position="75,138" size="600,320" title="Choose your Skin" >
26 <widget name="SkinList" position="10,10" size="275,300" scrollbarMode="showOnDemand" />
27 <widget name="Preview" position="305,45" size="280,210" alphatest="on"/>
32 root = "/usr/share/enigma2/"
34 def __init__(self, session, args = None):
36 self.skin = SkinSelector.skin
37 Screen.__init__(self, session)
40 self.session = session
43 os.path.walk(self.root, self.find, "")
46 self["SkinList"] = MenuList(self.skinlist)
47 self["Preview"] = Pixmap()
49 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
60 self.onLayoutFinish.append(self.loadPreview)
67 self["SkinList"].down()
71 self["SkinList"].pageUp()
75 self["SkinList"].pageDown()
79 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)
80 aboutbox.setTitle(_("About..."))
82 def find(self, arg, dirname, names):
85 if dirname <> self.root:
87 self.skinlist.append(subdir)
89 subdir = "Default Skin"
90 self.skinlist.append(subdir)
93 if self["SkinList"].getCurrent() == "Default Skin":
96 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
98 print "Skinselector: Selected Skin: "+self.root+skinfile
99 config.skin.primary_skin.value = skinfile
100 config.skin.primary_skin.save()
101 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)
102 restartbox.setTitle(_("Restart GUI now?"))
104 def loadPreview(self):
105 if self["SkinList"].getCurrent() == "Default Skin":
106 pngpath = self.root+"/prev.png"
108 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
110 if not os.path.exists(pngpath):
111 # FIXME: don't use hardcoded path
112 pngpath = "/usr/lib/enigma2/python/Plugins/SystemPlugins/SkinSelector/noprev.png"
114 if self.previewPath != pngpath:
115 self.previewPath = pngpath
117 self["Preview"].instance.setPixmapFromFile(self.previewPath)
119 def restartGUI(self, answer):
123 def SkinSelMain(session, **kwargs):
124 session.open(SkinSelector)
126 def SkinSelSetup(menuid):
127 if menuid == "system":
128 return [("Skin...", SkinSelMain)]
132 def Plugins(**kwargs):
133 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_SETUP, fnc=SkinSelSetup)