def create_colortheme(self): '''create a colortheme from current skin color settings''' try: current_skinfont = None json_response = kodi_json("Settings.GetSettingValue", {"setting": "lookandfeel.font"}) if json_response: current_skinfont = json_response current_skincolors = None json_response = kodi_json("Settings.GetSettingValue", {"setting": "lookandfeel.skincolors"}) if json_response: current_skincolors = json_response # user has to enter name for the theme themename = xbmcgui.Dialog().input(self.addon.getLocalizedString(32023), type=xbmcgui.INPUT_ALPHANUM) if not themename: return xbmc.executebuiltin("Skin.SetString(SkinHelper.LastColorTheme,%s)" % try_encode(themename)) # add screenshot custom_thumbnail = xbmcgui.Dialog().browse(2, self.addon.getLocalizedString(32024), 'files') if custom_thumbnail: xbmcvfs.copy(custom_thumbnail, self.userthemes_path + themename + ".jpg") # read the guisettings file to get all skin settings from resources.lib.backuprestore import BackupRestore skinsettingslist = BackupRestore().get_skinsettings( ["color", "opacity", "texture", "panel", "colour", "background", "image"]) newlist = [] if skinsettingslist: newlist.append(("THEMENAME", themename)) newlist.append(("DESCRIPTION", self.addon.getLocalizedString(32025))) newlist.append(("SKINTHEME", xbmc.getInfoLabel("Skin.CurrentTheme"))) newlist.append(("SKINFONT", current_skinfont)) newlist.append(("SKINCOLORS", current_skincolors)) # look for any images in the skin settings and translate them so they can # be included in the theme backup for skinsetting in skinsettingslist: setting_type = skinsetting[0] setting_name = skinsetting[1] setting_value = skinsetting[2] if setting_type == "string" and setting_value: if (setting_value and (setting_value.endswith(".png") or setting_value.endswith(".gif") or setting_value.endswith(".jpg")) and "resource://" not in setting_value): image = get_clean_image(setting_value) extension = image.split(".")[-1] newimage = "%s_%s.%s" % (themename, normalize_string(setting_name), extension) newimage_path = self.userthemes_path + newimage if xbmcvfs.exists(image): xbmcvfs.copy(image, newimage_path) skinsetting = (setting_type, setting_name, newimage_path) newlist.append(skinsetting) # save guisettings text_file_path = self.userthemes_path + themename + ".theme" text_file = xbmcvfs.File(text_file_path, "w") text_file.write(repr(newlist)) text_file.close() xbmcgui.Dialog().ok(self.addon.getLocalizedString(32026), self.addon.getLocalizedString(32027)) except Exception as exc: log_exception(__name__, exc) xbmcgui.Dialog().ok(self.addon.getLocalizedString(32028), self.addon.getLocalizedString(32030), str(exc))