some renaming, creating GuessingSetup scene and LabledSwitch

This commit is contained in:
2024-04-02 01:32:41 +03:00
parent e0ef46d0b8
commit 1da36b93d1
18 changed files with 146 additions and 70 deletions

View File

@@ -1,3 +1,3 @@
pub mod edit;
pub mod game;
pub mod settings;
pub mod setup;

View File

@@ -1,2 +1,2 @@
pub mod settings;
pub mod setup;
pub mod game;

View File

@@ -0,0 +1,41 @@
use crate::labled_switch::LabledSwitch;
use glib::subclass::InitializingObject;
use gtk::subclass::prelude::*;
use gtk::{glib, CompositeTemplate};
#[derive(CompositeTemplate, Default)]
#[template(resource = "/org/foxarmy/learn-hieroglyph/guessing/setup/ui.xml")]
pub struct GuessingSetupScene {
#[template_child]
pub question_label: TemplateChild<LabledSwitch>,
}
#[glib::object_subclass]
impl ObjectSubclass for GuessingSetupScene {
const NAME: &'static str = "GuessingSetupScene";
type Type = super::GuessingSetupScene;
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 GuessingSetupScene {
fn constructed(&self) {
self.parent_constructed();
}
}
impl WidgetImpl for GuessingSetupScene {}
impl WindowImpl for GuessingSetupScene {}
impl ApplicationWindowImpl for GuessingSetupScene {}

View File

@@ -0,0 +1,17 @@
mod imp;
use glib::Object;
use gtk::{gio, glib, Application};
glib::wrapper! {
pub struct GuessingSetupScene(ObjectSubclass<imp::GuessingSetupScene>)
@extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
@implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
}
impl GuessingSetupScene {
pub fn new(app: &Application) -> Self {
Object::builder().property("application", app).build()
}
}

View File

@@ -1,4 +1,4 @@
use crate::ui::{guessing::game::GuessingScene, cards::settings::MemoryCardsSetupScene};
use crate::ui::{guessing::setup::GuessingSetupScene, cards::setup::MemoryCardsSetupScene};
use glib::subclass::InitializingObject;
use gtk::glib::closure_local;
@@ -41,7 +41,7 @@ impl ObjectImpl for MenuScene {
"clicked",
false,
closure_local!(@strong binding => move |_button: &Button| {
let new_win: GuessingScene = GuessingScene::new(&binding.application().unwrap());
let new_win: GuessingSetupScene = GuessingSetupScene::new(&binding.application().unwrap());
new_win.present();
}),
);

View File

@@ -1,6 +1,6 @@
pub(crate) mod menu;
pub(crate) mod guessing;
mod cards;
pub mod menu;
pub mod guessing;
pub mod cards;
// use crate::ui::menu::build_menu_scene;