finish language-menu - the RT_VALIGN_CENTER doesn't work in eListboxPythonMultiConten...
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sun, 11 Dec 2005 01:42:36 +0000 (01:42 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sun, 11 Dec 2005 01:42:36 +0000 (01:42 +0000)
add language-screen to the start-wizard, which breaks the startwizard. bug in screen-handling?

data/startwizard.xml
lib/python/Components/Language.py
lib/python/Components/LanguageList.py [new file with mode: 0644]
lib/python/Components/Makefile.am
lib/python/Screens/LanguageSelection.py
lib/python/Screens/Wizard.py

index aade9c0..fbc1d49 100644 (file)
@@ -1,7 +1,9 @@
 <wizard>
                <step number="1">
 <wizard>
                <step number="1">
+                       <config screen="LanguageSelection" module="LanguageSelection" type="standalone" />
+               </step>
+               <step number="2">
                        <text value="Hello User.\n\nThis start-wizard will guide you through the basic setup of your Dreambox.\n\nPress the OK button on your remote control to move to the next step." />
                        <text value="Hello User.\n\nThis start-wizard will guide you through the basic setup of your Dreambox.\n\nPress the OK button on your remote control to move to the next step." />
-                       <config screen="LanguageSelection" module="LanguageSelection" type="MenuList" />
                        <code>
 self["arrowdown"].moveTo(557, 232, 10)
 self["rc"].moveTo(500, 50, 10)         
                        <code>
 self["arrowdown"].moveTo(557, 232, 10)
 self["rc"].moveTo(500, 50, 10)         
@@ -9,7 +11,7 @@ self["arrowdown"].startMoving()
 self["rc"].startMoving()
                        </code>
                </step>
 self["rc"].startMoving()
                        </code>
                </step>
-               <step number="2">
+               <step number="3">
                        <text value="Use the up/down keys on your remote control to select an option. After that, press OK." />
                        <list>
                                <listentry caption="Use wizard to set up basic features" step="next" />
                        <text value="Use the up/down keys on your remote control to select an option. After that, press OK." />
                        <list>
                                <listentry caption="Use wizard to set up basic features" step="next" />
@@ -22,7 +24,7 @@ self["arrowdown"].startMoving()
 self["arrowup"].startMoving()
                        </code>
                </step>
 self["arrowup"].startMoving()
                        </code>
                </step>
-               <step number="3">
+               <step number="4">
                        <text value="Please set up tuner A" />
                        <config screen="NimSetup" module="Satconfig" args="0" type="ConfigList" />
                        <code>
                        <text value="Please set up tuner A" />
                        <config screen="NimSetup" module="Satconfig" args="0" type="ConfigList" />
                        <code>
@@ -34,7 +36,7 @@ self["arrowdown"].addMovePoint(610, 300, 10)
 self["arrowdown"].startMoving()
                        </code>
                </step>
 self["arrowdown"].startMoving()
                        </code>
                </step>
-               <step number="4">
+               <step number="5">
                        <text value="Please set up tuner B" />
                        <config screen="NimSetup" module="Satconfig" args="1" type="ConfigList" />
                        <code>
                        <text value="Please set up tuner B" />
                        <config screen="NimSetup" module="Satconfig" args="1" type="ConfigList" />
                        <code>
@@ -46,14 +48,14 @@ self["arrowdown"].addMovePoint(610, 300, 10)
 self["arrowdown"].startMoving()
                        </code>
                </step>
 self["arrowdown"].startMoving()
                        </code>
                </step>
-               <step number="5">
+               <step number="6">
                        <text value="Do you want to do a service scan?" />
                        <list>
                                <listentry caption="Yes, scan now" step="next" />
                        <text value="Do you want to do a service scan?" />
                        <list>
                                <listentry caption="Yes, scan now" step="next" />
-                               <listentry caption="No, scan later manually" step="7" />
+                               <listentry caption="No, scan later manually" step="8" />
                        </list>
                </step>
                        </list>
                </step>
-               <step number="6">
+               <step number="7">
                        <text value="What do you want to scan?" />
                        <config screen="ScanSimple" module="ScanSetup" type="ConfigList" />
                        <code>
                        <text value="What do you want to scan?" />
                        <config screen="ScanSimple" module="ScanSetup" type="ConfigList" />
                        <code>
@@ -65,7 +67,7 @@ self["arrowdown"].addMovePoint(610, 300, 10)
 self["arrowdown"].startMoving()
                        </code>
                </step>
 self["arrowdown"].startMoving()
                        </code>
                </step>
-               <step number="7">
+               <step number="8">
                        <text value="Thanx for using the wizard. Your box is now ready to use." />
                        <code>
 self["arrowdown"].moveTo(740, 200, 10)
                        <text value="Thanx for using the wizard. Your box is now ready to use." />
                        <code>
 self["arrowdown"].moveTo(740, 200, 10)
index d6cdf17..bd188e5 100644 (file)
@@ -11,7 +11,7 @@ class Language:
 
        def addLanguage(self, name, lang):
                try:
 
        def addLanguage(self, name, lang):
                try:
-                       self.lang.append((_(name), gettext.translation('enigma2', '/enigma2/po', languages=[lang])))
+                       self.lang.append((_(name), gettext.translation('enigma2', '/enigma2/po', languages=[lang]), lang))
                except:
                        print "Language " + str(name) + " not found"
 
                except:
                        print "Language " + str(name) + " not found"
 
diff --git a/lib/python/Components/LanguageList.py b/lib/python/Components/LanguageList.py
new file mode 100644 (file)
index 0000000..82b13ee
--- /dev/null
@@ -0,0 +1,40 @@
+from HTMLComponent import *
+from GUIComponent import *
+
+from MenuList import MenuList
+
+from enigma import *
+
+RT_HALIGN_LEFT = 0
+RT_HALIGN_RIGHT = 1
+RT_HALIGN_CENTER = 2
+RT_HALIGN_BLOCK = 4
+
+RT_VALIGN_TOP = 0
+RT_VALIGN_CENTER = 8
+RT_VALIGN_BOTTOM = 16
+
+def LanguageEntryComponent(file, name):
+       res = [ None ]
+       res.append((70, 0, 400, 30, 0, RT_HALIGN_LEFT, name))
+       png = loadPNG("/usr/share/enigma2/countries/" + file + ".png")
+       if png == None:
+               png = loadPNG("/usr/share/enigma2/countries/missing.png")
+       res.append((0, 5, 60, 40, png))
+       
+       return res
+
+
+class LanguageList(HTMLComponent, GUIComponent, MenuList):
+       def __init__(self, list):
+               GUIComponent.__init__(self)
+               self.l = eListboxPythonMultiContent()
+               self.list = list
+               self.l.setList(list)
+               self.l.setFont(0, gFont("Arial", 25))
+       
+       def GUIcreate(self, parent):
+               self.instance = eListbox(parent)
+               self.instance.setContent(self.l)
+               self.instance.setItemHeight(50)
+
index 0a6eb59..f83403b 100644 (file)
@@ -10,4 +10,4 @@ install_PYTHON = \
        InputDevice.py ServicePosition.py SetupDevices.py Harddisk.py                                           \
        AVSwitch.py Network.py RFmod.py DiskInfo.py NimManager.py Lcd.py                                \
        EpgList.py ScrollLabel.py Timezones.py Language.py HelpMenuList.py \
        InputDevice.py ServicePosition.py SetupDevices.py Harddisk.py                                           \
        AVSwitch.py Network.py RFmod.py DiskInfo.py NimManager.py Lcd.py                                \
        EpgList.py ScrollLabel.py Timezones.py Language.py HelpMenuList.py \
-       BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py
+       BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py
index a0441b6..42f5420 100644 (file)
@@ -3,6 +3,8 @@ from Screen import Screen
 from Components.MenuList import MenuList
 from Components.ActionMap import ActionMap
 from Components.Language import language
 from Components.MenuList import MenuList
 from Components.ActionMap import ActionMap
 from Components.Language import language
+from Components.LanguageList import *
+
 
 class LanguageSelection(Screen):
        def __init__(self, session):
 
 class LanguageSelection(Screen):
        def __init__(self, session):
@@ -10,16 +12,18 @@ class LanguageSelection(Screen):
                
                self.list = []
                list = language.getLanguageList()
                
                self.list = []
                list = language.getLanguageList()
-               for x in list:
-                       self.list.append((x, None))
+               for x in language.lang:
+                       print x
+                       self.list.append(LanguageEntryComponent(x[2], x[0]))
 
 
-               self["list"] = MenuList(self.list)
+               self["list"] = LanguageList(self.list)
                
                self["actions"] = ActionMap(["OkCancelActions"], 
                {
                        "ok": self.save,
                        "cancel": self.close
                })
                
                self["actions"] = ActionMap(["OkCancelActions"], 
                {
                        "ok": self.save,
                        "cancel": self.close
                })
+               print "INIT LANGUAGESELECTION"
                
        def save(self):
                self.run()
                
        def save(self):
                self.run()
index 38235b1..07c5f9a 100644 (file)
@@ -118,8 +118,12 @@ class WelcomeWizard(Screen, HelpableScreen):
                        #})
 
        def ok(self):
                        #})
 
        def ok(self):
+               print "OK"
                if (self.wizard[self.currStep]["config"]["screen"] != None):
                if (self.wizard[self.currStep]["config"]["screen"] != None):
-                       self.configInstance.run()
+                       try: # don't die, if no run() is available
+                               self.configInstance.run()
+                       except:
+                               print "Failed to run configInstance"
                
                if (len(self.wizard[self.currStep]["list"]) > 0):
                        nextStep = self.wizard[self.currStep]["list"][self["list"].l.getCurrentSelectionIndex()][1]
                
                if (len(self.wizard[self.currStep]["list"]) > 0):
                        nextStep = self.wizard[self.currStep]["list"][self["list"].l.getCurrentSelectionIndex()][1]
@@ -137,6 +141,8 @@ class WelcomeWizard(Screen, HelpableScreen):
                else:
                        self.currStep += 1
                        self.updateValues()
                else:
                        self.currStep += 1
                        self.updateValues()
+                       
+               print "Now: " + str(self.currStep)
 
        def keyNumberGlobal(self, number):
                if (self.wizard[self.currStep]["config"]["screen"] != None):
 
        def keyNumberGlobal(self, number):
                if (self.wizard[self.currStep]["config"]["screen"] != None):
@@ -154,23 +160,28 @@ class WelcomeWizard(Screen, HelpableScreen):
 
        def up(self):
                if (self.wizard[self.currStep]["config"]["screen"] != None):
 
        def up(self):
                if (self.wizard[self.currStep]["config"]["screen"] != None):
-                       self[self.currConfig].instance.moveSelection(self[self.currConfig].instance.moveUp)
+                       self["config"].instance.moveSelection(self["config"].instance.moveUp)
                elif (len(self.wizard[self.currStep]["list"]) > 0):
                        self["list"].instance.moveSelection(self["config"].instance.moveUp)
                print "up"
                
        def down(self):
                if (self.wizard[self.currStep]["config"]["screen"] != None):
                elif (len(self.wizard[self.currStep]["list"]) > 0):
                        self["list"].instance.moveSelection(self["config"].instance.moveUp)
                print "up"
                
        def down(self):
                if (self.wizard[self.currStep]["config"]["screen"] != None):
-                       self[self.currConfig].instance.moveSelection(self[self.currConfig].instance.moveDown)
+                       self["config"].instance.moveSelection(self["config"].instance.moveDown)
                elif (len(self.wizard[self.currStep]["list"]) > 0):
                        self["list"].instance.moveSelection(self["config"].instance.moveDown)
                print "down"
                
        def updateValues(self):
                elif (len(self.wizard[self.currStep]["list"]) > 0):
                        self["list"].instance.moveSelection(self["config"].instance.moveDown)
                print "down"
                
        def updateValues(self):
+               print "Updating values in step " + str(self.currStep)
                self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
                self["stepslider"].setValue(self.currStep)
 
                self["text"].setText(self.wizard[self.currStep]["text"])
                self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
                self["stepslider"].setValue(self.currStep)
 
                self["text"].setText(self.wizard[self.currStep]["text"])
+
+               if self.wizard[self.currStep]["code"] != "":
+                       print self.wizard[self.currStep]["code"]
+                       exec(self.wizard[self.currStep]["code"])
                
                self["list"].instance.setZPosition(1)
                self.list = []
                
                self["list"].instance.setZPosition(1)
                self.list = []
@@ -182,25 +193,22 @@ class WelcomeWizard(Screen, HelpableScreen):
 
                self["config"].instance.setZPosition(1)
                if (self.wizard[self.currStep]["config"]["screen"] != None):
 
                self["config"].instance.setZPosition(1)
                if (self.wizard[self.currStep]["config"]["screen"] != None):
-                       if self.wizard[self.currStep]["config"]["type"] == "ConfigList":
-                               self.currConfig = "config"
-                       elif self.wizard[self.currStep]["config"]["type"] == "MenuList":
-                               self.currConfig = "list"
-
-                       self[self.currConfig].instance.setZPosition(2)
-                       print self.wizard[self.currStep]["config"]["screen"]
-                       if self.wizard[self.currStep]["config"]["args"] == None:
-                               self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
+                       if self.wizard[self.currStep]["config"]["type"] == "standalone":
+                               print "Type is standalone"
+                               self.session.openWithCallback(self.ok, self.wizard[self.currStep]["config"]["screen"])
                        else:
                        else:
-                               self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
-                       self[self.currConfig].l.setList(self.configInstance[self.currConfig].list)
-                       self.configInstance[self.currConfig] = self[self.currConfig]
+                               self["config"].instance.setZPosition(2)
+                               print self.wizard[self.currStep]["config"]["screen"]
+                               if self.wizard[self.currStep]["config"]["args"] == None:
+                                       self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
+                               else:
+                                       self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
+                               self["config"].l.setList(self.configInstance["config"].list)
+                               self.configInstance["config"] = self["config"]
                else:
                        self["config"].l.setList([])
 
                else:
                        self["config"].l.setList([])
 
-               if self.wizard[self.currStep]["code"] != "":
-                       print self.wizard[self.currStep]["code"]
-                       exec(self.wizard[self.currStep]["code"])
+
 
 def listActiveWizards():
        wizards = [ ]
 
 def listActiveWizards():
        wizards = [ ]