use uncode for textinput component
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 23 Aug 2006 23:53:30 +0000 (23:53 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 23 Aug 2006 23:53:30 +0000 (23:53 +0000)
lib/python/Components/Input.py
lib/python/Tools/NumericalTextInput.py
lib/python/enigma_python.i

index e27ef524048b810b3353285c8d7a985c5375876c..e7713d6db9ee73c4144267d4bba7c2bfad992413 100644 (file)
@@ -2,48 +2,46 @@ from HTMLComponent import *
 from GUIComponent import *
 from VariableText import *
 
-from enigma import eLabel, isUTF8, convertUTF8DVB, convertDVBUTF8
+from enigma import eLabel
 
 from Tools.NumericalTextInput import NumericalTextInput
 
 class Input(VariableText, HTMLComponent, GUIComponent):
        TEXT = 0
        PIN = 1
-       NUMBER = 2      
+       NUMBER = 2
 
        def __init__(self, text="", maxSize = False, type = TEXT):
                GUIComponent.__init__(self)
                VariableText.__init__(self)
-               self.table = 0
-               self.numericalTextInput = NumericalTextInput(self.right)
                self.type = type
                self.maxSize = maxSize
                self.currPos = 0
-               self.Text = text
                self.overwrite = 0
-               self.update()
+               self.numericalTextInput = NumericalTextInput(self.right)
+               self.setText(text)
 
        def update(self):
                self.setMarkedPos(self.currPos)
                if self.type == self.PIN:
-                       self.message = "*" * len(self.Text)
+                       self.text = "*" * len(self.Text)
                else:
-                       self.message = convertDVBUTF8(self.Text, self.table)
-               if self.instance:
-                       self.instance.setText(self.message)
+                       self.text = self.Text.encode("utf-8")
 
        def setText(self, text):
                if not len(text):
                        self.currPos = 0
-                       self.Text = ""
-               elif isUTF8(text):
-                       self.Text = convertUTF8DVB(text, self.table)
+                       self.Text = u""
                else:
-                       self.Text = text
+                       try:
+                               self.Text = text.decode("utf-8")
+                       except UnicodeDecodeError:
+                               print "utf8 kaputt!"
+                               self.Text = text
                self.update()
 
        def getText(self):
-               return convertDVBUTF8(self.Text, self.table)
+               return self.Text.encode("utf-8")
 
        def createWidget(self, parent):
                return eLabel(parent, self.currPos)
@@ -115,7 +113,7 @@ class Input(VariableText, HTMLComponent, GUIComponent):
                self.update()
 
        def handleAscii(self, code):
-               newChar = chr(code)
+               newChar = unichr(code)
                if self.overwrite==1:
                        self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
                else:
index d923290df084a6e168392047dc0148f92900dcb2..1acd2548e0e66fff36c3792691b217329a1d6040 100644 (file)
@@ -8,38 +8,38 @@ class NumericalTextInput:
                self.lang = language.getLanguage()
                
                if self.lang == 'de_DE':
-                       self.mapping.append (".,?'\"0-()@/:_") # 0
-                       self.mapping.append (" 1") # 1
-                       self.mapping.append ("aäbc2AÄBC") # 2
-                       self.mapping.append ("def3DEF") # 3
-                       self.mapping.append ("ghi4GHI") # 4
-                       self.mapping.append ("jkl5JKL") # 5
-                       self.mapping.append ("mnoö6MNOÖ") # 6
-                       self.mapping.append ("pqrsß7PQRSß") # 7
-                       self.mapping.append ("tuüv8TUÜV") # 8
-                       self.mapping.append ("wxyz9WXYZ") # 9
+                       self.mapping.append (u".,?'\"0-()@/:_") # 0
+                       self.mapping.append (u" 1") # 1
+                       self.mapping.append (u"aäbc2AÄBC") # 2
+                       self.mapping.append (u"def3DEF") # 3
+                       self.mapping.append (u"ghi4GHI") # 4
+                       self.mapping.append (u"jkl5JKL") # 5
+                       self.mapping.append (u"mnoö6MNOÖ") # 6
+                       self.mapping.append (u"pqrsß7PQRSß") # 7
+                       self.mapping.append (u"tuüv8TUÜV") # 8
+                       self.mapping.append (u"wxyz9WXYZ") # 9
                elif self.lang == 'es_ES':
-                       self.mapping.append (".,?'\"0-()@/:_") # 0
-                       self.mapping.append (" 1") # 1
-                       self.mapping.append ("abcáà2ABCÁÀ") # 2
-                       self.mapping.append ("deéèf3DEFÉÈ") # 3
-                       self.mapping.append ("ghiíì4GHIÍÌ") # 4
-                       self.mapping.append ("jkl5JKL") # 5
-                       self.mapping.append ("mnñoóò6MNÑOÓÒ") # 6
-                       self.mapping.append ("pqrs7PQRS") # 7
-                       self.mapping.append ("tuvúù8TUVÚÙ") # 8
-                       self.mapping.append ("wxyz9WXYZ") # 9
+                       self.mapping.append (u".,?'\"0-()@/:_") # 0
+                       self.mapping.append (u" 1") # 1
+                       self.mapping.append (u"abcáà2ABCÁÀ") # 2
+                       self.mapping.append (u"deéèf3DEFÉÈ") # 3
+                       self.mapping.append (u"ghiíì4GHIÍÌ") # 4
+                       self.mapping.append (u"jkl5JKL") # 5
+                       self.mapping.append (u"mnñoóò6MNÑOÓÒ") # 6
+                       self.mapping.append (u"pqrs7PQRS") # 7
+                       self.mapping.append (u"tuvúù8TUVÚÙ") # 8
+                       self.mapping.append (u"wxyz9WXYZ") # 9
                else:
-                       self.mapping.append (".,?'\"0-()@/:_") # 0
-                       self.mapping.append (" 1") # 1
-                       self.mapping.append ("abc2ABC") # 2
-                       self.mapping.append ("def3DEF") # 3
-                       self.mapping.append ("ghi4GHI") # 4
-                       self.mapping.append ("jkl5JKL") # 5
-                       self.mapping.append ("mno6MNO") # 6
-                       self.mapping.append ("pqrs7PQRS") # 7
-                       self.mapping.append ("tuv8TUV") # 8
-                       self.mapping.append ("wxyz9WXYZ") # 9
+                       self.mapping.append (u".,?'\"0-()@/:_") # 0
+                       self.mapping.append (u" 1") # 1
+                       self.mapping.append (u"abc2ABC") # 2
+                       self.mapping.append (u"def3DEF") # 3
+                       self.mapping.append (u"ghi4GHI") # 4
+                       self.mapping.append (u"jkl5JKL") # 5
+                       self.mapping.append (u"mno6MNO") # 6
+                       self.mapping.append (u"pqrs7PQRS") # 7
+                       self.mapping.append (u"tuv8TUV") # 8
+                       self.mapping.append (u"wxyz9WXYZ") # 9
                
                self.nextFunction = nextFunction
                self.Timer = eTimer()
@@ -48,8 +48,7 @@ class NumericalTextInput:
                self.pos = 0
 
        def getKey(self, num):
-               self.Timer.stop()
-               self.Timer.start(1000)
+               self.Timer.start(1000, True)
                if (self.lastKey != num):
                        self.lastKey = num
                        self.pos = 0
@@ -64,11 +63,10 @@ class NumericalTextInput:
                self.lastKey = -1
 
        def nextChar(self):
-               self.Timer.stop()
                print "Timer done"
                try:
                        self.nextKey()
                        if (self.nextFunction != None):
                                self.nextFunction()
-               except:
-                       pass
+               except AttributeError:
+                       print "Text Input object deleted with running nextChar timer?"
index 47d25ae83d7b17a86e6af256979b140d599bbc59..103889b99a5386efba7a71eb5ef4c25b00fa5c6a 100644 (file)
@@ -261,17 +261,7 @@ int getPrevAsciiCode();
 void runMainloop();
 void quitMainloop(int exit_code);
 eApplication *getApplication();
-int isUTF8(const std::string &);
-std::string convertUTF8DVB(const std::string &, int);
-std::string convertDVBUTF8(std::string text, int table);
 %{
-
-std::string convertDVBUTF8(std::string text, int table)
-{
-       int len = text.length();
-       return convertDVBUTF8(len?(unsigned char*)text.c_str():(unsigned char*)"", len, table, 0);
-}
-
 RESULT SwigFromPython(ePtr<gPixmap> &result, PyObject *obj)
 {      
        ePtr<gPixmap> *res;