Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions i18n/en/cosmic_files.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ quit = Quit
edit = Edit
cut = Cut
copy = Copy
copy-path = Copy path
paste = Paste
select-all = Select all

Expand Down
10 changes: 10 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub enum Action {
AddToSidebar,
Compress,
Copy,
CopyPath,
Cut,
CosmicSettingsDesktop,
CosmicSettingsDisplays,
Expand Down Expand Up @@ -208,6 +209,7 @@ impl Action {
Self::AddToSidebar => Message::AddToSidebar(entity_opt),
Self::Compress => Message::Compress(entity_opt),
Self::Copy => Message::Copy(entity_opt),
Self::CopyPath => Message::CopyPath(entity_opt),
Self::Cut => Message::Cut(entity_opt),
Self::CosmicSettingsDesktop => Message::CosmicSettings("desktop"),
Self::CosmicSettingsDisplays => Message::CosmicSettings("displays"),
Expand Down Expand Up @@ -330,6 +332,7 @@ pub enum Message {
Compress(Option<Entity>),
Config(Config),
Copy(Option<Entity>),
CopyPath(Option<Entity>),
CosmicSettings(&'static str),
Cut(Option<Entity>),
Delete(Option<Entity>),
Expand Down Expand Up @@ -2628,6 +2631,13 @@ impl Application for App {
let contents = ClipboardCopy::new(ClipboardKind::Copy, paths);
return clipboard::write_data(contents);
}
Message::CopyPath(entity_opt) => {
let paths = self.selected_paths(entity_opt);
let path_strings: Vec<String> =
paths.into_iter().map(|p| p.display().to_string()).collect();
let text = path_strings.join("\n");
return clipboard::write(text);
}
Message::Cut(entity_opt) => {
self.set_cut(entity_opt);
let paths = self.selected_paths(entity_opt);
Expand Down
1 change: 1 addition & 0 deletions src/key_bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub fn key_binds(mode: &tab::Mode) -> HashMap<KeyBind, Action> {
// App and desktop only keys
if matches!(mode, tab::Mode::App | tab::Mode::Desktop) {
bind!([Ctrl], Key::Character("c".into()), Copy);
bind!([Ctrl, Shift], Key::Character("c".into()), CopyPath);
bind!([Ctrl], Key::Character("x".into()), Cut);
bind!([], Key::Named(Named::Delete), Delete);
bind!([Shift], Key::Named(Named::Delete), PermanentlyDelete);
Expand Down
12 changes: 10 additions & 2 deletions src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ pub fn context_menu<'a>(
children.push(divider::horizontal::light().into());
children.push(menu_item(fl!("rename"), Action::Rename).into());
children.push(menu_item(fl!("cut"), Action::Cut).into());
children.push(menu_item(fl!("copy"), Action::Copy).into());
if modifiers.shift() && !modifiers.control() {
children.push(menu_item(fl!("copy-path"), Action::CopyPath).into());
} else {
children.push(menu_item(fl!("copy"), Action::Copy).into());
}
// Should this simply bypass trash and remove the shortcut?
children.push(menu_item(fl!("move-to-trash"), Action::Delete).into());
} else if selected > 0 {
Expand Down Expand Up @@ -204,7 +208,11 @@ pub fn context_menu<'a>(
children.push(menu_item(fl!("rename"), Action::Rename).into());
children.push(menu_item(fl!("cut"), Action::Cut).into());
}
children.push(menu_item(fl!("copy"), Action::Copy).into());
if modifiers.shift() && !modifiers.control() {
children.push(menu_item(fl!("copy-path"), Action::CopyPath).into());
} else {
children.push(menu_item(fl!("copy"), Action::Copy).into());
}

children.push(divider::horizontal::light().into());
let supported_archive_types = crate::archive::SUPPORTED_ARCHIVE_TYPES;
Expand Down
2 changes: 1 addition & 1 deletion src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ fn display_name_for_file(path: &Path, name: &str, get_from_gvfs: bool, is_deskto
);
} else if get_from_gvfs {
#[cfg(feature = "gvfs")]
return Item::display_name(glib::filename_display_name(path).as_str())
return Item::display_name(glib::filename_display_name(path).as_str());
}
Item::display_name(name)
}
Expand Down