Debian Codegraph @

tests/compile-fail/composite-template-missing-fq-child-attr.rs

raw symbols SCIP
1 // Take a look at the license at the top of the repository in the LICENSE file.
2
3 use gtk::prelude::*;
4 use gtk::glib;
5
6 mod imp {
7 use super::*;
8 use gtk::subclass::prelude::*;
9
10 #[derive(Debug, Default, gtk::CompositeTemplate)]
11 #[template(string = r#"
12 <interface>
13 <template class="MyWidget" parent="GtkWidget">
14 <child>
15 <object class="GtkLabel" id="label"/>
16 </child>
17 </template>
18 </interface>
19 "#)]
20 #[allow(dead_code)]
21 pub struct MyWidget {
22 label: gtk::TemplateChild<gtk::Label>,
23 }
24
25 #[glib::object_subclass]
26 impl ObjectSubclass for MyWidget {
27 const NAME: &'static str = "MyWidget";
28 type Type = super::MyWidget;
29 type ParentType = gtk::Widget;
30 fn class_init(klass: &mut Self::Class) {
31 klass.bind_template();
32 }
33 fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
34 obj.init_template();
35 }
36 }
37
38 impl ObjectImpl for MyWidget {
39 fn dispose(&self) {
40 while let Some(child) = self.obj().first_child() {
41 child.unparent();
42 }
43 }
44 }
45 impl WidgetImpl for MyWidget {}
46 }
47
48 glib::wrapper! {
49 pub struct MyWidget(ObjectSubclass<imp::MyWidget>) @extends gtk::Widget;
50 }
51
52 fn main() {}
53