2024-04-07 14:08:57 +03:00
|
|
|
use std::cell::RefCell;
|
|
|
|
|
|
|
|
use glib::subclass::InitializingObject;
|
|
|
|
use glib::Properties;
|
|
|
|
use gtk::subclass::prelude::*;
|
2024-04-08 16:34:14 +03:00
|
|
|
use gtk::{glib, prelude::*, BoxLayout, CompositeTemplate, Entry, Label, Picture};
|
2024-04-07 14:08:57 +03:00
|
|
|
|
|
|
|
#[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<Picture>,
|
|
|
|
#[template_child]
|
|
|
|
pub answer_entry: TemplateChild<Entry>,
|
2024-04-08 16:34:14 +03:00
|
|
|
#[template_child]
|
|
|
|
pub error_message: TemplateChild<Label>,
|
2024-04-07 14:08:57 +03:00
|
|
|
#[property(get, set)]
|
|
|
|
pub imagepath: RefCell<String>,
|
|
|
|
#[property(get, set)]
|
|
|
|
pub hieroglyph: RefCell<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[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::<gtk::BoxLayout>();
|
|
|
|
// klass.set_layout_manager_type(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn instance_init(obj: &InitializingObject<Self>) {
|
|
|
|
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));
|
2024-04-08 16:34:14 +03:00
|
|
|
self.picture.set_width_request(256);
|
|
|
|
self.picture.set_height_request(256);
|
|
|
|
// self.picture.
|
|
|
|
// self.picture.set
|
2024-04-07 14:08:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn dispose(&self) {
|
|
|
|
self.dispose_template();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl WidgetImpl for CardDisplay {}
|