How do I get the parent of a CompositeTemplate in gtk-rs?
#[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(resource = "/org/bil4x4/gnote/tree_view")]
pub struct GnoteTreeView {
#[template_child]
pub tree_store: TemplateChild<gtk::TreeStore>,
pub add_note_visible: Cell<bool>,
pub add_folder_visible: Cell<bool>,
pub remove_item_visible: Cell<bool>,
}
#[glib::object_subclass]
impl ObjectSubclass for GnoteTreeView {
const NAME: &'static str = "GnoteTreeView";
type Type = super::GnoteTreeView;
type ParentType = gtk::TreeView;
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
klass.bind_template_instance_callbacks();
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
so in the impl GnoteTreeView
section I am not sure how to get the gtk::TreeView
. I am pretty sure it is something like self.imp().?
I have tried looking in self.imp().?
and I am expecting to get a reference to the gtk::TreeView
from the CompositeTemplate parent.
The answer is to use
self.imp().instance()