2017-07-06 09:41:35 +00:00
|
|
|
use std::ops::Deref;
|
|
|
|
|
|
|
|
use htmlescape::encode_minimal;
|
|
|
|
|
|
|
|
use gtk;
|
|
|
|
use gtk::prelude::*;
|
|
|
|
|
|
|
|
use gtk_sys;
|
|
|
|
|
|
|
|
use shell;
|
|
|
|
|
|
|
|
pub struct ErrorArea {
|
|
|
|
base: gtk::Box,
|
|
|
|
label: gtk::Label,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ErrorArea {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
let base = gtk::Box::new(gtk::Orientation::Horizontal, 0);
|
|
|
|
|
|
|
|
let label = gtk::Label::new(None);
|
|
|
|
label.set_line_wrap(true);
|
|
|
|
let error_image = gtk::Image::new_from_icon_name("dialog-error",
|
|
|
|
gtk_sys::GTK_ICON_SIZE_DIALOG as i32);
|
|
|
|
base.pack_start(&error_image, false, true, 10);
|
|
|
|
base.pack_start(&label, true, true, 1);
|
|
|
|
|
|
|
|
ErrorArea { base, label }
|
|
|
|
}
|
|
|
|
|
2017-07-12 15:32:10 +00:00
|
|
|
pub fn show_nvim_init_error(&self, err: &str) {
|
|
|
|
error!("Can't initialize nvim: {}", err);
|
|
|
|
self.label.set_markup(&format!("<big>Can't initialize nvim:</big>\n\
|
|
|
|
<span foreground=\"red\"><i>{}</i></span>\n\n\
|
|
|
|
<big>Possible error reasons:</big>\n\
|
|
|
|
● Not supported nvim version (minimum supported version is <b>{}</b>)\n\
|
2017-10-13 10:16:52 +00:00
|
|
|
● Error in configuration file (init.vim or ginit.vim)",
|
2017-07-12 15:32:10 +00:00
|
|
|
encode_minimal(err), shell::MINIMUM_SUPPORTED_NVIM_VERSION));
|
|
|
|
self.base.show_all();
|
|
|
|
}
|
|
|
|
|
2017-07-06 09:41:35 +00:00
|
|
|
pub fn show_nvim_start_error(&self, err: &str, cmd: &str) {
|
|
|
|
error!("Can't start nvim: {}\nCommand line: {}", err, cmd);
|
|
|
|
self.label.set_markup(&format!("<big>Can't start nvim instance:</big>\n\
|
|
|
|
<i>{}</i>\n\
|
|
|
|
<span foreground=\"red\"><i>{}</i></span>\n\n\
|
|
|
|
<big>Possible error reasons:</big>\n\
|
|
|
|
● Not supported nvim version (minimum supported version is <b>{}</b>)\n\
|
|
|
|
● Error in configuration file (init.vim or ginit.vim)\n\
|
|
|
|
● Wrong nvim binary path \
|
2017-07-06 16:45:30 +00:00
|
|
|
(right path can be passed with <i>--nvim-bin-path=path_here</i>)",
|
2017-07-06 09:41:35 +00:00
|
|
|
encode_minimal(cmd), encode_minimal(err), shell::MINIMUM_SUPPORTED_NVIM_VERSION));
|
|
|
|
self.base.show_all();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Deref for ErrorArea {
|
|
|
|
type Target = gtk::Box;
|
|
|
|
|
|
|
|
fn deref(&self) -> >k::Box {
|
|
|
|
&self.base
|
|
|
|
}
|
|
|
|
}
|