From beecf0302502cb1afd0de3728628ac66b12740e8 Mon Sep 17 00:00:00 2001 From: Javier Feliz Date: Thu, 4 Sep 2025 21:20:58 -0400 Subject: [PATCH] Finally add descriptions to list items --- src/plugins/file_search.rs | 2 +- src/ui/gtk/mod.rs | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/plugins/file_search.rs b/src/plugins/file_search.rs index fd27c38..c1df2e4 100644 --- a/src/plugins/file_search.rs +++ b/src/plugins/file_search.rs @@ -25,7 +25,7 @@ impl LauncherListItem for FileEntry { return String::from(self.path.file_name().unwrap().to_string_lossy()); } fn description(&self) -> Option { - return None; + Some(self.path.to_string_lossy().to_string()) } fn execute(&self) -> Result<(), LaunchError> { diff --git a/src/ui/gtk/mod.rs b/src/ui/gtk/mod.rs index 4f02162..3d1f62c 100644 --- a/src/ui/gtk/mod.rs +++ b/src/ui/gtk/mod.rs @@ -65,6 +65,10 @@ impl LauncherItemObject { self.imp().icon.borrow().clone() } + pub fn description(&self) -> Option { + self.imp().description.borrow().clone() + } + pub fn index(&self) -> usize { *self.imp().index.borrow() } @@ -148,12 +152,29 @@ impl GtkLauncherUI { } image.set_pixel_size(icon_size); - // Create label - let label = Label::new(Some(&item_obj.title())); - label.set_xalign(0.0); + // Create text container (vertical box for title + description) + let text_box = GtkBox::new(Orientation::Vertical, 2); + text_box.set_hexpand(true); + text_box.set_valign(gtk::Align::Center); + + // Create title label + let title_label = Label::new(Some(&item_obj.title())); + title_label.set_xalign(0.0); + title_label.set_ellipsize(gtk::pango::EllipsizeMode::End); + text_box.append(&title_label); + + // Create description label if description exists + if let Some(description) = item_obj.description() { + let desc_label = Label::new(Some(&description)); + desc_label.set_xalign(0.0); + desc_label.set_ellipsize(gtk::pango::EllipsizeMode::Middle); + desc_label.add_css_class("dim-label"); // Make it visually secondary + desc_label.set_opacity(0.7); + text_box.append(&desc_label); + } child.append(&image); - child.append(&label); + child.append(&text_box); } });