c - 如何让 GTK 识别我创建的模板?

标签 c gtk gtk3

存储库位于:https://gitlab.com/tristan957/tllt-cp

程序编译顺利。我有一些未使用的变量,但这很好。在运行时,我看到以下警告,并且我运行的 GUI 与我提供的模板不同。

(tllt-cp:28723): Gtk-CRITICAL **: 22:18:00.249: Unable to load resource for composite template for type 'TlltCpWindow': The resource at “/com/gitlab/tristan957/TlltCp/tllt-cp-window.ui” does not exist

(tllt-cp:28723): Gtk-CRITICAL **: 22:18:00.249: gtk_widget_class_bind_template_child_full: assertion 'widget_class->priv->template != NULL' failed

(tllt-cp:28723): Gtk-CRITICAL **: 22:18:00.249: gtk_widget_class_bind_template_child_full: assertion 'widget_class->priv->template != NULL' failed
Initializing object

(tllt-cp:28723): Gtk-CRITICAL **: 22:18:00.249: gtk_widget_init_template: assertion 'template != NULL' failed

我不确定我错过了什么。

最佳答案

我需要添加以下功能

static void
tllt_cp_application_startup(GApplication *self)
{
    g_resources_register(tllt_cp_get_resource());
    g_application_set_resource_base_path(self, "/com/gitlab/tristan957/TlltCp");

    G_APPLICATION_CLASS(tllt_cp_application_parent_class)->startup(self);
}

关于c - 如何让 GTK 识别我创建的模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54662683/

相关文章:

gtk - 如何让 GtkTextView 看起来像 GtkEntry?

c++ - 小部件不在 Gtk 窗口内

visual-studio - 错误3错误LNK1104 : cannot open file 'gtk-3.lib'

python - 带有 PyGObject 自省(introspection) Gtk+ 3 的 GenericTreeModel?

c - 什么是具有副作用的表达式?为什么不应将它们传递给宏?

c - 使用硬编码内存地址主机测试 C 程序

c - 在 C 中表示二叉树的递归函数

linux - 如何处理不匹配的共享对象的 "undefined symbol"错误

c - MPI:处理器在单个 MPI 进程上无法达到 100%

gtk3 - 使用CSS设置gtk textview选择颜色