add open current file dir extension
This commit is contained in:
parent
720629935c
commit
d6c43d341c
20
extensions/fablabchemnitz/open_currentfile_dir/meta.json
Normal file
20
extensions/fablabchemnitz/open_currentfile_dir/meta.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "Open Current File Directory",
|
||||||
|
"id": "fablabchemnitz.de.open_currentfile_dir",
|
||||||
|
"path": "open_currentfile_dir",
|
||||||
|
"dependent_extensions": null,
|
||||||
|
"original_name": "Open Current File Directory",
|
||||||
|
"original_id": "fablabchemnitz.de.open_currentfile_dir",
|
||||||
|
"license": "GNU GPL v3",
|
||||||
|
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/LICENSE",
|
||||||
|
"comment": "Written by Mario Voigt",
|
||||||
|
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/open_currentfile_dir",
|
||||||
|
"fork_url": null,
|
||||||
|
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Open+Extension+Directory",
|
||||||
|
"inkscape_gallery_url": null,
|
||||||
|
"contributors": [
|
||||||
|
"github.com/eridur-de"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||||
|
<name>Open Current File Directory</name>
|
||||||
|
<id>fablabchemnitz.de.open_currentfile_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_currentfile_dir.py</command>
|
||||||
|
</script>
|
||||||
|
</inkscape-extension>
|
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import warnings
|
||||||
|
import inkex
|
||||||
|
|
||||||
|
DETACHED_PROCESS = 0x00000008
|
||||||
|
|
||||||
|
class OpenCurrentFileDirectory(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):
|
||||||
|
dir = os.path.dirname(self.document_path())
|
||||||
|
if dir == '':
|
||||||
|
inkex.utils.debug("Please save the document first!")
|
||||||
|
if os.name == 'nt':
|
||||||
|
explorer = "explorer"
|
||||||
|
else:
|
||||||
|
explorer = "xdg-open"
|
||||||
|
|
||||||
|
args = [explorer, dir]
|
||||||
|
try:
|
||||||
|
self.spawnIndependentProcess(args)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
inkex.utils.debug(e)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
OpenCurrentFileDirectory().run()
|
@ -1,15 +1,15 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "Open Extension Directory",
|
"name": "Open Extension Directory",
|
||||||
"id": "fablabchemnitz.de.open_dir",
|
"id": "fablabchemnitz.de.open_extensions_dir",
|
||||||
"path": "open_dir",
|
"path": "open_extensions_dir",
|
||||||
"dependent_extensions": null,
|
"dependent_extensions": null,
|
||||||
"original_name": "Open Extension Directory",
|
"original_name": "Open Extension Directory",
|
||||||
"original_id": "fablabchemnitz.de.open_dir",
|
"original_id": "fablabchemnitz.de.open_extensions_dir",
|
||||||
"license": "GNU GPL v3",
|
"license": "GNU GPL v3",
|
||||||
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/LICENSE",
|
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/LICENSE",
|
||||||
"comment": "Written by Mario Voigt",
|
"comment": "Written by Mario Voigt",
|
||||||
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/open_dir",
|
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/open_extensions_dir",
|
||||||
"fork_url": null,
|
"fork_url": null,
|
||||||
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Open+Extension+Directory",
|
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Open+Extension+Directory",
|
||||||
"inkscape_gallery_url": null,
|
"inkscape_gallery_url": null,
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||||
<name>Open Extension Directory</name>
|
<name>Open Extension Directory</name>
|
||||||
<id>fablabchemnitz.de.open_dir</id>
|
<id>fablabchemnitz.de.open_extensions_dir</id>
|
||||||
<effect needs-live-preview="false">
|
<effect needs-live-preview="false">
|
||||||
<object-type>all</object-type>
|
<object-type>all</object-type>
|
||||||
<effects-menu>
|
<effects-menu>
|
||||||
@ -9,6 +9,6 @@
|
|||||||
</effects-menu>
|
</effects-menu>
|
||||||
</effect>
|
</effect>
|
||||||
<script>
|
<script>
|
||||||
<command location="inx" interpreter="python">open_dir.py</command>
|
<command location="inx" interpreter="python">open_extensions_dir.py</command>
|
||||||
</script>
|
</script>
|
||||||
</inkscape-extension>
|
</inkscape-extension>
|
Loading…
Reference in New Issue
Block a user