hopefully fix sched badge
This commit is contained in:
parent
63eda09368
commit
112f56ad9c
@ -84,6 +84,11 @@ pub fn content(
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let sched_ext_badge_box = adw::Bin::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.build();
|
||||
|
||||
let kernel_branch_expander_row = adw::ExpanderRow::builder()
|
||||
.subtitle(t!("kernel_branch_expander_row_subtitle"))
|
||||
.build();
|
||||
@ -147,7 +152,7 @@ pub fn content(
|
||||
.height_request(50)
|
||||
.width_request(50)
|
||||
.tooltip_text(t!("config_kernel_button_tooltip_text"))
|
||||
.sensitive(is_scx_kernel())
|
||||
.sensitive(!is_scx_kernel())
|
||||
.hexpand(true)
|
||||
.build();
|
||||
config_kernel_button.add_css_class("circular");
|
||||
@ -157,9 +162,9 @@ pub fn content(
|
||||
.set_tooltip_text(Some(&t!("config_kernel_button_tooltip_text_no_scx").to_string()));
|
||||
}
|
||||
|
||||
config_kernel_button.connect_clicked(clone!(@weak content_stack, @weak window => move |_| {
|
||||
config_kernel_button.connect_clicked(clone!(@weak content_stack, @weak window, @weak sched_ext_badge_box => move |_| {
|
||||
content_stack.add_named(
|
||||
&sched_ext::sched_ext_page(&content_stack, &window),
|
||||
&sched_ext::sched_ext_page(&content_stack, &window, &sched_ext_badge_box),
|
||||
Some("sched_ext_page"),
|
||||
);
|
||||
content_stack.set_visible_child_name("sched_ext_page")
|
||||
@ -192,7 +197,9 @@ pub fn content(
|
||||
load_badge_async_context.spawn_local(clone!(@weak content_box, @weak loading_box, @weak kernel_badge_box, @strong selected_kernel_branch, @strong db_load_complete => async move {
|
||||
while let Ok(_state) = load_badge_async_receiver.recv().await {
|
||||
if *db_load_complete.borrow() == true {
|
||||
create_kernel_badges(&kernel_badge_box, &get_running_kernel_info(), &selected_kernel_branch);
|
||||
let running_kernel_info = get_running_kernel_info();
|
||||
create_kernel_badges(&kernel_badge_box, &running_kernel_info, &selected_kernel_branch);
|
||||
create_current_sched_badge(&sched_ext_badge_box, &running_kernel_info);
|
||||
loading_box.set_visible(false);
|
||||
content_box.set_sensitive(true)
|
||||
}
|
||||
@ -563,3 +570,25 @@ fn save_branch_config(branch: &str) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_current_sched_badge(
|
||||
badge_box: &adw::Bin,
|
||||
running_kernel_info: &RunningKernelInfo,
|
||||
) {
|
||||
//while let Some(widget) = badge_box.last_child() {
|
||||
// badge_box.remove(&widget);
|
||||
//}
|
||||
|
||||
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);
|
||||
|
||||
badge_box.set_child(Some(&crate::content::create_kernel_badge(
|
||||
&t!("kernel_badge_running_sched_label").to_string(),
|
||||
&running_kernel_info.sched,
|
||||
"background-accent-bg",
|
||||
&kernel_badges_size_group,
|
||||
&kernel_badges_size_group0,
|
||||
&kernel_badges_size_group1,
|
||||
)));
|
||||
}
|
@ -13,7 +13,7 @@ use std::rc::Rc;
|
||||
use std::time::Duration;
|
||||
use std::{fs, io, thread};
|
||||
|
||||
pub fn sched_ext_page(content_stack: >k::Stack, window: &adw::ApplicationWindow) -> gtk::Box {
|
||||
pub fn sched_ext_page(content_stack: >k::Stack, window: &adw::ApplicationWindow, badge_box: &adw::Bin) -> gtk::Box {
|
||||
let main_box = gtk::Box::builder()
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
@ -48,22 +48,8 @@ pub fn sched_ext_page(content_stack: >k::Stack, window: &adw::ApplicationWindo
|
||||
.build();
|
||||
main_label.add_css_class("symbolic-accent-bg");
|
||||
|
||||
let badge_box = gtk::Box::builder()
|
||||
.hexpand(true)
|
||||
.valign(Align::Start)
|
||||
.orientation(Orientation::Vertical)
|
||||
.build();
|
||||
|
||||
let initial_running_kernel_info = get_running_kernel_info();
|
||||
|
||||
create_current_sched_badge(
|
||||
&badge_box,
|
||||
&initial_running_kernel_info,
|
||||
&kernel_badges_size_group,
|
||||
&kernel_badges_size_group0,
|
||||
&kernel_badges_size_group1,
|
||||
);
|
||||
|
||||
let selected_scx_sched = Rc::new(RefCell::new(initial_running_kernel_info.clone().sched));
|
||||
|
||||
let cmd_status_dialog = adw::MessageDialog::builder()
|
||||
@ -128,37 +114,18 @@ pub fn sched_ext_page(content_stack: >k::Stack, window: &adw::ApplicationWindo
|
||||
apply_button.add_css_class("pill");
|
||||
apply_button.add_css_class("destructive-action");
|
||||
|
||||
apply_button.connect_clicked(clone! (@weak badge_box, @weak kernel_badges_size_group, @weak kernel_badges_size_group0, @weak kernel_badges_size_group1, @weak selected_scx_sched => move |_| {
|
||||
apply_button.connect_clicked(clone! (@weak selected_scx_sched => move |_| {
|
||||
let selected_scx_sched_clone1 = selected_scx_sched.borrow().clone();
|
||||
|
||||
match change_scx_scheduler(&selected_scx_sched_clone1,
|
||||
&badge_box,
|
||||
&kernel_badges_size_group,
|
||||
&kernel_badges_size_group0,
|
||||
&kernel_badges_size_group1,) {
|
||||
match change_scx_scheduler(&selected_scx_sched_clone1) {
|
||||
Ok(_) => {
|
||||
cmd_status_dialog.set_heading(Some(&t!("sched_ext_cmd_status_dialog_heading_success").to_string()));
|
||||
cmd_status_dialog.set_body(format!("{}: {}", t!("sched_ext_cmd_status_dialog_body_success"), &selected_scx_sched_clone1).as_str());
|
||||
cmd_status_dialog.present();
|
||||
create_current_sched_badge(
|
||||
&badge_box,
|
||||
&get_running_kernel_info(),
|
||||
&kernel_badges_size_group,
|
||||
&kernel_badges_size_group0,
|
||||
&kernel_badges_size_group1,
|
||||
);
|
||||
}
|
||||
Err(_) => {
|
||||
cmd_status_dialog.set_heading(Some(&t!("sched_ext_cmd_status_dialog_heading_failed").to_string()));
|
||||
cmd_status_dialog.set_body(format!("{}: {}", t!("sched_ext_cmd_status_dialog_body_failed"), &selected_scx_sched_clone1).as_str());
|
||||
cmd_status_dialog.present();
|
||||
create_current_sched_badge(
|
||||
&badge_box,
|
||||
&get_running_kernel_info(),
|
||||
&kernel_badges_size_group,
|
||||
&kernel_badges_size_group0,
|
||||
&kernel_badges_size_group1,
|
||||
);
|
||||
}
|
||||
};
|
||||
}));
|
||||
@ -188,7 +155,7 @@ pub fn sched_ext_page(content_stack: >k::Stack, window: &adw::ApplicationWindo
|
||||
window_bottombar.append(&back_button);
|
||||
window_bottombar.append(&apply_button);
|
||||
|
||||
main_box.append(&badge_box);
|
||||
main_box.append(badge_box);
|
||||
main_box.append(&scx_sched_expander_row_boxedlist);
|
||||
main_box.append(&main_icon);
|
||||
main_box.append(&main_label);
|
||||
@ -197,27 +164,6 @@ pub fn sched_ext_page(content_stack: >k::Stack, window: &adw::ApplicationWindo
|
||||
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(
|
||||
&t!("kernel_badge_running_sched_label").to_string(),
|
||||
&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,
|
||||
selected_scx_sched: &Rc<RefCell<String>>,
|
||||
@ -317,10 +263,6 @@ fn get_current_scx_scheduler() -> String {
|
||||
|
||||
fn change_scx_scheduler(
|
||||
scx_sched: &str,
|
||||
badge_box: >k::Box,
|
||||
kernel_badges_size_group: >k::SizeGroup,
|
||||
kernel_badges_size_group0: >k::SizeGroup,
|
||||
kernel_badges_size_group1: >k::SizeGroup,
|
||||
) -> Result<(), io::Error> {
|
||||
cmd!(
|
||||
"pkexec",
|
||||
@ -332,12 +274,5 @@ fn change_scx_scheduler(
|
||||
)
|
||||
)
|
||||
.run()?;
|
||||
create_current_sched_badge(
|
||||
&badge_box,
|
||||
&get_running_kernel_info(),
|
||||
&kernel_badges_size_group,
|
||||
&kernel_badges_size_group0,
|
||||
&kernel_badges_size_group1,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user