首页 > 解决方案 > GtkAda 简单窗口:找不到 pixbuf 加载程序或 mime 数据库

问题描述

使用 Gnat-2020-Community 版本和 Gtkada 我尝试在 Debian 10.2 (x86_64 GNU/Linux) 上创建一个简单的 gui。

该项目基于“从模板创建项目”对话框中的 GtkAda 的“简单窗口”项目(我假设代码开箱即用)。

 --  Initialize GtkAda.
   Gtk.Main.Init;

   --  Create a window with a size of 400x400
   Gtk_New (Win);
   Win.Set_Default_Size (400, 400);

   --  Create a box to organize vertically the contents of the window
   Gtk_New_Vbox (Box);
   Win.Add (Box);

   --  Add a label
   Gtk_New (Label, "Hello world.");
   Box.Add (Label);

   -- Stop the Gtk process when closing the window
   Win.On_Delete_Event (Delete_Event_Cb'Unrestricted_Access);

   --  Show the window and present it
   Win.Show_All;
   Win.Present;

   --  Start the Gtk+ main loop
   Gtk.Main.Main;

除了调整'with "gtkada";' 没有应用任何变化。到项目的 gpr 文件中 gtkada.gpr 文件的正确路径。

GtkAda 被正确检测到。该项目在静态和可重定位配置中均成功构建。

但是,程序无法成功运行,但在执行时会生成此终端输出 Win.Show_All;

/home/user/workspace_ada/Simple_Window/Simple_Window/obj/main
Fontconfig warning: "/home/user/workspace_ada/gnat-2020/etc/fonts/fonts.conf", line 86: unknown element "blank"

(main:4012): Gtk-WARNING **: 21:38:39.988: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.
**
Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /home/user/workspace_ada/gnat-2020/share/icons/Adwaita/16x16/status/image-missing.png: Format der Bilddatei unbekannt (gdk-pixbuf-error-quark, 3)

raised PROGRAM_ERROR : unhandled signal
[2020-08-20 21:38:40] process exited with status 1, elapsed time: 00.30s

我已经按照 Gtkada 的要求安装了以下软件包:libglib*, libgtk*.

此外,我还安装了libx11*and libncurses*,因为我觉得它似乎是有益的。

我已经在 stackoverflow 上搜索了互联网和 Gtkada 社区,但没有成功。

因此,我想向您,Stackoverflow 社区的 Ada 专家和大师请教一些想法或我缺少的东西。

提前谢谢了。此致。

标签: adagtkada

解决方案


问题:你不能直接在 Linux 上运行用 GtkAda 编写的程序。在启动程序之前,您必须始终使用脚本gtkada-env.sh或等效的脚本来为与 GtkAda 捆绑的 Gtk 设置正确的路径和环境变量。

如果您想查看启动脚本的外观,这里有一个小示例:https ://github.com/thindil/hunter/blob/master/hunter.sh

如果您打算使用gtkada-env.sh脚本,您只需要运行一次,因为它会创建一个具有正确路径和变量设置的新默认 shell


推荐阅读