From 44d576747209e8ed665a29aa8a2609d4f5e26b64 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sun, 4 Jul 2021 13:13:40 +0200 Subject: [PATCH] added simple inkscape interface --- .../{validate.sh => 000_validate.sh} | 0 .../simple/ui/menus.xml | 328 ++++++++++++++++++ .../simple/ui/toolbar-commands.ui | 41 +++ .../simple/ui/toolbar-tool.ui | 49 +++ .../simpleinkscape/simpleinkscape.inx | 36 ++ .../simpleinkscape/simpleinkscape.py | 93 +++++ 6 files changed, 547 insertions(+) rename extensions/fablabchemnitz/{validate.sh => 000_validate.sh} (100%) create mode 100644 extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/menus.xml create mode 100644 extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/toolbar-commands.ui create mode 100644 extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/toolbar-tool.ui create mode 100644 extensions/fablabchemnitz/simpleinkscape/simpleinkscape.inx create mode 100644 extensions/fablabchemnitz/simpleinkscape/simpleinkscape.py diff --git a/extensions/fablabchemnitz/validate.sh b/extensions/fablabchemnitz/000_validate.sh similarity index 100% rename from extensions/fablabchemnitz/validate.sh rename to extensions/fablabchemnitz/000_validate.sh diff --git a/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/menus.xml b/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/menus.xml new file mode 100644 index 00000000..fd11f443 --- /dev/null +++ b/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/menus.xml @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /--> + + + + + + + + + + + + + + + + + + + /--> + + + + + diff --git a/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/toolbar-commands.ui b/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/toolbar-commands.ui new file mode 100644 index 00000000..7e651837 --- /dev/null +++ b/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/toolbar-commands.ui @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/toolbar-tool.ui b/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/toolbar-tool.ui new file mode 100644 index 00000000..dc11514a --- /dev/null +++ b/extensions/fablabchemnitz/simpleinkscape/inkscape-simpleinkscape/simple/ui/toolbar-tool.ui @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/fablabchemnitz/simpleinkscape/simpleinkscape.inx b/extensions/fablabchemnitz/simpleinkscape/simpleinkscape.inx new file mode 100644 index 00000000..edd18aab --- /dev/null +++ b/extensions/fablabchemnitz/simpleinkscape/simpleinkscape.inx @@ -0,0 +1,36 @@ + + + Simple Inkscape (Interface) + fablabchemnitz.de.simpleinkscape + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz/simpleinkscape/simpleinkscape.py b/extensions/fablabchemnitz/simpleinkscape/simpleinkscape.py new file mode 100644 index 00000000..7f91d925 --- /dev/null +++ b/extensions/fablabchemnitz/simpleinkscape/simpleinkscape.py @@ -0,0 +1,93 @@ +#!/usr/bin/python3 +#-*- coding: utf-8 -*- + +# Simple Inkscape Version 0.1 + +# The purpose of this Inkscape extension is to provide a easy method to change the interface. +# The needed .xml and .ui files are provided in the zip file. +# These filese are moved into the .config/inkscape-simpleinkscape folder on first run. +# There are two option: default and simple. + +# This program has been released under the Gnu Public Licence version 2. It is free for everyone to use, copy and change. +# A copy of the GPLv2 licence has added to this program. + +import inkex +import shutil +import os +import platform +import subprocess + +#profiles = ['default', 'simple', 'lasercutter'] +profiles = ['default', 'simple'] +#folders = ['extensions','icons', 'keys', 'palettes', 'templates', 'ui'] +folders = ['ui'] + +def log (msg =''): + inkex.errormsg(msg) + +def debug (msg=''): + inkex.errormsg("DEBUG : " + msg) + pass + +class simpleinkscape(inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + self.arg_parser.add_argument("--interfaceVersion", type=str) + + def effect(self): + log ('\n*** Simple Inkscape ***\n') + + # Determine the platform, only continue on linux or windows + platfrm = platform.system() + if platfrm == 'Linux': sep = '/' + elif platfrm == 'Windows': sep = "\\" + else: + log ('\nError!\n\nThis extension works only on Linux and Windows.\nOther OSes have not been tested and will not work.\n\nExiting.') + exit() + + interfaceVersion = str(self.options.interfaceVersion).lower() + log ('Inkscape interface will be switched to : ' + interfaceVersion + '\n') + + # Set all folder paths and names + userfolder = subprocess.run(['inkscape', '--user-data-directory'], capture_output=True, text=True).stdout[0:-1]+sep + profilefolder = userfolder[:-1] + '-simpleinkscape' + sep + + # Create ProfileFolder and copy profiles from extensions folder on first run. + if not os.path.isdir (profilefolder): + log ('profile folder not existing. Creating it ...') + os.mkdir(profilefolder) + + extension_dir = os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)))) #go up to main dir /home//.config/inkscape/extensions/mightyscape-1.X/ + simpleinkscapefolder = extension_dir + sep + 'inkscape-simpleinkscape' + sep + + if os.path.isdir(simpleinkscapefolder): + shutil.copytree(simpleinkscapefolder, profilefolder, dirs_exist_ok=True) + + # Check if profile for chosen interface version exists. + if os.path.isdir (profilefolder + interfaceVersion) == False: + log ('Error!\n\nThe chosen profile folder does not exist in ' + profilefolder) + log ('User interface has not been changed.\n\nExiting.') + exit() + + # Go through list of folders and if they exist in the profile: replace contents + log ('Installing folders:') + for folder in folders: + # Folder exists inside profile? + if os.path.isdir (profilefolder + interfaceVersion + sep + folder): + # Delete folder from userfolder and replace by the one in profile + shutil.rmtree(userfolder + folder, ignore_errors=True) + os.mkdir(userfolder + folder) + log (' ' + userfolder + folder + sep) + shutil.copytree( profilefolder + interfaceVersion + sep + folder + sep, userfolder+folder+sep, dirs_exist_ok=True) + + log('\nSucces!\n\nThe Inkscape interface has been set to ' + interfaceVersion) + log('The changes will become visible after restarting inkscape') + log('\n*** End ***') + exit() + + +if __name__ == "__main__": + myExt = simpleinkscape() + myExt.run() +