2 from Plugins.Plugin import PluginDescriptor
3 from Screens.Screen import Screen
4 from Screens.ChoiceBox import ChoiceBox
5 from Screens.MessageBox import MessageBox
6 from Components.Label import Label
7 from Components.MenuList import MenuList
8 from Components.Pixmap import Pixmap
9 from Components.ActionMap import ActionMap, NumberActionMap
10 from Components.config import config,ConfigSubsection,ConfigSelection, getConfigListEntry
11 from Components.ConfigList import *
14 ###############################################################################
15 config.plugins.logomanager = ConfigSubsection()
16 config.plugins.logomanager.path = ConfigSelection([("/media/cf/bootlogos/",_("CF Drive")),("/media/hdd/bootlogos/",_("Harddisk"))],default="/media/hdd/bootlogos/")
20 def main(session,**kwargs):
21 if os.path.isdir(config.plugins.logomanager.path.value) is not True:
22 session.open(LogoManagerConfigScreen)
24 session.open(LogoManagerScreen)
26 def Plugins(path,**kwargs):
29 return PluginDescriptor(
31 description="manage logos to display at boottime",
32 where = PluginDescriptor.WHERE_PLUGINMENU,
35 ###############################################################################
36 class LogoManagerScreen(Screen):
38 <screen flags="wfNoBorder" position="60,450" size="600,29" title="Logo Manager" >
39 <widget name="filelist" position="0,0" size="600,30" />
43 ("bootlogo","/boot/bootlogo.mvi")
44 ,("wait","/boot/bootlogo_wait.mvi")
45 ,("backdrop","/boot/backdrop.mvi")
46 ,("radio","/usr/share/enigma2/radio.mvi")
49 def __init__(self, session, args = 0):
50 self.session = session
51 config.plugins.logomanager.path.value
52 self.skin = LogoManagerScreen.skin
53 Screen.__init__(self, session)
54 self["filelist"] = MenuList([])
55 self["filelist"].onSelectionChanged.append(self.showSelected)
56 self["actions"] = ActionMap(["WizardActions", "DirectionActions","MenuActions","ShortcutActions","GlobalActions"],
58 "ok": self.showSelected,
60 "menu": self.openMenu,
63 ## stop current service to free the videodevice
64 self.current_service = self.session.nav.getCurrentlyPlayingServiceReference()
65 self.session.nav.stopService()
68 self.setlist_to_avaiable()
70 self.makeBootWritable()
71 self.onShown.append(self.showSelected)
73 def check_backup(self):
74 """ if a copy of the original file is not found in the plugindir, backup them """
76 for target in self.targets:
77 file = target[1].split("/")[-1]
78 if os.path.isfile(plugin_path+file) is not True:
79 print "backing up original ",target[0]," from ",file
80 os.system("cp '%s' '%s'" %(target[1],plugin_path+"/"+file))
82 def restoreOriginal(self):
83 """ restoring original mvis from the backuped mvi in the plugindir"""
85 for target in self.targets:
86 file = target[1].split("/")[-1]
87 if os.path.isfile(plugin_path+"/"+file) is True:
88 print "restoring original ",target[0]," from ",plugin_path+"/"+file,"to",target[1]
89 os.system("cp '%s' '%s'" %(plugin_path+"/"+file,target[1]))
93 self.makeBootReadonly()
94 self.session.nav.playService(self.current_service)
97 def showSelected(self):
98 """ show the currently selected MVI of the list """
99 sel= self["filelist"].getCurrent()[1]
103 """ opens up the Main Menu """
105 menu.append(("install selected Logo as ...",self.action_install))
106 menu.append(("show aktive Logos",self.setlist_to_current))
107 menu.append(("show avaiable Logos",self.setlist_to_avaiable))
108 menu.append(("reset all Logos to default",self.restoreOriginal))
109 menu.append(("open configuration",self.openConfig))
110 self.session.openWithCallback(self.selectedMenu,ChoiceBox,_("please select a option"),menu)
112 def openConfig(self):
113 self.session.open(LogoManagerConfigScreen)
115 def selectedMenu(self,choice):
116 if choice is not None:
119 def setlist_to_current(self):
120 """ fills the list with the target MVIs"""
123 for i in self.targets:
124 filelist.append(i[1])
125 self.reloadPictures(filelist)
128 def setlist_to_avaiable(self):
129 """ fills the list with all found new MVIs"""
131 for i in os.listdir(config.plugins.logomanager.path.value):
132 if i.endswith(".mvi"):
133 filelist.append(config.plugins.logomanager.path.value+i)
135 self.reloadPictures(filelist)
138 def action_install(self):
139 """ choicebox, to select target to install an mvi to"""
140 self.session.openWithCallback(self.selectedTarget,ChoiceBox,_("select Target for logo"),self.targets)
142 def selectedTarget(self,choice):
143 if choice is not None:
144 self.installMVI(choice,self["filelist"].getCurrent()[1])
146 def reloadPictures(self,filelist):
147 """ build the menulist with givven files """
150 list.append((i.split("/")[-1],i))
151 self["filelist"].l.setList(list)
154 def showMVI(self,mvifile):
156 print "playing MVI",mvifile
157 os.system("/usr/bin/showiframe '%s'" % mvifile)
159 def installMVI(self,target,sourcefile):
160 """ installs a mvi by overwriting the target with a source mvi """
161 print "installing %s as %s on %s" %(sourcefile,target[0],target[1])
162 if os.path.isfile(target[1]):
164 os.system("cp '%s' '%s'"%(sourcefile,target[1]))
166 def makeBootWritable(self):
167 """ because /boot isnt writeable by default, we will change that here """
168 os.system("mount -o rw,remount /boot")
170 def makeBootReadonly(self):
171 """ make /boot writeprotected back again """
172 os.system("mount -o r,remount /boot")
174 class LogoManagerConfigScreen(ConfigListScreen,Screen):
176 <screen position="100,100" size="550,400" title="LogoManager Setup" >
177 <widget name="config" position="0,0" size="550,360" scrollbarMode="showOnDemand" />
178 <widget name="buttonred" position="10,360" size="100,40" backgroundColor="red" valign="center" halign="center" zPosition="2" foregroundColor="white" font="Regular;18"/>
179 <widget name="buttongreen" position="120,360" size="100,40" backgroundColor="green" valign="center" halign="center" zPosition="2" foregroundColor="white" font="Regular;18"/>
181 def __init__(self, session, args = 0):
182 self.session = session
183 Screen.__init__(self, session)
185 self.list.append(getConfigListEntry(_("Directory to scan for Logos"), config.plugins.logomanager.path))
186 ConfigListScreen.__init__(self, self.list)
187 self["buttonred"] = Label(_("cancel"))
188 self["buttongreen"] = Label(_("ok"))
189 self["setupActions"] = ActionMap(["SetupActions"],
194 "cancel": self.cancel,
200 for x in self["config"].list:
206 for x in self["config"].list: