Browse Source

Use GTK dialog (requires zenity)

master
reyk 3 years ago
parent
commit
908c14a5bc
  1. 1
      Cargo.toml
  2. 42
      src/server.rs

1
Cargo.toml

@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
bubblebabble = "0.1"
derive_more = "0.99"
dialog = "0.2.1"
dirs = "2.0"
env_logger = "0.7"
futures = "0.3"

42
src/server.rs

@ -13,10 +13,10 @@
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
use crate::Config;
use dialog::{backends::Zenity, DialogBox};
use std::{
io::{Error, ErrorKind, Result},
path::{PathBuf, MAIN_SEPARATOR},
process::Command,
};
use tokio::{
fs::{remove_file, File},
@ -119,6 +119,29 @@ pub(crate) async fn run(config: Config) -> Result<()> {
return;
}
// Print dialog
if !dont_ask {
let mut zenity = Zenity::new();
zenity.set_icon("question");
zenity.set_width(360);
let choice = dialog::Question::new(&format!(
"Do you want to accept\n{}\n({} bytes)?",
filename.display(),
file_size
))
.title("Yodle!")
.show_with(&zenity)
.expect("Could not display dialog box");
if choice != dialog::Choice::Yes {
info!(
"{} failed: rejected {}",
peer_addr,
filename.file_name().as_ref().unwrap().to_string_lossy()
);
return;
}
}
debug!(
"{} status: receiving {} ({} bytes)",
peer_addr,
@ -126,23 +149,6 @@ pub(crate) async fn run(config: Config) -> Result<()> {
file_size
);
if !dont_ask {
match Command::new("ssh-askpass")
.arg(&format!(
"Yo! Do you want to accept {} ({} bytes)?",
filename.display(),
file_size
))
.output()
{
Ok(output) if output.status.success() => {}
_ => {
info!("{} failed: rejected file", peer_addr);
return;
}
}
}
// Create output file
let file = match File::create(&filename).await {
Ok(f) => f,

Loading…
Cancel
Save