From 2da603941677654dc9486f0c1c2ee4370aeaf2b3 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 10 Nov 2014 23:01:52 +0100 Subject: [PATCH] Colorize votes on change list The list of changes for a given project has two columns showing the max vote for each change. Apply the min/max color on the votes, which with the default pallette yields red for negative scores and green for positive ones. The palette has supports for slightly different color when the vote is not the maximum allowed. Unfortunately the Gerrit API does not seem to expose the label scores available to a project which make it impossible to finely tune the color. Assuming the color of the max/min scores will work fine for most users. Change-Id: I9f42be4cf41466a3500dcd98f7ad1cb6187b62a9 --- gertty/view/change_list.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gertty/view/change_list.py b/gertty/view/change_list.py index a913a6a..7b72371 100644 --- a/gertty/view/change_list.py +++ b/gertty/view/change_list.py @@ -102,8 +102,11 @@ class ChangeRow(urwid.Button): v = change.getMaxForCategory(category) if v == 0: v = '' - else: - v = '%2i' % v + elif v < 0: + v = ('min-label', '%2i' % v) + elif v > 0: + v = ('max-label', '%2i' % v) + self.columns.contents.append((urwid.Text(v), self.columns.options('given', 2))) class ChangeListHeader(urwid.WidgetWrap):