gillescastel / inkscape-shortcut-manager

Inkscape shorcut manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What happens when a style is saved?

sturgman opened this issue · comments

Could you explain what happens when a style is saved? Inkscape does not have a "style library" functionality as far as I know. Are you defining the styles in some kind of svg file and importing them somehow? Thank you!

The code responsible for savings styles / objects is located in the styles.py file.

First, the code copies the object by pressing Ctrl+C:

self.press('c', X.ControlMask)

Then the get(TARGET) retrieves the content from the clipboard in the format specified by TARGET, which is a constant equal to 'image/x-inkscape-svg'. So this retrieves the svg code for the object.

Then the code writes this svg to a file located in the configuration directory (~/.config/inkscape-shortcut-manager/objects/name.svg or /styles/name.svg)

(directory / f'{name}.svg').write_text(get(TARGET))

When you apply a style, this file gets copied to your clipboard and the program presses Ctrl+Shift+V, which is 'paste style'.

Hopes this clears things up a bit!