update building
This commit is contained in:
		| @@ -12,4 +12,5 @@ gtk = { version = "0.8.1", package = "gtk4", features = ["v4_12"] } | |||||||
| rand = "0.8.5" | rand = "0.8.5" | ||||||
|  |  | ||||||
| [build-dependencies] | [build-dependencies] | ||||||
|  | dirs = "5.0.1" | ||||||
| glib-build-tools = "0.19.0" | glib-build-tools = "0.19.0" | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								build.rs
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								build.rs
									
									
									
									
									
								
							| @@ -1,4 +1,41 @@ | |||||||
|  | use dirs; | ||||||
|  | use std::process::Command; | ||||||
|  |  | ||||||
| fn main() { | 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( |     glib_build_tools::compile_resources( | ||||||
|         &["resources"], |         &["resources"], | ||||||
|         "resources/resources.gresource.xml", |         "resources/resources.gresource.xml", | ||||||
|   | |||||||
							
								
								
									
										0
									
								
								resources/cards/game/ui.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								resources/cards/game/ui.xml
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								resources/guessing/settings/ui.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								resources/guessing/settings/ui.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -1,9 +1,14 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <gresources> | <gresources> | ||||||
|   <gresource prefix="/org/foxarmy/learn-hieroglyph/"> |   <gresource prefix="/org/foxarmy/learn-hieroglyph/"> | ||||||
|     <file compressed="true" preprocess="xml-stripblanks">menu.ui.xml</file> |     <file compressed="true" preprocess="xml-stripblanks">org.foxarmy.settings.gschema.xml</file> | ||||||
|     <file compressed="true" preprocess="xml-stripblanks">guessing.ui.xml</file> |     <file compressed="true" preprocess="xml-stripblanks">menu/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">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> |   </gresource> | ||||||
| </gresources> | </gresources> | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -4,19 +4,17 @@ mod ui; | |||||||
|  |  | ||||||
| use crate::ui::menu::MenuScene; | use crate::ui::menu::MenuScene; | ||||||
|  |  | ||||||
|  | use gio::Settings; | ||||||
| use gtk::{prelude::*, ApplicationWindow}; | use gtk::{prelude::*, ApplicationWindow}; | ||||||
| use gtk::{glib, Application, gio}; | use gtk::{glib, Application, gio}; | ||||||
|  |  | ||||||
| const APP_ID: &str = "org.foxarmy.learn-hieroglyph"; | 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 { | fn main() -> glib::ExitCode { | ||||||
|  |     print!("cargo:rerun-if-changed=build.rs"); | ||||||
|     gio::resources_register_include!("compiled.gresource") |     gio::resources_register_include!("compiled.gresource") | ||||||
|         .expect("Cannot include gresources"); |         .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(); |     let app: Application = Application::builder().application_id(APP_ID).build(); | ||||||
|  |  | ||||||
|     app.connect_activate(test_ui); |     app.connect_activate(test_ui); | ||||||
| @@ -28,8 +26,10 @@ fn main() -> glib::ExitCode { | |||||||
| fn test_ui (app: &Application) { | fn test_ui (app: &Application) { | ||||||
|     let window: ApplicationWindow = MenuScene::new(app).into(); |     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(); |     window.present(); | ||||||
|  |  | ||||||
|     println!("{}", app.windows().len()); |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										0
									
								
								src/ui/cards/edit/imp.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/ui/cards/edit/imp.rs
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								src/ui/cards/edit/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/ui/cards/edit/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								src/ui/cards/game/imp.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/ui/cards/game/imp.rs
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								src/ui/cards/game/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/ui/cards/game/mod.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -1,17 +1,3 @@ | |||||||
| mod imp; | pub mod edit; | ||||||
|  | pub mod game; | ||||||
| use glib::Object; | pub mod settings; | ||||||
| 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() |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -4,7 +4,7 @@ use gtk::{glib, Button, CompositeTemplate}; | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #[derive(CompositeTemplate, Default)] | #[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 { | pub struct MemoryCardsSetupScene { | ||||||
|     #[template_child] |     #[template_child] | ||||||
|     pub edit_button: TemplateChild<Button>, |     pub edit_button: TemplateChild<Button>, | ||||||
							
								
								
									
										17
									
								
								src/ui/cards/settings/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/ui/cards/settings/mod.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -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)] | #[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 { | pub struct GuessingScene { | ||||||
|     #[template_child] |     #[template_child] | ||||||
|     pub question_label: TemplateChild<Label>, |     pub question_label: TemplateChild<Label>, | ||||||
							
								
								
									
										17
									
								
								src/ui/guessing/game/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/ui/guessing/game/mod.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -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; | pub mod settings; | ||||||
|  | pub mod game; | ||||||
| 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() |  | ||||||
|     } |  | ||||||
| } |  | ||||||
							
								
								
									
										0
									
								
								src/ui/guessing/settings/imp.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/ui/guessing/settings/imp.rs
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								src/ui/guessing/settings/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/ui/guessing/settings/mod.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -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 glib::subclass::InitializingObject; | ||||||
| use gtk::glib::closure_local; | use gtk::glib::closure_local; | ||||||
| @@ -6,7 +6,7 @@ use gtk::subclass::prelude::*; | |||||||
| use gtk::{glib, prelude::*, Box, Button, CompositeTemplate}; | use gtk::{glib, prelude::*, Box, Button, CompositeTemplate}; | ||||||
|  |  | ||||||
| #[derive(CompositeTemplate, Default)] | #[derive(CompositeTemplate, Default)] | ||||||
| #[template(resource = "/org/foxarmy/learn-hieroglyph/menu.ui.xml")] | #[template(resource = "/org/foxarmy/learn-hieroglyph/menu/ui.xml")] | ||||||
| pub struct MenuScene { | pub struct MenuScene { | ||||||
|     #[template_child] |     #[template_child] | ||||||
|     pub content: TemplateChild<Box>, |     pub content: TemplateChild<Box>, | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								{}/.local/share/glib-2.0/schemas/home/leca/gschemas.compiled
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								{}/.local/share/glib-2.0/schemas/home/leca/gschemas.compiled
									
									
									
									
									
										Normal file
									
								
							
										
											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> | ||||||
		Reference in New Issue
	
	Block a user