Use buffers instead of temp files
This commit is contained in:
parent
ceb4fc3a50
commit
cdc1ca25ae
@ -49,15 +49,20 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
_ => efi_error_page::efi_error_page(&window, &carousel)
|
_ => efi_error_page::efi_error_page(&window, &carousel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let language_selection_text_buffer = gtk::TextBuffer::builder().build();
|
||||||
|
let keymap_base_selection_text_buffer = gtk::TextBuffer::builder().build();
|
||||||
|
let keymap_varient_selection_text_buffer = gtk::TextBuffer::builder().build();
|
||||||
|
let timezone_selection_text_buffer = gtk::TextBuffer::builder().build();
|
||||||
|
|
||||||
let language_changed_action = gio::SimpleAction::new("lang-changed", None);
|
let language_changed_action = gio::SimpleAction::new("lang-changed", None);
|
||||||
|
|
||||||
language_page::language_page(&carousel, &language_changed_action);
|
language_page::language_page(&carousel, &language_selection_text_buffer, &language_changed_action);
|
||||||
|
|
||||||
eula_page::eula_page(&carousel, &language_changed_action);
|
eula_page::eula_page(&carousel, &language_changed_action);
|
||||||
|
|
||||||
keyboard_page::keyboard_page(&carousel, &language_changed_action);
|
keyboard_page::keyboard_page(&carousel, &keymap_base_selection_text_buffer, &keymap_varient_selection_text_buffer, &language_changed_action);
|
||||||
|
|
||||||
timezone_page::timezone_page(&carousel, &language_changed_action);
|
timezone_page::timezone_page(&carousel, &timezone_selection_text_buffer, &language_changed_action);
|
||||||
|
|
||||||
partitioning_page::partitioning_page(&carousel, &language_changed_action);
|
partitioning_page::partitioning_page(&carousel, &language_changed_action);
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ use std::{process::Command, fs, path::Path};
|
|||||||
|
|
||||||
pub fn keyboard_page(
|
pub fn keyboard_page(
|
||||||
main_carousel: &adw::Carousel,
|
main_carousel: &adw::Carousel,
|
||||||
|
keymap_base_data_buffer: >k::TextBuffer,
|
||||||
|
keymap_variant_data_buffer: >k::TextBuffer,
|
||||||
language_changed_action: &gio::SimpleAction
|
language_changed_action: &gio::SimpleAction
|
||||||
) {
|
) {
|
||||||
let keyboard_page = installer_stack_page::InstallerStackPage::new();
|
let keyboard_page = installer_stack_page::InstallerStackPage::new();
|
||||||
@ -70,12 +72,8 @@ pub fn keyboard_page(
|
|||||||
|
|
||||||
let keymap_list = gnome_desktop::XkbInfo::all_layouts(&xkbinfo);
|
let keymap_list = gnome_desktop::XkbInfo::all_layouts(&xkbinfo);
|
||||||
|
|
||||||
let keymap_base_data_buffer = gtk::TextBuffer::builder().build();
|
|
||||||
|
|
||||||
let keymap_base_data_buffer_clone0 = keymap_base_data_buffer.clone();
|
let keymap_base_data_buffer_clone0 = keymap_base_data_buffer.clone();
|
||||||
|
|
||||||
let keymap_variant_data_buffer = gtk::TextBuffer::builder().build();
|
|
||||||
|
|
||||||
let keymap_variant_data_buffer_clone0 = keymap_variant_data_buffer.clone();
|
let keymap_variant_data_buffer_clone0 = keymap_variant_data_buffer.clone();
|
||||||
|
|
||||||
for keymap in keymap_list.iter() {
|
for keymap in keymap_list.iter() {
|
||||||
@ -222,35 +220,6 @@ pub fn keyboard_page(
|
|||||||
main_carousel,
|
main_carousel,
|
||||||
move |_keyboard_page: installer_stack_page::InstallerStackPage|
|
move |_keyboard_page: installer_stack_page::InstallerStackPage|
|
||||||
{
|
{
|
||||||
if Path::new("/tmp/pika-installer-gtk4-keyboard-base.txt").exists() {
|
|
||||||
fs::remove_file("/tmp/pika-installer-gtk4-keyboard-base.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-keyboard-base.txt");
|
|
||||||
}
|
|
||||||
let base_data_text = keymap_base_data_buffer_clone0
|
|
||||||
.text(
|
|
||||||
&keymap_base_data_buffer_clone0.bounds().0,
|
|
||||||
&keymap_base_data_buffer_clone0.bounds().1,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
.to_string();
|
|
||||||
fs::write(
|
|
||||||
"/tmp/pika-installer-gtk4-keyboard-base.txt",
|
|
||||||
base_data_text
|
|
||||||
).expect("Unable to write file");
|
|
||||||
if Path::new("/tmp/pika-installer-gtk4-keyboard-variant.txt").exists() {
|
|
||||||
fs::remove_file("/tmp/pika-installer-gtk4-keyboard-variant.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-keyboard-variant.txt");
|
|
||||||
}
|
|
||||||
let varient_data_text = keymap_variant_data_buffer_clone0
|
|
||||||
.text(
|
|
||||||
&keymap_variant_data_buffer_clone0.bounds().0,
|
|
||||||
&keymap_variant_data_buffer_clone0.bounds().1,
|
|
||||||
true
|
|
||||||
).to_string();
|
|
||||||
if !varient_data_text.is_empty() {
|
|
||||||
fs::write(
|
|
||||||
"/tmp/pika-installer-gtk4-keyboard-variant.txt",
|
|
||||||
varient_data_text
|
|
||||||
).expect("Unable to write file");
|
|
||||||
}
|
|
||||||
main_carousel.scroll_to(&main_carousel.nth_page(4), true)
|
main_carousel.scroll_to(&main_carousel.nth_page(4), true)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -6,6 +6,7 @@ use std::{process::Command, env, fs, path::Path};
|
|||||||
|
|
||||||
pub fn language_page(
|
pub fn language_page(
|
||||||
main_carousel: &adw::Carousel,
|
main_carousel: &adw::Carousel,
|
||||||
|
lang_data_buffer: >k::TextBuffer,
|
||||||
language_changed_action: &gio::SimpleAction
|
language_changed_action: &gio::SimpleAction
|
||||||
) {
|
) {
|
||||||
let language_page = installer_stack_page::InstallerStackPage::new();
|
let language_page = installer_stack_page::InstallerStackPage::new();
|
||||||
@ -222,8 +223,6 @@ pub fn language_page(
|
|||||||
"pt_BR",
|
"pt_BR",
|
||||||
"pt_PT",];
|
"pt_PT",];
|
||||||
|
|
||||||
let lang_data_buffer = gtk::TextBuffer::builder().build();
|
|
||||||
|
|
||||||
let lang_data_buffer_clone0 = lang_data_buffer.clone();
|
let lang_data_buffer_clone0 = lang_data_buffer.clone();
|
||||||
|
|
||||||
for locale in locale_list.iter() {
|
for locale in locale_list.iter() {
|
||||||
@ -323,10 +322,6 @@ pub fn language_page(
|
|||||||
language_changed_action,
|
language_changed_action,
|
||||||
move |_language_page: installer_stack_page::InstallerStackPage|
|
move |_language_page: installer_stack_page::InstallerStackPage|
|
||||||
{
|
{
|
||||||
if Path::new("/tmp/pika-installer-gtk4-lang.txt").exists() {
|
|
||||||
fs::remove_file("/tmp/pika-installer-gtk4-lang.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-lang.txt");
|
|
||||||
}
|
|
||||||
fs::write("/tmp/pika-installer-gtk4-lang.txt", lang_data_buffer_clone0.text(&lang_data_buffer_clone0.bounds().0, &lang_data_buffer_clone0.bounds().1, true).to_string()).expect("Unable to write file");
|
|
||||||
//Command::new("sudo")
|
//Command::new("sudo")
|
||||||
// .arg("localectl")
|
// .arg("localectl")
|
||||||
// .arg("set-locale")
|
// .arg("set-locale")
|
||||||
|
@ -7,6 +7,7 @@ use std::io::BufRead;
|
|||||||
|
|
||||||
pub fn timezone_page(
|
pub fn timezone_page(
|
||||||
main_carousel: &adw::Carousel,
|
main_carousel: &adw::Carousel,
|
||||||
|
timezone_data_buffer: >k::TextBuffer,
|
||||||
language_changed_action: &gio::SimpleAction
|
language_changed_action: &gio::SimpleAction
|
||||||
) {
|
) {
|
||||||
let timezone_page = installer_stack_page::InstallerStackPage::new();
|
let timezone_page = installer_stack_page::InstallerStackPage::new();
|
||||||
@ -73,7 +74,6 @@ pub fn timezone_page(
|
|||||||
let timezone_stdout = timezone_cli.stdout.expect("could not get stdout");
|
let timezone_stdout = timezone_cli.stdout.expect("could not get stdout");
|
||||||
let timezone_reader = std::io::BufReader::new(timezone_stdout);
|
let timezone_reader = std::io::BufReader::new(timezone_stdout);
|
||||||
|
|
||||||
let timezone_data_buffer = gtk::TextBuffer::builder().build();
|
|
||||||
let timezone_data_buffer_clone0 = timezone_data_buffer.clone();
|
let timezone_data_buffer_clone0 = timezone_data_buffer.clone();
|
||||||
|
|
||||||
for timezone in timezone_reader.lines() {
|
for timezone in timezone_reader.lines() {
|
||||||
@ -186,10 +186,6 @@ pub fn timezone_page(
|
|||||||
move |_timezone_page: installer_stack_page::InstallerStackPage|
|
move |_timezone_page: installer_stack_page::InstallerStackPage|
|
||||||
{
|
{
|
||||||
let timezone_selection = timezone_data_buffer_clone0.text(&timezone_data_buffer_clone0.bounds().0, &timezone_data_buffer_clone0.bounds().1, true).to_string();
|
let timezone_selection = timezone_data_buffer_clone0.text(&timezone_data_buffer_clone0.bounds().0, &timezone_data_buffer_clone0.bounds().1, true).to_string();
|
||||||
if Path::new("/tmp/pika-installer-gtk4-timezone.txt").exists() {
|
|
||||||
fs::remove_file("/tmp/pika-installer-gtk4-timezone.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-timezone.txt");
|
|
||||||
}
|
|
||||||
fs::write("/tmp/pika-installer-gtk4-timezone.txt", &timezone_selection).expect("Unable to write file");
|
|
||||||
Command::new("sudo")
|
Command::new("sudo")
|
||||||
.arg("timedatectl")
|
.arg("timedatectl")
|
||||||
.arg("set-timezone")
|
.arg("set-timezone")
|
||||||
|
Loading…
Reference in New Issue
Block a user