Number of ui improvements

This commit is contained in:
daa 2017-11-05 20:52:29 +03:00
parent bb984c8223
commit 50bea23b6b
3 changed files with 33 additions and 18 deletions

View File

@ -107,7 +107,7 @@ impl PlugManagerConfigSource {
for plug in store.get_plugs() {
if !plug.removed {
builder += &format!("Plug '{}'\n", plug.get_plug_path());
builder += &format!("Plug '{}', {{ 'as': '{}' }}\n", plug.get_plug_path(), plug.name);
}
}

View File

@ -24,12 +24,17 @@ impl<'a> Builder<'a> {
);
let content = dlg.get_content_area();
let border = gtk::Box::new(gtk::Orientation::Horizontal, 0);
border.set_border_width(12);
let list = gtk::ListBox::new();
list.set_selection_mode(gtk::SelectionMode::None);
let path = gtk::Box::new(gtk::Orientation::Horizontal, 0);
let path = gtk::Box::new(gtk::Orientation::Horizontal, 5);
path.set_border_width(5);
let path_lbl = gtk::Label::new("Repo");
let path_e = gtk::Entry::new();
path_e.set_placeholder_text("user_name/repo_name");
path.pack_start(&path_lbl, true, true, 0);
path.pack_end(&path_e, false, true, 0);
@ -37,7 +42,8 @@ impl<'a> Builder<'a> {
list.add(&path);
let name = gtk::Box::new(gtk::Orientation::Horizontal, 0);
let name = gtk::Box::new(gtk::Orientation::Horizontal, 5);
name.set_border_width(5);
let name_lbl = gtk::Label::new("Name");
let name_e = gtk::Entry::new();
@ -46,9 +52,16 @@ impl<'a> Builder<'a> {
list.add(&name);
content.add(&list);
border.pack_start(&list, true, true, 0);
content.add(&border);
content.show_all();
path_e.connect_changed(clone!(name_e => move |p| {
if let Some(name) = p.get_text().and_then(|t| extract_name(&t)) {
name_e.set_text(&name);
}
}));
let ok: i32 = gtk::ResponseType::Ok.into();
let res = if dlg.run() == ok {
path_e.get_text().map(|path| {
@ -59,7 +72,7 @@ impl<'a> Builder<'a> {
} else {
Some(name)
})
.or_else(|| Builder::extract_name(&path))
.or_else(|| extract_name(&path))
.unwrap_or_else(|| path.clone());
store::PlugInfo::new(name.to_owned(), path.to_owned())
@ -72,18 +85,18 @@ impl<'a> Builder<'a> {
res
}
}
fn extract_name(path: &str) -> Option<String> {
if let Some(idx) = path.rfind(|c| c == '/' || c == '\\') {
if idx < path.len() - 1 {
let path = path.trim_right_matches(".git");
Some(path[idx + 1..].to_owned())
} else {
None
}
fn extract_name(path: &str) -> Option<String> {
if let Some(idx) = path.rfind(|c| c == '/' || c == '\\') {
if idx < path.len() - 1 {
let path = path.trim_right_matches(".git");
Some(path[idx + 1..].to_owned())
} else {
None
}
} else {
None
}
}

View File

@ -43,6 +43,7 @@ impl<'a> Ui<'a> {
let header_bar = gtk::HeaderBar::new();
let add_plug_btn = gtk::Button::new_with_label("Add..");
add_plug_btn.get_style_context().map(|c| c.add_class("suggested-action"));
header_bar.pack_end(&add_plug_btn);
@ -81,14 +82,14 @@ impl<'a> Ui<'a> {
&pages,
&format!(
"NeovimGtk plugin manager is a GUI for vim-plug.\n\
It can load plugins from vim-plug configuration if vim-plug sarted and self settings is empty.\n\
It can load plugins from vim-plug configuration if vim-plug sarted and NeovimGtk manager settings is empty.\n\
When enabled it generate and load vim-plug as simple vim file at startup before init.vim is processed.\n\
So after enabling this manager <b>you must disable vim-plug</b> configuration in init.vim.\n\
So <b>after</b> enabling this manager <b>you must disable vim-plug</b> configuration in init.vim.\n\
This manager currently only manage vim-plug configuration and do not any actions on plugin management.\n\
So you must call all vim-plug (PlugInstall, PlugUpdate, PlugClean) commands manually.\n\
Current configuration source is <b>{}</b>",
match self.manager.borrow().plug_manage_state {
manager::PlugManageState::NvimGtk => "config file",
manager::PlugManageState::NvimGtk => "NeovimGtk config file",
manager::PlugManageState::VimPlug => "loaded from vim-plug",
manager::PlugManageState::Unknown => "Unknown",
}
@ -155,8 +156,8 @@ fn create_up_down_btns(
manager: &Arc<UiMutex<manager::Manager>>,
) -> gtk::Box {
let buttons_panel = gtk::Box::new(gtk::Orientation::Horizontal, 5);
let up_btn = gtk::Button::new_from_icon_name("go-up", gtk_sys::GTK_ICON_SIZE_BUTTON as i32);
let down_btn = gtk::Button::new_from_icon_name("go-down", gtk_sys::GTK_ICON_SIZE_BUTTON as i32);
let up_btn = gtk::Button::new_from_icon_name("go-up-symbolic", gtk_sys::GTK_ICON_SIZE_BUTTON as i32);
let down_btn = gtk::Button::new_from_icon_name("go-down-symbolic", gtk_sys::GTK_ICON_SIZE_BUTTON as i32);
up_btn.connect_clicked(clone!(plugs_panel, manager => move |_| {
if let Some(row) = plugs_panel.get_selected_row() {
@ -188,6 +189,7 @@ fn create_up_down_btns(
buttons_panel.pack_start(&up_btn, false, true, 0);
buttons_panel.pack_start(&down_btn, false, true, 0);
buttons_panel.set_halign(gtk::Align::Center);
buttons_panel
}