update error list when report changes (esp. is viewed)

This commit is contained in:
Michael Hudson-Doyle 2019-11-04 15:53:29 +13:00
parent 3221b14294
commit 009d0598d0
2 changed files with 16 additions and 2 deletions

View File

@ -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):

View File

@ -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()