I'm trying to use libadwaita 1.1 in my Gtk-rs (GTK 4) application in order to access the new PreferenceGroup suffix feature introduced in 1.1. However, when I update my Cargo.toml to use libadwaita 0.1.1 (from 0.1) I get an error in most of my UI files:
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!() }`
I see the suggestion "implement the missing item", but I'm not sure exactly how to do that. Here is the relevant section of 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 {}
}
Here is my 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"
It turned out to be a problem with GTK 0.4.7. If I downgrade to 0.4.6 or upgrade to the 0.5 beta via GitHub, libadwaita 0.1.1 works fine.