From e77828b9abcfb5e01d1849061b573b5164975df2 Mon Sep 17 00:00:00 2001 From: Javier Feliz Date: Fri, 5 Sep 2025 20:15:58 -0400 Subject: [PATCH] Delete unused --- src/drun/mod.rs | 96 ------------------------------------------------- src/lib.rs | 1 - 2 files changed, 97 deletions(-) delete mode 100644 src/drun/mod.rs diff --git a/src/drun/mod.rs b/src/drun/mod.rs deleted file mode 100644 index 617a669..0000000 --- a/src/drun/mod.rs +++ /dev/null @@ -1,96 +0,0 @@ -use crate::{LaunchError, LauncherListItem}; -use gio::{AppInfo, DesktopAppInfo, Icon, prelude::*}; - -#[derive(Debug)] -pub struct DesktopEntry { - id: String, - name: String, - description: Option, - icon: Option, -} - -impl LauncherListItem for DesktopEntry { - fn id(&self) -> String { - self.id.clone() - } - - fn title(&self) -> String { - return self.name.to_owned(); - } - - fn description(&self) -> Option { - if let Some(glib_string) = &self.description { - return Some(glib_string.to_string().to_owned()); - } - - return None; - } - - fn execute(&self) -> Result<(), LaunchError> { - if let Some(di) = DesktopAppInfo::new(&self.id) { - let app: AppInfo = di.upcast(); - let ctx = gio::AppLaunchContext::new(); - if app.launch(&[], Some(&ctx)).ok().is_none() { - return Err(LaunchError::CouldNotLaunch("App failed to launch".into())); - }; - return Ok(()); - } - - return Err(LaunchError::CouldNotLaunch("Invalid .desktop entry".into())); - } - - fn icon(&self) -> String { - if let Some(icon) = &self.icon { - if let Ok(ti) = icon.clone().downcast::() { - // ThemedIcon may have multiple names, we take the first - if let Some(name) = ti.names().first() { - return name.to_string(); - } - } - - if let Ok(fi) = icon.clone().downcast::() { - if let Some(path) = fi.file().path() { - return path.to_string_lossy().to_string(); - } - } - } - - return "application-x-executable".into(); - } -} - -pub fn get_desktop_entries() -> Vec { - let mut entries = Vec::new(); - - for i in gio::AppInfo::all() { - let info: gio::DesktopAppInfo; - match i.downcast_ref::() { - Some(inf) => info = inf.to_owned(), - None => continue, - } - if !info.should_show() { - continue; - } - - let de = DesktopEntry { - id: info.id().unwrap_or_default().to_string(), - name: info.display_name().to_string(), - description: info.description(), - icon: info.icon(), - }; - - entries.push(de); - } - - entries -} - -pub fn all() -> Vec> { - let mut entries: Vec> = Vec::new(); - - for e in get_desktop_entries() { - entries.push(Box::new(e)); - } - - entries -} diff --git a/src/lib.rs b/src/lib.rs index 433755d..938e8bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -pub mod drun; pub mod launcher; pub mod plugins; pub mod ui;