From a67b1d4eb01b80fb2c25ec54ea7c6c1f0763ac23 Mon Sep 17 00:00:00 2001 From: Jonas Wielicki Date: Sun, 12 Nov 2017 17:33:58 +0100 Subject: Move definition of CCG_PALETTE to Theme object --- poezio/theming.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'poezio') diff --git a/poezio/theming.py b/poezio/theming.py index 4c93d396..af1c7839 100755 --- a/poezio/theming.py +++ b/poezio/theming.py @@ -277,6 +277,10 @@ class Theme(object): (212, -1), (213, -1), (214, -1), (215, -1), (216, -1), (217, -1), (218, -1), (219, -1), (220, -1), (221, -1), (222, -1), (223, -1), (224, -1), (225, -1), (226, -1), (227, -1)] + # XEP-0392 consistent color generation palette placeholder + # it’s generated on first use when accessing the ccg_palette property + CCG_PALETTE = None + CCG_Y = 0.5**0.45 # yapf: enable @@ -517,18 +521,14 @@ def prepare_ccolor_palette(theme): """ Prepare the Consistent Color Generation (XEP-0392) palette for a theme. """ - if hasattr(theme, "CCG_PALETTE"): - # theme overrides the palette + if theme.CCG_PALETTE is not None: return if any(bg != -1 for fg, bg in theme.LIST_COLOR_NICKNAMES): # explicitly disable CCG, can’t handle dynamic background colors - theme.CCG_PALETTE = None + theme.CCG_PALETTE = {} return - if not hasattr(theme, "CCG_Y"): - theme.CCG_Y = 0.5**0.45 - theme.CCG_PALETTE = colors.generate_ccg_palette( [ fg for fg, _ in theme.LIST_COLOR_NICKNAMES -- cgit v1.2.3