From: ghost Date: Thu, 5 Nov 2009 07:48:03 +0000 (+0100) Subject: fix not working default record pathes screen (add and install missing file) X-Git-Tag: 2.7.0~32^2~14^2~1 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/0271558b0e0d04a17e7fa5ce2314a855507c8a85 fix not working default record pathes screen (add and install missing file) --- diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am index 44994b86..585983c2 100755 --- a/lib/python/Screens/Makefile.am +++ b/lib/python/Screens/Makefile.am @@ -14,5 +14,5 @@ install_PYTHON = \ SubtitleDisplay.py SubservicesQuickzap.py ParentalControlSetup.py NumericalTextInputHelpDialog.py \ SleepTimerEdit.py Ipkg.py RdsDisplay.py Globals.py DefaultWizard.py \ SessionGlobals.py LocationBox.py WizardLanguage.py TaskView.py Rc.py VirtualKeyBoard.py \ - TextBox.py FactoryReset.py + TextBox.py FactoryReset.py RecordPaths.py diff --git a/lib/python/Screens/RecordPaths.py b/lib/python/Screens/RecordPaths.py new file mode 100644 index 00000000..c833266f --- /dev/null +++ b/lib/python/Screens/RecordPaths.py @@ -0,0 +1,194 @@ +from Screens.Screen import Screen +from Screens.LocationBox import MovieLocationBox, TimeshiftLocationBox +from Screens.MessageBox import MessageBox +from Components.Label import Label +from Components.config import config, ConfigSelection, getConfigListEntry, configfile +from Components.ConfigList import ConfigListScreen +from Components.ActionMap import ActionMap +from Tools.Directories import fileExists + + +class RecordPathsSettings(Screen,ConfigListScreen): + skin = """ + + + + + + + """ + + def __init__(self, session): + from Components.Sources.StaticText import StaticText + Screen.__init__(self, session) + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Save")) + + ConfigListScreen.__init__(self, []) + self.initConfigList() + + self["setupActions"] = ActionMap(["SetupActions", "ColorActions"], + { + "green": self.save, + "red": self.cancel, + "cancel": self.cancel, + "ok": self.ok, + }, -2) + + def checkReadWriteDir(self, configele): + print "checkReadWrite: ", configele.value + if configele.value in [x[0] for x in self.styles] or fileExists(configele.value, "w"): + configele.last_value = configele.value + return True + else: + dir = configele.value + configele.value = configele.last_value + self.session.open( + MessageBox, + _("The directory %s is not writable.\nMake sure you select a writable directory instead.")%dir, + type = MessageBox.TYPE_ERROR + ) + return False + + def initConfigList(self): + self.styles = [ ("", _("")), ("", _("")), ("", _("")) ] + styles_keys = [x[0] for x in self.styles] + tmp = config.movielist.videodirs.value + default = config.usage.default_path.value + if default not in tmp: + tmp = tmp[:] + tmp.append(default) + print "DefaultPath: ", default, tmp + self.default_dirname = ConfigSelection(default = default, choices = tmp) + tmp = config.movielist.videodirs.value + default = config.usage.timer_path.value + if default not in tmp and default not in styles_keys: + tmp = tmp[:] + tmp.append(default) + print "TimerPath: ", default, tmp + self.timer_dirname = ConfigSelection(default = default, choices = self.styles+tmp) + tmp = config.movielist.videodirs.value + default = config.usage.instantrec_path.value + if default not in tmp and default not in styles_keys: + tmp = tmp[:] + tmp.append(default) + print "InstantrecPath: ", default, tmp + self.instantrec_dirname = ConfigSelection(default = default, choices = self.styles+tmp) + default = config.usage.timeshift_path.value + tmp = config.usage.allowed_timeshift_paths.value + if default not in tmp: + tmp = tmp[:] + tmp.append(default) + print "TimeshiftPath: ", default, tmp + self.timeshift_dirname = ConfigSelection(default = default, choices = tmp) + self.default_dirname.addNotifier(self.checkReadWriteDir, initial_call=False, immediate_feedback=False) + self.timer_dirname.addNotifier(self.checkReadWriteDir, initial_call=False, immediate_feedback=False) + self.instantrec_dirname.addNotifier(self.checkReadWriteDir, initial_call=False, immediate_feedback=False) + self.timeshift_dirname.addNotifier(self.checkReadWriteDir, initial_call=False, immediate_feedback=False) + + self.list = [] + if config.usage.setup_level.index >= 2: + self.default_entry = getConfigListEntry(_("Default movie location"), self.default_dirname) + self.list.append(self.default_entry) + self.timer_entry = getConfigListEntry(_("Timer record location"), self.timer_dirname) + self.list.append(self.timer_entry) + self.instantrec_entry = getConfigListEntry(_("Instant record location"), self.instantrec_dirname) + self.list.append(self.instantrec_entry) + else: + self.default_entry = getConfigListEntry(_("Movie location"), self.default_dirname) + self.list.append(self.default_entry) + self.timeshift_entry = getConfigListEntry(_("Timeshift location"), self.timeshift_dirname) + self.list.append(self.timeshift_entry) + self["config"].setList(self.list) + + def ok(self): + currentry = self["config"].getCurrent() + self.lastvideodirs = config.movielist.videodirs.value + self.lasttimeshiftdirs = config.usage.allowed_timeshift_paths.value + if config.usage.setup_level.index >= 2: + txt = _("Default movie location") + else: + txt = _("Movie location") + if currentry == self.default_entry: + self.entrydirname = self.default_dirname + self.session.openWithCallback( + self.dirnameSelected, + MovieLocationBox, + txt, + self.default_dirname.value + ) + elif currentry == self.timer_entry: + self.entrydirname = self.timer_dirname + self.session.openWithCallback( + self.dirnameSelected, + MovieLocationBox, + _("Initial location in new timers"), + self.timer_dirname.value + ) + elif currentry == self.instantrec_entry: + self.entrydirname = self.instantrec_dirname + self.session.openWithCallback( + self.dirnameSelected, + MovieLocationBox, + _("Location for instant recordings"), + self.instantrec_dirname.value + ) + elif currentry == self.timeshift_entry: + self.entrydirname = self.timeshift_dirname + config.usage.timeshift_path.value = self.timeshift_dirname.value + self.session.openWithCallback( + self.dirnameSelected, + TimeshiftLocationBox + ) + + def dirnameSelected(self, res): + if res is not None: + self.entrydirname.value = res + if config.movielist.videodirs.value != self.lastvideodirs: + styles_keys = [x[0] for x in self.styles] + tmp = config.movielist.videodirs.value + default = self.default_dirname.value + if default not in tmp: + tmp = tmp[:] + tmp.append(default) + self.default_dirname.setChoices(tmp, default=default) + tmp = config.movielist.videodirs.value + default = self.timer_dirname.value + if default not in tmp and default not in styles_keys: + tmp = tmp[:] + tmp.append(default) + self.timer_dirname.setChoices(self.styles+tmp, default=default) + tmp = config.movielist.videodirs.value + default = self.instantrec_dirname.value + if default not in tmp and default not in styles_keys: + tmp = tmp[:] + tmp.append(default) + self.instantrec_dirname.setChoices(self.styles+tmp, default=default) + self.entrydirname.value = res + if config.usage.allowed_timeshift_paths.value != self.lasttimeshiftdirs: + tmp = config.usage.allowed_timeshift_paths.value + default = self.instantrec_dirname.value + if default not in tmp: + tmp = tmp[:] + tmp.append(default) + self.timeshift_dirname.setChoices(tmp, default=default) + self.entrydirname.value = res + if self.entrydirname.last_value != res: + self.checkReadWriteDir(self.entrydirname) + + def save(self): + currentry = self["config"].getCurrent() + if self.checkReadWriteDir(currentry[1]): + config.usage.default_path.value = self.default_dirname.value + config.usage.timer_path.value = self.timer_dirname.value + config.usage.instantrec_path.value = self.instantrec_dirname.value + config.usage.timeshift_path.value = self.timeshift_dirname.value + config.usage.default_path.save() + config.usage.timer_path.save() + config.usage.instantrec_path.save() + config.usage.timeshift_path.save() + self.close() + + def cancel(self): + self.close() +