curds: Have the PlaylistNode use the ETree.__insert__() function

And remove some duplicated code

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2019-12-12 10:30:19 -05:00
parent f200d4171a
commit 0e018473f7
1 changed files with 4 additions and 14 deletions

View File

@ -28,25 +28,15 @@ class PlaylistNode(tree.ETree):
nodes[id(self)] = self
self.__init_common__()
def __link_children__(self, a, b, c):
if a != None:
a.sibling = b
b.parent = self
b.sibling = c
def __insert_node__(self, child, index):
self.children.insert(index, child)
self.__link_children__(self.nth_child(index - 1), child,
self.nth_child(index + 1))
notify.notify("node-inserted", child, index)
return child
def __str__(self):
return f"<big>{self.name}</big>"
def append_child(self, child):
with self.lock:
return self.__insert_node__(child, len(self.children))
index = len(self.children)
self.__insert__(index, child)
notify.notify("node-inserted", child, index)
return child
def get_root(self):
if self.parent == None: