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

时间:2019-02-13 04:46:11

标签: 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

我不确定我缺少什么。

1 个答案:

答案 0 :(得分:0)

我需要添加以下功能

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);
}