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

View File

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

View File

@ -333,8 +333,14 @@ This Screen
self.commit_message.set_text(change.revisions[-1].message)
categories = []
max_values = {}
min_values = {}
approval_headers = [urwid.Text(('table-header', 'Name'))]
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:
continue
approval_headers.append(urwid.Text(('table-header', label.category)))
@ -346,15 +352,27 @@ This Screen
if not approvals:
approvals = {}
row = []
row.append(urwid.Text(approval.name))
row.append(urwid.Text(('reviewer-name', approval.name)))
for i, category in enumerate(categories):
w = urwid.Text(u'')
w = urwid.Text(u'', align=urwid.CENTER)
approvals[category] = w
row.append(w)
approvals_for_name[approval.name] = approvals
votes.addRow(row)
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')
# TODO: update the existing table rather than replacing it