From d7ff3f72a6ab62a87c20d5d882fdba5601fcee27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Silkeb=C3=A6kken?= Date: Mon, 10 Dec 2012 14:45:04 +0100 Subject: [PATCH] Allow theme configuration to override dividers --- powerline/core.py | 2 +- powerline/theme.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/powerline/core.py b/powerline/core.py index 45283c94..82d6284c 100644 --- a/powerline/core.py +++ b/powerline/core.py @@ -33,7 +33,7 @@ class Powerline(object): # Load and initialize extension theme theme_config = self._load_json_config(os.path.join('themes', ext, self.config_ext['theme'])) - self.theme = Theme(ext, theme_config) + self.theme = Theme(ext, theme_config, self.config) # Load and initialize extension renderer renderer_module_name = 'powerline.ext.{0}.renderer'.format(ext) diff --git a/powerline/theme.py b/powerline/theme.py index 05dfb4f9..a68f80c3 100644 --- a/powerline/theme.py +++ b/powerline/theme.py @@ -4,11 +4,12 @@ import importlib class Theme(object): - def __init__(self, ext, theme): + def __init__(self, ext, theme_config, common_config): + self.dividers = theme_config.get('dividers', common_config['dividers']) self.segments = [] for side in ['left', 'right']: - for segment in theme['segments'].get(side, []): + for segment in theme_config['segments'].get(side, []): contents = None segment_type = segment.get('type', 'function') @@ -40,5 +41,8 @@ class Theme(object): 'include_modes': segment.get('include_modes', []), }) + def get_divider(self, side='left', type='soft'): + return self.dividers[side][type] + def get_segments(self): return self.segments