parental control:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sun, 28 Oct 2007 09:22:33 +0000 (09:22 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sun, 28 Oct 2007 09:22:33 +0000 (09:22 +0000)
automatically wrap to validation pin entry in pin changing dialog when 4 figures were entered
leave dialog when 4 figures were entered in the validation pin entry

lib/python/Components/ConfigList.py
lib/python/Components/config.py
lib/python/Screens/ParentalControlSetup.py

index 7ed6031..47b577e 100644 (file)
@@ -48,6 +48,10 @@ class ConfigList(HTMLComponent, GUIComponent, object):
        def getCurrentIndex(self):
                return self.l.getCurrentSelectionIndex()
        
+       def setCurrentIndex(self, index):
+               if self.instance is not None:
+                       self.instance.moveSelectionTo(index)
+       
        def invalidateCurrent(self):
                self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
 
index a872c30..de06871 100644 (file)
@@ -328,6 +328,8 @@ class ConfigSequence(ConfigElement):
                
                self.default = default
                self.value = copy.copy(default)
+               
+               self.endNotifier = []
 
        def validate(self):
                max_pos = 0
@@ -344,6 +346,8 @@ class ConfigSequence(ConfigElement):
                        num += 1
 
                if self.marked_pos >= max_pos:
+                       for x in self.endNotifier:
+                               x(self)
                        self.marked_pos = max_pos - 1
 
                if self.marked_pos < 0:
@@ -357,6 +361,9 @@ class ConfigSequence(ConfigElement):
 
                if self.marked_pos >= total_len:
                        self.marked_pos = total_len - 1
+                       
+       def addEndNotifier(self, notifier):
+               self.endNotifier.append(notifier)
 
        def handleKey(self, key):
                if key == KEY_LEFT:
index abe09af..f5f48e2 100644 (file)
@@ -230,6 +230,8 @@ class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen):
                self.list = []
                self.pin1 = ConfigPIN(default = 1111, censor = "*")
                self.pin2 = ConfigPIN(default = 1112, censor = "*")
+               self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1))
+               self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2))
                self.list.append(getConfigListEntry(_("New pin"), NoSave(self.pin1)))
                self.list.append(getConfigListEntry(_("Reenter new pin"), NoSave(self.pin2)))
                ConfigListScreen.__init__(self, self.list)
@@ -243,6 +245,12 @@ class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen):
                        "cancel": self.cancel,
                }, -1)
 
+       def valueChanged(self, pin, value):
+               if pin == 1:
+                       self["config"].setCurrentIndex(1)
+               elif pin == 2:
+                       self.keyOK()
+
        def getPinText(self):
                return _("Please enter the old pin code")