69 lines
1.9 KiB
Rust
69 lines
1.9 KiB
Rust
use crate::ui::{cards::setup::MemoryCardsSetupScene, guessing::setup::GuessingSetupScene};
|
|
|
|
use glib::subclass::InitializingObject;
|
|
use gtk::glib::closure_local;
|
|
use gtk::subclass::prelude::*;
|
|
use gtk::{glib, prelude::*, Box, Button, CompositeTemplate};
|
|
|
|
#[derive(CompositeTemplate, Default)]
|
|
#[template(resource = "/org/foxarmy/learn-hieroglyph/menu/ui.xml")]
|
|
pub struct MenuScene {
|
|
#[template_child]
|
|
pub content: TemplateChild<Box>,
|
|
#[template_child]
|
|
pub hiragana_and_katakana: TemplateChild<Button>,
|
|
#[template_child]
|
|
pub memory_cards: TemplateChild<Button>,
|
|
}
|
|
|
|
#[glib::object_subclass]
|
|
impl ObjectSubclass for MenuScene {
|
|
const NAME: &'static str = "MenuScene";
|
|
type Type = super::MenuScene;
|
|
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 MenuScene {
|
|
fn constructed(&self) {
|
|
self.parent_constructed();
|
|
|
|
let binding = self.obj();
|
|
|
|
self.hiragana_and_katakana.connect_closure(
|
|
"clicked",
|
|
false,
|
|
closure_local!(@strong binding => move |_button: &Button| {
|
|
let new_win: GuessingSetupScene = GuessingSetupScene::new(&binding.application().unwrap());
|
|
new_win.present();
|
|
}),
|
|
);
|
|
|
|
self.memory_cards.connect_closure(
|
|
"clicked",
|
|
false,
|
|
closure_local!(@strong binding => move |_button: &Button| {
|
|
let new_win: MemoryCardsSetupScene = MemoryCardsSetupScene::new(&binding.application().unwrap());
|
|
new_win.present();
|
|
}),
|
|
);
|
|
}
|
|
}
|
|
|
|
impl WidgetImpl for MenuScene {}
|
|
|
|
impl WindowImpl for MenuScene {
|
|
fn activate_default(&self) {
|
|
self.parent_activate_default();
|
|
}
|
|
}
|
|
|
|
impl ApplicationWindowImpl for MenuScene {}
|