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.Sources.StaticText import StaticText
10 from Components.MenuList import MenuList
11 from Plugins.Plugin import PluginDescriptor
12 from Components.config import config
13 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
14 from os import path, walk
16 class SkinSelector(Screen):
18 # _("Choose your Skin")
20 root = "/usr/share/enigma2/"
22 def __init__(self, session, args = None):
24 Screen.__init__(self, session)
28 path.walk(self.root, self.find, "")
30 self["key_red"] = StaticText(_("Close"))
31 self["introduction"] = StaticText(_("Press OK to activate the selected skin."))
33 self["SkinList"] = MenuList(self.skinlist)
34 self["Preview"] = Pixmap()
36 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
48 self.onLayoutFinish.append(self.layoutFinished)
50 def layoutFinished(self):
51 tmp = config.skin.primary_skin.value.find('/skin.xml')
53 tmp = config.skin.primary_skin.value[:tmp]
55 for skin in self.skinlist:
59 if idx < len(self.skinlist):
60 self["SkinList"].moveToIndex(idx)
68 self["SkinList"].down()
72 self["SkinList"].pageUp()
76 self["SkinList"].pageDown()
80 aboutbox = self.session.open(MessageBox,_("Enigma2 Skinselector\n\nIf you experience any problems please contact\nstephan@reichholf.net\n\n\xA9 2006 - Stephan Reichholf"), MessageBox.TYPE_INFO)
81 aboutbox.setTitle(_("About..."))
83 def find(self, arg, dirname, names):
86 if dirname <> self.root:
88 self.skinlist.append(subdir)
90 subdir = "Default Skin"
91 self.skinlist.append(subdir)
94 if self["SkinList"].getCurrent() == "Default Skin":
97 skinfile = self["SkinList"].getCurrent()+"/skin.xml"
99 print "Skinselector: Selected Skin: "+self.root+skinfile
100 config.skin.primary_skin.value = skinfile
101 config.skin.primary_skin.save()
102 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)
103 restartbox.setTitle(_("Restart GUI now?"))
105 def loadPreview(self):
106 if self["SkinList"].getCurrent() == "Default Skin":
107 pngpath = self.root+"/prev.png"
109 pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png"
111 if not path.exists(pngpath):
112 pngpath = resolveFilename(SCOPE_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):
121 self.session.open(TryQuitMainloop, 3)
123 def SkinSelMain(session, **kwargs):
124 session.open(SkinSelector)
126 def SkinSelSetup(menuid, **kwargs):
127 if menuid == "system":
128 return [(_("Skin"), SkinSelMain, "skin_selector", None)]
132 def Plugins(**kwargs):
133 return PluginDescriptor(name="Skinselector", description="Select Your Skin", where = PluginDescriptor.WHERE_MENU, fnc=SkinSelSetup)