add onShown eventlist for executing stuff after the screen is drawn
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 22 Nov 2005 14:18:12 +0000 (14:18 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 22 Nov 2005 14:18:12 +0000 (14:18 +0000)
use SimpleChannelSelection to select a service in TimerEntry

lib/python/Screens/ChannelSelection.py
lib/python/Screens/Screen.py
lib/python/Screens/TimerEntry.py

index 37f594d..d392130 100644 (file)
@@ -158,7 +158,7 @@ class ChannelSelection(Screen):
 
                self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions", "ContextMenuActions"],
                        {
 
                self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions", "ContextMenuActions"],
                        {
-                               "cancel": self.close,
+                               "cancel": self.doClose,
                                "ok": self.channelSelected,
                                "mark": self.doMark,
                                "contextMenu": self.doContext,
                                "ok": self.channelSelected,
                                "mark": self.doMark,
                                "contextMenu": self.doContext,
@@ -374,11 +374,19 @@ class ChannelSelection(Screen):
                        refstr = ""
                config.tv.lastservice.value = refstr
                config.tv.lastservice.save()
                        refstr = ""
                config.tv.lastservice.value = refstr
                config.tv.lastservice.save()
+               
+       def doClose(self):
+               self.close()
 
 class SimpleChannelSelection(ChannelSelection):
        def __init__(self, session, title):
                ChannelSelection.__init__(self, session)
                self.title = title
 
 class SimpleChannelSelection(ChannelSelection):
        def __init__(self, session, title):
                ChannelSelection.__init__(self, session)
                self.title = title
+               self.onShown.append(self.onExecCallback)
+
+       def onExecCallback(self):
+               print "onExecCallback"
+               self.session.currentDialog.instance.setTitle(self.title)
                
        def channelSelected(self): # just return selected service
                ref = self.servicelist.getCurrent()
                
        def channelSelected(self): # just return selected service
                ref = self.servicelist.getCurrent()
@@ -386,4 +394,7 @@ class SimpleChannelSelection(ChannelSelection):
                
        def doContext(self): # don't show context menu
                pass
                
        def doContext(self): # don't show context menu
                pass
+       
+       def doClose(self):
+               self.close(None)
                
\ No newline at end of file
                
\ No newline at end of file
index 6e5ac21..13e31d6 100644 (file)
@@ -13,6 +13,7 @@ class Screen(dict, HTMLSkin, GUISkin):
                
                self.onClose = [ ]
                self.onExecBegin = [ ]
                
                self.onClose = [ ]
                self.onExecBegin = [ ]
+               self.onShown = [ ]
                
                # in order to support screens *without* a help,
                # we need the list in every screen. how ironic.
                
                # in order to support screens *without* a help,
                # we need the list in every screen. how ironic.
@@ -25,6 +26,9 @@ class Screen(dict, HTMLSkin, GUISkin):
 #              self.session = session
                for (name, val) in self.items():
                        val.execBegin()
 #              self.session = session
                for (name, val) in self.items():
                        val.execBegin()
+
+               for x in self.onShown:
+                       x()
        
        def execEnd(self):
                for (name, val) in self.items():
        
        def execEnd(self):
                for (name, val) in self.items():
index a03435e..8b4f6b4 100644 (file)
@@ -178,9 +178,10 @@ class TimerEntry(Screen):
                        self.session.openWithCallback(self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from"))
 
        def finishedChannelSelection(self, args):
                        self.session.openWithCallback(self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from"))
 
        def finishedChannelSelection(self, args):
-               self.timer.service_ref = ServiceReference(args)
-               config.timerentry.service.vals = (str(self.timer.service_ref.getServiceName()),)
-               self["config"].invalidate(config.timerentry.service)
+               if (args != None):
+                       self.timer.service_ref = ServiceReference(args)
+                       config.timerentry.service.vals = (str(self.timer.service_ref.getServiceName()),)
+                       self["config"].invalidate(config.timerentry.service)
 
        def keyNumberGlobal(self, number):
                print "You pressed number " + str(number)
 
        def keyNumberGlobal(self, number):
                print "You pressed number " + str(number)