Finally add descriptions to list items

This commit is contained in:
Javier Feliz 2025-09-04 21:20:58 -04:00
parent 7cf1b9efc7
commit beecf03025
2 changed files with 26 additions and 5 deletions

View File

@ -25,7 +25,7 @@ impl LauncherListItem for FileEntry {
return String::from(self.path.file_name().unwrap().to_string_lossy()); return String::from(self.path.file_name().unwrap().to_string_lossy());
} }
fn description(&self) -> Option<String> { fn description(&self) -> Option<String> {
return None; Some(self.path.to_string_lossy().to_string())
} }
fn execute(&self) -> Result<(), LaunchError> { fn execute(&self) -> Result<(), LaunchError> {

View File

@ -65,6 +65,10 @@ impl LauncherItemObject {
self.imp().icon.borrow().clone() self.imp().icon.borrow().clone()
} }
pub fn description(&self) -> Option<String> {
self.imp().description.borrow().clone()
}
pub fn index(&self) -> usize { pub fn index(&self) -> usize {
*self.imp().index.borrow() *self.imp().index.borrow()
} }
@ -148,12 +152,29 @@ impl GtkLauncherUI {
} }
image.set_pixel_size(icon_size); image.set_pixel_size(icon_size);
// Create label // Create text container (vertical box for title + description)
let label = Label::new(Some(&item_obj.title())); let text_box = GtkBox::new(Orientation::Vertical, 2);
label.set_xalign(0.0); 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(&image);
child.append(&label); child.append(&text_box);
} }
}); });