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.Standby import TryQuitMainloop
6 from Screens.MessageBox import MessageBox
7 from Components.ActionMap import NumberActionMap
8 from Components.Pixmap import Pixmap
9 from Components.MenuList import MenuList
10 from Plugins.Plugin import PluginDescriptor
11 from Components.config import config
13 from os import path, walk
15 class SkinSelector(Screen):
17 # _("Choose your Skin")
19 <screen position="75,138" size="600,320" title="Choose your Skin" >
20 <widget name="SkinList" position="10,10" size="275,300" scrollbarMode="showOnDemand" />
21 <widget name="Preview" position="305,45" size="280,210" alphatest="on"/>
26 root = "/usr/share/enigma2/"
28 def __init__(self, session, args = None):
30 self.skin = SkinSelector.skin
31 Screen.__init__(self, session)
36 path.walk(self.root, self.find, "")
39 self["SkinList"] = MenuList(self.skinlist)
40 self["Preview"] = Pixmap()
42 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
53 self.onLayoutFinish.append(self.layoutFinished)
55 def layoutFinished(self):
56 tmp = config.skin.primary_skin.value.find('/skin.xml')
58 tmp = config.skin.primary_skin.value[:tmp]
60 for skin in self.skinlist:
64 if idx < len(self.skinlist):
65 self["SkinList"].moveToIndex(idx)
73 self["SkinList"].down()
77 self["SkinList"].pageUp()
81 self["SkinList"].pageDown()
85 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)
86 aboutbox.setTitle(_("About..."))
88 def find(self, arg, dirname, names):
91 if dirname <> self.root:
93 self.skinlist.append(subdir)
95 subdir = "Default Skin"
96 self.skinlist.append(subdir)
99 if self["SkinList"].getCurrent() == "Default Skin":
100 skinfile = "skin.xml"
102 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
104 print "Skinselector: Selected Skin: "+self.root+skinfile
105 config.skin.primary_skin.value = skinfile
106 config.skin.primary_skin.save()
107 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)
108 restartbox.setTitle(_("Restart GUI now?"))
110 def loadPreview(self):
111 if self["SkinList"].getCurrent() == "Default Skin":
112 pngpath = self.root+"/prev.png"
114 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
116 if not path.exists(pngpath):
117 # FIXME: don't use hardcoded path
118 pngpath = "/usr/lib/enigma2/python/Plugins/SystemPlugins/SkinSelector/noprev.png"
120 if self.previewPath != pngpath:
121 self.previewPath = pngpath
123 self["Preview"].instance.setPixmapFromFile(self.previewPath)
125 def restartGUI(self, answer):
127 self.session.open(TryQuitMainloop, 3)
129 def SkinSelMain(session, **kwargs):
130 session.open(SkinSelector)
132 def SkinSelSetup(menuid, **kwargs):
133 if menuid == "system":
134 return [(_("Skin..."), SkinSelMain, "skin_selector", None)]
138 def Plugins(**kwargs):
139 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_MENU, fnc=SkinSelSetup)