fix kernel parse timeout
This commit is contained in:
parent
fd1fac0bec
commit
596bed8f4b
@ -36,6 +36,8 @@
|
||||
"kernel_install_dialog_reboot_label": "Reboot Now (Optional)",
|
||||
"kernel_install_dialog_body_successful": "Kernel installation was successful!",
|
||||
"kernel_install_dialog_body_failed": "Kernel installation failed!",
|
||||
"parse_loading_dialog_heading": "Please Wait!",
|
||||
"parse_loading_dialog_body": "Loading Kernel Repo Data....",
|
||||
"log_status_kernel_modify_successful": "Status: kernel modify Successful",
|
||||
"log_status_kernel_modify_failed": "Status: kernel modify Failed",
|
||||
"scx_sched_expander_row_subtitle": "Select Sched-EXT SCX Scheduler",
|
||||
|
Binary file not shown.
@ -133,10 +133,7 @@ pub fn content(
|
||||
|
||||
browse_kernels_button.connect_clicked(
|
||||
clone!(@weak window, @weak content_stack, @strong selected_kernel_branch => move |_| {
|
||||
content_stack.add_named(
|
||||
&kernel_pkg::kernel_pkg_page(&content_stack, &window, &selected_kernel_branch),
|
||||
Some("kernel_pkg_page"),
|
||||
);
|
||||
kernel_pkg::kernel_pkg_page(&content_stack, &window, &selected_kernel_branch);
|
||||
content_stack.set_visible_child_name("kernel_pkg_page")
|
||||
}),
|
||||
);
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{kernel_package_row, KernelBranch};
|
||||
use crate::{kernel_package_row, KernelBranch, KernelPackage};
|
||||
use adw::prelude::*;
|
||||
use duct::cmd;
|
||||
use glib::*;
|
||||
@ -16,9 +16,25 @@ pub fn kernel_pkg_page(
|
||||
content_stack: >k::Stack,
|
||||
window: &adw::ApplicationWindow,
|
||||
selected_kernel_branch: &Rc<RefCell<KernelBranch>>,
|
||||
) -> gtk::Box {
|
||||
) {
|
||||
let selected_kernel_branch_clone0 = selected_kernel_branch.borrow().clone();
|
||||
|
||||
let parse_loading_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(window)
|
||||
.extra_child(>k::Spinner::builder()
|
||||
.hexpand(true)
|
||||
.valign(Align::Start)
|
||||
.halign(Align::Center)
|
||||
.spinning(true)
|
||||
.height_request(128)
|
||||
.width_request(128)
|
||||
.build())
|
||||
.heading(t!("parse_loading_dialog_heading"))
|
||||
.body(t!("parse_loading_dialog_body"))
|
||||
.build();
|
||||
|
||||
parse_loading_dialog.present();
|
||||
|
||||
let main_box = gtk::Box::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
@ -66,6 +82,11 @@ pub fn kernel_pkg_page(
|
||||
.build();
|
||||
searchbar.add_css_class("rounded-all-25");
|
||||
|
||||
content_stack.add_named(
|
||||
&main_box,
|
||||
Some("kernel_pkg_page"),
|
||||
);
|
||||
|
||||
let packages_boxedlist = gtk::ListBox::builder()
|
||||
.selection_mode(SelectionMode::None)
|
||||
.margin_bottom(15)
|
||||
@ -77,10 +98,11 @@ pub fn kernel_pkg_page(
|
||||
let rows_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||
add_package_rows(
|
||||
&packages_boxedlist,
|
||||
&selected_kernel_branch_clone0.db,
|
||||
selected_kernel_branch_clone0.db,
|
||||
&window,
|
||||
&rows_size_group,
|
||||
&searchbar,
|
||||
&parse_loading_dialog
|
||||
);
|
||||
|
||||
let packages_viewport = gtk::ScrolledWindow::builder()
|
||||
@ -125,15 +147,16 @@ pub fn kernel_pkg_page(
|
||||
main_box.append(&packages_viewport);
|
||||
main_box.append(&window_bottombar);
|
||||
|
||||
main_box
|
||||
//parse_loading_dialog.close();
|
||||
}
|
||||
|
||||
fn add_package_rows(
|
||||
boxedlist: >k::ListBox,
|
||||
data: &str,
|
||||
data: String,
|
||||
window: &adw::ApplicationWindow,
|
||||
rows_size_group: >k::SizeGroup,
|
||||
searchbar: >k::SearchEntry,
|
||||
parse_loading_dialog: &adw::MessageDialog
|
||||
) {
|
||||
let cpu_feature_level: u32 = match get_cpu_feature_level().as_str() {
|
||||
"x86-64-v4" => 4,
|
||||
@ -141,6 +164,14 @@ fn add_package_rows(
|
||||
"x86-64-v2" => 2,
|
||||
_ => 1,
|
||||
};
|
||||
|
||||
let (kernel_package_sender, kernel_package_receiver) = async_channel::unbounded();
|
||||
let kernel_package_sender = kernel_package_sender.clone();
|
||||
|
||||
let (kernel_package_done_sender, kernel_package_done_receiver) = async_channel::unbounded();
|
||||
let kernel_package_done_sender = kernel_package_done_sender.clone();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
|
||||
if let serde_json::Value::Array(kernels) = &res["kernels"] {
|
||||
for kernel in kernels {
|
||||
@ -176,6 +207,30 @@ fn add_package_rows(
|
||||
_ => "Error".to_owned(),
|
||||
};
|
||||
|
||||
let kernel_package = KernelPackage{
|
||||
name: kernel_name,
|
||||
main_package: kernel_main_package,
|
||||
packages: kernel_packages,
|
||||
min_x86_march: kernel_min_x86_march,
|
||||
package_version: kernel_package_version,
|
||||
description: kernel_description
|
||||
};
|
||||
kernel_package_sender.send_blocking(kernel_package).expect("Kernel Package sender channel closed")
|
||||
}};
|
||||
kernel_package_done_sender.send_blocking(true).expect("Kernel Package done sender channel closed")
|
||||
});
|
||||
|
||||
let kernel_package_context = MainContext::default();
|
||||
// The main loop executes the asynchronous block
|
||||
kernel_package_context.spawn_local(clone!(@strong boxedlist, @strong window, @strong rows_size_group => async move {
|
||||
while let Ok(kernel_pkg_status) = kernel_package_receiver.recv().await {
|
||||
let kernel_name = kernel_pkg_status.name;
|
||||
let kernel_main_package = kernel_pkg_status.main_package;
|
||||
let kernel_packages = kernel_pkg_status.packages;
|
||||
let kernel_min_x86_march = kernel_pkg_status.min_x86_march;
|
||||
let kernel_package_version = kernel_pkg_status.package_version;
|
||||
let kernel_description = kernel_pkg_status.description;
|
||||
|
||||
let (log_loop_sender, log_loop_receiver) = async_channel::unbounded();
|
||||
let log_loop_sender: async_channel::Sender<String> = log_loop_sender.clone();
|
||||
|
||||
@ -207,10 +262,8 @@ fn add_package_rows(
|
||||
std::thread::sleep(Duration::from_secs(6));
|
||||
});
|
||||
|
||||
let kernel_main_package_clone0 = kernel_main_package.clone();
|
||||
|
||||
let kernel_expander_row = kernel_package_row::KernelPackageRow::new();
|
||||
kernel_expander_row.set_package(kernel_main_package_clone0);
|
||||
kernel_expander_row.set_package(kernel_main_package);
|
||||
let kernel_status_icon = gtk::Image::builder()
|
||||
.icon_name("emblem-default")
|
||||
.pixel_size(24)
|
||||
@ -288,7 +341,7 @@ fn add_package_rows(
|
||||
.build();
|
||||
|
||||
let kernel_install_dialog = adw::MessageDialog::builder()
|
||||
.transient_for(window)
|
||||
.transient_for(&window)
|
||||
.hide_on_close(true)
|
||||
.extra_child(&kernel_install_log_terminal_scroll)
|
||||
.width_request(400)
|
||||
@ -404,7 +457,14 @@ fn add_package_rows(
|
||||
boxedlist.append(&kernel_expander_row);
|
||||
}
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
let kernel_package_done_context = MainContext::default();
|
||||
kernel_package_done_context.spawn_local(clone!(@weak parse_loading_dialog => async move {
|
||||
while let Ok(_state) = kernel_package_done_receiver.recv().await {
|
||||
parse_loading_dialog.close();
|
||||
}
|
||||
}));
|
||||
|
||||
searchbar.connect_search_changed(clone!(@weak searchbar, @weak boxedlist => move |_| {
|
||||
let mut counter = boxedlist.first_child();
|
||||
|
@ -69,6 +69,15 @@ struct KernelBranch {
|
||||
init_script: String,
|
||||
}
|
||||
|
||||
struct KernelPackage {
|
||||
name: String,
|
||||
main_package: String,
|
||||
packages: String,
|
||||
min_x86_march: u32,
|
||||
package_version: String,
|
||||
description: String
|
||||
}
|
||||
|
||||
fn main() -> glib::ExitCode {
|
||||
let current_locale = match env::var_os("LANG") {
|
||||
Some(v) => v.into_string().unwrap().chars()
|
||||
|
Loading…
Reference in New Issue
Block a user