Colorize votes table

Also change the color of the review header to yellow.

Change-Id: I7b424807ba84ff82b521a4eadb927e9bcf5ed8dd
This commit is contained in:
James E. Blair 2014-05-05 13:31:20 -07:00
parent 9de2c568df
commit acf7ada140
2 changed files with 28 additions and 5 deletions
gertty

@ -32,6 +32,10 @@ palette=[('focused', 'default,standout', ''),
('error', 'light red', 'dark blue'), ('error', 'light red', 'dark blue'),
('table-header', 'white,bold', ''), ('table-header', 'white,bold', ''),
('filename', 'light cyan', ''), ('filename', 'light cyan', ''),
('positive-label', 'dark green', ''),
('negative-label', 'dark red', ''),
('max-label', 'light green', ''),
('min-label', 'light red', ''),
# Diff # Diff
('context-button', 'dark magenta', ''), ('context-button', 'dark magenta', ''),
('focused-context-button', 'light magenta', ''), ('focused-context-button', 'light magenta', ''),
@ -59,12 +63,13 @@ palette=[('focused', 'default,standout', ''),
('focused-revision-commit', 'dark blue,standout', ''), ('focused-revision-commit', 'dark blue,standout', ''),
('focused-revision-comments', 'default,standout', ''), ('focused-revision-comments', 'default,standout', ''),
('focused-revision-drafts', 'dark red,standout', ''), ('focused-revision-drafts', 'dark red,standout', ''),
('change-message-name', 'light blue', ''), ('change-message-name', 'yellow', ''),
('change-message-header', 'dark blue', ''), ('change-message-header', 'brown', ''),
('revision-button', 'dark magenta', ''), ('revision-button', 'dark magenta', ''),
('focused-revision-button', 'light magenta', ''), ('focused-revision-button', 'light magenta', ''),
('lines-added', 'light green', ''), ('lines-added', 'light green', ''),
('lines-removed', 'light red', ''), ('lines-removed', 'light red', ''),
('reviewer-name', 'yellow', ''),
# project list # project list
('unreviewed-project', 'white', ''), ('unreviewed-project', 'white', ''),
('subscribed-project', 'default', ''), ('subscribed-project', 'default', ''),

@ -333,8 +333,14 @@ This Screen
self.commit_message.set_text(change.revisions[-1].message) self.commit_message.set_text(change.revisions[-1].message)
categories = [] categories = []
max_values = {}
min_values = {}
approval_headers = [urwid.Text(('table-header', 'Name'))] approval_headers = [urwid.Text(('table-header', 'Name'))]
for label in change.labels: for label in change.labels:
if label.value > max_values.get(label.category, 0):
max_values[label.category] = label.value
if label.value < min_values.get(label.category, 0):
min_values[label.category] = label.value
if label.category in categories: if label.category in categories:
continue continue
approval_headers.append(urwid.Text(('table-header', label.category))) approval_headers.append(urwid.Text(('table-header', label.category)))
@ -346,15 +352,27 @@ This Screen
if not approvals: if not approvals:
approvals = {} approvals = {}
row = [] row = []
row.append(urwid.Text(approval.name)) row.append(urwid.Text(('reviewer-name', approval.name)))
for i, category in enumerate(categories): for i, category in enumerate(categories):
w = urwid.Text(u'') w = urwid.Text(u'', align=urwid.CENTER)
approvals[category] = w approvals[category] = w
row.append(w) row.append(w)
approvals_for_name[approval.name] = approvals approvals_for_name[approval.name] = approvals
votes.addRow(row) votes.addRow(row)
if str(approval.value) != '0': if str(approval.value) != '0':
approvals[approval.category].set_text(str(approval.value)) if approval.value > 0:
val = '+%i' % approval.value
if approval.value == max_values.get(approval.category):
val = ('max-label', val)
else:
val = ('positive-label', val)
else:
val = '%i' % approval.value
if approval.value == min_values.get(approval.category):
val = ('min-label', val)
else:
val = ('negative-label', val)
approvals[approval.category].set_text(val)
votes = urwid.Padding(votes, width='pack') votes = urwid.Padding(votes, width='pack')
# TODO: update the existing table rather than replacing it # TODO: update the existing table rather than replacing it