RR: Fix language row

This commit is contained in:
Ward from fusion-voyager-3 2024-02-20 00:22:42 +03:00
parent 2ad12278cc
commit a722ef7c04
2 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,5 @@
#! /usr/bin/python3
import gi import gi
gi.require_version('GnomeDesktop', '4.0') gi.require_version('GnomeDesktop', '4.0')
from gi.repository import GnomeDesktop from gi.repository import GnomeDesktop

View File

@ -17,8 +17,6 @@ use std::process::Stdio;
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
use gnome_desktop::*;
pub fn language_page(content_stack: &gtk::Stack) { pub fn language_page(content_stack: &gtk::Stack) {
// create the bottom box for next and back buttons // create the bottom box for next and back buttons
let bottom_box = gtk::Box::builder() let bottom_box = gtk::Box::builder()
@ -179,14 +177,27 @@ pub fn language_page(content_stack: &gtk::Stack) {
for locale in locale_reader.lines() { for locale in locale_reader.lines() {
let locale = locale.unwrap(); let locale = locale.unwrap();
let locale_name_cli = Command::new("/usr/lib/pika/pika-installer-gtk4/scripts/locale-name.py")
.arg(locale.clone())
.output()
.expect("failed to execute process");
let locale_name = String::from_utf8(locale_name_cli.stdout).unwrap();
let locale_clone = locale.clone(); let locale_clone = locale.clone();
let locale_checkbutton = gtk::CheckButton::builder().label(locale.clone()).build(); let locale_checkbutton = gtk::CheckButton::builder()
println!("{}", gnome_desktop::XkbInfo::new().languages_for_layout(&locale)); .valign(Align::Center)
.can_focus(false)
.build();
let locale_row = adw::ActionRow::builder()
.activatable_widget(&locale_checkbutton)
.title(locale_name)
.subtitle(locale.clone())
.build();
locale_row.add_prefix(&locale_checkbutton);
locale_checkbutton.set_group(Some(&null_checkbutton)); locale_checkbutton.set_group(Some(&null_checkbutton));
language_selection_expander_row_viewport_box.append(&locale_checkbutton); language_selection_expander_row_viewport_box.append(&locale_row);
locale_checkbutton.connect_toggled(clone!(@weak locale_checkbutton, @weak language_selection_expander_row, @weak bottom_next_button, @weak lang_data_buffer => move |_| { locale_checkbutton.connect_toggled(clone!(@weak locale_checkbutton, @weak language_selection_expander_row, @weak bottom_next_button, @weak lang_data_buffer => move |_| {
if locale_checkbutton.is_active() == true { if locale_checkbutton.is_active() == true {
language_selection_expander_row.set_title(&locale); language_selection_expander_row.set_title(&locale_row.title());
bottom_next_button.set_sensitive(true); bottom_next_button.set_sensitive(true);
lang_data_buffer.set_text(&locale); lang_data_buffer.set_text(&locale);
} }