added image preview (not fully working yet)
This commit is contained in:
+11
-10
@@ -1,22 +1,24 @@
|
||||
use gtk::prelude::*;
|
||||
use gtk::{glib, Application, ApplicationWindow, Button, Image};
|
||||
use gtk::{glib, Application, ApplicationWindow, Button, FlowBox, Image};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub fn gui() -> glib::ExitCode {
|
||||
let app = Application::builder().application_id("LinuxWEGUI").build();
|
||||
|
||||
app.connect_activate(|app| {
|
||||
let image = find_wallpapers();
|
||||
build_ui(app, image);
|
||||
build_ui(app);
|
||||
});
|
||||
|
||||
app.run()
|
||||
}
|
||||
|
||||
pub fn find_wallpapers() -> Image {
|
||||
fn build_ui(app: &Application) {
|
||||
let container = gtk::Box::new(gtk::Orientation::Vertical, 10);
|
||||
|
||||
let wallpaper_dir = "/home/user/Desktop/coding/LinuxWallpaperEngineGUI/431960.o";
|
||||
let image = Image::new();
|
||||
image.set_pixel_size(150);
|
||||
let flow_box = FlowBox::new();
|
||||
|
||||
for entry in WalkDir::new(wallpaper_dir)
|
||||
.max_depth(3)
|
||||
@@ -31,14 +33,13 @@ pub fn find_wallpapers() -> Image {
|
||||
{
|
||||
let path_str = path.to_str().unwrap();
|
||||
image.set_from_file(Some(path_str));
|
||||
flow_box.append(&image);
|
||||
println!("Found wallpaper preview: {}", path_str);
|
||||
}
|
||||
}
|
||||
|
||||
image
|
||||
}
|
||||
container.append(&flow_box);
|
||||
|
||||
fn build_ui(app: &Application, image: Image) {
|
||||
let button = Button::builder()
|
||||
.label("button")
|
||||
.margin_top(50)
|
||||
@@ -54,9 +55,9 @@ fn build_ui(app: &Application, image: Image) {
|
||||
let window = ApplicationWindow::builder()
|
||||
.application(app)
|
||||
.title("Linux Wallpaper Engine")
|
||||
.default_width(300)
|
||||
.default_height(100)
|
||||
.child(&image)
|
||||
.default_width(800)
|
||||
.default_height(600)
|
||||
.child(&container)
|
||||
.build();
|
||||
|
||||
window.present();
|
||||
|
||||
@@ -3,5 +3,4 @@ mod gui;
|
||||
fn main() {
|
||||
println!("Starting GUI application...\n");
|
||||
gui::gui();
|
||||
gui::find_wallpapers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user