Im working on a tool for animating SVG that uses inkscape to manipulate SVG's, and I need to update inkscape to show the selected state of the animated SVG in order to let the user make changes (It is an external tool not a plugin).
For example: A rectangle goes from x: 100 to x:300, the user pauses the animation when rectangle is at x:200, then the tool saves the SVG state with x:200, the only problem is that inkscape is not refreshed, so I need to close and open inkscape, or manually go to File>Revert.
I'v been investigating and I found that there was a verb (before verbs were removed in 1.2) that is called FileRevert, I tried with version 1.1 and with inkscape GUI open this command:
inkscape --verb FileRevert test.svg
This is the full output with the command: (full log at the end)
user@user:~/Desktop$ ./ink2.AppImage --verb FileRevert test.svg
WARNING: ignoring verb FileRevert - GUI required for this verb.
** (org.inkscape.Inkscape:6946): CRITICAL **: 08:40:38.988: static void Inkscape::FileVerb::perform(SPAction*, void*): assertion 'ensure_desktop_valid(action)' failed
So the error seems to be that is not detecting the GUI, idk if I have to tell to the cli where is the GUI or open inkscape from the GUI, but I tried this and the terminal is blocked until you close inkscape.
Then I tried with inkscape 1.2 actions since the documentation says that all verbs are available as actions:
but there is no FileRevert action in --action-list, and also there is no information about any deprecation of FileRevert on 1.2 release notes so It's been very difficult to make a guess on what is going on.
This is the output of trying FileRevert with actions: (full log at the end)
user@user:~/Desktop$ ./ink.AppImage --actions="FileRevert" test.svg
InkscapeApplication::parse_actions: could not find action for: FileRevert
So it seems it's not being able to find FileRevert action, probably that means that it's not supported or deprecated.
Im using linux mint in case that matters.
Any help is welcome, or any alternative solution to my problem... atm im considering so bad alternatives like just closing and reopening inkscape automatically every time you want to refresh it, or select inkscape window and trigger a hotkey to revert the file.
Thank you!
Full log 1.1 Verb try:
user@user:~/Desktop$ ./ink2.AppImage --verb FileRevert test.svg
Setting _INKSCAPE_GC=disable as a workaround for broken libgc
Gtk-Message: 08:40:38.030: Failed to load module "xapp-gtk3-module"
** (org.inkscape.Inkscape:6946): WARNING **: 08:40:38.964: <svg:rect id="">: CSS Style property: "stroke-width" with default value (1) not needed.
** (org.inkscape.Inkscape:6946): WARNING **: 08:40:38.964: <svg:rect id="rect786">: CSS Style property: "stroke-width" with default value (1) not needed.
** (org.inkscape.Inkscape:6946): WARNING **: 08:40:38.964: <svg:rect id="rect786">: CSS Style property: "stroke-width" with default value (1) not needed.
WARNING: ignoring verb FileRevert - GUI required for this verb.
** (org.inkscape.Inkscape:6946): CRITICAL **: 08:40:38.988: static void Inkscape::FileVerb::perform(SPAction*, void*): assertion 'ensure_desktop_valid(action)' failed
Full log 1.2 actions try:
user@user:~/Desktop$ ./ink.AppImage --actions="FileRevert" test.svg
Setting _INKSCAPE_GC=disable as a workaround for broken libgc
Gtk-Message: 08:49:36.363: Failed to load module "xapp-gtk3-module"
InkscapeApplication::parse_actions: could not find action for: FileRevert
** (org.inkscape.Inkscape:7139): WARNING **: 08:49:37.377: <svg:rect id="">: CSS Style property: "stroke-width" with default value (1) not needed.
** (org.inkscape.Inkscape:7139): WARNING **: 08:49:37.377: <svg:rect id="rect786">: CSS Style property: "stroke-width" with default value (1) not needed.
** (org.inkscape.Inkscape:7139): WARNING **: 08:49:37.378: <svg:rect id="rect786">: CSS Style property: "stroke-width" with default value (1) not needed.
CodePudding user response:
It seems that the file_revert action is not implemented in 1.2.x and above versions for Inkscape. See the issue here.
However, I would suggest using dbus instead. Here is an example on how revert document using dbus when you have inkscape running:
gdbus call --session --dest org.inkscape.Inkscape --object-path /org/inkscape/Inkscape/window/1 --method org.gtk.Actions.Activate document-revert [] {}
To get the list of actions that you can invoke via dbus run the following command:
gdbus call --session --dest org.inkscape.Inkscape --object-path /org/inkscape/Inkscape/window/1 --method org.gtk.Actions.List
Instead of the terminal, you can also use dbus on your C , Python, etc. codes. For the list of binding see: here.
An example using C : See here: https://github.com/makercrew/dbus-sample
For Python, see: https://wiki.python.org/moin/DbusExamples