diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2025-03-25 17:03:17 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-25 18:03:17 +0100 |
| commit | 6355d4790e3d543250cd4dddbe8273672c13bce5 (patch) | |
| tree | 7cc9664717fd0819f7f2673765f6b09f9349f47c /lib/extensions | |
| parent | c1759232b42c8926c080006223c382e20b9b2470 (diff) | |
Install thread palettes -> addons (thread palettes and symbols) (#3606)
Co-authored-by: CapellanCitizen
Diffstat (limited to 'lib/extensions')
| -rw-r--r-- | lib/extensions/install.py | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/lib/extensions/install.py b/lib/extensions/install.py index 501694ed..43e95414 100644 --- a/lib/extensions/install.py +++ b/lib/extensions/install.py @@ -1,31 +1,65 @@ # Authors: see git history # -# Copyright (c) 2010 Authors +# Copyright (c) 2025 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. -from .base import InkstitchExtension import os import sys from glob import glob -from ..utils import get_bundled_dir, guess_inkscape_config_path -from inkex import errormsg + +from inkex import Boolean, errormsg + from ..i18n import _ +from ..utils import get_bundled_dir, guess_inkscape_config_path +from .base import InkstitchExtension class Install(InkstitchExtension): def __init__(self, *args, **kwargs): InkstitchExtension.__init__(self, *args, **kwargs) + self.arg_parser.add_argument("--notebook") + self.arg_parser.add_argument("--install-palettes", type=Boolean, default=False, dest="install_palettes") + self.arg_parser.add_argument("--install-symbol-libraries", type=Boolean, default=False, dest="install_symbol_libraries") + + self.inkscape_config_path = guess_inkscape_config_path() + self.install_resources = get_bundled_dir('addons') def effect(self): - path = os.path.join(guess_inkscape_config_path(), 'palettes') + installation_success = [] + if self.options.install_palettes: + installation_success.append(self.install_palettes()) + if self.options.install_symbol_libraries: + installation_success.append(self.install_symbol_libraries()) + if all(installation_success): + self.install_success_message() + + def install_palettes(self): + path = os.path.join(self.inkscape_config_path, 'palettes') + # palettes are also used otherwise, so they have their own location src_dir = get_bundled_dir('palettes') try: copy_files(glob(os.path.join(src_dir, "*")), path) - errormsg(_("Successfully installed color palettes for Inkscape.\n\n" - "Please restart Inkscape.")) - except IOError: - errormsg(_("Could not install color palettes. Please file an issue on " - "https://github.com/inkstitch/inkstitch/issues")) + return True + except IOError as error: + self.install_error_message(_("Could not install color palettes. Please file an issue on"), error) + return False + + def install_symbol_libraries(self): + path = os.path.join(self.inkscape_config_path, 'symbols') + src_dir = os.path.join(self.install_resources, 'symbols') + try: + copy_files(glob(os.path.join(src_dir, "*")), path) + return True + except IOError as error: + self.install_error_message(_("Could not install color palettes. Please file an issue on"), error) + return False + + def install_success_message(self): + errormsg(_("Successfully installed Addons.\n\nPlease restart Inkscape.")) + + def install_error_message(self, text, error): + errormsg(text + " https://github.com/inkstitch/inkstitch/issues\n\n") + errormsg(error) if sys.platform == "win32": |
