make sharing to clipboard a feature that can be disabled
this is for users that want to eliminate dependences (e.g. libxcb). the feature is enabled by default and must be explicitly disabled. fixes #84
This commit is contained in:
@@ -2,6 +2,7 @@ extern crate clap;
|
||||
extern crate crossbeam_channel;
|
||||
#[macro_use]
|
||||
extern crate cursive;
|
||||
#[cfg(feature = "share_clipboard")]
|
||||
extern crate clipboard;
|
||||
extern crate directories;
|
||||
extern crate failure;
|
||||
|
||||
@@ -4,6 +4,7 @@ use cursive::view::ViewWrapper;
|
||||
use cursive::views::{Dialog, SelectView};
|
||||
use cursive::Cursive;
|
||||
|
||||
#[cfg(feature = "share_clipboard")]
|
||||
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||
use library::Library;
|
||||
use queue::Queue;
|
||||
@@ -30,6 +31,7 @@ impl ContextMenu {
|
||||
content.add_item("Show album", ContextMenuAction::ShowItem(Box::new(a)));
|
||||
}
|
||||
if let Some(url) = item.share_url() {
|
||||
#[cfg(feature = "share_clipboard")]
|
||||
content.add_item("Share", ContextMenuAction::ShareUrl(url));
|
||||
}
|
||||
|
||||
@@ -45,9 +47,12 @@ impl ContextMenu {
|
||||
}
|
||||
}
|
||||
ContextMenuAction::ShareUrl(url) => {
|
||||
ClipboardProvider::new()
|
||||
.and_then(|mut ctx: ClipboardContext| ctx.set_contents(url.to_string()))
|
||||
.ok();
|
||||
#[cfg(feature = "share_clipboard")]
|
||||
{
|
||||
ClipboardProvider::new()
|
||||
.and_then(|mut ctx: ClipboardContext| ctx.set_contents(url.to_string()))
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ use cursive::view::ScrollBase;
|
||||
use cursive::{Cursive, Printer, Rect, Vec2};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
#[cfg(feature = "share_clipboard")]
|
||||
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||
use command::{Command, GotoMode, MoveMode, TargetMode};
|
||||
use commands::CommandResult;
|
||||
@@ -321,6 +322,7 @@ impl<I: ListItem + Clone> ViewExt for ListView<I> {
|
||||
};
|
||||
|
||||
if let Some(url) = url {
|
||||
#[cfg(feature = "share_clipboard")]
|
||||
ClipboardProvider::new()
|
||||
.and_then(|mut ctx: ClipboardContext| ctx.set_contents(url))
|
||||
.ok();
|
||||
|
||||
Reference in New Issue
Block a user