Allow theme configuration to override dividers

This commit is contained in:
Kim Silkebækken 2012-12-10 14:45:04 +01:00
parent 87d5db9af7
commit d7ff3f72a6
2 changed files with 7 additions and 3 deletions

View File

@ -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)

View File

@ -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