branch config

This commit is contained in:
Ward from fusion-voyager-3 2024-06-18 19:12:41 +03:00
parent 89be715cbe
commit 39bcfa8737
5 changed files with 409 additions and 24 deletions

367
Cargo.lock generated
View File

@ -11,6 +11,21 @@ dependencies = [
"memchr",
]
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]]
name = "async-channel"
version = "2.3.1"
@ -37,7 +52,7 @@ checksum = "ebd71393f1ec0509b553aa012b9b58e81dadbdff7130bd3b8cba576e69b32f75"
dependencies = [
"bitflags 1.3.2",
"cexpr",
"cfg-if",
"cfg-if 0.1.10",
"clang-sys",
"lazy_static",
"peeking_take_while",
@ -60,6 +75,12 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "bumpalo"
version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "cairo-rs"
version = "0.19.4"
@ -115,6 +136,25 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [
"android-tzdata",
"iana-time-zone",
"num-traits",
"serde",
"windows-targets 0.52.5",
]
[[package]]
name = "clang-sys"
version = "0.28.1"
@ -135,6 +175,12 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
name = "crossbeam-utils"
version = "0.8.20"
@ -189,6 +235,7 @@ dependencies = [
"glib",
"glib-build-tools",
"gtk4",
"homedir",
"libadwaita",
"linux-version",
"serde_json",
@ -201,10 +248,25 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
dependencies = [
"memoffset",
"memoffset 0.9.1",
"rustc_version",
]
[[package]]
name = "futures"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.30"
@ -212,6 +274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
@ -248,6 +311,12 @@ dependencies = [
"syn",
]
[[package]]
name = "futures-sink"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
[[package]]
name = "futures-task"
version = "0.3.30"
@ -260,9 +329,13 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"slab",
@ -353,7 +426,7 @@ dependencies = [
"gobject-sys",
"libc",
"system-deps",
"windows-sys",
"windows-sys 0.52.0",
]
[[package]]
@ -545,6 +618,43 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "homedir"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22074da8bba2ef26fc1737ae6c777b5baab5524c2dc403b5c6a76166766ccda5"
dependencies = [
"cfg-if 1.0.0",
"nix 0.26.4",
"serde",
"widestring",
"windows-sys 0.48.0",
"wmi",
]
[[package]]
name = "iana-time-zone"
version = "0.1.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]]
name = "indexmap"
version = "2.2.6"
@ -561,6 +671,15 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "js-sys"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -622,16 +741,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "550e9ee19d3aaf145d93293ae69687db77c4d34515c44c197bffbcbafcf3ae29"
dependencies = [
"bindgen",
"nix",
"nix 0.17.0",
"semver 0.9.0",
]
[[package]]
name = "log"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "memoffset"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
dependencies = [
"autocfg",
]
[[package]]
name = "memoffset"
version = "0.9.1"
@ -649,11 +783,24 @@ checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
dependencies = [
"bitflags 1.3.2",
"cc",
"cfg-if",
"cfg-if 0.1.10",
"libc",
"void",
]
[[package]]
name = "nix"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
dependencies = [
"bitflags 1.3.2",
"cfg-if 1.0.0",
"libc",
"memoffset 0.7.1",
"pin-utils",
]
[[package]]
name = "nom"
version = "4.2.3"
@ -664,6 +811,15 @@ dependencies = [
"version_check",
]
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.19.0"
@ -677,7 +833,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29d73ba8daf8fac13b0501d1abeddcfe21ba7401ada61a819144b6c2a4f32209"
dependencies = [
"libc",
"windows-sys",
"windows-sys 0.52.0",
]
[[package]]
@ -1022,6 +1178,66 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "wasm-bindgen"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
name = "widestring"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311"
[[package]]
name = "winapi"
version = "0.3.9"
@ -1044,13 +1260,80 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
dependencies = [
"windows-core",
"windows-implement",
"windows-interface",
"windows-targets 0.52.5",
]
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets 0.52.5",
]
[[package]]
name = "windows-implement"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12168c33176773b86799be25e2a2ba07c7aab9968b37541f1094dbd7a60c8946"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "windows-interface"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d8dc32e0095a7eeccebd0e3f09e9509365ecb3fc6ac4d6f5f14a3f6392942d1"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
"windows-targets 0.52.5",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
]
[[package]]
@ -1059,28 +1342,46 @@ version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_aarch64_gnullvm 0.52.5",
"windows_aarch64_msvc 0.52.5",
"windows_i686_gnu 0.52.5",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
"windows_i686_msvc 0.52.5",
"windows_x86_64_gnu 0.52.5",
"windows_x86_64_gnullvm 0.52.5",
"windows_x86_64_msvc 0.52.5",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.5"
@ -1093,24 +1394,48 @@ version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.5"
@ -1134,3 +1459,17 @@ checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1"
dependencies = [
"memchr",
]
[[package]]
name = "wmi"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f0a4062ca522aad4705a2948fd4061b3857537990202a8ddd5af21607f79a"
dependencies = [
"chrono",
"futures",
"log",
"serde",
"thiserror",
"windows",
]

