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
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)
37 path.walk(self.root, self.find, "")
40 self["SkinList"] = MenuList(self.skinlist)
41 self["Preview"] = Pixmap()
43 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
54 self.onLayoutFinish.append(self.loadPreview)
61 self["SkinList"].down()
65 self["SkinList"].pageUp()
69 self["SkinList"].pageDown()
73 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)
74 aboutbox.setTitle(_("About..."))
76 def find(self, arg, dirname, names):
79 if dirname <> self.root:
81 self.skinlist.append(subdir)
83 subdir = "Default Skin"
84 self.skinlist.append(subdir)
87 if self["SkinList"].getCurrent() == "Default Skin":
90 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
92 print "Skinselector: Selected Skin: "+self.root+skinfile
93 config.skin.primary_skin.value = skinfile
94 config.skin.primary_skin.save()
95 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)
96 restartbox.setTitle(_("Restart GUI now?"))
98 def loadPreview(self):
99 if self["SkinList"].getCurrent() == "Default Skin":
100 pngpath = self.root+"/prev.png"
102 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
104 if not path.exists(pngpath):
105 # FIXME: don't use hardcoded path
106 pngpath = "/usr/lib/enigma2/python/Plugins/SystemPlugins/SkinSelector/noprev.png"
108 if self.previewPath != pngpath:
109 self.previewPath = pngpath
111 self["Preview"].instance.setPixmapFromFile(self.previewPath)
113 def restartGUI(self, answer):
115 self.session.open(TryQuitMainloop, 3)
117 def SkinSelMain(session, **kwargs):
118 session.open(SkinSelector)
120 def SkinSelSetup(menuid):
121 if menuid == "system":
122 return [("Skin...", SkinSelMain)]
126 def Plugins(**kwargs):
127 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_SETUP, fnc=SkinSelSetup)