header: Add a header bar to the window

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-06-08 10:00:14 -04:00
parent 5f23e34972
commit 5fc2944aec
4 changed files with 22 additions and 0 deletions

4
ui/header.py Normal file
View File

@ -0,0 +1,4 @@
# Copyright 2021 (c) Anna Schumaker.
from gi.repository import Gtk
Header = Gtk.HeaderBar()

8
ui/test_header.py Normal file
View File

@ -0,0 +1,8 @@
# Copyright 2021 (c) Anna Schumaker.
from . import header
from gi.repository import Gtk
import unittest
class TestHeader(unittest.TestCase):
def test_header_init(self):
self.assertIsInstance(header.Header, Gtk.HeaderBar)

View File

@ -2,6 +2,7 @@
from lib import settings
from lib import version
from . import window
from . import header
from gi.repository import Gtk
import unittest
@ -16,6 +17,8 @@ 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()
self.assertEqual(window.Window.get_title(), version.string())

View File

@ -4,6 +4,7 @@ from lib import version
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
from . import header
Window = Gtk.ApplicationWindow()
@ -31,3 +32,9 @@ 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)