From 6355d4790e3d543250cd4dddbe8273672c13bce5 Mon Sep 17 00:00:00 2001
From: Kaalleen <36401965+kaalleen@users.noreply.github.com>
Date: Tue, 25 Mar 2025 17:03:17 +0000
Subject: [PATCH] Install thread palettes -> addons (thread palettes and
symbols) (#3606)
Co-authored-by: CapellanCitizen
---
addons/symbols/inkstitch-motif-library.svg | 745 +++++++++++++++++++++
bin/build-distribution-archives | 4 +-
lib/extensions/install.py | 54 +-
templates/install.xml | 27 +-
4 files changed, 812 insertions(+), 18 deletions(-)
create mode 100644 addons/symbols/inkstitch-motif-library.svg
diff --git a/addons/symbols/inkstitch-motif-library.svg b/addons/symbols/inkstitch-motif-library.svg
new file mode 100644
index 000000000..a32df7852
--- /dev/null
+++ b/addons/symbols/inkstitch-motif-library.svg
@@ -0,0 +1,745 @@
+
+
+
+
diff --git a/bin/build-distribution-archives b/bin/build-distribution-archives
index 34085f3a1..26ec26e3b 100644
--- a/bin/build-distribution-archives
+++ b/bin/build-distribution-archives
@@ -4,7 +4,7 @@ ARCH="$(uname -m)"
mkdir artifacts
if [ "$BUILD" = "osx" ]; then
- cp -a icons locales print LICENSE VERSION palettes symbols fonts tiles dbus inx dist/inkstitch.app/Contents/Resources
+ cp -a addons icons locales print LICENSE VERSION palettes symbols fonts tiles dbus inx dist/inkstitch.app/Contents/Resources
# adding version to Info.plist
plutil -replace CFBundleShortVersionString -string ${VERSION} dist/inkstitch.app/Contents/Info.plist
rm -rf dist/inkstitch/
@@ -92,7 +92,7 @@ if [ "$BUILD" = "osx" ]; then
7z a ../artifacts/inkstitch-${VERSION}-${OS}-${ARCH}.zip *
cd ..
else
- cp -a palettes symbols fonts tiles dbus inx LICENSE VERSION dist/inkstitch
+ cp -a addons palettes symbols fonts tiles dbus inx LICENSE VERSION dist/inkstitch
cp -a icons locales print dist/inkstitch/bin
fi
diff --git a/lib/extensions/install.py b/lib/extensions/install.py
index 501694ed0..43e95414e 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":
diff --git a/templates/install.xml b/templates/install.xml
index 1ceb8a934..c221f1a7f 100644
--- a/templates/install.xml
+++ b/templates/install.xml
@@ -1,16 +1,31 @@
- Install thread color palettes for Inkscape
+ Install Addons for Inkscape
org.{{ id_inkstitch }}.install
install
-
+
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
all
{{ icon_path }}inx/color_management.svg
- Installs color palettes for various thread brands into Inkscape
+ Installs color palettes or a symbol library for motif stitches into Inkscape
-
-
-
+