curds: Remove the PlaylistManager parent() function
I'm transitioning this class to be a PlaylistNode, and nodes can easily access their parent through a .parent pointer Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
af54734726
commit
8aff4d7f8a
|
@ -15,6 +15,11 @@ class PlaylistManager(list):
|
|||
self.append(previous.PreviousPlaylist())
|
||||
self.append(genre.GenreNode())
|
||||
self.append(library.LibraryNode())
|
||||
|
||||
for plist in self:
|
||||
plist.parent = self
|
||||
self.children = self
|
||||
|
||||
self.current = [ self.lookup("Collection") ]
|
||||
self.track = None
|
||||
|
||||
|
@ -28,6 +33,9 @@ class PlaylistManager(list):
|
|||
old.changed()
|
||||
self.current[0].changed()
|
||||
|
||||
def get_path(self):
|
||||
return [ ]
|
||||
|
||||
def index(self, plist):
|
||||
for (i, pl) in enumerate(self):
|
||||
if id(pl) == id(plist): return i
|
||||
|
@ -76,12 +84,6 @@ class PlaylistManager(list):
|
|||
random.setstate(state)
|
||||
return res
|
||||
|
||||
def parent(self, child):
|
||||
parent = self
|
||||
if child and child.parent:
|
||||
return child.parent
|
||||
return parent if child in parent else None
|
||||
|
||||
def previous(self):
|
||||
self.track = self.lookup("Previous").next()
|
||||
return self.track
|
||||
|
|
|
@ -155,19 +155,10 @@ class ManagerModel(GObject.GObject, Gtk.TreeModel):
|
|||
playlist.PlistModel.set_playlist(plist)
|
||||
|
||||
def playlist_iter(self, plist):
|
||||
parent = curds.PlaylistManager.parent(plist)
|
||||
if parent == None:
|
||||
if plist == None or plist.parent == None:
|
||||
return None
|
||||
elif parent == curds.PlaylistManager:
|
||||
iter = Gtk.TreeIter()
|
||||
iter.user_data = parent.index(plist) + 1
|
||||
else:
|
||||
iter = self.playlist_iter(parent)
|
||||
try:
|
||||
iter.user_data2 = plist.node_index() + 1
|
||||
except:
|
||||
iter.user_data2 = parent.index(plist) + 1
|
||||
return iter
|
||||
path = plist.get_path()
|
||||
return self.do_get_iter(path)[1]
|
||||
|
||||
def set_filter_text(self, entry):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue