2024-04-07 14:08:57 +03:00
|
|
|
use crate::ui::cards::{edit::MemoryCardsEditScene, game::MemoryCardsGameScene};
|
2024-04-05 12:42:02 +03:00
|
|
|
|
2024-04-01 15:42:50 +03:00
|
|
|
use glib::subclass::InitializingObject;
|
2024-04-05 12:42:02 +03:00
|
|
|
use gtk::glib::closure_local;
|
2024-04-01 15:42:50 +03:00
|
|
|
use gtk::subclass::prelude::*;
|
2024-04-05 12:42:02 +03:00
|
|
|
use gtk::{glib, prelude::*, Button, CompositeTemplate};
|
2024-04-01 15:42:50 +03:00
|
|
|
|
|
|
|
#[derive(CompositeTemplate, Default)]
|
2024-04-05 12:42:02 +03:00
|
|
|
#[template(resource = "/org/foxarmy/learn-hieroglyph/cards/setup/ui.xml")]
|
2024-04-01 15:42:50 +03:00
|
|
|
pub struct MemoryCardsSetupScene {
|
|
|
|
#[template_child]
|
|
|
|
pub edit_button: TemplateChild<Button>,
|
|
|
|
#[template_child]
|
2024-04-02 15:23:56 +03:00
|
|
|
pub start_button: TemplateChild<Button>,
|
2024-04-01 15:42:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[glib::object_subclass]
|
|
|
|
impl ObjectSubclass for MemoryCardsSetupScene {
|
|
|
|
const NAME: &'static str = "MemoryCardsSetupScene";
|
|
|
|
type Type = super::MemoryCardsSetupScene;
|
|
|
|
type ParentType = gtk::ApplicationWindow;
|
|
|
|
|
|
|
|
fn class_init(klass: &mut Self::Class) {
|
|
|
|
klass.bind_template();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn instance_init(obj: &InitializingObject<Self>) {
|
|
|
|
obj.init_template();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ObjectImpl for MemoryCardsSetupScene {
|
|
|
|
fn constructed(&self) {
|
|
|
|
self.parent_constructed();
|
2024-04-05 12:42:02 +03:00
|
|
|
|
|
|
|
let binding = self.obj();
|
|
|
|
|
2024-04-07 14:08:57 +03:00
|
|
|
self.edit_button.connect_closure("clicked",false, closure_local!(@strong binding => move |_b: &Button| {
|
2024-04-05 12:42:02 +03:00
|
|
|
let new_win: MemoryCardsEditScene = MemoryCardsEditScene::new(&binding.application().unwrap());
|
|
|
|
new_win.present();
|
|
|
|
})
|
|
|
|
);
|
2024-04-07 14:08:57 +03:00
|
|
|
|
|
|
|
self.start_button.connect_closure("clicked", false, closure_local!(@strong binding => move |_b: &Button| {
|
|
|
|
let new_win: MemoryCardsGameScene = MemoryCardsGameScene::new(&binding.application().unwrap());
|
|
|
|
new_win.present();
|
|
|
|
}),
|
|
|
|
);
|
2024-04-01 15:42:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl WidgetImpl for MemoryCardsSetupScene {}
|
|
|
|
|
|
|
|
impl WindowImpl for MemoryCardsSetupScene {}
|
|
|
|
|
2024-04-02 15:23:56 +03:00
|
|
|
impl ApplicationWindowImpl for MemoryCardsSetupScene {}
|