def _register_palettes(self, palettes): """ Register custom plugin palettes in current skin """ if palettes is None: return current_skin = self.xyz.skin.name for pname, p in palettes.iteritems(): # Try current skin config = p.get(current_skin, None) # No entry for current skin, try default (None) if config is None: config = p.get(None, None) # No default entry - warn and continue if config is None: xyzlog.error(_(u"Unable to register palette %s: "\ u"neither entry for current skin (%s) " u"nor default one found") % (pname, current_skin)) continue palette = Palette(None, *Palette.convert(config)) self.xyz.skin.add_custom_palette(u"ui."+self.ns.pfull, pname, palette) # Register new palette self.xyz.screen.register_palette( [palette.get_palette(self.xyz.driver)])
def palette(cls, config): """ Create internal palette object @param config: Dictionary of form: { 'foreground': COLOR, 'background': COLOR, 'fg_attributes': [ATTR], 'mono': [ATTR], 'foreground_high': HG_COLOR, 'background_high': HG_COLOR } """ try: return Palette(None, *Palette.convert(config)) except Exception, e: error(_(u"Error creating Palette instance: %s") % unicode(e))