playlist: Create a custom columns class for the playlist ColumnView
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
fa088ae8ea
commit
849503eaf2
|
@ -1,4 +1,5 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from . import column
|
||||
from gi.repository import Gtk
|
||||
|
||||
Selection = Gtk.SingleSelection()
|
||||
|
@ -7,5 +8,14 @@ View = Gtk.ColumnView()
|
|||
View.set_hexpand(True)
|
||||
View.set_model(Selection)
|
||||
|
||||
View.append_column(column.Column("#"))
|
||||
View.append_column(column.Column("Title"))
|
||||
View.append_column(column.Column("Length"))
|
||||
View.append_column(column.Column("Artist"))
|
||||
View.append_column(column.Column("Album"))
|
||||
View.append_column(column.Column("Year"))
|
||||
View.append_column(column.Column("Count"))
|
||||
View.append_column(column.Column("Last Played"))
|
||||
|
||||
Scroll = Gtk.ScrolledWindow()
|
||||
Scroll.set_child(View)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from gi.repository import Gtk
|
||||
|
||||
class Column(Gtk.ColumnViewColumn):
|
||||
def __init__(self, title):
|
||||
Gtk.ColumnViewColumn.__init__(self)
|
||||
|
||||
self.set_resizable(True)
|
||||
self.set_title(title)
|
|
@ -0,0 +1,12 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from . import column
|
||||
from gi.repository import Gtk
|
||||
import unittest
|
||||
|
||||
class TestPlaylistColumn(unittest.TestCase):
|
||||
def test_playlist_column_init(self):
|
||||
col = column.Column("Test")
|
||||
self.assertIsInstance(col, Gtk.ColumnViewColumn)
|
||||
|
||||
self.assertEqual(col.get_title(), "Test")
|
||||
self.assertTrue(col.get_resizable())
|
|
@ -3,6 +3,10 @@ from gi.repository import Gtk
|
|||
import playlist
|
||||
import unittest
|
||||
|
||||
|
||||
columns = [ "#", "Title", "Length", "Artist", "Album",
|
||||
"Year", "Count", "Last Played" ]
|
||||
|
||||
class TestPlaylist(unittest.TestCase):
|
||||
def test_playlist_init(self):
|
||||
self.assertIsInstance(playlist.Selection, Gtk.SingleSelection)
|
||||
|
@ -13,3 +17,6 @@ class TestPlaylist(unittest.TestCase):
|
|||
self.assertEqual(playlist.Scroll.get_child(), playlist.View)
|
||||
|
||||
self.assertTrue(playlist.View.get_hexpand())
|
||||
|
||||
for (i, c) in enumerate(playlist.View.get_columns()):
|
||||
self.assertEqual(c.get_title(), columns[i])
|
||||
|
|
Loading…
Reference in New Issue