From 009d0598d066b525a572a3e5fe97754307b95576 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Mon, 4 Nov 2019 15:53:29 +1300 Subject: [PATCH] update error list when report changes (esp. is viewed) --- subiquity/controllers/error.py | 3 ++- subiquity/ui/views/error.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/subiquity/controllers/error.py b/subiquity/controllers/error.py index 95ff3409..391302ed 100644 --- a/subiquity/controllers/error.py +++ b/subiquity/controllers/error.py @@ -82,7 +82,7 @@ class ErrorReport(metaclass=urwid.MetaSignals): def from_file(cls, controller, fpath): base = os.path.splitext(os.path.basename(fpath))[0] report = cls( - controller, base, pr=apport.Report(), + controller, base, pr=apport.Report(date='???'), state=ErrorReportState.LOADING, file=open(fpath, 'rb')) try: fp = open(report.meta_path, 'r') @@ -179,6 +179,7 @@ class ErrorReport(metaclass=urwid.MetaSignals): def mark_seen(self): self.set_meta("seen", True) + urwid.emit_signal(self, "changed") @property def kind(self): diff --git a/subiquity/ui/views/error.py b/subiquity/ui/views/error.py index 3aa3b89d..26e4ab0e 100644 --- a/subiquity/ui/views/error.py +++ b/subiquity/ui/views/error.py @@ -188,8 +188,11 @@ class ErrorReportListStretchy(Stretchy): Text(_("STATUS")), Text(""), ])] + self.report_to_row = {} for report in self.ec.reports: - rows.append(self.row_for_report(report)) + connect_signal(report, "changed", self._report_changed, report) + r = self.report_to_row[report] = self.row_for_report(report) + rows.append(r) self.table = TablePile(rows, colspecs={1: ColSpec(can_shrink=True)}) widgets = [ Text(_("Select an error report to view:")), @@ -223,3 +226,13 @@ class ErrorReportListStretchy(Stretchy): def row_for_report(self, report): return Color.menu_button( TableRow(self.cells_for_report(report))) + + def _report_changed(self, report): + old_r = self.report_to_row.get(report) + if old_r is None: + return + old_r = old_r.base_widget + new_cells = self.cells_for_report(report) + for (s1, old_c), new_c in zip(old_r.cells, new_cells): + old_c.set_text(new_c.text) + self.table.invalidate()