diff --git a/src/plug_manager/store.rs b/src/plug_manager/store.rs index 2f9c9ec..df8de13 100644 --- a/src/plug_manager/store.rs +++ b/src/plug_manager/store.rs @@ -29,6 +29,10 @@ impl Store { Store { settings } } + + pub fn get_plugs(&self) -> &[PlugInfo] { + &self.settings.plugs + } } #[derive(Serialize, Deserialize)] @@ -56,8 +60,8 @@ impl SettingsLoader for Settings { #[derive(Serialize, Deserialize)] pub struct PlugInfo { - name: String, - url: String, + pub name: String, + pub url: String, } impl PlugInfo { diff --git a/src/plug_manager/ui.rs b/src/plug_manager/ui.rs index 56e0297..29ab093 100644 --- a/src/plug_manager/ui.rs +++ b/src/plug_manager/ui.rs @@ -24,24 +24,25 @@ impl<'a> Ui<'a> { &[("Ok", OK_ID)], ); + dlg.set_default_size(800, 600); let content = dlg.get_content_area(); let tabs = gtk::Notebook::new(); let vim_plug_state = self.get_state(); match vim_plug_state { vim_plug::State::AlreadyLoaded => { - let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 0); - let warn_lbl = gtk::Label::new( - "vim-plug manager already loaded.\n\ + let get_plugins = gtk::Box::new(gtk::Orientation::Vertical, 3); + let warn_lbl = gtk::Label::new(None); + warn_lbl.set_markup("Note: vim-plug manager already loaded.\n\ NeovimGtk manages plugins using vim-plug as backend.\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\ 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"); - get_plugins.add(©_btn); + get_plugins.pack_start(©_btn, false, false, 0); let get_plugins_lbl = gtk::Label::new("Help"); 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); self.fill_plugin_list(&plugins, &store); @@ -62,7 +63,7 @@ impl<'a> Ui<'a> { tabs.append_page(&plugins, Some(&plugins_lbl)); tabs.set_tab_pos(gtk::PositionType::Left); - content.add(&tabs); + content.pack_start(&tabs, true, true, 0); content.show_all(); @@ -77,15 +78,25 @@ impl<'a> Ui<'a> { } fn fill_plugin_list(&self, panel: >k::Box, store: &Store) { - let tree = gtk::TreeView::new(); let scroll = gtk::ScrolledWindow::new(None, None); + let plugs_panel = gtk::ListBox::new(); - tree.set_headers_visible(false); - tree.set_can_focus(false); - scroll.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic); - scroll.add(&tree); + for plug_info in store.get_plugs() { + let grid = gtk::Grid::new(); - panel.add(&scroll); + let name_lbl = gtk::Label::new(None); + name_lbl.set_markup(&format!("{}", 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"); panel.add(©_btn);