From daf5eed6a4ab17401a0b481146d57a05900e3a2e Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Fri, 6 Oct 2023 10:46:45 +0800 Subject: [PATCH] chore: remove deps in lib for libwayshot --- Cargo.lock | 1 - libs/screenshotdialog/Cargo.toml | 1 - libs/screenshotdialog/src/lib.rs | 16 ++-------------- src/screenshot.rs | 11 +++++++++-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ac2ea2..a852ccd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3481,7 +3481,6 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" name = "screenshotdialog" version = "0.1.0" dependencies = [ - "libwayshot", "slint", "slint-build", ] diff --git a/libs/screenshotdialog/Cargo.toml b/libs/screenshotdialog/Cargo.toml index 2690e24..863ede1 100644 --- a/libs/screenshotdialog/Cargo.toml +++ b/libs/screenshotdialog/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" [dependencies] slint = "1.2.1" -libwayshot = { git = "https://github.com/waycrate/wayshot.git" } [build-dependencies] slint-build = "1.2.1" diff --git a/libs/screenshotdialog/src/lib.rs b/libs/screenshotdialog/src/lib.rs index 7a339bd..f274bc4 100644 --- a/libs/screenshotdialog/src/lib.rs +++ b/libs/screenshotdialog/src/lib.rs @@ -1,6 +1,5 @@ use std::rc::Rc; -use libwayshot::output::OutputInfo; use slint::VecModel; slint::include_modules!(); @@ -32,20 +31,9 @@ fn init_slots(ui: &AppWindow, sender: mpsc::Sender) { }); } -pub fn selectgui(screen: Vec) -> SlintSelection { +pub fn selectgui(screen: Vec) -> SlintSelection { let ui = AppWindow::new().unwrap(); - ui.set_infos( - Rc::new(VecModel::from( - screen - .iter() - .map(|screen| ScreenInfo { - name: screen.name.clone().into(), - description: screen.description.clone().into(), - }) - .collect::>(), - )) - .into(), - ); + ui.set_infos(Rc::new(VecModel::from(screen)).into()); let (sender, receiver) = mpsc::channel(); init_slots(&ui, sender); ui.run().unwrap(); diff --git a/src/screenshot.rs b/src/screenshot.rs index 7bf3b82..6167600 100644 --- a/src/screenshot.rs +++ b/src/screenshot.rs @@ -1,4 +1,5 @@ use libwayshot::WayshotConnection; +use screenshotdialog::ScreenInfo; use screenshotdialog::SlintSelection; use std::collections::HashMap; use zbus::zvariant::{DeserializeDict, SerializeDict, Type, Value}; @@ -53,8 +54,14 @@ impl ScreenShotBackend { })? .get_all_outputs() .clone(); - - match screenshotdialog::selectgui(wayinfos.clone()) { + let screen_infos = wayinfos + .iter() + .map(|screen| ScreenInfo { + name: screen.name.clone().into(), + description: screen.description.clone().into(), + }) + .collect(); + match screenshotdialog::selectgui(screen_infos) { SlintSelection::Canceled => return Ok(PortalResponse::Cancelled), SlintSelection::Slurp => { let slurp = std::process::Command::new("slurp")