2024-06-19 01:44:47 +03:00
|
|
|
use std::cell::RefCell;
|
2024-06-18 15:45:10 +03:00
|
|
|
use crate::content::get_running_kernel_info;
|
2024-06-19 01:44:47 +03:00
|
|
|
use crate::{KernelBranch, RunningKernelInfo};
|
2024-06-18 15:45:10 +03:00
|
|
|
use adw::prelude::*;
|
|
|
|
use glib::*;
|
|
|
|
use gtk::prelude::*;
|
|
|
|
use gtk::*;
|
|
|
|
use std::fs;
|
|
|
|
use std::fs::*;
|
2024-06-19 01:44:47 +03:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
pub fn kernel_pkg_page(content_stack: >k::Stack, selected_kernel_branch: &Rc<RefCell<KernelBranch>>) -> gtk::Box {
|
|
|
|
let selected_kernel_branch_clone0 = selected_kernel_branch.borrow().clone();
|
2024-06-18 15:45:10 +03:00
|
|
|
|
|
|
|
let main_box = gtk::Box::builder()
|
|
|
|
.hexpand(true)
|
|
|
|
.vexpand(true)
|
|
|
|
.orientation(Orientation::Vertical)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let main_label = gtk::Label::builder()
|
2024-06-19 01:44:47 +03:00
|
|
|
.label(format!("Available Kernel Packages for {}", &selected_kernel_branch_clone0.name))
|
2024-06-18 15:45:10 +03:00
|
|
|
.hexpand(true)
|
|
|
|
.margin_start(10)
|
|
|
|
.margin_end(10)
|
|
|
|
.margin_bottom(20)
|
|
|
|
.margin_top(20)
|
|
|
|
.build();
|
|
|
|
main_label.add_css_class("symbolic-accent-bg");
|
2024-06-19 01:44:47 +03:00
|
|
|
main_label.add_css_class("size-20-font");
|
2024-06-18 15:45:10 +03:00
|
|
|
|
2024-06-19 01:44:47 +03:00
|
|
|
let searchbar = gtk::SearchEntry::builder()
|
|
|
|
.search_delay(500)
|
|
|
|
.margin_bottom(15)
|
|
|
|
.margin_start(15)
|
|
|
|
.margin_end(15)
|
|
|
|
.margin_start(15)
|
2024-06-18 15:45:10 +03:00
|
|
|
.build();
|
2024-06-19 01:44:47 +03:00
|
|
|
searchbar.add_css_class("rounded-all-25");
|
2024-06-18 15:45:10 +03:00
|
|
|
|
2024-06-19 01:44:47 +03:00
|
|
|
let packages_boxedlist = gtk::ListBox::builder()
|
|
|
|
.selection_mode(SelectionMode::None)
|
2024-06-18 15:45:10 +03:00
|
|
|
.build();
|
2024-06-19 01:44:47 +03:00
|
|
|
packages_boxedlist.add_css_class("boxed-list");
|
|
|
|
add_package_rows(&packages_boxedlist, &selected_kernel_branch_clone0.db);
|
2024-06-18 15:45:10 +03:00
|
|
|
|
2024-06-19 01:44:47 +03:00
|
|
|
let packages_viewport = gtk::ScrolledWindow::builder()
|
|
|
|
.hscrollbar_policy(PolicyType::Never)
|
2024-06-18 15:45:10 +03:00
|
|
|
.vexpand(true)
|
2024-06-19 01:44:47 +03:00
|
|
|
.hexpand(true)
|
|
|
|
.margin_bottom(15)
|
|
|
|
.margin_start(15)
|
|
|
|
.margin_end(15)
|
|
|
|
.margin_start(15)
|
|
|
|
.height_request(390)
|
|
|
|
.child(&packages_boxedlist)
|
2024-06-18 15:45:10 +03:00
|
|
|
.build();
|
|
|
|
|
|
|
|
let window_bottombar = gtk::Box::builder()
|
|
|
|
.hexpand(true)
|
|
|
|
.homogeneous(true)
|
2024-06-19 01:44:47 +03:00
|
|
|
.vexpand(true)
|
|
|
|
.valign(Align::End)
|
2024-06-18 15:45:10 +03:00
|
|
|
.margin_bottom(15)
|
|
|
|
.margin_start(15)
|
|
|
|
.margin_end(15)
|
|
|
|
.margin_start(15)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let back_button = gtk::Button::builder()
|
|
|
|
.halign(Align::Start)
|
|
|
|
.label("Back")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
back_button.add_css_class("pill");
|
|
|
|
|
2024-06-19 01:20:46 +03:00
|
|
|
back_button.connect_clicked(clone!(@weak content_stack, @weak main_box => move |_| {
|
|
|
|
content_stack.set_visible_child_name("content_page");
|
|
|
|
content_stack.remove(&main_box);
|
2024-06-18 15:45:10 +03:00
|
|
|
}));
|
|
|
|
|
|
|
|
window_bottombar.append(&back_button);
|
|
|
|
|
|
|
|
main_box.append(&main_label);
|
2024-06-19 01:44:47 +03:00
|
|
|
main_box.append(&searchbar);
|
|
|
|
main_box.append(&packages_viewport);
|
2024-06-18 15:45:10 +03:00
|
|
|
main_box.append(&window_bottombar);
|
|
|
|
|
|
|
|
main_box
|
|
|
|
}
|
|
|
|
|
2024-06-19 01:44:47 +03:00
|
|
|
fn add_package_rows(boxedlist: >k::ListBox, data: &str) {
|
2024-06-18 15:45:10 +03:00
|
|
|
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
|
|
|
|
if let serde_json::Value::Array(scheds) = &res["scx_schedulers"] {
|
2024-06-19 01:44:47 +03:00
|
|
|
for sched in scheds {
|