Add Inkscape Config

This commit is contained in:
Thomas Dehaeze 2020-11-03 11:30:27 +01:00
parent 83a4ac8f74
commit a1be22f44b

103
dotfiles/inkscape.org Normal file
View File

@ -0,0 +1,103 @@
#+TITLE: Inkscape
:DRAWER:
#+STARTUP: overview
#+LANGUAGE: en
#+EMAIL: dehaeze.thomas@gmail.com
#+AUTHOR: Dehaeze Thomas
#+HTML_LINK_HOME: ./index.html
#+HTML_LINK_UP: ./index.html
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/readtheorg.css"/>
#+HTML_HEAD: <script type="text/javascript" src="./js/jquery.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/jquery.stickytableheaders.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/readtheorg.js"></script>
#+PROPERTY: header-args :comments no
#+PROPERTY: header-args+ :mkdirp yes
:END:
* Save Selection to SVG extension
** =ink= file
#+begin_src xml :tangle ~/.config/inkscape/extensions/save_selection/save_selection.inx
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<!-- _name must have same name as .py file but capitalise it. Shows on Menu this way-->
<_name>Save Selection</_name>
<!-- id should be unique. Associates entered values with this menu -->
<id>org.inkscape.save_selection</id>
<!-- mention a dependency here and will check for existence (optional)-->
<dependency type="executable" location="inx">save_selection.py</dependency>
<!-- start notebook -->
<param name="param" type="float" min="0.1" max="1000.0" precision="5" _gui-text="A floating value">1.0</param>
<param name="achoice" type="bool" _gui-text="A boolean value">false</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu _name="Save Selection"/>
</effects-menu>
</effect>
<!-- py file again -->
<script>
<command location="inx" interpreter="python">save_selection.py</command>
</script>
</inkscape-extension>
#+end_src
** =py= file
:PROPERTIES:
:header-args: :shebang "#!/usr/bin/env python"
:header-args+: :comments both :mkdirp yes
:header-args+: :tangle ~/.config/inkscape/extensions/save_selection/save_selection.py
:END:
#+begin_src python
import os
import inkex
import inkex.command
class SaveSelection(inkex.OutputExtension): # choose a better name
def add_arguments(self, pars):
pars.add_argument("--param", type=float, dest="param", default=1.0)
pars.add_argument("-x", "--achoice", type=inkex.Boolean, dest="achoice", default=False)
def save(self, stream):
# param2 = self.options.param
# choice = self.options.achoice
# inkex.command.inkscape_command(self.svg, verbs=['EditInvert']);
# inkex.command.inkscape_command(self.svg, verbs=['EditDelete']);
# filename = os.popen('rofi -dmenu -p "Filename"')
# print(filename)
# inkex.debug(self.svg.selected.svg)
self.document.write(self.svg.selected)
# Get selected objects
# selection = self.svg.selected
# selection = inkex.load_svg(
# inkex.command.inkscape_command(
# self.svg, verbs=['FitCanvasToDrawing']))
# # Create a Canvas ovject
# # Write File
# # stream.write(b''.join(self.svg.selected.tostring()))
# inkex.command.write_svg(selection, "/home/thomas/", "test.svg")
if __name__ == '__main__':
SaveSelection().run()
#+end_src