Windows GUI
This commit is contained in:
Generated
+238
@@ -30,6 +30,12 @@ version = "1.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitvec"
|
name = "bitvec"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
@@ -51,6 +57,12 @@ dependencies = [
|
|||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.20.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
@@ -244,6 +256,30 @@ version = "2.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
|
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-task"
|
||||||
|
version = "0.3.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-util"
|
||||||
|
version = "0.3.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-task",
|
||||||
|
"pin-project-lite",
|
||||||
|
"slab",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "generic-array"
|
name = "generic-array"
|
||||||
version = "0.14.7"
|
version = "0.14.7"
|
||||||
@@ -282,12 +318,36 @@ dependencies = [
|
|||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.98"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"futures-util",
|
||||||
|
"once_cell",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.186"
|
version = "0.2.186"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libm"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsvld"
|
name = "libsvld"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -332,6 +392,43 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "native-windows-derive"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76134ae81020d89d154f619fd2495a2cecad204276b1dc21174b55e4d0975edd"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-crate",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "native-windows-gui"
|
||||||
|
version = "1.0.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4f7003a669f68deb6b7c57d74fff4f8e533c44a3f0b297492440ef4ff5a28454"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"lazy_static",
|
||||||
|
"newline-converter",
|
||||||
|
"plotters",
|
||||||
|
"plotters-backend",
|
||||||
|
"stretch",
|
||||||
|
"winapi",
|
||||||
|
"winapi-build",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "newline-converter"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1f71d09d5c87634207f894c6b31b6a2b2c64ea3bdcf71bd5599fdbbe1600c00f"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-segmentation",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nom"
|
||||||
version = "7.1.3"
|
version = "7.1.3"
|
||||||
@@ -360,6 +457,12 @@ dependencies = [
|
|||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.21.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "page_size"
|
name = "page_size"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
@@ -413,6 +516,30 @@ dependencies = [
|
|||||||
"sha2",
|
"sha2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
"plotters-backend",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-backend"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "positioned-io"
|
name = "positioned-io"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
@@ -424,6 +551,15 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-crate"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
|
||||||
|
dependencies = [
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.106"
|
version = "1.0.106"
|
||||||
@@ -515,6 +651,22 @@ dependencies = [
|
|||||||
"digest",
|
"digest",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slab"
|
||||||
|
version = "0.4.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stretch"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b0dc6d20ce137f302edf90f9cd3d278866fd7fb139efca6f246161222ad6d87"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"libm",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "svldcli"
|
name = "svldcli"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -523,6 +675,16 @@ dependencies = [
|
|||||||
"libsvld",
|
"libsvld",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "svldgui"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"can-dbc 9.1.0",
|
||||||
|
"libsvld",
|
||||||
|
"native-windows-derive",
|
||||||
|
"native-windows-gui",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.109"
|
version = "1.0.109"
|
||||||
@@ -571,6 +733,15 @@ dependencies = [
|
|||||||
"syn 2.0.117",
|
"syn 2.0.117",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typenum"
|
name = "typenum"
|
||||||
version = "1.20.0"
|
version = "1.20.0"
|
||||||
@@ -589,6 +760,12 @@ version = "1.0.24"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-segmentation"
|
||||||
|
version = "1.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.5"
|
version = "0.9.5"
|
||||||
@@ -604,6 +781,61 @@ dependencies = [
|
|||||||
"rayon",
|
"rayon",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.121"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.121"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.121"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.117",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.121"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.98"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b572dff8bcf38bad0fa19729c89bb5748b2b9b1d8be70cf90df697e3a8f32aa"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@@ -614,6 +846,12 @@ dependencies = [
|
|||||||
"winapi-x86_64-pc-windows-gnu",
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-build"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-i686-pc-windows-gnu"
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
|||||||
+3
-2
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "3"
|
resolver = "3"
|
||||||
members = ["libsvld", "svldcli"]
|
members = ["libsvld", "svldcli", "svldgui"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
@@ -15,7 +15,8 @@ panic = "abort"
|
|||||||
[profile.release-dbg]
|
[profile.release-dbg]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
|
||||||
lto = "thin"
|
# lto = "thin"
|
||||||
|
lto = false
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
debug = true
|
debug = true
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
name = "svldgui"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "svldgui"
|
||||||
|
test = false
|
||||||
|
bench = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
libsvld = { path = "../libsvld" }
|
||||||
|
native-windows-gui = { version = "1.0.13", features = ["file-dialog"] }
|
||||||
|
native-windows-derive = "1.0.5"
|
||||||
|
can-dbc = "9.1.0"
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
|
extern crate native_windows_gui as nwg;
|
||||||
|
extern crate native_windows_derive as nwd;
|
||||||
|
|
||||||
|
use std::{cell::RefCell, ffi::OsStr, fs, path::PathBuf};
|
||||||
|
|
||||||
|
use can_dbc::Dbc;
|
||||||
|
use nwd::NwgUi;
|
||||||
|
use nwg::NativeUi;
|
||||||
|
|
||||||
|
#[derive(Default, NwgUi)]
|
||||||
|
pub struct BasicApp {
|
||||||
|
#[nwg_control(size: (800, 200), title: "Sane Vector Log Decoder", flags: "WINDOW|VISIBLE")]
|
||||||
|
#[nwg_events( OnWindowClose: [BasicApp::say_goodbye] )]
|
||||||
|
window: nwg::Window,
|
||||||
|
|
||||||
|
#[nwg_layout(parent: window, spacing: 1)]
|
||||||
|
grid: nwg::GridLayout,
|
||||||
|
|
||||||
|
#[nwg_resource(title: "Select DBC", action: nwg::FileDialogAction::Open, filters: "DBC(*.dbc)|Any(*.*)")]
|
||||||
|
dbc_dialog: nwg::FileDialog,
|
||||||
|
|
||||||
|
#[nwg_resource(title: "Select ASC(s)", action: nwg::FileDialogAction::Open, multiselect: true, filters: "ASC(*.asc)|Any(*.*)")]
|
||||||
|
asc_dialog: nwg::FileDialog,
|
||||||
|
|
||||||
|
#[nwg_resource(title: "Select output directory", action: nwg::FileDialogAction::OpenDirectory)]
|
||||||
|
out_dialog: nwg::FileDialog,
|
||||||
|
|
||||||
|
#[nwg_control(readonly: true)]
|
||||||
|
#[nwg_layout_item(layout: grid, col: 1, row: 0, col_span: 2)]
|
||||||
|
dbc_file_name: nwg::TextInput,
|
||||||
|
|
||||||
|
#[nwg_control(readonly: true)]
|
||||||
|
#[nwg_layout_item(layout: grid, col: 1, row: 1, col_span: 2)]
|
||||||
|
asc_file_names: nwg::TextInput,
|
||||||
|
|
||||||
|
#[nwg_control(readonly: true)]
|
||||||
|
#[nwg_layout_item(layout: grid, col: 1, row: 2, col_span: 2)]
|
||||||
|
out_directory: nwg::TextInput,
|
||||||
|
|
||||||
|
#[nwg_control(text: "Select DBC")]
|
||||||
|
#[nwg_layout_item(layout: grid, col: 0, row: 0)]
|
||||||
|
#[nwg_events( OnButtonClick: [BasicApp::pick_dbc] )]
|
||||||
|
dbc_button: nwg::Button,
|
||||||
|
|
||||||
|
#[nwg_control(text: "Select ASC(s)")]
|
||||||
|
#[nwg_layout_item(layout: grid, col: 0, row: 1)]
|
||||||
|
#[nwg_events( OnButtonClick: [BasicApp::pick_asc] )]
|
||||||
|
asc_button: nwg::Button,
|
||||||
|
|
||||||
|
#[nwg_control(text: "Select output dir")]
|
||||||
|
#[nwg_layout_item(layout: grid, col: 0, row: 2)]
|
||||||
|
#[nwg_events( OnButtonClick: [BasicApp::pick_out] )]
|
||||||
|
outdir_button: nwg::Button,
|
||||||
|
|
||||||
|
#[nwg_control(text: "Zrób fikołka")]
|
||||||
|
#[nwg_layout_item(layout: grid, col: 0, row: 3, col_span: 3)]
|
||||||
|
#[nwg_events( OnButtonClick: [BasicApp::action] )]
|
||||||
|
action_button: nwg::Button,
|
||||||
|
|
||||||
|
dbc_path: RefCell<Option<PathBuf>>,
|
||||||
|
asc_paths: RefCell<Option<Vec<PathBuf>>>,
|
||||||
|
out_path: RefCell<Option<PathBuf>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BasicApp {
|
||||||
|
fn action(&self) {
|
||||||
|
let dbc_path = self.dbc_path.borrow();
|
||||||
|
let asc_paths = self.asc_paths.borrow();
|
||||||
|
let out_path = self.out_path.borrow();
|
||||||
|
|
||||||
|
if let Some(dbc_path) = dbc_path.as_ref() &&
|
||||||
|
let Some(asc_paths) = asc_paths.as_ref() &&
|
||||||
|
let Some(out_path) = out_path.as_ref() {
|
||||||
|
let dbc_data = fs::read_to_string(dbc_path).unwrap();
|
||||||
|
let dbc = Dbc::try_from(dbc_data.as_str()).unwrap();
|
||||||
|
for asc_path in asc_paths {
|
||||||
|
libsvld::decode(&dbc, asc_path, out_path.as_path());
|
||||||
|
}
|
||||||
|
nwg::modal_info_message(&self.window,
|
||||||
|
"Okej",
|
||||||
|
"Finished!");
|
||||||
|
} else {
|
||||||
|
nwg::modal_error_message(&self.window,
|
||||||
|
"ERROR",
|
||||||
|
"Select all the paths first, you idiot");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pick_dbc(&self) {
|
||||||
|
if self.dbc_dialog.run(Some(&self.window)) &&
|
||||||
|
let Ok(file) = self.dbc_dialog.get_selected_item() {
|
||||||
|
*self.dbc_path.borrow_mut() = Some(file.clone().try_into().unwrap());
|
||||||
|
self.dbc_file_name.set_text(&file.into_string().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pick_asc(&self) {
|
||||||
|
println!("here");
|
||||||
|
if self.asc_dialog.run(Some(&self.window)) &&
|
||||||
|
let Ok(files) = self.asc_dialog.get_selected_items() {
|
||||||
|
*self.asc_paths.borrow_mut() = Some(files
|
||||||
|
.clone()
|
||||||
|
.iter()
|
||||||
|
.map(|x| x.try_into().unwrap())
|
||||||
|
.collect());
|
||||||
|
self.asc_file_names.set_text(&files.join(OsStr::new("; ")).into_string().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pick_out(&self) {
|
||||||
|
if self.out_dialog.run(Some(&self.window)) &&
|
||||||
|
let Ok(path) = self.out_dialog.get_selected_item() {
|
||||||
|
*self.out_path.borrow_mut() = Some(path.clone().try_into().unwrap());
|
||||||
|
self.out_directory.set_text(&path.into_string().unwrap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn say_goodbye(&self) {
|
||||||
|
nwg::stop_thread_dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
nwg::init().expect("Failed to init Native Windows GUI");
|
||||||
|
nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font");
|
||||||
|
let _app = BasicApp::build_ui(Default::default()).expect("Failed to build UI");
|
||||||
|
nwg::dispatch_thread_events();
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user