header: Add Title and Subtitle widgets
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
5fc2944aec
commit
3566db7ede
21
ui/header.py
21
ui/header.py
|
@ -2,3 +2,24 @@
|
|||
from gi.repository import Gtk
|
||||
|
||||
Header = Gtk.HeaderBar()
|
||||
Box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
Title = Gtk.Label()
|
||||
Subtitle = Gtk.Label()
|
||||
|
||||
Title.add_css_class("title")
|
||||
Subtitle.add_css_class("subtitle")
|
||||
Box.append(Title)
|
||||
Box.append(Subtitle)
|
||||
Header.set_title_widget(Box)
|
||||
|
||||
|
||||
def set_title(text):
|
||||
Title.set_markup(f"<big>{text}</big>")
|
||||
|
||||
def set_subtitle(text):
|
||||
Subtitle.set_markup(f"<big>{text}</big>")
|
||||
|
||||
def initialize():
|
||||
set_title("Emmental")
|
||||
set_subtitle("The Cheesy Music Player")
|
||||
initialize()
|
||||
|
|
|
@ -6,3 +6,22 @@ import unittest
|
|||
class TestHeader(unittest.TestCase):
|
||||
def test_header_init(self):
|
||||
self.assertIsInstance(header.Header, Gtk.HeaderBar)
|
||||
self.assertIsInstance(header.Title, Gtk.Label)
|
||||
self.assertIsInstance(header.Subtitle, Gtk.Label)
|
||||
self.assertIsInstance(header.Box, Gtk.Box)
|
||||
|
||||
def test_title(self):
|
||||
self.assertEqual(header.Title.get_text(), "Emmental")
|
||||
self.assertTrue(header.Title.has_css_class("title"))
|
||||
self.assertTrue(header.Title in header.Box)
|
||||
|
||||
header.set_title("Test Title")
|
||||
self.assertEqual(header.Title.get_text(), "Test Title")
|
||||
|
||||
def test_subtitle(self):
|
||||
self.assertEqual(header.Subtitle.get_text(), "The Cheesy Music Player")
|
||||
self.assertTrue(header.Subtitle.has_css_class("subtitle"))
|
||||
self.assertTrue(header.Subtitle in header.Box)
|
||||
|
||||
header.set_subtitle("Test Subtitle")
|
||||
self.assertEqual(header.Subtitle.get_text(), "Test Subtitle")
|
||||
|
|
|
@ -17,7 +17,6 @@ class TestUIWindow(unittest.TestCase):
|
|||
|
||||
def test_window_init(self):
|
||||
self.assertIsInstance(window.Window, Gtk.ApplicationWindow)
|
||||
|
||||
self.assertEqual(window.Window.get_titlebar(), header.Header)
|
||||
window.Window.present()
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ initialize()
|
|||
|
||||
Window.set_title(version.string())
|
||||
Window.set_icon_name("emmental")
|
||||
Window.set_titlebar(header.Header)
|
||||
Window.set_default_size(settings.get_int("window.width"),
|
||||
settings.get_int("window.height"))
|
||||
if settings.get_bool("window.maximized"):
|
||||
|
@ -32,9 +33,3 @@ Window.connect("notify::default-height", on_change_height)
|
|||
def on_maximized(window, maximized):
|
||||
settings.set("window.maximized", window.is_maximized())
|
||||
Window.connect("notify::maximized", on_maximized)
|
||||
|
||||
|
||||
#
|
||||
# Set up the window's header bar
|
||||
#
|
||||
Window.set_titlebar(header.Header)
|
||||
|
|
Loading…
Reference in New Issue