Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store file path in tooltip #42

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn get_file(row: &CenterBox) -> gio::File {
} else {
row.center_widget().unwrap()
};
gio::File::for_path(file_widget.downcast::<Label>().unwrap().text())
gio::File::for_path(file_widget.tooltip_text().unwrap())
}

// Setup the widgets in the ListView
Expand Down Expand Up @@ -146,8 +146,11 @@ fn setup_factory(factory: &SignalListItemFactory, list: &MultiSelection) {
.and_downcast::<CenterBox>()
.expect("The child has to be a `Label`.");

// show either relative or absolute path
// This is safe because the file needs to exist
let path = file_object.file().parse_name().to_string();

// show either relative or absolute path
// only used for the display label
let str = if ARGS.get().unwrap().basename || file_object
.file()
.has_parent(Some(CURRENT_DIRECTORY.get().unwrap())
Expand All @@ -157,15 +160,14 @@ fn setup_factory(factory: &SignalListItemFactory, list: &MultiSelection) {
.to_str().unwrap()
.to_string()
} else {
file_object.file()
.parse_name().to_string()
path.to_owned()
};

let label = Label::builder()
.label(&str)
.hexpand(true)
.ellipsize(gtk::pango::EllipsizeMode::End)
.tooltip_text(&str);
.tooltip_text(&path);

if ARGS.get().unwrap().icons_only {
file_row.set_start_widget(Some(&label.visible(false).build()));
Expand Down
Loading