add branch db

This commit is contained in:
Ward from fusion-voyager-3 2024-06-18 20:42:04 +03:00
parent 39bcfa8737
commit b219774cb7
3 changed files with 23 additions and 39 deletions

View File

@ -0,0 +1,8 @@
{
"branches": [
{
"name": "kernel-cachyos",
"db": "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db_kernel_cachy.json"
}
]
}

View File

@ -116,28 +116,6 @@ pub fn content(content_stack: &gtk::Stack, selected_kernel_branch: &Rc<RefCell<K
content_box.append(&kernel_branch_expander_row_boxedlist); content_box.append(&kernel_branch_expander_row_boxedlist);
content_box.append(&button_box); content_box.append(&button_box);
let window_bottombar = gtk::Box::builder()
.hexpand(true)
.homogeneous(true)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.margin_start(15)
.build();
let apply_button = gtk::Button::builder()
.halign(Align::End)
.label("Apply Changes")
.build();
apply_button.add_css_class("pill");
apply_button.add_css_class("destructive-action");
let cancel_button = gtk::Button::builder()
.halign(Align::Start)
.label("Cancel Changes")
.build();
let selected_kernel_branch_clone0 = selected_kernel_branch.clone(); let selected_kernel_branch_clone0 = selected_kernel_branch.clone();
let selected_kernel_branch_clone1 = selected_kernel_branch.clone(); let selected_kernel_branch_clone1 = selected_kernel_branch.clone();
@ -155,13 +133,6 @@ pub fn content(content_stack: &gtk::Stack, selected_kernel_branch: &Rc<RefCell<K
} }
}; };
cancel_button.add_css_class("pill");
window_bottombar.append(&cancel_button);
window_bottombar.append(&apply_button);
content_box.append(&window_bottombar);
content_box content_box
} }
@ -305,17 +276,22 @@ pub fn create_kernel_badge(
} }
fn get_kernel_branches() -> Vec<KernelBranch> { fn get_kernel_branches() -> Vec<KernelBranch> {
let test_branch = KernelBranch { let mut kernel_branches_array: Vec<KernelBranch> = Vec::new();
name: "kernel-cachy".to_string(), let data = fs::read_to_string(
db: "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db-kernel-cachy.json".to_string() "/home/ward/RustroverProjects/fedora-kernel-manager/data/kernel_branches.json",
}; )
.expect("Unable to read file");
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
if let serde_json::Value::Array(branches) = &res["branches"] {
for branch in branches {
let branch = KernelBranch{
name: branch["name"].as_str().to_owned().unwrap().to_string(),
db: branch["db"].as_str().to_owned().unwrap().to_string(),
};
kernel_branches_array.push(branch)
}};
let test_branch2 = KernelBranch { kernel_branches_array
name: "kernel-tkg".to_string(),
db: "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db-kernel-cachy.json".to_string()
};
vec![test_branch, test_branch2]
} }
pub fn get_running_kernel_info() -> RunningKernelInfo { pub fn get_running_kernel_info() -> RunningKernelInfo {
let kernel = match Command::new("uname") let kernel = match Command::new("uname")