use std::cell::RefCell; use glib::subclass::InitializingObject; use glib::Properties; use gtk::subclass::prelude::*; use gtk::{glib, prelude::*, BoxLayout, CompositeTemplate, Entry, Picture}; #[derive(CompositeTemplate, Properties, Default)] #[properties(wrapper_type = super::CardDisplay)] #[template(resource = "/org/foxarmy/learn-hieroglyph/widgets/card_display/template.ui.xml")] pub struct CardDisplay { #[template_child] pub picture: TemplateChild, #[template_child] pub answer_entry: TemplateChild, #[property(get, set)] pub imagepath: RefCell, #[property(get, set)] pub hieroglyph: RefCell, } #[glib::object_subclass] impl ObjectSubclass for CardDisplay { const NAME: &'static str = "CardDisplay"; type Type = super::CardDisplay; type ParentType = gtk::Widget; fn class_init(klass: &mut Self::Class) { klass.bind_template(); klass.set_layout_manager_type::(); // klass.set_layout_manager_type(a); } fn instance_init(obj: &InitializingObject) { obj.init_template(); } } #[glib::derived_properties] impl ObjectImpl for CardDisplay { fn constructed(&self) { self.parent_constructed(); let layout_manager: BoxLayout = BoxLayout::new(gtk::Orientation::Vertical); self.obj().set_layout_manager(Some(layout_manager)); } fn dispose(&self) { self.dispose_template(); } } impl WidgetImpl for CardDisplay {}