Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating overlay widget #5

Merged
merged 15 commits into from
Sep 23, 2024
90 changes: 63 additions & 27 deletions Cargo.lock

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

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "icy_browser"
version = "0.1.0"
edition = "2021"
rust-version = "1.79.0"
rust-version = "1.81.0"
description = "iced browser widgets"
repository = "https://github.com/LegitCamper/rust-browser"

Expand Down Expand Up @@ -33,13 +33,19 @@ ultralight = ["ul-next"]
[dependencies]
env_home = "0.1.0"
iced = { version = "0.13", features = ["advanced", "image", "tokio", "lazy"] }
iced_aw = { version = "0.10", features = ["tab_bar", "icons"] }
iced_aw = { version = "0.10", features = [
"tab_bar",
"icons",
"selection_list",
] }
iced_on_focus_widget = "0.1.1"
rand = "0.8.5"
reqwest = "0.12.5"
serde = "1.0.207"
serde_json = "1.0.124"
smol_str = "0.2.2"
strum = { version = "0.26.3", features = ["derive"] }
strum_macros = "0.26.4"
tempfile = "3.12.0"
ul-next = { version = "0.4", optional = true }
url = "2.5.2"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img src="https://raw.githubusercontent.com/gist/hecrj/ad7ecd38f6e47ff3688a38c79fd108f0/raw/74384875ecbad02ae2a926425e9bcafd0695bade/color.svg" width=8%>

### Supported Platforms
| Platform | Support |
| Platform | Support |
| Windows | <span>&#10003;</span> |
| Linux | <span>&#10003;</span> |

Expand Down
96 changes: 96 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
use std::fs::{self, DirEntry};
use std::path::Path;

const PATH: &str = env!("CARGO_MANIFEST_DIR");

fn main() {
// ensure runtime resources exist
#[cfg(feature = "ultralight")]
{
let mut possible_directories = Vec::new();

let target = Path::new(PATH).join("target");
let debug_path = target.clone().join("debug");
let release_path = target.clone().join("release");

if let Ok(debug) = fs::exists(debug_path.clone()) {
if debug {
get_paths(
&mut possible_directories,
debug_path.join("build").to_str().unwrap().to_string(),
)
}
} else if let Ok(release) = fs::exists(release_path.clone()) {
if release {
get_paths(
&mut possible_directories,
release_path.join("build").to_str().unwrap().to_string(),
)
}
} else {
panic!("Could not find either debug or release dirs")
}

assert!(!possible_directories.is_empty());

let local_resources = Path::new(PATH).join("resources");

for path in possible_directories {
if let Ok(resources) = fs::exists(path.path().join("out/ul-sdk/resources")) {
if resources {
if let Ok(local_resources_exist) = fs::exists(local_resources.clone()) {
if local_resources_exist {
fs::remove_dir_all(local_resources.clone())
.expect("Failed to delete resources dir")
}
}

fs::create_dir(local_resources.clone())
.expect("Failed to create resources dir");

copy_file(
path.path().join("out/ul-sdk/resources").as_path(),
local_resources.clone().join("").as_path(),
"cacert.pem",
)
.expect("Failed to copy cacert.pem");
copy_file(
path.path().join("out/ul-sdk/resources").as_path(),
local_resources.clone().join("").as_path(),
"icudt67l.dat",
)
.expect("Failed to copy icudt67l.dat");

break;
}
} else {
panic!("The resouce dir entered has not resources")
}
}
}

println!("cargo:rerun-if-changed=resources");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=Cargo.lock");
}

fn copy_file(from: &Path, to: &Path, file_name: &str) -> Result<u64, std::io::Error> {
fs::copy(from.join(file_name), to.join(file_name))
}

fn get_paths(possible_paths: &mut Vec<fs::DirEntry>, path_str: String) {
let mut paths: Vec<DirEntry> = fs::read_dir(path_str)
.expect("Could not read dir")
.map(|f| f.unwrap())
.filter(|file| file.path().to_string_lossy().contains("ul-next-sys"))
.collect();
// TODO: check if sort working
paths.sort_by(|a, b| {
a.metadata()
.unwrap()
.modified()
.unwrap()
.cmp(&b.metadata().unwrap().modified().unwrap())
});
possible_paths.append(&mut paths);
}
Loading
Loading