Skip to content

Export plugins - #1289

Merged
morevnaproject merged 8 commits into
synfig:masterfrom
mbasaglia:export_plugins
Mar 31, 2020
Merged

morevnaproject merged 8 commits into
synfig:masterfrom
mbasaglia:export_plugins

Conversation

@mbasaglia

@mbasaglia mbasaglia commented Mar 26, 2020 •

Copy link
Copy Markdown
Contributor

Adds more metadata to the plugins to support a proper export system.

I've also updated the lottie exporter to use this system.

This is said plugin description as an example:

<?xml version="1.0" encoding="UTF-8"?>
<plugin type="exporter">
   <_name>Export to Lottie format</_name>
   <exec>lottie-exporter.py</exec>
   <extension>.json</extension>
   <description>Lottie Animation (*.json)</description>
</plugin> 

if the type attribute is present and its value is "exporter", the plugin will be added to a list of exporters. The <extension> and <description> elements are used by the new "Export" dialog to set up the file filters.

Such plugins no longer show in the Plugins menu, they are only accessible through File > Export...

@lgtm-com

lgtm-com Bot commented Mar 26, 2020

Copy link
Copy Markdown

This pull request introduces 3 alerts when merging 714f228 into f806eb5 - view on LGTM.com

new alerts:

  • 3 for Unnecessary pass

@AnishGG

AnishGG commented Mar 27, 2020

Copy link
Copy Markdown
Member

@mbasaglia seems like great work! Did you test this locally? The travis build is failing with some errors.
Also as @morevnaproject proposed, we need a behaviour like this: #1218 where a file's undo history should not be erased. ^_^

@AnishGG

AnishGG commented Mar 27, 2020

Copy link
Copy Markdown
Member

I tried building your PR locally and it worked. Don't know why is it failing on travis.
@ice0 can you have a look here. ^__^

@mbasaglia

mbasaglia commented Mar 27, 2020 •

Copy link
Copy Markdown
Contributor Author

ah sorry about pdb, I was using that when I was making my telegram exporter and forgot about it -_-

@mbasaglia

Copy link
Copy Markdown
Contributor Author

Also as @morevnaproject proposed, we need a behaviour like this: #1218 where a file's undo history should not be erased. ^_^

It should already work on this branch, I've modified run_plugin with an argument that disables reloading the canvas.

I've also extracted the code that actually runs the plugin into a different function, which doesn't save a temp file, so it might be used in the future for things import plugins (that wouldn't require a canvas)

@mbasaglia

Copy link
Copy Markdown
Contributor Author

By the way, I was also considering adding support for a single plugin directory to define multiple plugins.

In the case of export, it might be helpful to define multiple exporters based on a single codebase.

Something like if the root element of the plugin xml file is <plugins>, it can define multiple <plugin> elements inside it.

@mbasaglia

Copy link
Copy Markdown
Contributor Author

Looks like the build errors on travis are about Glib::RefPtr::get, probably different Glib versions than what I have

@AnishGG

AnishGG commented Mar 27, 2020

Copy link
Copy Markdown
Member

@ice0 could you review this please. ^__^

@AnishGG

AnishGG commented Mar 27, 2020

Copy link
Copy Markdown
Member

Also @mbasaglia, as mentioned in #1218, could you change the menu item name from export to export for web.

@mbasaglia

Copy link
Copy Markdown
Contributor Author

Also @mbasaglia, as mentioned in #1218, could you change the menu item name from export to export for web.

This is more general than just Lottie though, it can be used for any exporter. Main reason I made this is that I want to make my own exporters.

I already have a Telegram sticker exporter, and I might also add a SVG exporter.

@mbasaglia

Copy link
Copy Markdown
Contributor Author

I've added an extra commit just to make the XML parsing a bit simpler / more readable. I've also changed the type from an element into an attribute since that seems more appropriate.

@ice0 ice0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbasaglia Awesome work, Mattia!

@morevnaproject can you take a look too?

Comment thread synfig-studio/src/gui/instance.cpp Resolved
Comment thread synfig-studio/src/gui/instance.cpp Resolved
Comment thread synfig-studio/src/gui/instance.cpp Resolved
Comment thread synfig-studio/src/gui/instance.cpp Resolved
Comment thread synfig-studio/src/gui/instance.cpp Resolved
Comment thread synfig-studio/src/gui/instance.cpp Resolved
Comment on lines +226 to +227
bool
studio::Instance::run_plugin_with_arguments(std::string plugin_path, const std::vector<std::string>& args)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd split up this function in two:

  • One detects a valid python binary filepath - and maybe build the full command line
  • Other runs the script (open pipe and everything)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to keep this merge request small so I haven't refactored much of the plugin code.

But I think it would also be a good idea to move most of the code in run_plugin into the plugin manager (or maybe even have plugin struct become a proper class and have it there).

run_plugin_with_arguments is really just extracting part of the code that used to be in run_plugin.

Comment thread synfig-studio/src/gui/instance.cpp Resolved
Comment thread synfig-studio/src/gui/instance.cpp Resolved
Comment thread synfig-studio/src/gui/pluginmanager.cpp Resolved
@morevnaproject morevnaproject self-assigned this Mar 31, 2020
@morevnaproject

morevnaproject commented Mar 31, 2020 •

Copy link
Copy Markdown
Member

@mbasaglia Thank you for the great addition! I like how it works. ^__^

Just one request:
Currently the Export dialog allows to select file type (just one option at the moment - "Lottie JSON"). But when export is done it creates two files - "json" and "html". It would be nice to have two filetype options - "Lottie JSON" and "Lottie HTML".

But that request can be a separate issue, I think this PR is ready to merge. ^__^

@mbasaglia

Copy link
Copy Markdown
Contributor Author

Just one request:
Currently the Export dialog allows to select file type (just one option at the moment - "Lottie JSON"). But when export is done it creates two files - "json" and "html". It would be nice to have two filetype options - "Lottie JSON" and "Lottie HTML".

Yeah I'd like to add the ability to do something like that, maybe having some way of defining multiple plugins in the same directory.

It could be implemented by having multiple exporters in a single plugin but I think allowing multiple plugins in the same directory (sharing the same codebase) is more future-proof.

As I was also considering adding support for "import" plugins, so you could have a single installed plugin, that defines various functionality like both import and export in some format or the like.

The way inkscape handles this is by searching for files with a specific extension in the plugin directory (instead of just plugin.xml like synfig does). An alternative could be to add support different root element in plugin.xml that defines multiple <plugin> elements inside it.

I can work on this but I think the decision on how this is handled should be made by someone with more experience in this project.

@morevnaproject

Copy link
Copy Markdown
Member

@mbasaglia Can you please rebase your branch on top of the latest master, so I can make a clean merge? ^__^

@mbasaglia

Copy link
Copy Markdown
Contributor Author

@morevnaproject pushed rebased commits

@morevnaproject

Copy link
Copy Markdown
Member

@mbasaglia I have created new issue to continue discussion - #1309

@rodolforg rodolforg mentioned this pull request May 7, 2020
12 tasks done
@rodolforg

rodolforg commented May 10, 2021 •

Copy link
Copy Markdown
Contributor

@ice0 @morevnaproject maybe backport this and #1313 to v1.4.2?

Maybe t fixes the problems wih AppImage/Flatpak #993 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants