gtk: Add the Sidebar to the Window

And connect things so changing the runid in the sidebar changes the
displayed xfstests run.

Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
This commit is contained in:
Anna Schumaker 2023-11-03 15:41:21 -04:00
parent 521c96b432
commit 6c8e155a44
2 changed files with 22 additions and 6 deletions

View File

@ -88,20 +88,28 @@ class TestApplication(unittest.TestCase):
mock_add_style: unittest.mock.Mock):
"""Check that startup sets up our application instance correctly."""
self.assertIsNone(self.application.win)
self.assertIsNone(self.application.sidebar)
self.assertIsNone(self.application.view)
self.application.emit("startup")
self.assertIsInstance(self.application.sidebar,
xfstestsdb.gtk.sidebar.Sidebar)
self.assertIsInstance(self.application.view,
xfstestsdb.gtk.view.XfstestsView)
self.assertIsInstance(self.application.win,
xfstestsdb.gtk.window.Window)
self.assertEqual(self.application.win.child, self.application.view)
self.assertEqual(self.application.win.sidebar,
self.application.sidebar)
self.assertEqual(self.application.sidebar.sql,
self.application.sql)
mock_startup.assert_called_with(self.application)
mock_add_window.assert_called_with(self.application.win)
mock_add_style.assert_called()
self.application.runid = 42
self.application.sidebar.runid = 42
self.assertEqual(self.application.runid, 42)
self.assertEqual(self.application.win.runid, 42)
self.application.show_sidebar = True

View File

@ -8,6 +8,7 @@ from gi.repository import GObject
from gi.repository import Gio
from gi.repository import Adw
from . import model
from . import sidebar
from . import view
from . import window
from .. import commands
@ -24,6 +25,7 @@ class Application(Adw.Application):
summary = GObject.Property(type=model.SummaryList)
model = GObject.Property(type=model.TestCaseList)
win = GObject.Property(type=window.Window)
sidebar = GObject.Property(type=sidebar.Sidebar)
view = GObject.Property(type=view.XfstestsView)
sql = GObject.Property(type=GObject.TYPE_PYOBJECT)
@ -33,6 +35,14 @@ class Application(Adw.Application):
resource_base_path=gsetup.RESOURCE_PATH,
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
sql=sql)
self.connect("notify::runid", self.__notify_runid)
def __notify_runid(self, app: Adw.Application,
param: GObject.ParamSpec) -> None:
self.properties = model.PropertyList(self.sql, self.runid)
self.environment = self.properties.environment
self.model = model.TestCaseList(self.sql, self.runid)
self.summary = model.SummaryList(self.sql, self.runid)
def do_command_line(self, cmd_line: Gio.ApplicationCommandLine) -> int:
"""Handle the Adw.Application::command-line signal."""
@ -43,10 +53,6 @@ class Application(Adw.Application):
match split[0]:
case "runid":
self.runid = int(split[1])
self.properties = model.PropertyList(self.sql, self.runid)
self.environment = self.properties.environment
self.model = model.TestCaseList(self.sql, self.runid)
self.summary = model.SummaryList(self.sql, self.runid)
case "show-sidebar":
self.show_sidebar = True
@ -58,10 +64,12 @@ class Application(Adw.Application):
Adw.Application.do_startup(self)
gsetup.add_style()
self.sidebar = sidebar.Sidebar(self.sql)
self.view = view.XfstestsView()
self.win = window.Window(child=self.view)
self.win = window.Window(child=self.view, sidebar=self.sidebar)
self.win.headerbar.pack_end(self.view.filterbuttons)
self.sidebar.bind_property("runid", self, "runid")
self.bind_property("runid", self.win, "runid")
self.bind_property("show-sidebar", self.win, "show-sidebar")
self.bind_property("environment", self.view, "environment")