diff --git a/AppImage/.DirIcon b/AppImage/.DirIcon new file mode 120000 index 0000000..12585c9 --- /dev/null +++ b/AppImage/.DirIcon @@ -0,0 +1 @@ +icon.png \ No newline at end of file diff --git a/AppImage/AppRun b/AppImage/AppRun new file mode 100755 index 0000000..c5f1c0b --- /dev/null +++ b/AppImage/AppRun @@ -0,0 +1,2 @@ +#!/bin/bash +exec $APPDIR/usr/bin/learn-hieroglyph diff --git a/AppImage/icon.png b/AppImage/icon.png new file mode 100644 index 0000000..7ee14c3 Binary files /dev/null and b/AppImage/icon.png differ diff --git a/AppImage/learn-hieroglyph.desktop b/AppImage/learn-hieroglyph.desktop new file mode 100644 index 0000000..cd29199 --- /dev/null +++ b/AppImage/learn-hieroglyph.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Type=Application +Name=Learn Hieroglyph +Exec=learn-hieroglyph +Icon=icon +Categories=Utility; diff --git a/AppImage/usr/bin/learn-hieroglyph b/AppImage/usr/bin/learn-hieroglyph new file mode 100755 index 0000000..3e46893 Binary files /dev/null and b/AppImage/usr/bin/learn-hieroglyph differ diff --git a/AppImage/usr/share/glib-2.0/schemas/gschemas.compiled b/AppImage/usr/share/glib-2.0/schemas/gschemas.compiled new file mode 100644 index 0000000..17e0624 Binary files /dev/null and b/AppImage/usr/share/glib-2.0/schemas/gschemas.compiled differ diff --git a/build.rs b/build.rs index 19284ad..50d1c3b 100644 --- a/build.rs +++ b/build.rs @@ -30,6 +30,10 @@ fn main() { .arg(&path) .spawn() .expect("failed to copy schema to dest. dir"); + Command::new("glib-compile-schemas") + .arg("resources") + .spawn() + .expect("Could not compile glib schemas. Probably you don't have glib build tools on your system."); Command::new("glib-compile-schemas") .arg(path) .spawn() diff --git a/build_for_windows.sh b/build_for_windows.sh new file mode 100755 index 0000000..d5d69da --- /dev/null +++ b/build_for_windows.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +#This script is intended to help with building for windows systems. Everyting was +#snatched from https://martinber.github.io/gtk-rs.github.io/docs-src/tutorial/cross. +#Before executing, you need to install some libraries. +#Arch linux: yay -S mingw-w64-gtk4 +#Other distros: Feeling pity for u :) +#Useful: https://web.archive.org/web/20180719181100/http://win32builder.gnome.org/ + +if [[ $1 == "" ]]; then + echo "[WARNING] PKG_CONFIG_PATH as a first argument was not defined. Using default value '/usr/i686-w64-mingw32/lib/pkgconfig'" + export PKG_CONFIG_PATH=/usr/i686-w64-mingw32/lib/pkgconfig +else + echo "[INFO] Setting PKG_CONFIG_PATH to '$1'" + export PKG_CONFIG_PATH=$1 +fi +export PKG_CONFIG_ALLOW_CROSS=1 +cargo build --target=x86_64-pc-windows-gnu --release diff --git a/pack_appimage.sh b/pack_appimage.sh new file mode 100755 index 0000000..6e118ff --- /dev/null +++ b/pack_appimage.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if ! command -v appimagetool &> /dev/null +then + echo "No appimage tool installed. Please, install it." + exit 1 +fi + +cargo build --release + +mkdir -p AppImage/usr/bin +mkdir -p AppImage/usr/share/glib-2.0/schemas +cp resources/gschemas.compiled AppImage/usr/share/glib-2.0/schemas/ # Copy settings +cp target/release/learn-hieroglyph AppImage/usr/bin + +chmod +x AppImage/AppRun +ARCH=x86_64 appimagetool AppImage learn-hieroglyph.AppImage diff --git a/src/main.rs b/src/main.rs index f352787..66a9c35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,4 @@ -/* -TODOS: - 4. With incorrect answerd card, it shows hieroglyp, reading ant its translation -*/ +#![windows_subsystem = "windows"] mod db; mod game; diff --git a/src/ui/cards/game/imp.rs b/src/ui/cards/game/imp.rs index bdedf99..b2d6d1d 100644 --- a/src/ui/cards/game/imp.rs +++ b/src/ui/cards/game/imp.rs @@ -52,7 +52,7 @@ impl ObjectImpl for MemoryCardsGameScene { let self_binding = self.obj(); self.update_card(); - + card_display_binding.get_answer_entry().connect_activate(clone!(@strong card_display_binding, @strong self_binding => move |e: &Entry| { card_display_binding.imp().incorrect_message.set_visible(false); let incorrect_message_label = &card_display_binding.imp().incorrect_message; @@ -70,8 +70,6 @@ impl ObjectImpl for MemoryCardsGameScene { e.set_text(""); })); } - - } impl MemoryCardsGameScene { @@ -83,8 +81,8 @@ impl MemoryCardsGameScene { self.card_display.set_reading(card.reading()); self.card_display.set_translation(card.translation()); self.card_display.update_file_for_image(); - }, - None => { self.obj().show_no_cards_msg() } + } + None => self.obj().show_no_cards_msg(), } } } @@ -114,7 +112,12 @@ fn generate_card() -> Option { None => return None, }; let generated_card = CardDisplay::new( - &(get_images_store_path() + "/" + &random_card.image_path().unwrap()), + &(get_images_store_path() + + "/" + + match &random_card.image_path() { + Some(path) => &path[..], + None => return None, + }), &random_card.hieroglyph().unwrap(), Some(&random_card.reading().unwrap()), &random_card.translation().unwrap(),