From 6c8e155a44186577767273b1891a4dd7afa07c63 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Fri, 3 Nov 2023 15:41:21 -0400 Subject: [PATCH] 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 --- tests/test_gtk.py | 10 +++++++++- xfstestsdb/gtk/__init__.py | 18 +++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/test_gtk.py b/tests/test_gtk.py index 82be6b0..bd9d0ee 100644 --- a/tests/test_gtk.py +++ b/tests/test_gtk.py @@ -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 diff --git a/xfstestsdb/gtk/__init__.py b/xfstestsdb/gtk/__init__.py index 4261a17..4e006ca 100644 --- a/xfstestsdb/gtk/__init__.py +++ b/xfstestsdb/gtk/__init__.py @@ -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")