1 # -*- coding: utf-8 -*-
2 # for localized messages
4 from Screens.Screen import Screen
5 from Components.Label import Label
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="90,140" size="560,350" title="UserManager">
18 <widget source="config" render="Listbox" position="10,10" size="540,220" scrollbarMode="showOnDemand">
19 <convert type="TemplatedMultiContent">
21 MultiContentEntryText(pos = (80, 5), size = (400, 50), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name
22 MultiContentEntryPixmapAlphaTest(pos = (0, 0), size = (48, 48), png = 3), # index 4 is the status pixmap
24 "fonts": [gFont("Regular", 40)],
29 <widget name="introduction" position="50,270" size="500,20" zPosition="10" font="Regular;21" halign="center" transparent="1" />
30 <widget name="ButtonRedtext" position="410,305" size="140,21" zPosition="10" font="Regular;21" transparent="1" />
31 <widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="390,305" zPosition="10" size="15,16" transparent="1" alphatest="on" />
32 <ePixmap pixmap="skin_default/buttons/button_yellow.png" position="30,305" zPosition="10" size="15,16" transparent="1" alphatest="on" />
33 <widget name="deletetext" position="50,305" size="350,21" zPosition="10" font="Regular;21" transparent="1" />
34 <ePixmap pixmap="skin_default/bottombar.png" position="10,250" size="540,120" zPosition="1" transparent="1" alphatest="on" />
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,
49 self["ButtonRed"] = Pixmap()
50 self["ButtonRedtext"] = Label(_("Close"))
51 self["introduction"] = Label(_("Press OK to edit selected settings."))
52 self["deletetext"] = Label(_("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):