Add clipboard suppor:t, make URL open feature toggleable

This commit is contained in:
timvisee 2018-03-18 19:15:17 +01:00
parent a4aa1b93e5
commit 523cbc3a19
No known key found for this signature in database
GPG key ID: 109CBA0BF74036C2
5 changed files with 161 additions and 5 deletions

View file

@ -1,8 +1,11 @@
extern crate clipboard;
extern crate open;
use std::error::Error;
use std::io::Error as IoError;
use std::process::{exit, ExitStatus};
use self::clipboard::{ClipboardContext, ClipboardProvider};
use ffsend_api::url::Url;
/// Quit the application with an error code,
@ -26,3 +29,9 @@ pub fn open_url(url: Url) -> Result<ExitStatus, IoError> {
pub fn open_path(path: &str) -> Result<ExitStatus, IoError> {
open::that(path)
}
/// Set the clipboard of the user to the given `content` string.
pub fn set_clipboard(content: String) -> Result<(), Box<Error>> {
let mut context: ClipboardContext = ClipboardProvider::new()?;
context.set_contents(content)
}