Skip to content

Rework the plugin system - #1313

Merged
ice0 merged 20 commits into
synfig:masterfrom
mbasaglia:plugin_improvements
Apr 29, 2020
Merged

ice0 merged 20 commits into
synfig:masterfrom
mbasaglia:plugin_improvements

Conversation

@mbasaglia

Copy link
Copy Markdown
Contributor

Implements most of the things mentioned here: #1309 (comment)

@ice0

ice0 commented Apr 1, 2020

Copy link
Copy Markdown
Collaborator

It's ok, what travis build is errored, i will fix it ASAP.

@ice0

ice0 commented Apr 1, 2020

Copy link
Copy Markdown
Collaborator

Ok, Travis build fixed. After rebase all should be fine.

@mbasaglia
mbasaglia force-pushed the plugin_improvements branch from ee214c9 to 35fabe1 Compare April 1, 2020 14:09
@mbasaglia

Copy link
Copy Markdown
Contributor Author

I've added support for importers defined in plugins.

To test this you can use my plugin: http://mattia.basaglia.gitlab.io/tgs/downloads.html
It supports a couple different formats, probably the easiest to test is SVG.

@morevnaproject

Copy link
Copy Markdown
Member

@mbasaglia Thank you for an awesome addition! Please check my comments here - #1309 (comment) ^__^

@morevnaproject

Copy link
Copy Markdown
Member

I have tested this PR, here are my thoughts:

  1. We now have two "Import" menu commands:
    screenshot_001

I was unable to test properly "Import file..." command, because importer gave me an error when I made an attempt to import Lottie json file. But that's different issue.

I guess that "Import file..." opens imported file in a new tab (not adds to currently opened document). So, I think the meaning of it is more like "File" - "Open" command.

I think that we should merge "Import file..." and "Open" commands for better UX.

  1. Export command works perfectly, I have tested with html and json export. ^__^

@morevnaproject morevnaproject removed their assignment Apr 2, 2020
@mbasaglia

Copy link
Copy Markdown
Contributor Author

yeah it does work more like open, I'll move the code to that dialog.

to test import the easiest way is to create a simple drawing in synfig, export with "[TGS] SVG" and import the same file.

@morevnaproject

Copy link
Copy Markdown
Member

Thank you! I want to say that I am absolutely excited about this feature and which possibilities it opens for further development.

For example, a very common case when newbie user tries to import some image using "File" - "Open" command. Synfig give them error, because images intended to be added via "File" - "import" command. But newbie users are not aware about that and they often reach out to support asking what's wrong.

With new plugins system we can create a very simple plugin, which allows to open images via "File" - "Open" command. The plugin will do simple thing - it will create a new document with imported image. ^__^

@mbasaglia

mbasaglia commented Apr 2, 2020 •

Copy link
Copy Markdown
Contributor Author

I've pushed some changes that do that and also fixed some issues.

@rodolforg rodolforg left a comment

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 believe it is the whole filepath, right?

@mbasaglia

Copy link
Copy Markdown
Contributor Author

Yea

@mbasaglia

Copy link
Copy Markdown
Contributor Author

CI fail seems unrelated to my changes

$ ./1-setup-osx-brew.sh

Checking adwaita-icon-theme...

==> Downloading https://homebrew.bintray.com/bottles/gnome-icon-theme-3.22.0.yos

Error: Failed to download resource "gnome-icon-theme"

Download failed: https://homebrew.bintray.com/bottles/gnome-icon-theme-3.22.0.yosemite.bottle.tar.gz

[...]

==> Downloading https://download.gnome.org/sources/adwaita-icon-theme/3.22/adwai

Error: Failed to download resource "gnome-icon-theme"

Download failed: https://download.gnome.org/sources/adwaita-icon-theme/3.22/adwaita-icon-theme-3.22.0.tar.xz

The command "./1-setup-osx-brew.sh" failed and exited with 1 during .

@AnishGG

AnishGG commented Apr 2, 2020

Copy link
Copy Markdown
Member

I have restarted the job. Sometimes the download fails because of network errors at the server.

@lgtm-com

lgtm-com Bot commented Apr 3, 2020

Copy link
Copy Markdown

This pull request fixes 1 alert when merging ef1f20e into f584626 - view on LGTM.com

fixed alerts:

  • 1 for Variable defined multiple times

@morevnaproject

Copy link
Copy Markdown
Member

I've pushed some changes that do that and also fixed some issues.

Thank you! I will be able to test it on Tuesday. ^__^

@mbasaglia

Copy link
Copy Markdown
Contributor Author

By the way, as a side effect of this PR, #1252 should be much easier to fix as all that is required is to recreate / update the menu items when language is changed.
(Previously plugin names were loaded at startup and not using the correct language).

@morevnaproject

Copy link
Copy Markdown
Member

Hi! I did one more round of testing and found the following:

The Lottie plugin (which is only capable for export currently) for some reason is displayed in "File" - "Open" dialog. The plugin doesn't has any importers declared, so I guess it shouldn't be there. ^__^

(I do not have any other export/import plugins installed, besides Lottie, which is shipped with this version of Synfig).

screenshot_001

@morevnaproject

Copy link
Copy Markdown
Member

Also, I suggest to make "Open history" button inactive when any filetype handled by plugin is selected.
screenshot_003

@mbasaglia

Copy link
Copy Markdown
Contributor Author

Also, I suggest to make "Open history" button inactive when any filetype handled by plugin is selected.
screenshot_003

I'm not too familiar with Gtk(mm) and I wasn't able to find a signal for when the filter changes (doesn't help that the documentation isn't great) do you know how that's done?

https://developer.gnome.org/gtkmm/stable/classGtk_1_1FileChooserDialog.html

@rodolforg

Copy link
Copy Markdown
Contributor

