begin kernel packages imp
This commit is contained in:
parent
0fdcc0af5a
commit
8f98353a71
@ -2,6 +2,14 @@
|
||||
color: @accent_bg_color;
|
||||
}
|
||||
|
||||
.size-20-font {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.rounded-all-25 {
|
||||
border-radius: 25px;
|
||||
}
|
||||
|
||||
.background-accent-bg {
|
||||
background: @accent_bg_color;
|
||||
border-radius: 10px;
|
||||
|
@ -128,9 +128,9 @@ pub fn content(
|
||||
.build();
|
||||
browse_kernels_button.add_css_class("circular");
|
||||
|
||||
browse_kernels_button.connect_clicked(clone!(@weak content_stack => move |_| {
|
||||
browse_kernels_button.connect_clicked(clone!(@weak content_stack, @strong selected_kernel_branch => move |_| {
|
||||
content_stack.add_named(
|
||||
&kernel_pkg::kernel_pkg_page(&content_stack),
|
||||
&kernel_pkg::kernel_pkg_page(&content_stack, &selected_kernel_branch),
|
||||
Some("kernel_pkg_page"),
|
||||
);
|
||||
content_stack.set_visible_child_name("kernel_pkg_page")
|
||||
|
@ -1,39 +1,25 @@
|
||||
use std::cell::RefCell;
|
||||
use crate::content::get_running_kernel_info;
|
||||
use crate::RunningKernelInfo;
|
||||
use crate::{KernelBranch, RunningKernelInfo};
|
||||
use adw::prelude::*;
|
||||
use glib::*;
|
||||
use gtk::prelude::*;
|
||||
use gtk::*;
|
||||
use std::fs;
|
||||
use std::fs::*;
|
||||
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();
|
||||
|
||||
pub fn kernel_pkg_page(content_stack: >k::Stack) -> gtk::Box {
|
||||
let main_box = gtk::Box::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let kernel_badges_size_group = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||
let kernel_badges_size_group0 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||
let kernel_badges_size_group1 = gtk::SizeGroup::new(SizeGroupMode::Both);
|
||||
|
||||
let main_icon = gtk::Image::builder()
|
||||
.pixel_size(128)
|
||||
.halign(Align::Center)
|
||||
.hexpand(true)
|
||||
.margin_start(10)
|
||||
.margin_end(10)
|
||||
.margin_bottom(20)
|
||||
.margin_top(20)
|
||||
.build();
|
||||
|
||||
main_icon.set_icon_name(Some("tux-symbolic"));
|
||||
|
||||
main_icon.add_css_class("symbolic-accent-bg");
|
||||
|
||||
let main_label = gtk::Label::builder()
|
||||
.label("Sched-EXT Configuration Settings")
|
||||
.label(format!("Available Kernel Packages for {}", &selected_kernel_branch_clone0.name))
|
||||
.hexpand(true)
|
||||
.margin_start(10)
|
||||
.margin_end(10)
|
||||
@ -41,45 +27,40 @@ pub fn kernel_pkg_page(content_stack: >k::Stack) -> gtk::Box {
|
||||
.margin_top(20)
|
||||
.build();
|
||||
main_label.add_css_class("symbolic-accent-bg");
|
||||
main_label.add_css_class("size-20-font");
|
||||
|
||||
let badge_box = gtk::Box::builder()
|
||||
.hexpand(true)
|
||||
.valign(Align::Start)
|
||||
.orientation(Orientation::Vertical)
|
||||
let searchbar = gtk::SearchEntry::builder()
|
||||
.search_delay(500)
|
||||
.margin_bottom(15)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.margin_start(15)
|
||||
.build();
|
||||
searchbar.add_css_class("rounded-all-25");
|
||||
|
||||
create_current_sched_badge(
|
||||
&badge_box,
|
||||
&get_running_kernel_info(),
|
||||
&kernel_badges_size_group,
|
||||
&kernel_badges_size_group0,
|
||||
&kernel_badges_size_group1,
|
||||
);
|
||||
|
||||
let scx_sched_expander_row = adw::ExpanderRow::builder()
|
||||
.subtitle("Select Sched-EXT Scheduler")
|
||||
.build();
|
||||
|
||||
scx_sched_expander_row.add_row(&scx_sched_expandable(&scx_sched_expander_row));
|
||||
|
||||
let scx_sched_expander_row_boxedlist = gtk::ListBox::builder()
|
||||
let packages_boxedlist = gtk::ListBox::builder()
|
||||
.selection_mode(SelectionMode::None)
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.valign(Align::Start)
|
||||
.halign(Align::Center)
|
||||
.margin_start(10)
|
||||
.margin_end(10)
|
||||
.margin_bottom(20)
|
||||
.margin_top(20)
|
||||
.build();
|
||||
packages_boxedlist.add_css_class("boxed-list");
|
||||
add_package_rows(&packages_boxedlist, &selected_kernel_branch_clone0.db);
|
||||
|
||||
scx_sched_expander_row_boxedlist.add_css_class("boxed-list");
|
||||
scx_sched_expander_row_boxedlist.append(&scx_sched_expander_row);
|
||||
let packages_viewport = gtk::ScrolledWindow::builder()
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.vexpand(true)
|
||||
.hexpand(true)
|
||||
.margin_bottom(15)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.margin_start(15)
|
||||
.height_request(390)
|
||||
.child(&packages_boxedlist)
|
||||
.build();
|
||||
|
||||
let window_bottombar = gtk::Box::builder()
|
||||
.hexpand(true)
|
||||
.homogeneous(true)
|
||||
.vexpand(true)
|
||||
.valign(Align::End)
|
||||
.margin_bottom(15)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
@ -100,118 +81,15 @@ pub fn kernel_pkg_page(content_stack: >k::Stack) -> gtk::Box {
|
||||
|
||||
window_bottombar.append(&back_button);
|
||||
|
||||
main_box.append(&badge_box);
|
||||
main_box.append(&scx_sched_expander_row_boxedlist);
|
||||
main_box.append(&main_icon);
|
||||
main_box.append(&main_label);
|
||||
main_box.append(&searchbar);
|
||||
main_box.append(&packages_viewport);
|
||||
main_box.append(&window_bottombar);
|
||||
|
||||
main_box
|
||||
}
|
||||
|
||||
fn create_current_sched_badge(
|
||||
badge_box: >k::Box,
|
||||
running_kernel_info: &RunningKernelInfo,
|
||||
kernel_badges_size_group: >k::SizeGroup,
|
||||
kernel_badges_size_group0: >k::SizeGroup,
|
||||
kernel_badges_size_group1: >k::SizeGroup,
|
||||
) {
|
||||
while let Some(widget) = badge_box.last_child() {
|
||||
badge_box.remove(&widget);
|
||||
}
|
||||
|
||||
badge_box.append(&crate::content::create_kernel_badge(
|
||||
"Running Sched",
|
||||
&running_kernel_info.sched,
|
||||
"background-accent-bg",
|
||||
&kernel_badges_size_group,
|
||||
&kernel_badges_size_group0,
|
||||
&kernel_badges_size_group1,
|
||||
));
|
||||
}
|
||||
|
||||
fn scx_sched_expandable(expander_row: &adw::ExpanderRow) -> gtk::ListBox {
|
||||
let searchbar = gtk::SearchEntry::builder().search_delay(500).build();
|
||||
searchbar.add_css_class("round-border-only-top");
|
||||
|
||||
let boxedlist = gtk::ListBox::builder()
|
||||
.selection_mode(SelectionMode::None)
|
||||
.build();
|
||||
|
||||
boxedlist.append(&searchbar);
|
||||
|
||||
let sched_container = gtk::ListBox::builder()
|
||||
.selection_mode(SelectionMode::None)
|
||||
.build();
|
||||
sched_container.add_css_class("boxed-list");
|
||||
|
||||
let null_checkbutton = gtk::CheckButton::builder()
|
||||
.label("No branch selected")
|
||||
.build();
|
||||
|
||||
let mut scx_sched_array: Vec<String> = Vec::new();
|
||||
let data = fs::read_to_string(
|
||||
"/home/ward/RustroverProjects/fedora-kernel-manager/data/scx_scheds.json",
|
||||
)
|
||||
.expect("Unable to read file");
|
||||
fn add_package_rows(boxedlist: >k::ListBox, data: &str) {
|
||||
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
|
||||
if let serde_json::Value::Array(scheds) = &res["scx_schedulers"] {
|
||||
for sched in scheds {
|
||||
let sched = sched["name"].as_str().to_owned().unwrap().to_string();
|
||||
let sched_checkbutton = gtk::CheckButton::builder()
|
||||
.valign(Align::Center)
|
||||
.can_focus(false)
|
||||
.build();
|
||||
let branch_row = adw::ActionRow::builder()
|
||||
.activatable_widget(&sched_checkbutton)
|
||||
.title(sched)
|
||||
.build();
|
||||
branch_row.add_prefix(&sched_checkbutton);
|
||||
sched_checkbutton.set_group(Some(&null_checkbutton));
|
||||
sched_container.append(&branch_row);
|
||||
sched_checkbutton.connect_toggled(
|
||||
clone!(@weak sched_checkbutton, @weak expander_row => move |_| {
|
||||
if sched_checkbutton.is_active() == true {
|
||||
expander_row.set_title(&branch_row.title());
|
||||
}
|
||||
}),
|
||||
);
|
||||
//if current_keyboard.contains(&(keyboard_layout_clone)) {
|
||||
// keyboard_layout_checkbutton.set_active(true);
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
let branch_container_viewport = gtk::ScrolledWindow::builder()
|
||||
.child(&sched_container)
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.height_request(160)
|
||||
.build();
|
||||
|
||||
sched_container.add_css_class("round-border-only-bottom");
|
||||
|
||||
boxedlist.append(&branch_container_viewport);
|
||||
|
||||
searchbar.connect_search_changed(clone!(@weak searchbar, @weak sched_container => move |_| {
|
||||
let mut counter = sched_container.first_child();
|
||||
while let Some(row) = counter {
|
||||
if row.widget_name() == "AdwActionRow" {
|
||||
if !searchbar.text().is_empty() {
|
||||
if row.property::<String>("subtitle").to_lowercase().contains(&searchbar.text().to_string().to_lowercase()) || row.property::<String>("title").to_lowercase().contains(&searchbar.text().to_string().to_lowercase()) {
|
||||
//row.grab_focus();
|
||||
//row.add_css_class("highlight-widget");
|
||||
row.set_property("visible", true);
|
||||
searchbar.grab_focus();
|
||||
} else {
|
||||
row.set_property("visible", false);
|
||||
}
|
||||
} else {
|
||||
row.set_property("visible", true);
|
||||
}
|
||||
}
|
||||
counter = row.next_sibling();
|
||||
}
|
||||
}));
|
||||
|
||||
boxedlist
|
||||
}
|
||||
for sched in scheds {
|
@ -79,6 +79,8 @@ pub fn sched_ext_page(content_stack: >k::Stack) -> gtk::Box {
|
||||
|
||||
let window_bottombar = gtk::Box::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.valign(Align::End)
|
||||
.homogeneous(true)
|
||||
.margin_bottom(15)
|
||||
.margin_start(15)
|
||||
|
Loading…
Reference in New Issue
Block a user