add open dir extension

This commit is contained in:
Mario Voigt 2021-11-09 16:27:19 +01:00
parent 8d8a9a14eb
commit 60789871de
4 changed files with 71 additions and 1 deletions

View File

@ -36,7 +36,7 @@ DETACHED_PROCESS = 0x00000008
class AnimateOrder(inkex.EffectExtension):
def spawnIndependentProcess(self, args): #function to spawn non-blocking inkscape instance. the inkscape command is available because it is added to ENVIRONMENT when Inkscape main instance is started
def spawnIndependentProcess(self, args):
warnings.simplefilter('ignore', ResourceWarning) #suppress "enable tracemalloc to get the object allocation traceback"
if os.name == 'nt':
subprocess.Popen(args, close_fds=True, creationflags=DETACHED_PROCESS)

View File

@ -0,0 +1,20 @@
[
{
"name": "Open Extension Directory",
"id": "fablabchemnitz.de.open_dir",
"path": "open_dir",
"dependent_extensions": null,
"original_name": "Animate Order",
"original_id": "fablabchemnitz.de.open_dir",
"license": "GNU GPL v3",
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/LICENSE",
"comment": "Written by Mario Voigt",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/animate_order",
"fork_url": null,
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Open+Dir",
"inkscape_gallery_url": null,
"main_authors": [
"github.com/vmario89"
]
}
]

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Open Extension Directory</name>
<id>fablabchemnitz.de.open_dir</id>
<effect needs-live-preview="false">
<object-type>all</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz"/>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">open_dir.py</command>
</script>
</inkscape-extension>

View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
import subprocess
import os
import sys
import warnings
import inkex
DETACHED_PROCESS = 0x00000008
class OpenExtensionDirectory(inkex.EffectExtension):
def spawnIndependentProcess(self, args):
warnings.simplefilter('ignore', ResourceWarning) #suppress "enable tracemalloc to get the object allocation traceback"
if os.name == 'nt':
subprocess.Popen(args, close_fds=True, creationflags=DETACHED_PROCESS)
else:
subprocess.Popen(args, start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
warnings.simplefilter("default", ResourceWarning)
def effect(self):
extension_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', '..')
if os.name == 'nt':
explorer = "explorer"
else:
explorer = "xdg-open"
args = [explorer, extension_dir]
try:
self.spawnIndependentProcess(args)
except FileNotFoundError as e:
inkex.utils.debug(e)
exit(1)
if __name__ == '__main__':
OpenExtensionDirectory().run()