Allow primary selection for sharing

Adds a feature flag to use the primary selection instead of the
clipboard. Only works on Linux.
This commit is contained in:
Felix Van der Jeugt
2020-12-14 23:42:56 +01:00
committed by Henrik Friedrichsen
parent 3ab32a7c51
commit 02b66b6cdd
5 changed files with 44 additions and 14 deletions

View File

@@ -8,6 +8,8 @@ use crate::commands::CommandResult;
use crate::library::Library;
use crate::playable::Playable;
use crate::queue::Queue;
#[cfg(feature = "share_clipboard")]
use crate::sharing::write_share;
use crate::track::Track;
use crate::traits::{ListItem, ViewExt};
use crate::ui::layout::Layout;
@@ -17,8 +19,6 @@ use crate::{
playlist::Playlist,
spotify::Spotify,
};
#[cfg(feature = "share_clipboard")]
use clipboard::{ClipboardContext, ClipboardProvider};
use cursive::traits::{Finder, Nameable};
pub struct ContextMenu {
@@ -145,9 +145,7 @@ impl ContextMenu {
}
ContextMenuAction::ShareUrl(url) => {
#[cfg(feature = "share_clipboard")]
ClipboardProvider::new()
.and_then(|mut ctx: ClipboardContext| ctx.set_contents(url.to_string()))
.ok();
write_share(url.to_string());
}
ContextMenuAction::AddToPlaylist(track) => {
let dialog =