【问题标题】:Inkscape CLI FileRevert doesn't work in 1.1 or 1.2, trying to refresh Inkscape GUIInkscape CLI FileRevert 在 1.1 或 1.2 中不起作用,尝试刷新 Inkscape GUI
【发布时间】:2022-10-15 17:53:03
【问题描述】:

我正在开发一个使用 inkscape 来操作 SVG 的 SVG 动画工具,我需要更新 inkscape 以显示动画 SVG 的选定状态,以便让用户进行更改(它是一个外部工具而不是插件)。

例如:一个矩形从 x:100 变为 x:300,当矩形在 x:200 时用户暂停动画,然后工具将 SVG 状态保存为 x:200,唯一的问题是inkscape 没有刷新,所以我需要关闭并打开inkscape,或者手动转到文件>恢复。

我一直在调查,发现有一个称为 FileRevert 的动词(在 1.2 中删除动词之前),我尝试使用 1.1 版并使用 inkscape GUI 打开此命令:

inkscape --verb FileRevert test.svg

这是命令的完整输出:(最后的完整日志)

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

所以错误似乎是没有检测到 GUI,idk 如果我必须告诉 cli GUI 在哪里或从 GUI 打开 inkscape,但我尝试了这个并且终端被阻止,直到你关闭 inkscape。

然后我尝试了 inkscape 1.2 动作,因为文档说所有动词都可以作为动作使用:

但在 --action-list 中没有 FileRevert 操作,而且在 1.2 发行说明中也没有关于 FileRevert 任何弃用的信息,因此很难猜测发生了什么。

这是使用操作尝试 FileRevert 的输出:(最后的完整日志)

user@user:~/Desktop$ ./ink.AppImage --actions="FileRevert" test.svg

InkscapeApplication::parse_actions: could not find action for: FileRevert

所以它似乎无法找到 FileRevert 操作,这可能意味着它不受支持或不推荐使用。

我正在使用 linux mint 以防万一。

欢迎任何帮助,或者我的问题的任何替代解决方案...... atm 我正在考虑如此糟糕的替代方案,比如每次你想刷新它时自动关闭和重新打开inkscape,或者选择inkscape窗口并触发一个热键来恢复文件。

谢谢!

完整日志 1.1 动词尝试:

  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

完整日志 1.2 操作尝试:

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.

编辑:在 Inkscape 中工作和更新的工具演示: https://www.youtube.com/watch?v=fDAIVKd19YU

【问题讨论】:

  • FileRevert 是一个动词。动词在 1.2.x 中被完全删除并替换为动作
  • @s.ouchene 我知道,这就是为什么我尝试将 1.1 版作为动词,也作为 1.2 中的动作,因为假设所有动词都转换为动作:wiki.inkscape.org/wiki/Release_notes/1.2#Behind_the_curtains“命令行'动词'已被删除. 所有动词都可以作为“动作”使用”
  • 动词需要 GUI。对于 1.1.x 使用 --with-gui 选项。
  • 我认为发行说明中有错误。查看我在这里打开的问题:gitlab.com/inkscape/inbox/-/issues/7704
  • winodws 不是指操作系统,而是指 GUI。

标签: svg inkscape


【解决方案1】:

似乎在 Inkscape 的 1.2.x 及更高版本中未实现 file_revert 操作。请参阅问题here

但是,我建议改用dbus。下面是一个关于在运行 inkscape 时如何使用 dbus 恢复文档的示例:

gdbus call --session --dest org.inkscape.Inkscape --object-path /org/inkscape/Inkscape/window/1 --method org.gtk.Actions.Activate document-revert [] {}

要获取可以通过 dbus 调用的操作列表,请运行以下命令:

gdbus call --session --dest org.inkscape.Inkscape --object-path /org/inkscape/Inkscape/window/1 --method org.gtk.Actions.List

除了终端,您还可以在 C++、Python 等代码上使用 dbus。绑定列表见:here

【讨论】:

  • Linux mint 错误可能吗? :~/Desktop$ gdbus call --session --dest org.inkscape.Inkscape --object-path /org/inkscape/Inkscape/window/1 --method org.gtk.Actions.Activate document-revert [] {}错误:GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown:名称 org.inkscape.Inkscape 不是由任何 .service 文件提供的
  • 您应该打开 Inkscape。
  • 好的,我打开了 1.1,所以我关闭它并尝试使用 1.2,现在出现此错误:连接错误:无法连接:连接被拒绝
  • 好的,我重新启动了我的电脑,现在似乎已经工作了:)
  • @Of3lia:查看更新。您可以通过 dbus 获取可以使用的命令列表。
猜你喜欢
  • 1970-01-01
  • 2012-10-26
  • 2023-03-26
  • 2018-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多