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