RR: Fix Keyboard page layout

This commit is contained in:
Ward from fusion-voyager-3 2024-02-19 22:23:47 +03:00
parent 5253f5d7c8
commit 918c035edb
3 changed files with 68 additions and 5 deletions

53
Cargo.lock generated
View File

@ -423,6 +423,35 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "gnome-desktop"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a7207b3f81001aa7db2f5f130c2999ba4917c096968a7d078d550c4c83ee674"
dependencies = [
"gdk-pixbuf",
"gio",
"glib",
"gnome-desktop-sys",
"gsettings-desktop-schemas",
"libc",
]
[[package]]
name = "gnome-desktop-sys"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87b888414e3a79ebfb9488414beb4f8e7a2794889925e507ebebe83f24cb36f1"
dependencies = [
"gdk-pixbuf-sys",
"gio-sys",
"glib-sys",
"gobject-sys",
"gsettings-desktop-schemas-sys",
"libc",
"system-deps",
]
[[package]]
name = "gobject-sys"
version = "0.18.0"
@ -457,6 +486,29 @@ dependencies = [
"system-deps",
]
[[package]]
name = "gsettings-desktop-schemas"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875c5582b4695e2de7bf763bedd3e4b610adcaa08c13028d38cc421c4e5857b5"
dependencies = [
"bitflags 2.4.1",
"glib",
"gsettings-desktop-schemas-sys",
"libc",
]
[[package]]
name = "gsettings-desktop-schemas-sys"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3badaaef1ab8bd74d009abde5694c2713178b0ee6f7c9bf70af986a8ed7cee58"
dependencies = [
"glib-sys",
"libc",
"system-deps",
]
[[package]]
name = "gsk4"
version = "0.7.3"
@ -763,6 +815,7 @@ dependencies = [
"gettext-rs",
"glib",
"glob",
"gnome-desktop",
"gtk4",
"libadwaita",
"pretty-bytes",

View File

@ -19,3 +19,4 @@ glob = "0.3.1"
gettext-rs = { version = "0.7", features = ["gettext-system"] }
serde_json = "1.0.113"
serde = { version = "1.0", features = ["derive"] }
gnome-desktop = "0.4.2"

View File

@ -17,6 +17,8 @@ use std::str;
use std::fs;
use std::path::Path;
use gnome_desktop::*;
pub fn keyboard_page(content_stack: &gtk::Stack) {
// create the bottom box for next and back buttons
let bottom_box = gtk::Box::builder()
@ -125,11 +127,11 @@ pub fn keyboard_page(content_stack: &gtk::Stack) {
.build();
let keyboard_selection_expander_row_viewport =
gtk::ScrolledWindow::builder().height_request(200).build();
gtk::ScrolledWindow::builder().height_request(450).build();
let keyboard_selection_expander_row_viewport_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
let keyboard_selection_expander_row_viewport_box = gtk::ListBox::builder()
.build();
keyboard_selection_expander_row_viewport_box.add_css_class("boxed-list");
let keyboard_selection_expander_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(SelectionMode::None)
@ -187,10 +189,17 @@ pub fn keyboard_page(content_stack: &gtk::Stack) {
let keyboard_layout = keyboard_layout.unwrap();
let keyboard_layout_clone = keyboard_layout.clone();
let keyboard_layout_checkbutton = gtk::CheckButton::builder()
.label(keyboard_layout.clone())
.valign(Align::Center)
.can_focus(false)
.build();
let keyboard_layout_row = adw::ActionRow::builder()
.activatable_widget(&keyboard_layout_checkbutton)
.title(gnome_desktop::XkbInfo::new().layout_info(&keyboard_layout).unwrap().0.unwrap())
.subtitle(keyboard_layout.clone())
.build();
keyboard_layout_row.add_prefix(&keyboard_layout_checkbutton);
keyboard_layout_checkbutton.set_group(Some(&null_checkbutton));
keyboard_selection_expander_row_viewport_box.append(&keyboard_layout_checkbutton);
keyboard_selection_expander_row_viewport_box.append(&keyboard_layout_row);
keyboard_layout_checkbutton.connect_toggled(clone!(@weak keyboard_layout_checkbutton, @weak keyboard_selection_expander_row, @weak bottom_next_button, @weak keyboard_data_buffer => move |_| {
if keyboard_layout_checkbutton.is_active() == true {
keyboard_selection_expander_row.set_title(&keyboard_layout);