1 # -*- coding: utf-8 -*-
2 # for localized messages
3 #from __init__ import _
4 from Screens.Screen import Screen
5 from Components.Sources.StaticText import StaticText
6 from Components.Pixmap import Pixmap
7 from Components.ActionMap import ActionMap
8 from Components.Sources.List import List
10 from Tools.LoadPixmap import LoadPixmap
11 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
12 from UserDialog import UserDialog
13 from os import unlink, listdir, path as os_path
15 class UserManager(Screen):
17 <screen name="UserManager" position="center,center" size="560,400" title="UserManager">
18 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
19 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
20 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
21 <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
22 <widget source="config" render="Listbox" position="5,50" size="540,220" scrollbarMode="showOnDemand">
23 <convert type="TemplatedMultiContent">
25 MultiContentEntryText(pos = (80, 5), size = (400, 50), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name
26 MultiContentEntryPixmapAlphaTest(pos = (0, 0), size = (48, 48), png = 3), # index 4 is the status pixmap
28 "fonts": [gFont("Regular", 40)],
33 <ePixmap pixmap="skin_default/div-h.png" position="0,360" zPosition="1" size="560,2" />
34 <widget source="introduction" render="Label" position="10,370" size="540,21" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/>
37 def __init__(self, session, plugin_path):
38 self.skin_path = plugin_path
39 self.session = session
40 Screen.__init__(self, session)
41 self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"],
47 "yellow": self.delete,
50 self["key_red"] = StaticText(_("Close"))
51 self["introduction"] = StaticText(_("Press OK to edit selected settings."))
52 self["key_yellow"] = StaticText(_("Delete"))
55 self["config"] = List(self.list)
57 self.onShown.append(self.setWindowTitle)
59 def setWindowTitle(self):
60 self.setTitle(_("Usermanager"))
64 for file in listdir('/etc/enigma2'):
65 if file.endswith('.cache'):
66 if file == 'networkbrowser.cache':
69 hostpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/host.png"))
70 self.list.append(( file[:-6],'edit',file,hostpng ))
71 self["config"].setList(self.list)
76 def keyOK(self, returnValue = None):
77 cur = self["config"].getCurrent()
81 if returnValue is "edit":
82 self.session.open(UserDialog, self.skin_path,hostinfo)
84 def delete(self, returnValue = None):
85 cur = self["config"].getCurrent()
88 cachefile = '/etc/enigma2/' + returnValue.strip()
89 if os_path.exists(cachefile):