gillescastel / inkscape-shortcut-manager

Inkscape shorcut manager
MIT License
360 stars 98 forks source link

What happens when a style is saved? #11

Closed sturgman closed 4 years ago

sturgman commented 4 years ago

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!

gillescastel commented 4 years ago

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

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

https://github.com/gillescastel/inkscape-shortcut-manager/blob/da65ba20709e4d2d1116669efa219bfbeb8ed0ed/styles.py#L79

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)

https://github.com/gillescastel/inkscape-shortcut-manager/blob/da65ba20709e4d2d1116669efa219bfbeb8ed0ed/styles.py#L105

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!

sturgman commented 4 years ago

That is awesome. Thank you so much for the explanation!

On Thu, Jun 25, 2020, 8:20 AM Gilles Castel notifications@github.com wrote:

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

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

https://github.com/gillescastel/inkscape-shortcut-manager/blob/da65ba20709e4d2d1116669efa219bfbeb8ed0ed/styles.py#L79

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)

https://github.com/gillescastel/inkscape-shortcut-manager/blob/da65ba20709e4d2d1116669efa219bfbeb8ed0ed/styles.py#L105

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!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gillescastel/inkscape-shortcut-manager/issues/11#issuecomment-649506637, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7ODQFUECG4IKMG676L3Z3RYM6IBANCNFSM4OC6E24Q .