Skip to content

Commit

Permalink
Merge pull request #4 from ggand0/win
Browse files Browse the repository at this point in the history
Add codes to build for Windows
  • Loading branch information
ggand0 authored Apr 29, 2024
2 parents 76ada32 + 5ba32f3 commit 4cc40e7
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 11 deletions.
117 changes: 110 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"
description = "Visual data viewer for people working with large data."


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
iced_native = "0.10"
Expand All @@ -16,6 +17,7 @@ num-traits = "0.2"
cargo-bundle = "0.6.0"
#natord = "1.0.9"
alphanumeric-sort = "1.5.3"
image = "0.23"


[target.'cfg(not(target_os = "linux"))'.dependencies]
Expand Down Expand Up @@ -51,6 +53,13 @@ iced_aw = { version = "0.7.0", features = [
] }
iced_widget = { package = "iced_widget", version = "0.1.1" }

[build-dependencies]
winres = "0.1.12"

[package.metadata.winres]
OriginalFilename = "view_skater.exe"
FileDescription = "Visual data viewer for people working with large data."

#iced = {version = "0.10", features = ["image", "tokio", "svg", "lazy"]}
##iced_aw = { version = "0.7.0", features = [
# "menu",
Expand All @@ -73,4 +82,4 @@ name = "ViewSkater"
identifier = "com.ggando.viewskater"
#icon = ["icon.icns"]
icon = ["assets/icon_16.png", "assets/icon_32.png", "assets/icon_48.png", "assets/icon_128.png", "assets/icon_256.png"]
short_description = "Visual data viewer for browsing a large number of data."
short_description = "Visual data viewer for browsing a large number of data."
Binary file modified assets/icon.ico
Binary file not shown.
21 changes: 21 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use {
std::{
env,
io,
},
winres::WindowsResource,
};

fn main() -> io::Result<()> {
if env::var_os("CARGO_CFG_WINDOWS").is_some() {
WindowsResource::new()
// This path can be absolute, or relative to your crate root.
// When building on Windows, comment out the first 3 lines of this block (just call set_icon)
.set_toolkit_path("/usr/bin")
.set_windres_path("x86_64-w64-mingw32-windres")
.set_ar_path("x86_64-w64-mingw32-ar")
.set_icon("./assets/icon.ico")
.compile()?;
}
Ok(())
}
Binary file added icon.ico
Binary file not shown.
27 changes: 24 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

#![windows_subsystem = "windows"]

#[cfg(target_os = "linux")]
mod other_os {
pub use iced;
Expand Down Expand Up @@ -889,12 +892,30 @@ impl Application for DataViewer {
}
}


// Include the icon image data at compile time
static ICON: &[u8] = if cfg!(target_os = "windows") {
include_bytes!("../assets/icon_512.png")
} else if cfg!(target_os = "macos") {
include_bytes!("../assets/icon_512.png")
} else {
include_bytes!("../assets/icon_48.png")
};


fn main() -> iced::Result {
env_logger::init();
use iced::window;

//let icon = iced::window::icon::from_file("icon.ico");
let icon = iced::window::icon::from_file("icon.png");

/*use image::io::Reader as ImageReader;
let icon_data = ImageReader::new(std::io::Cursor::new(ICON))
.with_guessed_format()
.unwrap()
.decode()
.unwrap()
.to_rgba8();*/
let icon = iced::window::icon::from_file_data(ICON, Option::None);

match icon {
Ok(icon) => {
info!("Icon loaded successfully");
Expand Down

0 comments on commit 4cc40e7

Please sign in to comment.