def _add_path(group_def, labels, over=False): if not over: if group_def['type'] == 'shortcut': heading = utils.get_string(32043) elif group_def['type'] == 'widget': heading = utils.get_string(32044) labels['label'] = dialog.input(heading=heading, defaultt=labels['label']) labels['id'] = utils.get_unique_id(labels['label']) labels['version'] = utils._addon_version manage.write_path(group_def, path_def=labels)
def _remove_path(path_id, group_id, over=False): if not over: choice = dialog.yesno('AutoWidget', utils.get_string(32035)) if over or choice: group_def = manage.get_group_by_id(group_id) paths = group_def['paths'] for path_def in paths: if path_def['id'] == path_id: path_name = path_def['label'] group_def['paths'].remove(path_def) dialog.notification('AutoWidget', utils.get_string(32045).format(path_name)) manage.write_path(group_def)
def edit_dialog(group_id, path_id=None, base_key=None): updated = False if advanced and not warning_shown: _warn() group_def = manage.get_group_by_id(group_id) path_def = manage.get_path_by_id(path_id, group_id) if not group_def or path_id and not path_def: return updated = _show_options(group_def, path_def) if updated: manage.write_path(group_def, path_def=path_def, update=path_id) utils.update_container(group_def['type'] == 'shortcut') edit_dialog(group_id, path_id)
def _remove_path(path_id, group_id, over=False): if not over: choice = dialog.yesno("AutoWidget", utils.get_string(32035)) if over or choice: group_def = manage.get_group_by_id(group_id) paths = group_def["paths"] for path_def in paths: if path_def["id"] == path_id: path_name = path_def["label"] group_def["paths"].remove(path_def) dialog.notification( "AutoWidget", utils.get_string(32045).format(six.text_type(path_name)), ) manage.write_path(group_def)
def edit_dialog(group_id, path_id=''): dialog = xbmcgui.Dialog() updated = False if advanced and not warning_shown: _warn() group_def = manage.get_group_by_id(group_id) if not group_def: return if path_id: path_def = manage.get_path_by_id(path_id, group_id) if not path_def: return edit_def = path_def if path_id else group_def options = _get_options(edit_def) remove_label = utils.get_string(32025) if path_id else utils.get_string( 32023) options.append('[COLOR firebrick]{}[/COLOR]'.format(remove_label)) idx = dialog.select(utils.get_string(32048), options) if idx < 0: return elif idx == len(options) - 1: if path_id: _remove_path(path_id, group_id) utils.update_container(group_def['type']) else: _remove_group(group_id) utils.update_container(group_def['type']) return else: key = _clean_key(options[idx]) updated = _get_value(edit_def, key) utils.log(updated, xbmc.LOGNOTICE) if updated: if path_id: manage.write_path(group_def, path_def=path_def, update=path_id) else: manage.write_path(group_def) utils.update_container(group_def['type']) edit_dialog(group_id, path_id)
def _add_path(group_def, labels, over=False): if not over: if group_def["type"] == "shortcut": heading = utils.get_string(32043) elif group_def["type"] == "widget": heading = utils.get_string(32044) labels["label"] = dialog.input(heading=heading, defaultt=labels["label"]) labels["id"] = utils.get_unique_id(labels["label"]) labels["version"] = utils._addon_version if labels["target"] == "settings": labels["file"]["filetype"] = "file" labels["file"]["file"] = labels["file"]["file"].split("&")[0] manage.write_path(group_def, path_def=labels)
def copy_group(group_id, type): old_group_def = manage.get_group_by_id(group_id) new_group_id = add_group(type, old_group_def.get("label")) if not new_group_id: return new_group_def = manage.get_group_by_id(new_group_id) new_group_def["art"] = old_group_def.get("art", {}) new_group_def["content"] = old_group_def.get( "content", new_group_def.get("content", "files")) paths = old_group_def.get("paths", []) new_group_def["paths"] = manage.choose_paths(utils.get_string(30121), paths, indices=False) manage.write_path(new_group_def) utils.update_container()
def shift_path(group_id, path_id, target): group_def = manage.get_group_by_id(group_id) paths = group_def['paths'] for idx, path_def in enumerate(paths): if path_def['id'] == path_id: if target == 'up' and idx > 0: temp = paths[idx - 1] paths[idx - 1] = path_def paths[idx] = temp elif target == 'down' and idx < len(paths) - 1: temp = paths[idx + 1] paths[idx + 1] = path_def paths[idx] = temp break group_def['paths'] = paths manage.write_path(group_def) utils.update_container(group_def['type'])
def _add_path(group_def, labels, over=False): if not over: if group_def["type"] == "shortcut": heading = utils.get_string(30028) elif group_def["type"] == "widget": heading = utils.get_string(30029) dialog = xbmcgui.Dialog() labels["label"] = dialog.input(heading=heading, defaultt=labels["label"]) del dialog labels["id"] = utils.get_unique_id(labels["label"]) labels["version"] = settings.get_addon_info("version") if labels["target"] == "settings": labels["file"]["filetype"] = "file" labels["file"]["file"] = labels["file"]["file"].split("&")[0] elif labels["target"] == "shortcut" and labels["file"]["filetype"] == "file": labels["content"] = None manage.write_path(group_def, path_def=labels)
def shift_path(group_id, path_id, target): group_def = manage.get_group_by_id(group_id) paths = group_def['paths'] for idx, path_def in enumerate(paths): if path_def['id'] == path_id: if target == 'up' and idx >= 0: if idx > 0: temp = paths[idx - 1] paths[idx - 1] = path_def paths[idx] = temp else: paths.append(paths.pop(idx)) elif target == 'down' and idx <= len(paths) - 1: if idx < len(paths) - 1: temp = paths[idx + 1] paths[idx + 1] = path_def paths[idx] = temp else: paths.insert(0, paths.pop()) break group_def['paths'] = paths manage.write_path(group_def) utils.update_container(group_def['type'] == 'shortcut')