View File

@ -12,6 +12,7 @@ async-channel = "2.3.1"
duct = "0.13.7"
glib = "0.19.7"
gtk = { version = "0.8.2", package = "gtk4", features = ["v4_14"] }
homedir = "0.2.1"
linux-version = "0.1.1"
serde_json = "1.0.117"
version-compare = "0.2.0"

View File

@ -1,7 +1,6 @@
use crate::{content, kernel_pkg, sched_ext, KernelBranch, PRETTY_NAME};
use adw::prelude::*;
use adw::*;
use async_channel::*;
use glib::{clone, MainContext};
use gtk::prelude::*;
use gtk::*;
@ -9,10 +8,11 @@ use std::cell::RefCell;
use std::process::Command;
use std::rc::Rc;
use std::{thread, time};
use glib::property::PropertyGet;
pub fn build_ui(app: &adw::Application) {
let internet_connected = Rc::new(RefCell::new(false));
let selected_kernel_branch: Rc<RefCell<KernelBranch>>;
let selected_kernel_branch: Rc<RefCell<KernelBranch>> = Rc::new(RefCell::new(KernelBranch{name: "?".to_owned(), db:"?".to_owned()}));
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
let internet_loop_sender = internet_loop_sender.clone();
@ -33,6 +33,8 @@ pub fn build_ui(app: &adw::Application) {
let internet_connected_status = internet_connected.clone();
let selected_kernel_branch2 = selected_kernel_branch.clone();
let internet_loop_context = MainContext::default();
// The main loop executes the asynchronous block
internet_loop_context.spawn_local(clone!(@weak window_banner => async move {
@ -40,6 +42,7 @@ pub fn build_ui(app: &adw::Application) {
let banner_text = "Warning: No internet connection";
if state == true {
*internet_connected_status.borrow_mut()=true;
println!("{}", selected_kernel_branch.borrow().name);
if window_banner.title() == banner_text {
window_banner.set_revealed(false)
}
@ -61,7 +64,9 @@ pub fn build_ui(app: &adw::Application) {
let window_toolbar = adw::ToolbarView::builder().content(&content_stack).build();
content_stack.add_named(&content::content(&content_stack), Some("content_page"));
content_stack.add_named(
&content::content(&content_stack, &selected_kernel_branch2),
Some("content_page"));
content_stack.add_named(
&sched_ext::sched_ext_page(&content_stack),
Some("sched_ext_page"),

View File

@ -1,3 +1,4 @@
use std::cell::RefCell;
use crate::{KernelBranch, RunningKernelInfo};
use adw::prelude::*;
use adw::ExpanderRow;
@ -8,10 +9,13 @@ use gtk::*;
use std::fs;
use std::path::Path;
use std::process::{Command, Stdio};
use std::rc::Rc;
use version_compare::Version;
use homedir::get_my_home;
use Vec;
use glib::property::PropertyGet;
pub fn content(content_stack: &gtk::Stack) -> gtk::Box {
pub fn content(content_stack: &gtk::Stack, selected_kernel_branch: &Rc<RefCell<KernelBranch>>) -> gtk::Box {
let running_kernel_info = get_running_kernel_info();
let content_box = gtk::Box::builder()
@ -44,7 +48,7 @@ pub fn content(content_stack: &gtk::Stack) -> gtk::Box {
.subtitle("Kernel Branch")
.build();
kernel_branch_expander_row.add_row(&kernel_branch_expandable(&kernel_branch_expander_row));
kernel_branch_expander_row.add_row(&kernel_branch_expandable(&kernel_branch_expander_row, selected_kernel_branch));
let kernel_branch_expander_row_boxedlist = gtk::ListBox::builder()
.selection_mode(SelectionMode::None)
@ -134,6 +138,23 @@ pub fn content(content_stack: &gtk::Stack) -> gtk::Box {
.label("Cancel Changes")
.build();
let selected_kernel_branch_clone0 = selected_kernel_branch.clone();
let selected_kernel_branch_clone1 = selected_kernel_branch.clone();
match get_my_home().unwrap().unwrap().join(".config/fedora-kernel-manager/branch").exists() {
true => {
let narrow_branch: Vec<KernelBranch> = get_kernel_branches().clone().into_iter()
.filter(|a| a.name == fs::read_to_string(get_my_home().unwrap().unwrap().join(".config/fedora-kernel-manager/branch")).unwrap())
.collect();
*selected_kernel_branch_clone0.borrow_mut()=narrow_branch.get(0).unwrap().clone()
}
_ => {
let normal_branch = get_kernel_branches().clone().get(0).unwrap().clone();
*selected_kernel_branch_clone0.borrow_mut()=normal_branch
}
};
cancel_button.add_css_class("pill");
window_bottombar.append(&cancel_button);
@ -144,7 +165,7 @@ pub fn content(content_stack: &gtk::Stack) -> gtk::Box {
content_box
}
fn kernel_branch_expandable(expander_row: &adw::ExpanderRow) -> gtk::ListBox {
fn kernel_branch_expandable(expander_row: &adw::ExpanderRow, selected_kernel_branch: &Rc<RefCell<KernelBranch>>) -> gtk::ListBox {
let searchbar = gtk::SearchEntry::builder().search_delay(500).build();
searchbar.add_css_class("round-border-only-top");
@ -164,6 +185,8 @@ fn kernel_branch_expandable(expander_row: &adw::ExpanderRow) -> gtk::ListBox {
.build();
for branch in get_kernel_branches() {
let branch_clone0 = branch.clone();
let branch_clone1 = branch.clone();
let branch_checkbutton = gtk::CheckButton::builder()
.valign(Align::Center)
.can_focus(false)
@ -175,16 +198,21 @@ fn kernel_branch_expandable(expander_row: &adw::ExpanderRow) -> gtk::ListBox {
branch_row.add_prefix(&branch_checkbutton);
branch_checkbutton.set_group(Some(&null_checkbutton));
branch_container.append(&branch_row);
let selected_kernel_branch_clone0 = selected_kernel_branch.clone();
branch_checkbutton.connect_toggled(
clone!(@weak branch_checkbutton, @weak expander_row => move |_| {
if branch_checkbutton.is_active() == true {
expander_row.set_title(&branch_row.title());
save_branch_config(&branch_row.title().to_string());
*selected_kernel_branch_clone0.borrow_mut()=branch_clone0.clone()
}
}),
);
//if current_keyboard.contains(&(keyboard_layout_clone)) {
// keyboard_layout_checkbutton.set_active(true);
//}
match get_my_home().unwrap().unwrap().join(".config/fedora-kernel-manager/branch").exists() {
true if fs::read_to_string(get_my_home().unwrap().unwrap().join(".config/fedora-kernel-manager/branch")).unwrap() == branch_clone1.name => branch_checkbutton.set_active(true),
_ => {}
}
}
let branch_container_viewport = gtk::ScrolledWindow::builder()
@ -283,7 +311,7 @@ fn get_kernel_branches() -> Vec<KernelBranch> {
};
let test_branch2 = KernelBranch {
name: "kernel-cachy".to_string(),
name: "kernel-tkg".to_string(),
db: "https://raw.githubusercontent.com/CosmicFusion/fedora-kernel-manager/main/data/db-kernel-cachy.json".to_string()
};
@ -409,3 +437,14 @@ fn create_kernel_badges(badge_box: &gtk::Box, running_kernel_info: &RunningKerne
&kernel_badges_size_group1,
));
}
fn save_branch_config(branch: &str) {
let config_path = get_my_home().unwrap().unwrap().join(".config/fedora-kernel-manager");
match &config_path.exists() {
true => fs::write(config_path.join("branch"), branch).unwrap(),
_ => {
fs::create_dir(&config_path).unwrap();
fs::write(config_path.join("branch"), branch).unwrap();
}
}
}

View File

@ -17,6 +17,7 @@ struct RunningKernelInfo {
sched: String,
}
#[derive(Clone)]
struct KernelBranch {
name: String,
db: String,