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.MessageBox import MessageBox
6 from Components.ActionMap import NumberActionMap
7 from Components.Pixmap import Pixmap
8 from Components.MenuList import MenuList
9 from Plugins.Plugin import PluginDescriptor
10 from Components.config import config
11 from Tools.Directories import SCOPE_SKIN
12 from Components.config import config
14 from os import path, walk
15 from enigma import quitMainloop
17 class SkinSelector(Screen):
19 # _("Choose your Skin")
21 <screen position="75,138" size="600,320" title="Choose your Skin" >
22 <widget name="SkinList" position="10,10" size="275,300" scrollbarMode="showOnDemand" />
23 <widget name="Preview" position="305,45" size="280,210" alphatest="on"/>
28 root = "/usr/share/enigma2/"
30 def __init__(self, session, args = None):
32 self.skin = SkinSelector.skin
33 Screen.__init__(self, session)
36 self.session = session
39 path.walk(self.root, self.find, "")
42 self["SkinList"] = MenuList(self.skinlist)
43 self["Preview"] = Pixmap()
45 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
56 self.onLayoutFinish.append(self.loadPreview)
63 self["SkinList"].down()
67 self["SkinList"].pageUp()
71 self["SkinList"].pageDown()
75 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)
76 aboutbox.setTitle(_("About..."))
78 def find(self, arg, dirname, names):
81 if dirname <> self.root:
83 self.skinlist.append(subdir)
85 subdir = "Default Skin"
86 self.skinlist.append(subdir)
89 if self["SkinList"].getCurrent() == "Default Skin":
92 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
94 print "Skinselector: Selected Skin: "+self.root+skinfile
95 config.skin.primary_skin.value = skinfile
96 config.skin.primary_skin.save()
97 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)
98 restartbox.setTitle(_("Restart GUI now?"))
100 def loadPreview(self):
101 if self["SkinList"].getCurrent() == "Default Skin":
102 pngpath = self.root+"/prev.png"
104 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
106 if not path.exists(pngpath):
107 # FIXME: don't use hardcoded path
108 pngpath = "/usr/lib/enigma2/python/Plugins/SystemPlugins/SkinSelector/noprev.png"
110 if self.previewPath != pngpath:
111 self.previewPath = pngpath
113 self["Preview"].instance.setPixmapFromFile(self.previewPath)
115 def restartGUI(self, answer):
119 def SkinSelMain(session, **kwargs):
120 session.open(SkinSelector)
122 def SkinSelSetup(menuid):
123 if menuid == "system":
124 return [("Skin...", SkinSelMain)]
128 def Plugins(**kwargs):
129 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_SETUP, fnc=SkinSelSetup)