From 69c213f9bab37c770551451ded4dd73dd9cf8117 Mon Sep 17 00:00:00 2001 From: Javier Feliz Date: Wed, 3 Sep 2025 01:50:08 -0400 Subject: [PATCH] WIP --- src/drun/mod.rs | 24 ++++++++++++++++++++---- src/main.rs | 33 ++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/drun/mod.rs b/src/drun/mod.rs index 65c14a2..1de3faf 100644 --- a/src/drun/mod.rs +++ b/src/drun/mod.rs @@ -5,7 +5,7 @@ use std::env; use std::path::{Path, PathBuf}; #[derive(Debug)] -struct DesktopEntry { +pub struct DesktopEntry { id: String, name: String, generic_name: Option, @@ -17,6 +17,12 @@ struct DesktopEntry { is_terminal_app: bool, } +impl DesktopEntry { + pub fn path(&self) -> PathBuf { + self.path.clone() + } +} + impl LauncherListItem for DesktopEntry { fn title(&self) -> String { return self.name.to_owned(); @@ -89,8 +95,8 @@ fn get_desktop_files() -> Vec { return files; } -pub fn all() -> Vec> { - let mut entries: Vec> = Vec::new(); +pub fn get_desktop_entries() -> Vec { + let mut entries = Vec::new(); for f in get_desktop_files() { if let Some(info) = DesktopAppInfo::from_filename(&f) { @@ -110,9 +116,19 @@ pub fn all() -> Vec> { is_terminal_app: info.boolean("Terminal"), }; - entries.push(Box::new(de)); + 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/main.rs b/src/main.rs index 973b918..0a0a897 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,16 +29,33 @@ impl ListItem { fn create_widget(&self) -> GtkBox { let container = GtkBox::new(Orientation::Horizontal, 10); - let image = Image::new(); - image.set_pixel_size(50); - image.set_icon_name(Some(&self.icon)); + // let icon = if self.icon.eq("com.discordapp.Discord") + // || self.icon.eq("preferences-desktop-theme") + // || self.icon.eq("solaar") + // || self.icon.eq("kvantum") + // { + // println!("Failed: {}", self.icon); + // gio::Icon::for_string("vscode") + // } else { + // let x = String::from(self.icon.clone()); + // gio::Icon::for_string(&x) + // }; + // // let icon = gio::Icon::for_string("kvantum"); + // let image: Image = match icon { + // Ok(ic) => Image::from_gicon(&ic), + // Err(_) => Image::from_icon_name("vscode"), + // }; + // let image = Image::from_icon_name("vscode"); + let image = gtk::Image::from_icon_name(&self.icon); + image.set_pixel_size(32); + // image.set_icon_name(Some("application-x-executable")); // Safe fallback let label = Label::new(Some(&self.text)); label.set_xalign(0.0); - // container.append(&image); + container.append(&image); container.append(&label); - + println!("Icon: {}", self.icon); container } } @@ -154,4 +171,10 @@ fn main() { }); app.run(); + // for e in drun::get_desktop_entries() { + // println!("---"); + // println!("Icon: {}", e.icon()); + // println!("Path: {}", e.path().to_string_lossy()); + // println!("---"); + // } }