diff options
| author | acid-burn <acidburn@opendreambox.org> | 2009-10-07 16:05:42 +0200 |
|---|---|---|
| committer | acid-burn <acidburn@opendreambox.org> | 2009-10-07 16:05:42 +0200 |
| commit | f9e68c68b63b86c6cdb940681e66231a856c21f9 (patch) | |
| tree | b3f0663603b2d86cdfe404055f444a8a82756858 /lib/python/Plugins/SystemPlugins/CleanupWizard | |
| parent | 7ac3daaddd1d808a9238391cd14613931900e4f9 (diff) | |
| download | enigma2-f9e68c68b63b86c6cdb940681e66231a856c21f9.tar.gz enigma2-f9e68c68b63b86c6cdb940681e66231a856c21f9.zip | |
CleanupWizard/plugin.py: - add configuration screen to mainmenu->system.
It is now possible to enable/disable the CleanupWizard and also to manually define the free space threshold for the warning.
Diffstat (limited to 'lib/python/Plugins/SystemPlugins/CleanupWizard')
| -rwxr-xr-x | lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py | 118 |
1 files changed, 112 insertions, 6 deletions
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py b/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py index 125f7844..6667e3e3 100755 --- a/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py @@ -1,29 +1,135 @@ from Screens.Screen import Screen from Plugins.Plugin import PluginDescriptor from Components.PluginComponent import plugins -from Components.config import config +from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigYesNo, ConfigNumber +from Components.ConfigList import ConfigListScreen +from Components.ActionMap import ActionMap +from Components.Sources.StaticText import StaticText from CleanupWizard import checkFreeSpaceAvailable +config.plugins.cleanupwizard = ConfigSubsection() +config.plugins.cleanupwizard.enable = ConfigYesNo(default = True) +config.plugins.cleanupwizard.threshold = ConfigNumber(default = 2048) + freeSpace = checkFreeSpaceAvailable() print "[CleanupWizard] freeSpaceAvailable-->",freeSpace - if freeSpace is None: internalMemoryExceeded = 0 -elif int(freeSpace) <= 2048: +elif int(freeSpace) <= config.plugins.cleanupwizard.threshold.value: internalMemoryExceeded = 1 else: internalMemoryExceeded = 0 +class CleanupWizardConfiguration(Screen, ConfigListScreen): + + skin = """ + <screen name="CleanupWizardConfiguration" position="center,center" size="560,440" title="CleanupWizard settings" > + <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> + <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" /> + <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" /> + <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" /> + <widget name="config" zPosition="2" position="5,50" size="550,300" scrollbarMode="showOnDemand" transparent="1" /> + <ePixmap pixmap="skin_default/div-h.png" position="0,390" zPosition="10" size="560,2" transparent="1" alphatest="on" /> + <widget source="status" render="Label" position="10,400" size="540,40" zPosition="10" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/> + </screen>""" + + def __init__(self, session): + Screen.__init__(self, session) + self.session = session + self.EnableEntry = None + self.freeSpaceEntry = None + self.onChangedEntry = [ ] + self.setup_title = _("Cleanup Wizard") + + self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ], + { + "ok": self.keySave, + "cancel": self.keyCancel, + "red": self.keyCancel, + "green": self.keySave, + }, -2) + + self.list = [] + ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry) + self.createSetup() + + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Save")) + self["status"] = StaticText() + self.onShown.append(self.setWindowTitle) + + def setWindowTitle(self): + self.setTitle(_("Cleanup Wizard settings")) + + def keyLeft(self): + ConfigListScreen.keyLeft(self) + self.newConfig() + + def keyRight(self): + ConfigListScreen.keyRight(self) + self.newConfig() + + def createSetup(self): + self.list = [] + self.EnableEntry = getConfigListEntry(_("Enable Cleanup Wizard?"), config.plugins.cleanupwizard.enable) + self.freeSpaceEntry = getConfigListEntry(_("Warn if free space drops below (kB):"), config.plugins.cleanupwizard.threshold) + self.list.append( self.EnableEntry ) + if config.plugins.cleanupwizard.enable.value is True: + self.list.append( self.freeSpaceEntry ) + + self["config"].list = self.list + self["config"].l.setList(self.list) + if not self.selectionChanged in self["config"].onSelectionChanged: + self["config"].onSelectionChanged.append(self.selectionChanged) + + def newConfig(self): + if self["config"].getCurrent() == self.EnableEntry: + self.createSetup() + + def selectionChanged(self): + current = self["config"].getCurrent() + if current == self.EnableEntry: + self["status"].setText(_("Decide if you want to enable or disable the Cleanup Wizard.")) + elif current == self.freeSpaceEntry: + self["status"].setText(_("Set available internal memory threshold for the warning.")) + + # for summary: + def changedEntry(self): + for x in self.onChangedEntry: + x() + self.selectionChanged() + + def getCurrentEntry(self): + return self["config"].getCurrent()[0] + + def getCurrentValue(self): + return str(self["config"].getCurrent()[1].getText()) + + def createSummary(self): + from Screens.Setup import SetupSummary + return SetupSummary + def CleanupWizard(*args, **kwargs): from CleanupWizard import CleanupWizard return CleanupWizard(*args, **kwargs) +def openconfig(session, **kwargs): + session.open(CleanupWizardConfiguration) + +def selSetup(menuid, **kwargs): + if menuid != "system": + return [ ] + + return [(_("Cleanup Wizard settings") + "...", openconfig, "cleanup_config", 71)] + def Plugins(**kwargs): list = [] - if not config.misc.firstrun.value: - if internalMemoryExceeded: - list.append(PluginDescriptor(name=_("Cleanup Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=(1, CleanupWizard))) + list.append(PluginDescriptor(name=_("CleanupWizard"), description=_("Cleanup Wizard settings"),where=PluginDescriptor.WHERE_MENU, fnc=selSetup)) + if config.plugins.cleanupwizard.enable.value: + if not config.misc.firstrun.value: + if internalMemoryExceeded: + list.append(PluginDescriptor(name=_("Cleanup Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=(1, CleanupWizard))) return list |
