From 714b6059f188a5b2dc7a10f9c0af6feda4e00fa1 Mon Sep 17 00:00:00 2001 From: daa Date: Tue, 7 Mar 2017 13:52:01 +0300 Subject: [PATCH] Make save button work --- src/ui.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 1c648ae..c79dc17 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -97,12 +97,9 @@ impl Ui { button_bar.set_icon_size(IconSize::SmallToolbar); button_bar.set_hexpand(true); - let open_image = Image::new_from_icon_name("document-open", 50); - let open_btn = ToolButton::new(Some(&open_image), None); - button_bar.add(&open_btn); - let save_image = Image::new_from_icon_name("document-save", 50); let save_btn = ToolButton::new(Some(&save_image), None); + save_btn.connect_clicked(|_| save_all()); button_bar.add(&save_btn); let exit_image = Image::new_from_icon_name("application-exit", 50); @@ -195,6 +192,16 @@ fn gtk_motion_notify(_: &DrawingArea, ev: &EventMotion) -> Inhibit { Inhibit(false) } +fn save_all() { + UI.with(|ui_cell| { + let mut ui = ui_cell.borrow_mut(); + + if let Err(e) = ui.nvim().command(":wa") { + println!("Error save all files {}", e); + } + }); +} + fn quit() { UI.with(|ui_cell| { let mut ui = ui_cell.borrow_mut();