From e45147dbcd757ecf841b20b08fda4fbc19bbae35 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Mon, 23 Sep 2024 17:45:51 +0300 Subject: [PATCH] make sources refresh --- src/bin/gui/apt_manage_page/mod.rs | 401 +++++++++++++++-------------- 1 file changed, 204 insertions(+), 197 deletions(-) diff --git a/src/bin/gui/apt_manage_page/mod.rs b/src/bin/gui/apt_manage_page/mod.rs index 86ab9a3..cfd59a6 100644 --- a/src/bin/gui/apt_manage_page/mod.rs +++ b/src/bin/gui/apt_manage_page/mod.rs @@ -20,6 +20,10 @@ use tokio::runtime::Runtime; mod add_dialog; +enum AptSourceConfig { + Legacy(apt_legacy_tools::LegacyAptSource), + DEB822(apt_deb822_tools::Deb822Repository) +} pub fn apt_manage_page( window: adw::ApplicationWindow, @@ -28,8 +32,6 @@ pub fn apt_manage_page( let deb822_sources = Deb822Repository::get_deb822_sources().unwrap(); - let mut unofficial_deb822_sources = deb822_sources.clone(); - let system_source = deb822_sources.iter().filter(|x| { match &x.repolib_id { Some(t) => { @@ -38,17 +40,6 @@ pub fn apt_manage_page( None => false } }).next().unwrap(); - - unofficial_deb822_sources.retain(|x| { - match &x.repolib_id { - Some(t) => { - !(t == "system") - } - None => true - } - }); - - let legacy_apt_repos = apt_legacy_tools::LegacyAptSource::get_legacy_sources(); let main_box = Box::builder() .hexpand(true) @@ -112,164 +103,168 @@ pub fn apt_manage_page( .margin_end(15) .build(); - let unofficial_sources_list_store = gio::ListStore::new::(); - - enum AptSourceConfig { - Legacy(apt_legacy_tools::LegacyAptSource), - DEB822(apt_deb822_tools::Deb822Repository) - } - - for deb822_source in unofficial_deb822_sources { - unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::DEB822(deb822_source))); - }; - - match legacy_apt_repos { - Ok(vec) => { - for legacy_repo in vec { - unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::Legacy(legacy_repo))); - }; - } - Err(_) => {} - } - - let unofficial_sources_selection_model = SingleSelection::new(Some(unofficial_sources_list_store)); - - /*let unofficial_sources_item_factory = SignalListItemFactory::new(); - - unofficial_sources_item_factory.connect_setup(|_item_factory, list_item| { - let label = gtk::Label::new(Some("DDD")); - - let list_item = list_item.downcast_ref::().unwrap(); - - list_item.set_child(Some(&label)); - }); - - unofficial_sources_item_factory.connect_bind(|_item_factory, list_item| { - let list_item = list_item.downcast_ref::().unwrap(); - - let list_item_item = list_item.item().unwrap().to_value().get::().unwrap(); - let list_item_label = list_item.child().unwrap().downcast::().unwrap(); - - list_item_label.set_label(&list_item_item); - }); - */ - - let unofficial_sources_columnview = ColumnView::builder() - .vexpand(true) - .model(&unofficial_sources_selection_model) - .build(); - - // - - let unofficial_sources_columnview_factory0 = gtk::SignalListItemFactory::new(); - - unofficial_sources_columnview_factory0.connect_setup(move |_factory, item| { - let item = item.downcast_ref::().unwrap(); - let row = Label::builder() - .halign(Align::Start) - .build(); - item.set_child(Some(&row)); - }); - - unofficial_sources_columnview_factory0.connect_bind(move |_factory, item| { - let item: &ListItem = item.downcast_ref::().unwrap(); - let child = item.child().and_downcast::