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
16 class SkinSelector(Screen):
18 # _("Choose your Skin")
20 <screen position="75,138" size="600,320" title="Choose your Skin" >
21 <widget name="SkinList" position="10,10" size="275,300" scrollbarMode="showOnDemand" />
22 <widget name="Preview" position="305,45" size="280,210" alphatest="on"/>
27 root = "/usr/share/enigma2/"
29 def __init__(self, session, args = None):
31 self.skin = SkinSelector.skin
32 Screen.__init__(self, session)
35 self.session = session
38 path.walk(self.root, self.find, "")
41 self["SkinList"] = MenuList(self.skinlist)
42 self["Preview"] = Pixmap()
44 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
55 self.onLayoutFinish.append(self.loadPreview)
62 self["SkinList"].down()
66 self["SkinList"].pageUp()
70 self["SkinList"].pageDown()
74 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)
75 aboutbox.setTitle(_("About..."))
77 def find(self, arg, dirname, names):
80 if dirname <> self.root:
82 self.skinlist.append(subdir)
84 subdir = "Default Skin"
85 self.skinlist.append(subdir)
88 if self["SkinList"].getCurrent() == "Default Skin":
91 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
93 print "Skinselector: Selected Skin: "+self.root+skinfile
94 config.skin.primary_skin.value = skinfile
95 config.skin.primary_skin.save()
96 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)
97 restartbox.setTitle(_("Restart GUI now?"))
99 def loadPreview(self):
100 if self["SkinList"].getCurrent() == "Default Skin":
101 pngpath = self.root+"/prev.png"
103 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
105 if not path.exists(pngpath):
106 # FIXME: don't use hardcoded path
107 pngpath = "/usr/lib/enigma2/python/Plugins/SystemPlugins/SkinSelector/noprev.png"
109 if self.previewPath != pngpath:
110 self.previewPath = pngpath
112 self["Preview"].instance.setPixmapFromFile(self.previewPath)
114 def restartGUI(self, answer):
118 def SkinSelMain(session, **kwargs):
119 session.open(SkinSelector)
121 def SkinSelSetup(menuid):
122 if menuid == "system":
123 return [("Skin...", SkinSelMain)]
127 def Plugins(**kwargs):
128 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_SETUP, fnc=SkinSelSetup)