As far as I can tell, you can't access the filter combobox (and its signals) in a normal way, only what filter is currently active.

So I think "Open history" should behave differently according to the selected filter – if it's possible.

Regarding the Gtkmm docs, I use it, but often I read the Gtk docs themselves, as they're more ordered and cleaner than mm counterpart.

@mbasaglia

Copy link
Copy Markdown
Contributor Author

As far as I can tell, you can't access the filter combobox (and its signals) in a normal way, only what filter is currently active.

So I think "Open history" should behave differently according to the selected filter – if it's possible.

Currently for plugins "open history" just acts like open.

So I guess it isn't possible to disable the open history button, even if it's possible to write the code that enables/disables based on the current filter, it can't be run when the filter changes if we can't hook to the combo signal.

@rodolforg

Copy link
Copy Markdown
Contributor

Couldn't the "Open history" action callback check what is the selected filter instead of (sadly) disabling the button?

@mbasaglia

Copy link
Copy Markdown
Contributor Author

I'm not sure I follow, what should happen if someone clicks it when a plugin importer is selected?

@mbasaglia

Copy link
Copy Markdown
Contributor Author

This is the relevant code btw, clicking on "Open history" just sets an output variable when clicked from the dialog

show_history = response == RESPONSE_ACCEPT_WITH_HISTORY;

And this is where it's used, looks like it only does something for ".sfg" files? So clicking on .sif, .sifz doesn't do anything special either (from what I gather)

while(dialog_open_file_with_history_button(_("Please select a file"), filename, show_history, ANIMATION_DIR_PREFERENCE, plugin_importer))
{
// If the filename still has wildcards, then we should
// continue looking for the file we want
if(find(filename.begin(),filename.end(),'*')!=filename.end())
continue;
if ( !plugin_importer.empty() )
{
open_from_plugin(filename, plugin_importer);
return;
}
FileContainerZip::file_size_t truncate_storage_size = 0;
// TODO: ".sfg" literal
if (show_history && filename_extension(filename) == ".sfg")
{
// read history
std::list<FileContainerZip::HistoryRecord> history
= FileContainerZip::read_history(filename);
// build list of history entries for dialog (descending)
std::list<std::string> list;
int index = 0;
for(std::list<FileContainerZip::HistoryRecord>::const_iterator i = history.begin(); i != history.end(); i++)
list.push_front(strprintf("%s%d", _("History entry #"), ++index));
// show dialog
index=0;
if (!dialog_select_list_item(_("Please select a file"), _("Select one of previous versions of file"), list, index))
continue;
// find selected entry in list (descending)
for(std::list<FileContainerZip::HistoryRecord>::const_reverse_iterator i = history.rbegin(); i != history.rend(); i++)
if (0 == index--)
truncate_storage_size = i->storage_size;
}
if(open(filename,truncate_storage_size))
break;
get_ui_interface()->error(_("Unable to open file"));

@lgtm-com

lgtm-com Bot commented Apr 7, 2020

Copy link
Copy Markdown

This pull request fixes 1 alert when merging 742010d into 90e4e3b - view on LGTM.com

fixed alerts:

  • 1 for Variable defined multiple times

@morevnaproject

Copy link
Copy Markdown
Member

And this is where it's used, looks like it only does something for ".sfg" files?

Yes, the "Open history" works for ".sfg" format only.

I am not insist on reworking behavior of "Open history" button right now, in this exact PR. Just brought that up that maybe this could be fixed in the future if not now. ^__^

I am testing the PR again now. Thanks to everyone! ^__^

@morevnaproject

Copy link
Copy Markdown
Member

I found the crash is happening now with current code.
To reproduce it I have installed TGS plugin (as it is providing importers, we need them to trigger the crash).

Also, you will need 2 Lottie JSON (or any other importable) files to reproduce the crash.
I have used those ones -
lottie-2.zip

  1. In Synfig choose "File" - "Open".
  2. Navigate to directory where you have saved your Lottie JSON files.
  3. From filetype dropdown choose "[TGS} Lottie JSON" (otherwise you will not see json files in open dialog)
    screenshot_006
  4. Choose first file "ball-1.json" and click open.
  5. File will be opened.
  6. After that choose "File" - "Open" again from menu
  7. Notice that filetype dropdown has empty value now. I guess this is the reason of the bug.
    screenshot_007
  8. Select "ball-1.json" and click Open button.
  9. Synfig crashes.

@mbasaglia

Copy link
Copy Markdown
Contributor Author

hmm, it seems to only affect some files

@rodolforg

Copy link
Copy Markdown
Contributor

Can you check if until commit 6e6eee5 it still worked?

If so, try to git bisect from this commit on ;)

@lgtm-com

lgtm-com Bot commented Apr 18, 2020

Copy link
Copy Markdown

This pull request fixes 1 alert when merging b133f7c into 2ed703e - view on LGTM.com

fixed alerts:

  • 1 for Variable defined multiple times

@mbasaglia

Copy link
Copy Markdown
Contributor Author

Found a fix

@mbasaglia
mbasaglia force-pushed the plugin_improvements branch from 2e0f0ce to 3fb1847 Compare April 28, 2020 19:31
@mbasaglia

Copy link
Copy Markdown
Contributor Author

um, I re-based again. Any chance of this getting merged?

@ice0
ice0 merged commit 51ba106 into synfig:master Apr 29, 2020
@ice0

ice0 commented Apr 29, 2020

Copy link
Copy Markdown
Collaborator

Sorry. Was busy last days.

Merged. Thank you!

@mbasaglia

Copy link
Copy Markdown
Contributor Author

Cool, I'll be documenting the new stuff in the XML file on the wiki

@rodolforg rodolforg mentioned this pull request May 10, 2021
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