aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Components/ConfigList.py28
-rw-r--r--lib/python/Screens/Satconfig.py6
-rw-r--r--lib/python/Screens/Setup.py27
3 files changed, 28 insertions, 33 deletions
diff --git a/lib/python/Components/ConfigList.py b/lib/python/Components/ConfigList.py
index 4dd401f9..8b880fba 100644
--- a/lib/python/Components/ConfigList.py
+++ b/lib/python/Components/ConfigList.py
@@ -3,6 +3,7 @@ from GUIComponent import *
from config import KEY_LEFT, KEY_RIGHT, KEY_0, KEY_DELETE, KEY_OK, KEY_TIMEOUT, ConfigElement
from Components.ActionMap import NumberActionMap
from enigma import eListbox, eListboxPythonConfigContent, eTimer
+from Screens.MessageBox import MessageBox
class ConfigList(HTMLComponent, GUIComponent, object):
def __init__(self, list, session = None):
@@ -94,6 +95,13 @@ class ConfigList(HTMLComponent, GUIComponent, object):
def timeout(self):
self.handleKey(KEY_TIMEOUT)
+ def isChanged(self):
+ is_changed = False
+ for x in self.list:
+ is_changed |= x[1].isChanged()
+
+ return is_changed
+
class ConfigListScreen:
def __init__(self, list, session = None, on_change = None):
self["config_actions"] = NumberActionMap(["SetupActions", "TextInputActions"],
@@ -139,3 +147,23 @@ class ConfigListScreen:
self["config"].handleKey(KEY_0 + number)
self.__changed()
+ # keySave and keyCancel are just provided in case you need them.
+ # you have to call them by yourself.
+ def keySave(self):
+ for x in self["config"].list:
+ x[1].save()
+ self.close()
+
+ def cancelConfirm(self, result):
+ if not result:
+ return
+
+ for x in self["config"].list:
+ x[1].cancel()
+ self.close()
+
+ def keyCancel(self):
+ if self["config"].isChanged():
+ self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
+ else:
+ self.close()
diff --git a/lib/python/Screens/Satconfig.py b/lib/python/Screens/Satconfig.py
index d6d9904c..226c3a82 100644
--- a/lib/python/Screens/Satconfig.py
+++ b/lib/python/Screens/Satconfig.py
@@ -153,11 +153,6 @@ class NimSetup(Screen, ConfigListScreen):
self.run()
self.close()
- def keyCancel(self):
- for x in self["config"].list:
- x[1].cancel()
- self.close()
-
def __init__(self, session, slotid):
Screen.__init__(self, session)
self.list = [ ]
@@ -198,4 +193,3 @@ class NimSelection(Screen):
selection = self["nimlist"].getCurrent()
if selection[1].nimType != -1: #unknown/empty
self.session.open(NimSetup, selection[1].slotid)
-
diff --git a/lib/python/Screens/Setup.py b/lib/python/Screens/Setup.py
index 59f0ff57..432d8245 100644
--- a/lib/python/Screens/Setup.py
+++ b/lib/python/Screens/Setup.py
@@ -1,5 +1,4 @@
from Screen import Screen
-from MessageBox import MessageBox
from Components.ActionMap import NumberActionMap
from Components.config import config, KEY_LEFT, KEY_RIGHT, KEY_OK
from Components.ConfigList import ConfigList, ConfigListScreen
@@ -125,32 +124,6 @@ class Setup(ConfigListScreen, Screen):
# the second one is converted to string.
list.append( (item_text, item) )
- def keySave(self):
- print "save requested"
- for x in self["config"].list:
- x[1].save()
- self.close()
-
- def cancelConfirm(self, result):
- if not result:
- return
-
- print "cancel requested"
-
- for x in self["config"].list:
- x[1].cancel()
- self.close()
-
- def keyCancel(self):
- is_changed = False
- for x in self["config"].list:
- is_changed |= x[1].isChanged()
-
- if is_changed:
- self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
- else:
- self.close()
-
def getSetupTitle(id):
xmldata = setupdom.childNodes[0].childNodes
for x in elementsWithTag(xmldata, "setup"):