playlist: Move the Runtime and Visible widgets into the Playlist pane

Rather than being in a fixed position at the bottom of the window
they'll now align themselves based on the position of the Gtk.Paned
divider.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-07-14 14:39:37 -04:00
parent 5633d50024
commit 146777119c
5 changed files with 22 additions and 10 deletions

View File

@ -49,3 +49,5 @@ Scroll.set_child(View)
Box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
Box.append(Model.Controls)
Box.append(Scroll)
Box.append(Gtk.Separator.new(Gtk.Orientation.HORIZONTAL))
Box.append(runtime.Box)

View File

@ -2,11 +2,12 @@
from gi.repository import Gtk
Runtime = Gtk.Label()
Visible = Gtk.Label()
Runtime.set_margin_end(10)
Runtime.set_halign(Gtk.Align.END)
Runtime.set_hexpand(True)
Visible = Gtk.Label()
Visible.set_halign(Gtk.Align.START)
Visible.set_hexpand(True)
def set_runtime(seconds):
res = [ ]
@ -30,3 +31,10 @@ def set_visible_count(count):
else:
Visible.set_text(f"Showing {count} tracks")
set_visible_count(0)
Box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
Box.set_margin_start(5)
Box.set_margin_end(5)
Box.append(Visible)
Box.append(Runtime)

View File

@ -11,13 +11,21 @@ class TestPlaylistRuntime(unittest.TestCase):
def test_runtime_init(self):
self.assertIsInstance(runtime.Runtime, Gtk.Label)
self.assertIsInstance(runtime.Visible, Gtk.Label)
self.assertIsInstance(runtime.Box, Gtk.Box)
self.assertEqual(runtime.Runtime.get_text(), "0 seconds")
self.assertEqual(runtime.Runtime.get_halign(), Gtk.Align.END)
self.assertEqual(runtime.Runtime.get_margin_end(), 10)
self.assertTrue(runtime.Runtime.get_hexpand())
self.assertEqual(runtime.Visible.get_text(), "Showing 0 tracks")
self.assertEqual(runtime.Visible.get_halign(), Gtk.Align.START)
self.assertTrue(runtime.Visible.get_hexpand())
self.assertEqual(runtime.Box.get_margin_start(), 5)
self.assertEqual(runtime.Box.get_margin_end(), 5)
self.assertIn(runtime.Visible, runtime.Box)
self.assertIn(runtime.Runtime, runtime.Box)
def test_runtime_set_runtime(self):
runtime.set_runtime(0)

View File

@ -1,7 +1,6 @@
# Copyright 2021 (c) Anna Schumaker.
from lib import settings
from lib import version
from playlist import runtime
from . import window
from . import header
from . import pane
@ -26,8 +25,6 @@ class TestUIWindow(unittest.TestCase):
self.assertTrue(window.Grid.get_column_homogeneous())
self.assertIn(pane.Pane, window.Grid)
self.assertIn(pulser.Bar, window.Grid)
self.assertIn(runtime.Visible, window.Grid)
self.assertIn(runtime.Runtime, window.Grid)
self.assertIn(window.Sep, window.Grid)
self.assertEqual(window.Window.get_titlebar(), header.Header)

View File

@ -1,7 +1,6 @@
# Copyright 2021 (c) Anna Schumaker.
from lib import settings
from lib import version
from playlist import runtime
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
@ -23,8 +22,6 @@ Grid.set_column_homogeneous(True)
Grid.attach(pane.Pane, 0, 0, 4, 1)
Grid.attach(Sep, 0, 1, 4, 1)
Grid.attach(pulser.Bar, 0, 2, 1, 1)
Grid.attach(runtime.Visible, 1, 2, 1, 1)
Grid.attach(runtime.Runtime, 2, 2, 2, 1)
Window.set_title(version.string())
Window.set_icon_name("emmental")