sidebar: Push selected rows onto the trackdb TagStack
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
d6b7a4bb8b
commit
aa15f9bf69
|
@ -2,6 +2,7 @@
|
|||
from . import tagrow
|
||||
from gi.repository import Gtk
|
||||
import lib
|
||||
import trackdb
|
||||
|
||||
class TagBox(Gtk.ScrolledWindow):
|
||||
def __init__(self, tagstore, icon, header=False):
|
||||
|
@ -17,9 +18,11 @@ class TagBox(Gtk.ScrolledWindow):
|
|||
for tag in self.tagstore.tags():
|
||||
self.on_tag_added(tag)
|
||||
|
||||
self.listbox.set_activate_on_single_click(False)
|
||||
self.listbox.set_sort_func(self.sort_func)
|
||||
if header == True:
|
||||
self.listbox.set_header_func(self.header_func)
|
||||
self.listbox.connect("row-activated", self.row_activated)
|
||||
|
||||
tagstore.Added.register(self.tag_added)
|
||||
tagstore.Removed.register(self.tag_removed)
|
||||
|
@ -42,6 +45,9 @@ class TagBox(Gtk.ScrolledWindow):
|
|||
else:
|
||||
cur.set_header(None)
|
||||
|
||||
def row_activated(self, listbox, row):
|
||||
trackdb.Stack.push(row.tag)
|
||||
|
||||
def sort_func(self, lhs, rhs):
|
||||
if lhs.tag < rhs.tag:
|
||||
return -1
|
||||
|
|
|
@ -21,7 +21,9 @@ class TestTagBox(unittest.TestCase):
|
|||
viewport = tbox.get_child()
|
||||
self.assertIsInstance(viewport, Gtk.Viewport)
|
||||
self.assertEqual(viewport.get_child(), tbox.listbox)
|
||||
|
||||
self.assertTrue(tbox.get_vexpand())
|
||||
self.assertFalse(tbox.listbox.get_activate_on_single_click())
|
||||
|
||||
self.assertIn(tbox.tag_added, store.Added.subscribers)
|
||||
self.assertIn(tbox.tag_removed, store.Removed.subscribers)
|
||||
|
|
Loading…
Reference in New Issue