Add EULA PAGE
This commit is contained in:
parent
4f89b88f48
commit
de4e48df4e
@ -1,8 +1,6 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use gtk::{prelude::*, glib as glib, gio as gio};
|
use gtk::{prelude::*, glib as glib, gio as gio};
|
||||||
use crate::efi_error_page;
|
use crate::{efi_error_page, welcome_page, language_page, eula_page};
|
||||||
use crate::welcome_page;
|
|
||||||
use crate::language_page;
|
|
||||||
|
|
||||||
pub fn build_ui(app: &adw::Application) {
|
pub fn build_ui(app: &adw::Application) {
|
||||||
glib::set_prgname(Some("pikaos_installer"));
|
glib::set_prgname(Some("pikaos_installer"));
|
||||||
@ -53,7 +51,9 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
|
|
||||||
let language_changed_action = gio::SimpleAction::new("lang-changed", None);
|
let language_changed_action = gio::SimpleAction::new("lang-changed", None);
|
||||||
|
|
||||||
language_page::language_page(&window, &carousel);
|
language_page::language_page(&window, &carousel, &language_changed_action);
|
||||||
|
|
||||||
|
eula_page::eula_page(&carousel, &language_changed_action);
|
||||||
|
|
||||||
window.present()
|
window.present()
|
||||||
}
|
}
|
@ -1,10 +1,14 @@
|
|||||||
use crate::installer_stack_page;
|
use crate::installer_stack_page;
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use gtk::{prelude::*, glib as glib, Justification};
|
use gtk::{prelude::*, glib as glib, gio as gio};
|
||||||
use adw::{prelude::*};
|
use adw::{prelude::*};
|
||||||
use glib::{clone, closure_local};
|
use glib::{clone, closure_local};
|
||||||
use std::{process::Command, env};
|
use std::{process::Command, env, fs, path::Path};
|
||||||
pub fn language_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carousel) {
|
pub fn language_page(
|
||||||
|
window: &adw::ApplicationWindow,
|
||||||
|
main_carousel: &adw::Carousel,
|
||||||
|
language_changed_action: &gio::SimpleAction
|
||||||
|
) {
|
||||||
let language_page = installer_stack_page::InstallerStackPage::new();
|
let language_page = installer_stack_page::InstallerStackPage::new();
|
||||||
language_page.set_page_title(t!("select_a_language"));
|
language_page.set_page_title(t!("select_a_language"));
|
||||||
language_page.set_page_subtitle(t!("please_select_locale"));
|
language_page.set_page_subtitle(t!("please_select_locale"));
|
||||||
@ -55,6 +59,8 @@ pub fn language_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carou
|
|||||||
.search_delay(500)
|
.search_delay(500)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
language_search_bar.add_css_class("rounded-all-25");
|
||||||
|
|
||||||
let current_locale = match env::var_os("LANG") {
|
let current_locale = match env::var_os("LANG") {
|
||||||
Some(v) => v.into_string().unwrap(),
|
Some(v) => v.into_string().unwrap(),
|
||||||
None => panic!("$LANG is not set"),
|
None => panic!("$LANG is not set"),
|
||||||
@ -223,6 +229,8 @@ pub fn language_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carou
|
|||||||
|
|
||||||
let lang_data_buffer = gtk::TextBuffer::builder().build();
|
let lang_data_buffer = gtk::TextBuffer::builder().build();
|
||||||
|
|
||||||
|
let lang_data_buffer_clone0 = lang_data_buffer.clone();
|
||||||
|
|
||||||
for locale in locale_list.iter() {
|
for locale in locale_list.iter() {
|
||||||
let locale = locale.to_string();
|
let locale = locale.to_string();
|
||||||
let locale_name_cli =
|
let locale_name_cli =
|
||||||
@ -248,14 +256,14 @@ pub fn language_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carou
|
|||||||
#[weak]
|
#[weak]
|
||||||
locale_checkbutton,
|
locale_checkbutton,
|
||||||
#[weak]
|
#[weak]
|
||||||
lang_data_buffer,
|
lang_data_buffer_clone0,
|
||||||
#[weak]
|
#[weak]
|
||||||
language_page,
|
language_page,
|
||||||
move |_|
|
move |_|
|
||||||
{
|
{
|
||||||
if locale_checkbutton.is_active() == true {
|
if locale_checkbutton.is_active() == true {
|
||||||
language_page.set_next_sensitive(true);
|
language_page.set_next_sensitive(true);
|
||||||
lang_data_buffer.set_text(&locale);
|
lang_data_buffer_clone0.set_text(&locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
@ -274,8 +282,6 @@ pub fn language_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carou
|
|||||||
content_box.append(&language_search_bar);
|
content_box.append(&language_search_bar);
|
||||||
content_box.append(&language_selection_row_viewport);
|
content_box.append(&language_selection_row_viewport);
|
||||||
|
|
||||||
let lang_data_buffer_clone = lang_data_buffer.clone();
|
|
||||||
|
|
||||||
language_search_bar.connect_search_changed(clone!(
|
language_search_bar.connect_search_changed(clone!(
|
||||||
#[weak]
|
#[weak]
|
||||||
language_search_bar,
|
language_search_bar,
|
||||||
@ -323,8 +329,22 @@ pub fn language_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carou
|
|||||||
closure_local!(
|
closure_local!(
|
||||||
#[weak]
|
#[weak]
|
||||||
main_carousel,
|
main_carousel,
|
||||||
|
#[strong]
|
||||||
|
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")
|
||||||
|
// .arg("localectl")
|
||||||
|
// .arg("set-locale")
|
||||||
|
// .arg("LANG=".to_owned() + &lang_data_buffer_clone0.text(&lang_data_buffer_clone0.bounds().0, &lang_data_buffer_clone0.bounds().1, true).to_string() + ".UTF-8")
|
||||||
|
// .spawn()
|
||||||
|
// .expect("locale failed to start");
|
||||||
|
rust_i18n::set_locale(&lang_data_buffer_clone0.text(&lang_data_buffer_clone0.bounds().0, &lang_data_buffer_clone0.bounds().1, true).to_string());
|
||||||
|
language_changed_action.activate(None);
|
||||||
main_carousel.scroll_to(&main_carousel.nth_page(2), true)
|
main_carousel.scroll_to(&main_carousel.nth_page(2), true)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -5,8 +5,12 @@ mod config;
|
|||||||
mod build_ui;
|
mod build_ui;
|
||||||
mod efi_error_page;
|
mod efi_error_page;
|
||||||
mod installer_stack_page;
|
mod installer_stack_page;
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
mod welcome_page;
|
mod welcome_page;
|
||||||
mod language_page;
|
mod language_page;
|
||||||
|
mod eula_page;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rust_i18n;
|
extern crate rust_i18n;
|
||||||
|
@ -34,3 +34,12 @@
|
|||||||
background-color:green;
|
background-color:green;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rounded-all-25 {
|
||||||
|
border-radius: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rounded-all-25-with-padding {
|
||||||
|
border-radius: 25px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
use crate::installer_stack_page;
|
use crate::installer_stack_page;
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use gtk::{prelude::*, glib as glib, Justification};
|
use gtk::{prelude::*, glib as glib};
|
||||||
use glib::clone;
|
use glib::clone;
|
||||||
pub fn welcome_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carousel) {
|
pub fn welcome_page(
|
||||||
|
window: &adw::ApplicationWindow,
|
||||||
|
main_carousel: &adw::Carousel,
|
||||||
|
) {
|
||||||
let welcome_page = installer_stack_page::InstallerStackPage::new();
|
let welcome_page = installer_stack_page::InstallerStackPage::new();
|
||||||
welcome_page.set_page_title(t!("welcome"));
|
welcome_page.set_page_title(t!("welcome"));
|
||||||
welcome_page.set_page_subtitle(t!("welcome_to_pikaos"));
|
welcome_page.set_page_subtitle(t!("welcome_to_pikaos"));
|
||||||
|
Loading…
Reference in New Issue
Block a user