support only one upstream element (source)
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 24 Jul 2006 23:56:06 +0000 (23:56 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 24 Jul 2006 23:56:06 +0000 (23:56 +0000)
lib/python/Components/Element.py
lib/python/Components/Renderer/Listbox.py

index 5b8bed866cf1368c88fbb8574b7e46121fc87726..884c87d393d920f0b1bec8a2e012be0b80d25e0e 100644 (file)
@@ -7,7 +7,6 @@ from Tools.CList import CList
 class Element:
        def __init__(self):
                self.downstream_elements = CList()
 class Element:
        def __init__(self):
                self.downstream_elements = CList()
-               self.upstream_elements = CList()
                self.master = None
                self.source = None
 
                self.master = None
                self.source = None
 
@@ -17,8 +16,8 @@ class Element:
                        self.master = downstream
        
        def connectUpstream(self, upstream):
                        self.master = downstream
        
        def connectUpstream(self, upstream):
-               self.upstream_elements.append(upstream)
-               self.source = upstream # for single-source elements (i.e., most of them.)
+               assert self.source is None
+               self.source = upstream
                self.changed()
        
        def connect(self, upstream):
                self.changed()
        
        def connect(self, upstream):
@@ -30,10 +29,7 @@ class Element:
                # we should not disconnect from upstream if
                # there are still elements depending on us.
                assert len(self.downstream_elements) == 0, "there are still downstream elements left"
                # we should not disconnect from upstream if
                # there are still elements depending on us.
                assert len(self.downstream_elements) == 0, "there are still downstream elements left"
-               
-               # disconnect all upstream elements from us
-               for upstream in self.upstream_elements:
-                       upstream.disconnectDownstream(self)
+               self.source.disconnectDownstream(self)
        
        def disconnectDownstream(self, downstream):
                self.downstream_elements.remove(downstream)
        
        def disconnectDownstream(self, downstream):
                self.downstream_elements.remove(downstream)
@@ -46,3 +42,7 @@ class Element:
        # default action: push downstream
        def changed(self, *args, **kwargs):
                self.downstream_elements.changed(*args, **kwargs)
        # default action: push downstream
        def changed(self, *args, **kwargs):
                self.downstream_elements.changed(*args, **kwargs)
+
+       def reconnectUpstream(self, new_upstream):
+               assert self.source is not None
+               self.source = new_upstream
index fb787bfacae78cc0708aabbbbb8132bfdf10340c..ab696c23e99205a967993593cff6cc3621b3b502 100644 (file)
@@ -50,7 +50,7 @@ class Listbox(Renderer, object):
        wrap_around = property(lambda self: self.__wrap_around, setWrapAround)
 
        def selectionChanged(self):
        wrap_around = property(lambda self: self.__wrap_around, setWrapAround)
 
        def selectionChanged(self):
-               self.upstream_elements.selectionChanged(self.index)
+               self.source.selectionChanged(self.index)
 
        def getIndex(self):
                if self.instance is None:
 
        def getIndex(self):
                if self.instance is None: