Update gui.rs
This commit is contained in:
+27
-27
@@ -32,40 +32,39 @@ fn build_ui(app: &Application) {
|
|||||||
.margin_end(2)
|
.margin_end(2)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let container = GtkBox::new(Orientation::Horizontal, 5);
|
let main_box = GtkBox::new(Orientation::Horizontal, 5);
|
||||||
|
|
||||||
// let image_path = "/home/user/Pictures/Wallpapers/*.png";
|
|
||||||
// let image = Image::from_file(image_path);
|
|
||||||
// fs::create_dir("/home/user/.cache/LinuxWEGUI");
|
|
||||||
// fs::copy(image_path, "/home/user/.cache/LinuxWEGUI/a32xicnes4k91.png");
|
|
||||||
|
|
||||||
// let image_dir = "/media/gamedisk4/SteamLibrary/steamapps/workshop/content/431960/";
|
// let image_dir = "/media/gamedisk4/SteamLibrary/steamapps/workshop/content/431960/";
|
||||||
let image_dir = "/home/user/Desktop/LinuxWallpaperEngineGUI";
|
let image_dir = "/home/user/Desktop/LinuxWallpaperEngineGUI";
|
||||||
|
|
||||||
for entry in WalkDir::new(image_dir).into_iter().filter_map(Result::ok) {
|
let mut column_box = GtkBox::new(Orientation::Vertical, 5);
|
||||||
|
let mut images_in_column = 0;
|
||||||
|
|
||||||
|
for entry in WalkDir::new(image_dir)
|
||||||
|
.max_depth(3)
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(Result::ok)
|
||||||
|
{
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
println!("processing file: {}", path.to_string_lossy());
|
|
||||||
|
|
||||||
let cache_file = Path::new("/home/user/.cache/LinuxWEGUI/").join(path.file_name().unwrap());
|
if path.file_name().map_or(false, |name| name == "preview.jpg") {
|
||||||
if cache_file.exists() {
|
let image = Image::from_file(path);
|
||||||
if path.file_name().map_or(false, |name| name == "preview.png") {
|
image.set_pixel_size(150);
|
||||||
let image = Image::from_file(
|
|
||||||
"/home/user/Desktop/LinuxWallpaperEngineGUI/431960/864310972/preview.png",
|
|
||||||
);
|
|
||||||
image.set_pixel_size(150);
|
|
||||||
container.append(&image);
|
|
||||||
|
|
||||||
let dest_path =
|
column_box.append(&image);
|
||||||
Path::new("/home/user/.cache/LinuxWEGUI/").join(path.file_name().unwrap());
|
images_in_column += 1;
|
||||||
|
|
||||||
if let Some(parent_dir) = dest_path.parent() {
|
if images_in_column == 5 {
|
||||||
fs::create_dir_all(parent_dir).expect("Failed to create parent directory");
|
main_box.append(&column_box);
|
||||||
} else {
|
column_box = GtkBox::new(Orientation::Vertical, 5);
|
||||||
fs::copy(path, dest_path).expect("yeet");
|
images_in_column = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if images_in_column > 0 {
|
||||||
|
main_box.append(&column_box);
|
||||||
|
}
|
||||||
|
println!("Fertsch\n");
|
||||||
|
|
||||||
// fs::copy(path, dest_path).expect("yeet");
|
// fs::copy(path, dest_path).expect("yeet");
|
||||||
|
|
||||||
@@ -102,9 +101,10 @@ fn build_ui(app: &Application) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attach the button to the window and show everything
|
let wrapper_box = GtkBox::new(Orientation::Vertical, 5);
|
||||||
window.set_child(Some(&button));
|
wrapper_box.append(&button);
|
||||||
// window.set_child(Some(&image));
|
wrapper_box.append(&main_box);
|
||||||
window.set_child(Some(&container));
|
|
||||||
|
window.set_child(Some(&wrapper_box));
|
||||||
window.present();
|
window.present();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user