缺少 libadwaita-rs 1.1 check_template_children

libadwaita-rs 1.1 missing check_template_children

我正在尝试在我的 Gtk-rs (GTK 4) 应用程序中使用 libadwaita 1.1,以便访问 1.1 中引入的新 PreferenceGroup 后缀功能。但是,当我更新 Cargo.toml 以使用 libadwaita 0.1.1(从 0.1 开始)时,我在大多数 UI 文件中遇到错误:

error[E0046]: not all trait items implemented, missing: `check_template_children`
  --> src/ui/window.rs:39:30
   |
39 |     #[derive(Debug, Default, CompositeTemplate)]
   |                              ^^^^^^^^^^^^^^^^^ missing `check_template_children` in implementation
   |
   = note: this error originates in the derive macro `CompositeTemplate` (in Nightly builds, run with -Z macro-backtrace for more info)
   = help: implement the missing item: `fn check_template_children(_: &<Self as gtk4::subclass::prelude::ObjectSubclass>::Type) { todo!() }`

我看到了“实施缺失项目”的建议,但我不确定具体该怎么做。这是window.rs的相关部分:

mod imp {
    use super::*;

    #[derive(Debug, Default, CompositeTemplate)]
    #[template(resource = "/com/lakoliu/Furtherance/gtk/window.ui")]
    pub struct FurtheranceWindow {
        // Template widgets
        #[template_child]
        pub header_bar: TemplateChild<gtk::HeaderBar>,
        ...
    }

    #[glib::object_subclass]
    impl ObjectSubclass for FurtheranceWindow {
        const NAME: &'static str = "FurtheranceWindow";
        type Type = super::FurtheranceWindow;
        type ParentType = adw::ApplicationWindow;

        fn class_init(klass: &mut Self::Class) {
            FurHistoryBox::static_type();
            Self::bind_template(klass);
        }

        fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
            obj.init_template();
        }
    }

    impl ObjectImpl for FurtheranceWindow {
        fn constructed(&self, obj: &Self::Type) {
            obj.setup_widgets();
            self.parent_constructed(obj);
        }
    }
    impl WidgetImpl for FurtheranceWindow {}
    impl WindowImpl for FurtheranceWindow {}
    impl ApplicationWindowImpl for FurtheranceWindow {}
    impl AdwApplicationWindowImpl for FurtheranceWindow {}
}

这是我的 Cargo.toml:

[dependencies]
gettext-rs = { version = "0.7", features = ["gettext-system"] }
rusqlite = "0.26.3"
chrono = "0.4"
directories = "4.0"
once_cell = "1.9.0"
dbus = "0.9.5"
dbus-codegen = "0.10.0"
log = "0.4"

[dependencies.gtk]
package = "gtk4"
version = "0.4.7"

[dependencies.adw]
package = "libadwaita"
version = "0.1.1"

原来是GTK 0.4.7的问题。如果我通过 GitHub 降级到 0.4.6 或升级到 0.5 beta,libadwaita 0.1.1 工作正常。