playlist: Have the last column expand to fill any remaining space
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
fc9b734e38
commit
6e1da0f7b4
|
@ -9,7 +9,7 @@ View.set_hexpand(True)
|
|||
View.set_model(Selection)
|
||||
|
||||
View.append_column(column.Column("#"))
|
||||
View.append_column(column.Column("Title", width=250))
|
||||
View.append_column(column.Column("Title", width=250, expand=True))
|
||||
View.append_column(column.Column("Length"))
|
||||
View.append_column(column.Column("Artist", width=150))
|
||||
View.append_column(column.Column("Album", width=150))
|
||||
|
|
|
@ -3,12 +3,13 @@ from lib import settings
|
|||
from gi.repository import Gtk
|
||||
|
||||
class Column(Gtk.ColumnViewColumn):
|
||||
def __init__(self, title, width=-1):
|
||||
def __init__(self, title, width=-1, expand=False):
|
||||
Gtk.ColumnViewColumn.__init__(self)
|
||||
|
||||
settings.initialize(f"column.{title}", width)
|
||||
|
||||
self.set_fixed_width(settings.get_int(f"column.{title}"))
|
||||
self.set_expand(expand)
|
||||
self.set_resizable(True)
|
||||
self.set_title(title)
|
||||
self.connect("notify::fixed-width", self.on_width_changed)
|
||||
|
|
|
@ -14,6 +14,10 @@ class TestPlaylistColumn(unittest.TestCase):
|
|||
|
||||
self.assertEqual(col.get_title(), "Test")
|
||||
self.assertTrue(col.get_resizable())
|
||||
self.assertFalse(col.get_expand())
|
||||
|
||||
col = column.Column("Test2", expand=True)
|
||||
self.assertTrue(col.get_expand())
|
||||
|
||||
def test_playlist_column_width(self):
|
||||
col = column.Column("Test", width=100)
|
||||
|
|
|
@ -3,9 +3,20 @@ from gi.repository import Gtk
|
|||
import playlist
|
||||
import unittest
|
||||
|
||||
columns = [ ("#", -1), ("Title", 250), ("Length", -1),
|
||||
("Artist", 150), ("Album", 150),
|
||||
("Year", -1), ("Count", -1), ("Last Played", 150) ]
|
||||
class ColumnEV:
|
||||
def __init__(self, title, width, expand):
|
||||
self.title = title
|
||||
self.width = width
|
||||
self.expand = expand
|
||||
|
||||
columns = [ ColumnEV("#", -1, False),
|
||||
ColumnEV("Title", 250, True),
|
||||
ColumnEV("Length", -1, False),
|
||||
ColumnEV("Artist", 150, False),
|
||||
ColumnEV("Album", 150, False),
|
||||
ColumnEV("Year", -1, False),
|
||||
ColumnEV("Count", -1, False),
|
||||
ColumnEV("Last Played", 150, False) ]
|
||||
|
||||
class TestPlaylist(unittest.TestCase):
|
||||
def test_playlist_init(self):
|
||||
|
@ -19,5 +30,6 @@ class TestPlaylist(unittest.TestCase):
|
|||
self.assertTrue(playlist.View.get_hexpand())
|
||||
|
||||
for (i, c) in enumerate(playlist.View.get_columns()):
|
||||
self.assertEqual(c.get_title(), columns[i][0])
|
||||
self.assertEqual(c.get_fixed_width(), columns[i][1])
|
||||
self.assertEqual(c.get_title(), columns[i].title)
|
||||
self.assertEqual(c.get_fixed_width(), columns[i].width)
|
||||
self.assertEqual(c.get_expand(), columns[i].expand)
|
||||
|
|
Loading…
Reference in New Issue