rind: Refactor iter_playlist() and playlist_iter()
I want these two functions to be the foundation of the NodeTreeModel, so they have to be defined without using the GtkTreeModel interface. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
cf8b88b833
commit
02f271bba0
23
rind/node.py
23
rind/node.py
|
@ -28,19 +28,16 @@ class NodeTreeModel(GObject.GObject, Gtk.TreeModel):
|
|||
return str
|
||||
|
||||
def do_get_iter(self, path):
|
||||
iter = Gtk.TreeIter()
|
||||
iter.user_data = path[0] + 1
|
||||
iter.user_data2 = path[1] + 1 if len(path) >= 2 else 0
|
||||
plist = curds.playlist.Root.get_node(path.get_indices())
|
||||
iter = self.playlist_iter(plist)
|
||||
return self.iter_valid(iter)
|
||||
|
||||
def do_get_n_columns(self):
|
||||
return 3
|
||||
|
||||
def do_get_path(self, iter):
|
||||
path = Gtk.TreePath(iter.user_data - 1)
|
||||
if iter.user_data2 > 0:
|
||||
path.append_index(iter.user_data2 - 1)
|
||||
return path
|
||||
plist = self.iter_playlist(iter)
|
||||
return Gtk.TreePath(plist.get_path())
|
||||
|
||||
def do_get_node_value(self, plist, column):
|
||||
if column == 1:
|
||||
|
@ -106,8 +103,10 @@ class NodeTreeModel(GObject.GObject, Gtk.TreeModel):
|
|||
|
||||
def iter_playlist(self, iter):
|
||||
if iter and iter.user_data > 0:
|
||||
path = self.get_path(iter)
|
||||
return curds.playlist.Root.get_node(path.get_indices())
|
||||
path = Gtk.TreePath(iter.user_data - 1)
|
||||
if iter.user_data2 > 0:
|
||||
path.append_index(iter.user_data2 - 1)
|
||||
return curds.playlist.Root.get_node(path)
|
||||
return curds.playlist.Root
|
||||
|
||||
def iter_valid(self, iter):
|
||||
|
@ -146,7 +145,11 @@ class NodeTreeModel(GObject.GObject, Gtk.TreeModel):
|
|||
def playlist_iter(self, plist):
|
||||
if plist == None or plist.parent == None:
|
||||
return None
|
||||
return self.get_iter(plist.get_path())
|
||||
path = plist.get_path()
|
||||
iter = Gtk.TreeIter()
|
||||
iter.user_data = path[0] + 1
|
||||
iter.user_data2 = path[1] + 1 if len(path) >= 2 else 0
|
||||
return iter
|
||||
|
||||
def set_filter_text(self, entry):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue