Start UI Rewrite

This commit is contained in:
Ward from fusion-voyager-3 2024-08-04 23:56:30 +03:00
parent 2ed95c72a0
commit 6eec9cdc04
29 changed files with 443 additions and 277 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
/target
.idea
.vscode

8
.idea/.gitignore vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pkg-pika-installer-gtk4.iml" filepath="$PROJECT_DIR$/.idea/pkg-pika-installer-gtk4.iml" />
</modules>
</component>
</project>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="EMPTY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,8 +0,0 @@
{
"css.lint.emptyRules": "ignore",
"scss.lint.emptyRules": "ignore",
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./Cargo.toml"
]
}

63
Cargo.lock generated
View File

@ -46,18 +46,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23"
[[package]]
name = "bitflags"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
[[package]]
name = "bitflags"
version = "1.3.2"
@ -424,19 +412,6 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "glib"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81f514a8abd315ede0e94e39ce5987fdb99191c5f812e5066bc5bdb965104fc4"
dependencies = [
"bitflags 0.5.0",
"glib-sys 0.3.4",
"gobject-sys 0.3.4",
"lazy_static 0.2.11",
"libc",
]
[[package]]
name = "glib"
version = "0.18.5"
@ -509,17 +484,6 @@ dependencies = [
"syn 2.0.72",
]
[[package]]
name = "glib-sys"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8826cbc94631507bdd91ee40f7e099bfaa3cc4f43c086b4d1c15cff5b4e8220b"
dependencies = [
"bitflags 0.8.2",
"libc",
"pkg-config",
]
[[package]]
name = "glib-sys"
version = "0.18.1"
@ -599,18 +563,6 @@ dependencies = [
"system-deps 6.2.0",
]
[[package]]
name = "gobject-sys"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87373f64e136e9ea192ff5d3ef676a51e9ac6ab06b629223a081e0523c5f04e2"
dependencies = [
"bitflags 0.8.2",
"glib-sys 0.3.4",
"libc",
"pkg-config",
]
[[package]]
name = "gobject-sys"
version = "0.18.0"
@ -843,12 +795,6 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "lazy_static"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -980,7 +926,7 @@ version = "1.0.2"
dependencies = [
"async-channel",
"duct",
"glib 0.1.3",
"glib 0.20.0",
"glob",
"gnome-desktop",
"gtk4",
@ -1156,7 +1102,7 @@ checksum = "399801f4d955abf1c3ce3ce2215dc76bd40beb4ae39e3a84936b21a79ce2caa5"
dependencies = [
"arc-swap",
"globwalk",
"lazy_static 1.4.0",
"lazy_static",
"normpath",
"once_cell",
"proc-macro2",
@ -1220,11 +1166,12 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.113"
version = "1.0.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79"
checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]

View File

@ -24,3 +24,22 @@ install:
#cp -vf data/pika-drivers.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/
#cp -vf data/com.pika.drivers.desktop $(DESTDIR)/usr/share/applications/
#makepot $(DESTDIR)/usr/share/locale
install_no_build_debug:
#cp -vf target/release/pika-installer-gtk4 $(DESTDIR)/usr/bin/
#chmod 755 $(DESTDIR)/usr/bin/pika-installer-gtk4
mkdir -p $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/bin/
cp -vf target/debug/pika-installer-gtk4 $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/bin/
chmod 755 $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/bin/pika-installer-gtk4
mkdir -p $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/
mkdir -p $(DESTDIR)/usr/share/glib-2.0/schemas/
cp -rvf data/scripts/*.sh $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/
cp -rvf data/scripts/*.py $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/
cp data/*.xml $(DESTDIR)/usr/share/glib-2.0/schemas/
chmod 755 $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/*.sh
chmod 755 $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/*.py
mkdir -p $(DESTDIR)/usr/share/applications
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps
#cp -vf data/pika-drivers.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/
#cp -vf data/com.pika.drivers.desktop $(DESTDIR)/usr/share/applications/
#makepot $(DESTDIR)/usr/share/locale

View File

@ -72,6 +72,7 @@
"eula_buffer": "There are a few things to keep in mind: \n 1 - You understand that this distribution is -NOT- to be considered an Ubuntu Flavor. \n 2 - This is a hobby distribution, so we will try our best to provide formal support but it will -NOT- be guaranteed. \n 3 - Although PikaOS might provide identical patches and user experience to the Nobara project, we are -NOT- directly a part of them so questions and bug reports should not be sent directly to them (they dont have to deal with it!) \n 4 - While the installer is running DO NOT INTERRUPT IT! or you will end up with a corrupted system. \n 5 - Try to use pikman instead of apt when using the terminal, it is much faster! \n 6 - You understand the xone driver downloads needed binaries locally and does not directly package or distribute any copyrighted firmware or other related data. \n 7 - Automatic partitioning will format all partitons on a drive, so if you want to dualboot make a separate EFI partition for PikaOS and use manual partitioning \n 8 - In case you need the login info for this session: \n - username: pikaos \n - password: \n MEANING: JUST PRESS ENTER",
"i_agree_eula": "I Agree and Accept the User license Agreement",
"eula": "EULA",
"bad_boot_platform": "Un Supported Boot Platform",
"pika_nowork_csm": "PikaOS Only works on GPT UEFI Systems, this machine is booted in CSM/LEGACY mode.",
"exit": "Exit",
"subtitle_partition": "Partition",

View File

@ -1,114 +1,66 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gtk::glib;
use gtk::glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::*;
use std::path::Path;
use gtk::{prelude::*, glib as glib};
use vte::ffi::VTE_ALIGN_CENTER;
use crate::efi_error_page;
use crate::installer_stack_page;
use crate::save_window_size::save_window_size;
use crate::welcome_page::welcome_page;
use crate::efi_error_page::efi_error_page;
use crate::language_page::language_page;
// build ui function linked to app startup above
pub fn build_ui(app: &adw::Application) {
// setup glib
gtk::glib::set_prgname(Some("pikaos_installer"));
glib::set_prgname(Some("pikaos_installer"));
glib::set_application_name(&t!("pikaos_installer"));
let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikainstallergtk4");
// Widget Bank
let _main_box = gtk::Box::builder()
// that puts items vertically
.orientation(Orientation::Vertical)
.build();
let window_title_bar = adw::HeaderBar::builder().build();
let content_stack = gtk::Stack::builder()
.hexpand(true)
let carousel = adw::Carousel::builder()
.allow_long_swipes(false)
.allow_mouse_drag(false)
.allow_scroll_wheel(false)
.interactive(false)
.vexpand(true)
.transition_type(StackTransitionType::SlideLeftRight)
.hexpand(true)
.build();
let content_stack_switcher = gtk::StackSwitcher::builder()
.stack(&content_stack)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.sensitive(false)
let carousel_indicator = adw::CarouselIndicatorDots::builder()
.carousel(&carousel)
.build();
// / _main_box appends
//// Add the a title bar to the _main_box
_main_box.append(&window_title_bar);
//// Add the step indicator to _main_box
_main_box.append(&content_stack_switcher);
//// Add the stack pager containing all the steps to _main_box
_main_box.append(&content_stack);
let window_headerbar = adw::HeaderBar::builder()
.show_start_title_buttons(true)
.title_widget(&carousel_indicator)
.build();
let toolbarview = adw::ToolbarView::builder()
.top_bar_style(adw::ToolbarStyle::Flat)
.content(&carousel)
.build();
toolbarview.add_top_bar(&window_headerbar);
let window = adw::ApplicationWindow::builder()
// The text on the titlebar
.title(t!("pikaos_installer"))
// link it to the application "app"
.application(app)
// Add the box called "_main_box" to it
.content(&_main_box)
// Application icon
.icon_name("calamares")
// Get current size from glib
.default_width(glib_settings.int("window-width"))
.default_height(glib_settings.int("window-height"))
// Minimum Size/Default
.width_request(700)
.height_request(500)
// Hide window instead of destroy
.hide_on_close(true)
//
.default_width(700)
.default_height(500)
.deletable(false)
// Startup
.content(&toolbarview)
.startup_id("pika-installer-gtk4")
// build the window
.build();
// Add welcome_page.rs as a page for content_stack
if Path::new("/sys/firmware/efi/efivars").exists() {
welcome_page(&window, &content_stack);
} else {
efi_error_page(&window, &content_stack);
match Path::new("/sys/firmware/efi/efivars").exists() {
true => {
let page = installer_stack_page::InstallerStackPage::new();
page.set_page_icon("pika-logo");
page.set_page_title("Title");
page.set_page_subtitle("Subtitle");
let gbox = gtk::Box::new(gtk::Orientation::Vertical, 0);
gbox.append(&gtk::Image::builder().icon_name("pika-logo").build());
page.set_child_widget(&gbox);
carousel.append(&page);
}
_ => efi_error_page::efi_error_page(&window, &carousel)
}
//welcome_page(&window, &carousel),
//language_page(&window, &carousel);
// bottom_box moved per page
// if content_stack visible child becomes NOT content_stack, show the buttom box
//content_stack.connect_visible_child_notify(clone!(@weak bottom_box => move |content_stack| {
// let state = content_stack.visible_child_name().as_deref() != Some("welcome_page");
// bottom_box.set_visible(state);
// }));
// Add language_page.rs as a page for content_stack
language_page(&content_stack, &window);
// glib maximization
if glib_settings.boolean("is-maximized") == true {
window.maximize()
}
// Connect the hiding of window to the save_window_size function and window destruction
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
window.connect_hide(clone!(@weak window => move |_| window.destroy()));
// bottom_box moved per page
//let content_stack_clone = content_stack.clone();
//let content_stack_clone2 = content_stack.clone();
//bottom_next_button.connect_clicked(move |_| content_stack_clone.set_visible_child(&content_stack_clone.visible_child().expect("null").next_sibling().unwrap()));
//bottom_back_button.connect_clicked(move |_| content_stack_clone2.set_visible_child(&content_stack_clone2.visible_child().expect("null").prev_sibling().unwrap()));
window.present();
}
window.present()
}

View File

@ -1,32 +1,22 @@
use gtk::{prelude::*, glib as glib, Justification};
use glib::clone;
pub fn efi_error_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carousel) {
// Use libraries
use adw::prelude::*;
use adw::*;
use gtk::glib;
use gtk::glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::*;
pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stack) {
// the header box for the efi_error page
let efi_error_main_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.orientation(gtk::Orientation::Vertical)
.build();
// the header box for the efi_error page
let efi_error_header_box = gtk::Box::builder()
.orientation(Orientation::Horizontal)
.orientation(gtk::Orientation::Horizontal)
.build();
// the header text for the efi_error page
let efi_error_header_text = gtk::Label::builder()
.label(t!("bad_boot_platfrom"))
.label(t!("bad_boot_platform"))
.halign(gtk::Align::End)
.hexpand(true)
.wrap(true)
.justify(Justification::Center)
.width_chars(20)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
@ -34,7 +24,6 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stac
.build();
efi_error_header_text.add_css_class("header_sized_text");
// the header icon for the efi_error icon
let efi_error_header_icon = gtk::Image::builder()
.icon_name("emblem-error")
.halign(gtk::Align::Start)
@ -46,9 +35,8 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stac
.margin_end(15)
.build();
// make efi_error selection box for choosing installation or live media
let efi_error_selection_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.orientation(gtk::Orientation::Vertical)
.margin_bottom(15)
.margin_top(15)
.margin_start(15)
@ -59,6 +47,7 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stac
.vexpand(true)
.hexpand(true)
.label(t!("pika_nowork_csm"))
.wrap(true)
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.build();
@ -72,40 +61,22 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stac
.valign(gtk::Align::Center)
.build();
// / efi_error_selection_box appends
// / efi_error_header_box appends
//// Add the efi_error page header text and icon
efi_error_header_box.append(&efi_error_header_text);
efi_error_header_box.append(&efi_error_header_icon);
// / efi_error_main_box appends
//// Add the efi_error header to efi_error main box
efi_error_main_box.append(&efi_error_header_box);
//// Add the efi_error selection/page content box to efi_error main box
efi_error_main_box.append(&efi_error_selection_box);
// Start Appending widgets to boxes
// / efi_error_selection_box appends
//// add live and install media button to efi_error page selections
efi_error_selection_box.append(&efi_error_text);
efi_error_selection_box.append(&exit_button);
// / efi_error_header_box appends
//// Add the efi_error page header text and icon
efi_error_header_box.append(&efi_error_header_text);
efi_error_header_box.append(&efi_error_header_icon);
// / efi_error_main_box appends
//// Add the efi_error header to efi_error main box
efi_error_main_box.append(&efi_error_header_box);
//// Add the efi_error selection/page content box to efi_error main box
efi_error_main_box.append(&efi_error_selection_box);
main_carousel.append(&efi_error_main_box);
// / Content stack appends
//// Add the efi_error_main_box as page: efi_error_page, Give it nice title
content_stack.add_titled(&efi_error_main_box, Some("efi_error_page"), "Welcome");
exit_button.connect_clicked(clone!(@weak window => move |_| window.close()));
exit_button.connect_clicked(clone!(
#[weak]
window,
move |_|
window.close()
));
}

View File

@ -1,59 +1,41 @@
// Use libraries
use std::env;
use crate::build_ui::build_ui;
use adw::prelude::*;
use adw::*;
use gdk::Display;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::{CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION};
use gtk::{CssProvider, gdk, STYLE_PROVIDER_PRIORITY_APPLICATION, prelude::*};
use gdk::{Display};
mod config;
use config::{APP_ID};
mod build_ui;
mod efi_error_page;
mod installer_stack_page;
// Init translations for current crate.
#[macro_use]
extern crate rust_i18n;
i18n!("locales", fallback = "en_US");
mod automatic_partitioning;
mod build_ui;
mod done_page;
mod drive_mount_row;
mod efi_error_page;
mod eula_page;
mod install_page;
mod keyboard_page;
mod language_page;
mod manual_partitioning;
mod partitioning_page;
mod save_window_size;
mod timezone_page;
mod welcome_page;
/// main function
fn main() {
fn main() -> glib::ExitCode {
let current_locale = match env::var_os("LANG") {
Some(v) => v.into_string().unwrap(),
Some(v) => v.into_string().unwrap().chars()
.take_while(|&ch| ch != '.')
.collect::<String>(),
None => panic!("$LANG is not set"),
};
rust_i18n::set_locale(current_locale.strip_suffix(".UTF-8").unwrap());
let application = adw::Application::new(Some(APP_ID), Default::default());
application.connect_startup(|app| {
// The CSS "magic" happens here.
let provider = CssProvider::new();
provider.load_from_string(include_str!("style.css"));
// We give the CssProvided to the default screen so the CSS rules we added
// can be applied to our window.
gtk::style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display."),
&provider,
STYLE_PROVIDER_PRIORITY_APPLICATION,
);
app.connect_activate(build_ui);
rust_i18n::set_locale(&current_locale);
let app = adw::Application::builder().application_id(config::APP_ID).build();
app.connect_startup(|app| {
load_css();
app.connect_activate(build_ui::build_ui);
});
application.run();
// Run the application
app.run()
}
fn load_css() {
let provider = CssProvider::new();
provider.load_from_string(include_str!("style.css"));
gtk::style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display."),
&provider,
STYLE_PROVIDER_PRIORITY_APPLICATION,
);
}

114
src2/build_ui.rs Normal file
View File

@ -0,0 +1,114 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gtk::glib;
use gtk::glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::*;
use std::path::Path;
use crate::save_window_size::save_window_size;
use crate::welcome_page::welcome_page;
use crate::efi_error_page::efi_error_page;
use crate::language_page::language_page;
// build ui function linked to app startup above
pub fn build_ui(app: &adw::Application) {
// setup glib
gtk::glib::set_prgname(Some("pikaos_installer"));
glib::set_application_name(&t!("pikaos_installer"));
let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikainstallergtk4");
// Widget Bank
let _main_box = gtk::Box::builder()
// that puts items vertically
.orientation(Orientation::Vertical)
.build();
let window_title_bar = adw::HeaderBar::builder().build();
let content_stack = gtk::Stack::builder()
.hexpand(true)
.vexpand(true)
.transition_type(StackTransitionType::SlideLeftRight)
.build();
let content_stack_switcher = gtk::StackSwitcher::builder()
.stack(&content_stack)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.sensitive(false)
.build();
// / _main_box appends
//// Add the a title bar to the _main_box
_main_box.append(&window_title_bar);
//// Add the step indicator to _main_box
_main_box.append(&content_stack_switcher);
//// Add the stack pager containing all the steps to _main_box
_main_box.append(&content_stack);
let window = adw::ApplicationWindow::builder()
// The text on the titlebar
.title(t!("pikaos_installer"))
// link it to the application "app"
.application(app)
// Add the box called "_main_box" to it
.content(&_main_box)
// Application icon
.icon_name("calamares")
// Get current size from glib
.default_width(glib_settings.int("window-width"))
.default_height(glib_settings.int("window-height"))
// Minimum Size/Default
.width_request(700)
.height_request(500)
// Hide window instead of destroy
.hide_on_close(true)
//
.deletable(false)
// Startup
.startup_id("pika-installer-gtk4")
// build the window
.build();
// Add welcome_page.rs as a page for content_stack
if Path::new("/sys/firmware/efi/efivars").exists() {
welcome_page(&window, &content_stack);
} else {
efi_error_page(&window, &content_stack);
}
// bottom_box moved per page
// if content_stack visible child becomes NOT content_stack, show the buttom box
//content_stack.connect_visible_child_notify(clone!(@weak bottom_box => move |content_stack| {
// let state = content_stack.visible_child_name().as_deref() != Some("welcome_page");
// bottom_box.set_visible(state);
// }));
// Add language_page.rs as a page for content_stack
language_page(&content_stack, &window);
// glib maximization
if glib_settings.boolean("is-maximized") == true {
window.maximize()
}
// Connect the hiding of window to the save_window_size function and window destruction
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
window.connect_hide(clone!(@weak window => move |_| window.destroy()));
// bottom_box moved per page
//let content_stack_clone = content_stack.clone();
//let content_stack_clone2 = content_stack.clone();
//bottom_next_button.connect_clicked(move |_| content_stack_clone.set_visible_child(&content_stack_clone.visible_child().expect("null").next_sibling().unwrap()));
//bottom_back_button.connect_clicked(move |_| content_stack_clone2.set_visible_child(&content_stack_clone2.visible_child().expect("null").prev_sibling().unwrap()));
window.present();
}

7
src2/config.rs Normal file
View File

@ -0,0 +1,7 @@
pub const APP_ID: &str = "com.github.pikaos-linux.pikainstallergtk4";
//pub const GETTEXT_PACKAGE: &str = env!("CARGO_PKG_NAME");
//pub const LOCALEDIR: &str = "/usr/share/locale";
//pub const PKGDATADIR: &str = " /usr/share";
//pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource");
//pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const DISTRO_ICON: &str = "pika-logo";

111
src2/efi_error_page/mod.rs Normal file
View File

@ -0,0 +1,111 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gtk::glib;
use gtk::glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::*;
pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stack) {
// the header box for the efi_error page
let efi_error_main_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.build();
// the header box for the efi_error page
let efi_error_header_box = gtk::Box::builder()
.orientation(Orientation::Horizontal)
.build();
// the header text for the efi_error page
let efi_error_header_text = gtk::Label::builder()
.label(t!("bad_boot_platfrom"))
.halign(gtk::Align::End)
.hexpand(true)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(5)
.build();
efi_error_header_text.add_css_class("header_sized_text");
// the header icon for the efi_error icon
let efi_error_header_icon = gtk::Image::builder()
.icon_name("emblem-error")
.halign(gtk::Align::Start)
.hexpand(true)
.pixel_size(78)
.margin_top(15)
.margin_bottom(15)
.margin_start(0)
.margin_end(15)
.build();
// make efi_error selection box for choosing installation or live media
let efi_error_selection_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.margin_bottom(15)
.margin_top(15)
.margin_start(15)
.margin_end(15)
.build();
let efi_error_text = gtk::Label::builder()
.vexpand(true)
.hexpand(true)
.label(t!("pika_nowork_csm"))
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.build();
efi_error_text.add_css_class("big_error_text");
let exit_button = gtk::Button::builder()
.label(t!("exit"))
.vexpand(true)
.hexpand(true)
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.build();
// / efi_error_selection_box appends
// / efi_error_header_box appends
//// Add the efi_error page header text and icon
efi_error_header_box.append(&efi_error_header_text);
efi_error_header_box.append(&efi_error_header_icon);
// / efi_error_main_box appends
//// Add the efi_error header to efi_error main box
efi_error_main_box.append(&efi_error_header_box);
//// Add the efi_error selection/page content box to efi_error main box
efi_error_main_box.append(&efi_error_selection_box);
// Start Appending widgets to boxes
// / efi_error_selection_box appends
//// add live and install media button to efi_error page selections
efi_error_selection_box.append(&efi_error_text);
efi_error_selection_box.append(&exit_button);
// / efi_error_header_box appends
//// Add the efi_error page header text and icon
efi_error_header_box.append(&efi_error_header_text);
efi_error_header_box.append(&efi_error_header_icon);
// / efi_error_main_box appends
//// Add the efi_error header to efi_error main box
efi_error_main_box.append(&efi_error_header_box);
//// Add the efi_error selection/page content box to efi_error main box
efi_error_main_box.append(&efi_error_selection_box);
// / Content stack appends
//// Add the efi_error_main_box as page: efi_error_page, Give it nice title
content_stack.add_titled(&efi_error_main_box, Some("efi_error_page"), "Welcome");
exit_button.connect_clicked(clone!(@weak window => move |_| window.close()));
}

59
src2/main.rs Normal file
View File

@ -0,0 +1,59 @@
// Use libraries
use std::env;
use crate::build_ui::build_ui;
use adw::prelude::*;
use adw::*;
use gdk::Display;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::{CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION};
mod config;
use config::{APP_ID};
// Init translations for current crate.
#[macro_use]
extern crate rust_i18n;
i18n!("locales", fallback = "en_US");
mod automatic_partitioning;
mod build_ui;
mod done_page;
mod drive_mount_row;
mod efi_error_page;
mod eula_page;
mod install_page;
mod keyboard_page;
mod language_page;
mod manual_partitioning;
mod partitioning_page;
mod save_window_size;
mod timezone_page;
mod welcome_page;
/// main function
fn main() {
let current_locale = match env::var_os("LANG") {
Some(v) => v.into_string().unwrap(),
None => panic!("$LANG is not set"),
};
rust_i18n::set_locale(current_locale.strip_suffix(".UTF-8").unwrap());
let application = adw::Application::new(Some(APP_ID), Default::default());
application.connect_startup(|app| {
// The CSS "magic" happens here.
let provider = CssProvider::new();
provider.load_from_string(include_str!("style.css"));
// We give the CssProvided to the default screen so the CSS rules we added
// can be applied to our window.
gtk::style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display."),
&provider,
STYLE_PROVIDER_PRIORITY_APPLICATION,
);
app.connect_activate(build_ui);
});
application.run();
}

36
src2/style.css Normal file
View File

@ -0,0 +1,36 @@
.small_error_text {
font-size: 14px;
color: red;
}
.small_warn_text {
font-size: 14px;
color: orange;
}
.small_valid_text {
font-size: 14px;
color: green;
}
.small_fg_text {
font-size: 48px;
}
.big_error_text {
font-size: 32px;
color: red;
}
.header_sized_text {
font-size: 32px;
}
.medium_sized_text {
font-size: 18px;
}
.valid-action {
background-color:green;
color: white;
}