List plugins
This commit is contained in:
parent
c1b6bbca88
commit
15bcb1f25d
@ -29,6 +29,10 @@ impl Store {
|
|||||||
|
|
||||||
Store { settings }
|
Store { settings }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_plugs(&self) -> &[PlugInfo] {
|
||||||
|
&self.settings.plugs
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@ -56,8 +60,8 @@ impl SettingsLoader for Settings {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct PlugInfo {
|
pub struct PlugInfo {
|
||||||
name: String,
|
pub name: String,
|
||||||
url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlugInfo {
|
impl PlugInfo {
|
||||||
|
@ -24,24 +24,25 @@ impl<'a> Ui<'a> {
|
|||||||
&[("Ok", OK_ID)],
|
&[("Ok", OK_ID)],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
dlg.set_default_size(800, 600);
|
||||||
let content = dlg.get_content_area();
|
let content = dlg.get_content_area();
|
||||||
let tabs = gtk::Notebook::new();
|
let tabs = gtk::Notebook::new();
|
||||||
|
|
||||||
let vim_plug_state = self.get_state();
|
let vim_plug_state = self.get_state();
|
||||||
match vim_plug_state {
|
match vim_plug_state {
|
||||||
vim_plug::State::AlreadyLoaded => {
|
vim_plug::State::AlreadyLoaded => {
|
||||||
let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 3);
|
||||||
let warn_lbl = gtk::Label::new(
|
let warn_lbl = gtk::Label::new(None);
|
||||||
"vim-plug manager already loaded.\n\
|
warn_lbl.set_markup("<span foreground=\"red\">Note:</span> <b>vim-plug</b> manager already loaded.\n\
|
||||||
NeovimGtk manages plugins using vim-plug as backend.\n\
|
NeovimGtk manages plugins using vim-plug as backend.\n\
|
||||||
To allow NeovimGtk manage plugins please disable vim-plug in your configuration.\n\
|
To allow NeovimGtk manage plugins please disable vim-plug in your configuration.\n\
|
||||||
You can convert vim-plug configuration to NeovimGtk conviguration using button below.\n\
|
You can convert vim-plug configuration to NeovimGtk conviguration using button below.\n\
|
||||||
List of current vim-plug plugins can be found in 'Plugins' tab.",
|
List of current vim-plug plugins can be found in 'Plugins' tab.",
|
||||||
);
|
);
|
||||||
get_plugins.add(&warn_lbl);
|
get_plugins.pack_start(&warn_lbl, true, false, 0);
|
||||||
|
|
||||||
let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration");
|
let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration");
|
||||||
get_plugins.add(©_btn);
|
get_plugins.pack_start(©_btn, false, false, 0);
|
||||||
|
|
||||||
let get_plugins_lbl = gtk::Label::new("Help");
|
let get_plugins_lbl = gtk::Label::new("Help");
|
||||||
tabs.append_page(&get_plugins, Some(&get_plugins_lbl));
|
tabs.append_page(&get_plugins, Some(&get_plugins_lbl));
|
||||||
@ -53,7 +54,7 @@ impl<'a> Ui<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let plugins = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
let plugins = gtk::Box::new(gtk::Orientation::Vertical, 3);
|
||||||
let store = self.manager.load_store(&vim_plug_state);
|
let store = self.manager.load_store(&vim_plug_state);
|
||||||
|
|
||||||
self.fill_plugin_list(&plugins, &store);
|
self.fill_plugin_list(&plugins, &store);
|
||||||
@ -62,7 +63,7 @@ impl<'a> Ui<'a> {
|
|||||||
tabs.append_page(&plugins, Some(&plugins_lbl));
|
tabs.append_page(&plugins, Some(&plugins_lbl));
|
||||||
|
|
||||||
tabs.set_tab_pos(gtk::PositionType::Left);
|
tabs.set_tab_pos(gtk::PositionType::Left);
|
||||||
content.add(&tabs);
|
content.pack_start(&tabs, true, true, 0);
|
||||||
content.show_all();
|
content.show_all();
|
||||||
|
|
||||||
|
|
||||||
@ -77,15 +78,25 @@ impl<'a> Ui<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fill_plugin_list(&self, panel: >k::Box, store: &Store) {
|
fn fill_plugin_list(&self, panel: >k::Box, store: &Store) {
|
||||||
let tree = gtk::TreeView::new();
|
|
||||||
let scroll = gtk::ScrolledWindow::new(None, None);
|
let scroll = gtk::ScrolledWindow::new(None, None);
|
||||||
|
let plugs_panel = gtk::ListBox::new();
|
||||||
|
|
||||||
tree.set_headers_visible(false);
|
for plug_info in store.get_plugs() {
|
||||||
tree.set_can_focus(false);
|
let grid = gtk::Grid::new();
|
||||||
scroll.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic);
|
|
||||||
scroll.add(&tree);
|
|
||||||
|
|
||||||
panel.add(&scroll);
|
let name_lbl = gtk::Label::new(None);
|
||||||
|
name_lbl.set_markup(&format!("<b>{}</b>", plug_info.name.as_str()));
|
||||||
|
name_lbl.set_halign(gtk::Align::Start);
|
||||||
|
let url_lbl = gtk::Label::new(Some(plug_info.url.as_str()));
|
||||||
|
|
||||||
|
grid.attach(&name_lbl, 0, 0, 1, 1);
|
||||||
|
grid.attach(&url_lbl, 0, 1, 1, 1);
|
||||||
|
|
||||||
|
plugs_panel.insert(&grid, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
scroll.add(&plugs_panel);
|
||||||
|
panel.pack_start(&scroll, true, true, 0);
|
||||||
|
|
||||||
let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration");
|
let copy_btn = gtk::Button::new_with_label("Copy plugins from current vim-plug configuration");
|
||||||
panel.add(©_btn);
|
panel.add(©_btn);
|
||||||
|
Loading…
Reference in New Issue
Block a user