Merge remote-tracking branch 'origin/master' into ext_cmdline

This commit is contained in:
daa84 2018-03-30 12:37:34 +03:00
commit fb9d51c928
4 changed files with 53 additions and 20 deletions

View File

@ -180,7 +180,9 @@ impl FileBrowserWidget {
cd_action.connect_activate(clone!(state_ref, nvim_ref => move |_, _| { cd_action.connect_activate(clone!(state_ref, nvim_ref => move |_, _| {
let mut nvim = nvim_ref.nvim().unwrap(); let mut nvim = nvim_ref.nvim().unwrap();
if let Some(ref path) = state_ref.borrow().selected_path { if let Some(ref path) = state_ref.borrow().selected_path {
nvim.set_current_dir(&path).report_err(); nvim.set_current_dir_async(&path)
.cb(|r| r.report_err())
.call();
} }
})); }));
actions.add_action(cd_action); actions.add_action(cd_action);
@ -201,11 +203,10 @@ impl FileBrowserWidget {
&["getcwd()"], &["getcwd()"],
clone!(store, state_ref, dir_list_model, dir_list => move |args| { clone!(store, state_ref, dir_list_model, dir_list => move |args| {
let dir = args.into_iter().next().unwrap(); let dir = args.into_iter().next().unwrap();
let mut state = state_ref.borrow_mut(); if dir != state_ref.borrow().current_dir {
if dir != *state.current_dir { state_ref.borrow_mut().current_dir = dir.to_owned();
update_dir_list(&dir, &dir_list_model, &dir_list); update_dir_list(&dir, &dir_list_model, &dir_list);
state.current_dir = dir; tree_reload(&store, &state_ref.borrow());
tree_reload(&store, &state);
} }
}), }),
); );
@ -277,18 +278,20 @@ impl FileBrowserWidget {
// Connect directory list. // Connect directory list.
let nvim_ref = self.nvim.as_ref().unwrap(); let nvim_ref = self.nvim.as_ref().unwrap();
self.comps.dir_list.connect_changed(clone!(nvim_ref => move |dir_list| { self.comps.dir_list.connect_changed(clone!(nvim_ref, state_ref => move |dir_list| {
if let Some(iter) = dir_list.get_active_iter() { if let Some(iter) = dir_list.get_active_iter() {
let model = dir_list.get_model().unwrap(); let model = dir_list.get_model().unwrap();
if let Some(dir) = model.get_value(&iter, 2).get::<&str>() { if let Some(dir) = model.get_value(&iter, 2).get::<&str>() {
let mut nvim = nvim_ref.nvim().unwrap(); if dir != state_ref.borrow().current_dir {
nvim.set_current_dir(dir).report_err(); let mut nvim = nvim_ref.nvim().unwrap();
nvim.set_current_dir_async(dir)
.cb(|r| r.report_err())
.call();
}
} }
} }
})); }));
let store = &self.store;
let state_ref = &self.state;
let context_menu = &self.comps.context_menu; let context_menu = &self.comps.context_menu;
let cd_action = &self.comps.cd_action; let cd_action = &self.comps.cd_action;
self.tree.connect_button_press_event( self.tree.connect_button_press_event(
@ -337,8 +340,11 @@ impl FileBrowserWidget {
fn cmp_dirs_first(lhs: &DirEntry, rhs: &DirEntry) -> io::Result<Ordering> { fn cmp_dirs_first(lhs: &DirEntry, rhs: &DirEntry) -> io::Result<Ordering> {
let lhs_metadata = fs::metadata(lhs.path())?; let lhs_metadata = fs::metadata(lhs.path())?;
let rhs_metadata = fs::metadata(rhs.path())?; let rhs_metadata = fs::metadata(rhs.path())?;
if lhs_metadata.file_type() == rhs_metadata.file_type() { if lhs_metadata.is_dir() == rhs_metadata.is_dir() {
Ok(lhs.path().cmp(&rhs.path())) Ok(lhs.path()
.to_string_lossy()
.to_lowercase()
.cmp(&rhs.path().to_string_lossy().to_lowercase()))
} else { } else {
if lhs_metadata.is_dir() { if lhs_metadata.is_dir() {
Ok(Ordering::Less) Ok(Ordering::Less)

View File

@ -1,3 +1,5 @@
#![windows_subsystem = "windows"]
extern crate cairo; extern crate cairo;
extern crate env_logger; extern crate env_logger;
extern crate gdk; extern crate gdk;

View File

@ -79,6 +79,13 @@ impl error::Error for NvimInitError {
} }
} }
#[cfg(target_os = "windows")]
fn set_windows_creation_flags(cmd: &mut Command) {
use std::os::windows::process::CommandExt;
cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW
}
pub fn start( pub fn start(
shell: Arc<UiMutex<shell::State>>, shell: Arc<UiMutex<shell::State>>,
nvim_bin_path: Option<&String>, nvim_bin_path: Option<&String>,
@ -100,6 +107,9 @@ pub fn start(
.arg("let g:GtkGuiLoaded = 1") .arg("let g:GtkGuiLoaded = 1")
.stderr(Stdio::inherit()); .stderr(Stdio::inherit());
#[cfg(target_os = "windows")]
set_windows_creation_flags(&mut cmd);
if let Ok(runtime_path) = env::var("NVIM_GTK_RUNTIME_PATH") { if let Ok(runtime_path) = env::var("NVIM_GTK_RUNTIME_PATH") {
cmd.arg("--cmd").arg( cmd.arg("--cmd").arg(
format!("let &rtp.=',{}'", runtime_path), format!("let &rtp.=',{}'", runtime_path),

View File

@ -73,6 +73,9 @@ impl Projects {
projects.setup_tree(); projects.setup_tree();
projects.tree.set_activate_on_single_click(true);
projects.tree.set_hover_selection(true);
projects.tree.set_grid_lines(gtk::TreeViewGridLines::Horizontal);
let vbox = gtk::Box::new(Orientation::Vertical, 5); let vbox = gtk::Box::new(Orientation::Vertical, 5);
vbox.set_border_width(5); vbox.set_border_width(5);
@ -89,11 +92,12 @@ impl Projects {
); );
projects.scroll.add(&projects.tree); projects.scroll.add(&projects.tree);
projects.scroll.set_shadow_type(gtk::ShadowType::In);
vbox.pack_start(&projects.scroll, true, true, 0); vbox.pack_start(&projects.scroll, true, true, 0);
let open_btn = gtk::Button::new_with_label("Other Documents…"); let open_btn = gtk::Button::new_with_label("Other Documents…");
vbox.pack_start(&open_btn, true, true, 0); vbox.pack_start(&open_btn, true, true, 5);
vbox.show_all(); vbox.show_all();
projects.popup.add(&vbox); projects.popup.add(&vbox);
@ -129,7 +133,12 @@ impl Projects {
let prj_ref = projects.clone(); let prj_ref = projects.clone();
projects.borrow().tree.connect_row_activated( projects.borrow().tree.connect_row_activated(
move |tree, _, _| { move |tree, _, column| {
// Don't activate if the user clicked the checkbox.
let toggle_column = tree.get_column(2).unwrap();
if *column == toggle_column {
return;
}
let selection = tree.get_selection(); let selection = tree.get_selection();
if let Some((model, iter)) = selection.get_selected() { if let Some((model, iter)) = selection.get_selected() {
prj_ref.borrow().open_uri(&model, &iter); prj_ref.borrow().open_uri(&model, &iter);
@ -281,6 +290,7 @@ impl Projects {
let image_column = TreeViewColumn::new(); let image_column = TreeViewColumn::new();
let icon_renderer = CellRendererPixbuf::new(); let icon_renderer = CellRendererPixbuf::new();
icon_renderer.set_padding(5, 0);
image_column.pack_start(&icon_renderer, true); image_column.pack_start(&icon_renderer, true);
image_column.add_attribute( image_column.add_attribute(
@ -293,18 +303,23 @@ impl Projects {
let text_column = TreeViewColumn::new(); let text_column = TreeViewColumn::new();
self.name_renderer.set_property_width_chars(60); self.name_renderer.set_property_width_chars(45);
self.path_renderer.set_property_width_chars(60); self.path_renderer.set_property_width_chars(45);
self.name_renderer.set_property_ellipsize(
pango::EllipsizeMode::Middle,
);
self.path_renderer.set_property_ellipsize( self.path_renderer.set_property_ellipsize(
pango::EllipsizeMode::Start, pango::EllipsizeMode::Start,
); );
self.name_renderer.set_padding(0, 5);
self.path_renderer.set_padding(0, 5);
text_column.pack_start(&self.name_renderer, true); text_column.pack_start(&self.name_renderer, true);
text_column.pack_start(&self.path_renderer, true); text_column.pack_start(&self.path_renderer, true);
text_column.add_attribute( text_column.add_attribute(
&self.name_renderer, &self.name_renderer,
"markup", "text",
ProjectViewColumns::Name as i32, ProjectViewColumns::Name as i32,
); );
text_column.add_attribute( text_column.add_attribute(
@ -492,7 +507,7 @@ impl Entry {
format!("<small>{}</small>", encode_minimal(&s.to_string_lossy())) format!("<small>{}</small>", encode_minimal(&s.to_string_lossy()))
}) })
.unwrap_or_else(|| "".to_owned()), .unwrap_or_else(|| "".to_owned()),
file_name: format!("<big>{}</big>", encode_minimal(name)), file_name: encode_minimal(name),
name: name.to_owned(), name: name.to_owned(),
pixbuf: BOOKMARKED_PIXBUF, pixbuf: BOOKMARKED_PIXBUF,
project: true, project: true,
@ -513,7 +528,7 @@ impl Entry {
format!("<small>{}</small>", encode_minimal(&s.to_string_lossy())) format!("<small>{}</small>", encode_minimal(&s.to_string_lossy()))
}) })
.unwrap_or_else(|| "".to_owned()), .unwrap_or_else(|| "".to_owned()),
file_name: format!("<big>{}</big>", encode_minimal(&name)), file_name: encode_minimal(&name),
name, name,
pixbuf: CURRENT_DIR_PIXBUF, pixbuf: CURRENT_DIR_PIXBUF,
project: true, project: true,
@ -534,7 +549,7 @@ impl Entry {
format!("<small>{}</small>", encode_minimal(&s.to_string_lossy())) format!("<small>{}</small>", encode_minimal(&s.to_string_lossy()))
}) })
.unwrap_or_else(|| "".to_owned()), .unwrap_or_else(|| "".to_owned()),
file_name: format!("<big>{}</big>", encode_minimal(&name)), file_name: encode_minimal(&name),
name, name,
pixbuf: PLAIN_FILE_PIXBUF, pixbuf: PLAIN_FILE_PIXBUF,
project: false, project: false,