update building
This commit is contained in:
parent
5bd625add4
commit
9bb20dcc32
|
@ -12,4 +12,5 @@ gtk = { version = "0.8.1", package = "gtk4", features = ["v4_12"] }
|
|||
rand = "0.8.5"
|
||||
|
||||
[build-dependencies]
|
||||
dirs = "5.0.1"
|
||||
glib-build-tools = "0.19.0"
|
||||
|
|
37
build.rs
37
build.rs
|
@ -1,4 +1,41 @@
|
|||
use dirs;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let home = dirs::home_dir().unwrap().to_str().unwrap().to_string();
|
||||
|
||||
if cfg!(target_os = "windows") {
|
||||
Command::new("mkdir")
|
||||
.arg("C:/ProgramData/glib-2.0/schemas/")
|
||||
.spawn()
|
||||
.expect("failed to make dir for schemas!");
|
||||
Command::new("cp")
|
||||
.arg("resources/org.foxarmy.settings.gschema.xml")
|
||||
.arg("C:/ProgramData/glib-2.0/schemas/")
|
||||
.spawn()
|
||||
.expect("failed to copy schema to dest. dir");
|
||||
Command::new("glib-compile-schemas")
|
||||
.arg("C:/ProgramData/glib-2.0/schemas/")
|
||||
.spawn()
|
||||
.expect("Could not compile glib schemas. Probably you don't have glib build tools on your system.");
|
||||
} else {
|
||||
let path = format!("{}/.local/share/glib-2.0/schemas", &home);
|
||||
Command::new("mkdir")
|
||||
.arg("-p")
|
||||
.arg(&path)
|
||||
.spawn()
|
||||
.expect("failed to make dir for schemas!");
|
||||
Command::new("cp")
|
||||
.arg("resources/org.foxarmy.settings.gschema.xml")
|
||||
.arg(&path)
|
||||
.spawn()
|
||||
.expect("failed to copy schema to dest. dir");
|
||||
Command::new("glib-compile-schemas")
|
||||
.arg(path)
|
||||
.spawn()
|
||||
.expect("Could not compile glib schemas. Probably you don't have glib build tools on your system.");
|
||||
};
|
||||
|
||||
glib_build_tools::compile_resources(
|
||||
&["resources"],
|
||||
"resources/resources.gresource.xml",
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/foxarmy/learn-hieroglyph/">
|
||||
<file compressed="true" preprocess="xml-stripblanks">menu.ui.xml</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">guessing.ui.xml</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">settings.gschema.xml</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">memory_cards_settings.ui.xml</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">org.foxarmy.settings.gschema.xml</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">menu/ui.xml</file>
|
||||
|
||||
<file compressed="true" preprocess="xml-stripblanks">guessing/game/ui.xml</file>
|
||||
<!-- <file compressed="true" preprocess="xml-stripblanks">guessing/settings/ui.xml</file> -->
|
||||
<file compressed="true" preprocess="xml-stripblanks">cards/settings/ui.xml</file>
|
||||
|
||||
<!-- <file compressed="true" preprocess="xml-stripblanks">cards/game/ui.xml</file> -->
|
||||
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -4,19 +4,17 @@ mod ui;
|
|||
|
||||
use crate::ui::menu::MenuScene;
|
||||
|
||||
use gio::Settings;
|
||||
use gtk::{prelude::*, ApplicationWindow};
|
||||
use gtk::{glib, Application, gio};
|
||||
|
||||
const APP_ID: &str = "org.foxarmy.learn-hieroglyph";
|
||||
// const APP: Option<RefCell<Application>> = None;//RefCell::new(Application::builder().application_id(APP_ID).build());
|
||||
// pub const S: Stack = Stack::new();
|
||||
|
||||
fn main() -> glib::ExitCode {
|
||||
print!("cargo:rerun-if-changed=build.rs");
|
||||
gio::resources_register_include!("compiled.gresource")
|
||||
.expect("Cannot include gresources");
|
||||
|
||||
// APP = Option::from(RefCell::new(Application::builder().application_id(APP_ID).build()));
|
||||
// *APP.unwrap().borrow_mut() = Application::builder().application_id(APP_ID).build();
|
||||
|
||||
let app: Application = Application::builder().application_id(APP_ID).build();
|
||||
|
||||
app.connect_activate(test_ui);
|
||||
|
@ -28,8 +26,10 @@ fn main() -> glib::ExitCode {
|
|||
fn test_ui (app: &Application) {
|
||||
let window: ApplicationWindow = MenuScene::new(app).into();
|
||||
|
||||
let settings = Settings::new(APP_ID);
|
||||
|
||||
println!("{}", settings.boolean("is-ktr-enabled"));
|
||||
println!("{}", settings.boolean("is-ktr-enabled"));
|
||||
|
||||
window.present();
|
||||
|
||||
println!("{}", app.windows().len());
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,3 @@
|
|||
mod imp;
|
||||
|
||||
use glib::Object;
|
||||
use gtk::{gio, glib, Application};
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct MemoryCardsSetupScene(ObjectSubclass<imp::MemoryCardsSetupScene>)
|
||||
@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 MemoryCardsSetupScene {
|
||||
pub fn new(app: &Application) -> Self {
|
||||
Object::builder().property("application", app).build()
|
||||
}
|
||||
}
|
||||
pub mod edit;
|
||||
pub mod game;
|
||||
pub mod settings;
|
|
@ -4,7 +4,7 @@ use gtk::{glib, Button, CompositeTemplate};
|
|||
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/org/foxarmy/learn-hieroglyph/memory_cards_settings.ui.xml")]
|
||||
#[template(resource = "/org/foxarmy/learn-hieroglyph/cards/settings/ui.xml")]
|
||||
pub struct MemoryCardsSetupScene {
|
||||
#[template_child]
|
||||
pub edit_button: TemplateChild<Button>,
|
|
@ -0,0 +1,17 @@
|
|||
mod imp;
|
||||
|
||||
use glib::Object;
|
||||
use gtk::{gio, glib, Application};
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct MemoryCardsSetupScene(ObjectSubclass<imp::MemoryCardsSetupScene>)
|
||||
@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 MemoryCardsSetupScene {
|
||||
pub fn new(app: &Application) -> Self {
|
||||
Object::builder().property("application", app).build()
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ use rand::Rng;
|
|||
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/org/foxarmy/learn-hieroglyph/guessing.ui.xml")]
|
||||
#[template(resource = "/org/foxarmy/learn-hieroglyph/guessing/game/ui.xml")]
|
||||
pub struct GuessingScene {
|
||||
#[template_child]
|
||||
pub question_label: TemplateChild<Label>,
|
|
@ -0,0 +1,17 @@
|
|||
mod imp;
|
||||
|
||||
use glib::Object;
|
||||
use gtk::{gio, glib, Application};
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct GuessingScene(ObjectSubclass<imp::GuessingScene>)
|
||||
@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 GuessingScene {
|
||||
pub fn new(app: &Application) -> Self {
|
||||
Object::builder().property("application", app).build()
|
||||
}
|
||||
}
|
|
@ -1,17 +1,2 @@
|
|||
mod imp;
|
||||
|
||||
use glib::Object;
|
||||
use gtk::{gio, glib, Application};
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct GuessingScene(ObjectSubclass<imp::GuessingScene>)
|
||||
@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 GuessingScene {
|
||||
pub fn new(app: &Application) -> Self {
|
||||
Object::builder().property("application", app).build()
|
||||
}
|
||||
}
|
||||
pub mod settings;
|
||||
pub mod game;
|
|
@ -1,4 +1,4 @@
|
|||
use crate::ui::{guessing::GuessingScene, cards::MemoryCardsSetupScene};
|
||||
use crate::ui::{guessing::game::GuessingScene, cards::settings::MemoryCardsSetupScene};
|
||||
|
||||
use glib::subclass::InitializingObject;
|
||||
use gtk::glib::closure_local;
|
||||
|
@ -6,7 +6,7 @@ use gtk::subclass::prelude::*;
|
|||
use gtk::{glib, prelude::*, Box, Button, CompositeTemplate};
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/org/foxarmy/learn-hieroglyph/menu.ui.xml")]
|
||||
#[template(resource = "/org/foxarmy/learn-hieroglyph/menu/ui.xml")]
|
||||
pub struct MenuScene {
|
||||
#[template_child]
|
||||
pub content: TemplateChild<Box>,
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<schemalist>
|
||||
<schema id="org.foxarmy.learn-hieroglyph" path="/org/foxarmy/learn-hieroglyph/">
|
||||
<key name="is-rtk-enabled" type="b">
|
||||
<default>false</default>
|
||||
<summary>Enable romaji to kana</summary>
|
||||
</key>
|
||||
<key name="is-ktr-enabled" type="b">
|
||||
<default>true</default>
|
||||
<summary>Enable kana to romaji</summary>
|
||||
</key>
|
||||
<key name="is-hiragana-enabled" type="b">
|
||||
<default>true</default>
|
||||
<summary>Enable hiragana</summary>
|
||||
</key>
|
||||
<key name="is-katakana-enabled" type="b">
|
||||
<default>false</default>
|
||||
<summary>Enable katakana</summary>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<schemalist>
|
||||
<schema id="org.foxarmy.learn-hieroglyph" path="/org/foxarmy/learn-hieroglyph/">
|
||||
<key name="is-rtk-enabled" type="b">
|
||||
<default>false</default>
|
||||
<summary>Enable romaji to kana</summary>
|
||||
</key>
|
||||
<key name="is-ktr-enabled" type="b">
|
||||
<default>true</default>
|
||||
<summary>Enable kana to romaji</summary>
|
||||
</key>
|
||||
<key name="is-hiragana-enabled" type="b">
|
||||
<default>true</default>
|
||||
<summary>Enable hiragana</summary>
|
||||
</key>
|
||||
<key name="is-katakana-enabled" type="b">
|
||||
<default>false</default>
|
||||
<summary>Enable katakana</summary>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
Loading…
Reference in New Issue