No Network Page

This commit is contained in:
Ward from fusion-voyager-3 2024-02-23 21:38:03 +03:00
parent f82b897d1a
commit c888b2ebd7
5 changed files with 103 additions and 79 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "pika-drivers" name = "pika-drivers"
version = "0.4.4" version = "1.0.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -14,5 +14,5 @@ install:
chmod 755 $(DESTDIR)/usr/lib/pika/drivers/*.sh chmod 755 $(DESTDIR)/usr/lib/pika/drivers/*.sh
mkdir -p $(DESTDIR)/usr/share/applications mkdir -p $(DESTDIR)/usr/share/applications
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps 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.github.pikaos-linux.pikadrivers.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/
cp -vf data/com.github.pikaos-linux.pikadrivers.desktop $(DESTDIR)/usr/share/applications/ cp -vf data/com.github.pikaos-linux.pikadrivers.desktop $(DESTDIR)/usr/share/applications/

5
locales/en_US.json Normal file
View File

@ -0,0 +1,5 @@
{
"app_name": "PikaOS Driver Manager",
"app_dev": "Cosmo",
"loading_label_label": "Scanning for drivers..."
}

View File

@ -18,9 +18,9 @@ use std::process::Command;
use users::*; use users::*;
pub fn build_ui(app: &adw::Application) { pub fn build_ui(app: &adw::Application) {
gtk::glib::set_prgname(Some(APP_NAME)); gtk::glib::set_prgname(Some(t!("app_name").to_string()));
glib::set_application_name(APP_NAME); glib::set_application_name(&t!("app_name").to_string());
let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikadrivers"); let glib_settings = gio::Settings::new(APP_ID);
let content_box = gtk::Box::builder() let content_box = gtk::Box::builder()
.orientation(Orientation::Vertical) .orientation(Orientation::Vertical)
@ -59,7 +59,7 @@ pub fn build_ui(app: &adw::Application) {
.build(); .build();
let loading_label = gtk::Label::builder() let loading_label = gtk::Label::builder()
.label("Scanning for drivers...") .label(t!("loading_label_label"))
.margin_top(20) .margin_top(20)
.margin_bottom(20) .margin_bottom(20)
.margin_start(20) .margin_start(20)
@ -75,13 +75,13 @@ pub fn build_ui(app: &adw::Application) {
loading_box.append(&loading_label); loading_box.append(&loading_label);
let window = adw::ApplicationWindow::builder() let window = adw::ApplicationWindow::builder()
.title(APP_NAME) .title(t!("app_name"))
.application(app) .application(app)
.content(&content_box) .content(&content_box)
.icon_name(APP_ICON) .icon_name(APP_ICON)
.default_width(glib_settings.int("window-width")) .default_width(glib_settings.int("window-width"))
.default_height(glib_settings.int("window-height")) .default_height(glib_settings.int("window-height"))
.width_request(900) .width_request(950)
.height_request(500) .height_request(500)
.startup_id(APP_ID) .startup_id(APP_ID)
.hide_on_close(true) .hide_on_close(true)
@ -99,16 +99,15 @@ pub fn build_ui(app: &adw::Application) {
let credits_window = adw::AboutWindow::builder() let credits_window = adw::AboutWindow::builder()
.application_icon(APP_ICON) .application_icon(APP_ICON)
.application_name(APP_NAME) .application_name(t!("app_name"))
.transient_for(&window) .transient_for(&window)
.version(VERSION) .version(VERSION)
.hide_on_close(true) .hide_on_close(true)
.developer_name(APP_DEV) .developer_name(t!("app_dev"))
.issue_url(APP_GITHUB.to_owned() + "/issues") .issue_url(APP_GITHUB.to_owned() + "/issues")
.build(); .build();
content_box.append(&window_title_bar); content_box.append(&window_title_bar);
content_box.append(&loading_box);
window_title_bar.pack_end(&credits_button.clone()); window_title_bar.pack_end(&credits_button.clone());
@ -119,11 +118,18 @@ pub fn build_ui(app: &adw::Application) {
.connect_clicked(clone!(@weak credits_button => move |_| credits_window.present())); .connect_clicked(clone!(@weak credits_button => move |_| credits_window.present()));
println!("Downloading driver DB..."); println!("Downloading driver DB...");
let check_internet_connection_cli = Command::new("ping")
.arg("ppa.pika-os.com")
.arg("-c 1")
.output()
.expect("failed to execute process");
if check_internet_connection_cli.status.success() {
content_box.append(&loading_box);
let data = reqwest::blocking::get(DRIVER_DB_JSON_URL) let data = reqwest::blocking::get(DRIVER_DB_JSON_URL)
.unwrap() .unwrap()
.text() .text()
.unwrap(); .unwrap();
let (drive_hws_sender, drive_hws_receiver) = async_channel::unbounded(); let (drive_hws_sender, drive_hws_receiver) = async_channel::unbounded();
let drive_hws_sender = drive_hws_sender.clone(); let drive_hws_sender = drive_hws_sender.clone();
// The long running operation runs now in a separate thread // The long running operation runs now in a separate thread
@ -189,6 +195,18 @@ pub fn build_ui(app: &adw::Application) {
} }
}), }),
); );
} else {
println!("Network Error!");
let loading_no_internet_box_text = adw::StatusPage::builder()
.icon_name("network-cellular-offline")
.title(t!("first_setup_gameutils_box_text_title"))
.description(t!("first_setup_gameutils_box_text_description"))
.build();
loading_no_internet_box_text.add_css_class("compact");
content_box.append(&loading_no_internet_box_text);
window.present();
}
} }
const DRIVER_MODIFY_PROG: &str = r###" const DRIVER_MODIFY_PROG: &str = r###"
@ -226,12 +244,17 @@ fn get_drivers(
.margin_bottom(20) .margin_bottom(20)
.margin_start(20) .margin_start(20)
.margin_end(20) .margin_end(20)
.hexpand(true)
.vexpand(true)
.orientation(Orientation::Vertical) .orientation(Orientation::Vertical)
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.build(); .build();
let main_scroll = gtk::ScrolledWindow::builder() let main_scroll = gtk::ScrolledWindow::builder()
.max_content_width(650) .max_content_width(650)
.min_content_width(300) .min_content_width(300)
.hscrollbar_policy(gtk::PolicyType::Never)
.child(&main_box) .child(&main_box)
.build(); .build();
@ -255,8 +278,6 @@ fn get_drivers(
.label("Device: ".to_owned() + &device) .label("Device: ".to_owned() + &device)
.halign(gtk::Align::Center) .halign(gtk::Align::Center)
.valign(gtk::Align::Center) .valign(gtk::Align::Center)
.wrap(true)
.wrap_mode(gtk::pango::WrapMode::Word)
.build(); .build();
device_label.add_css_class("deviceLabel"); device_label.add_css_class("deviceLabel");

View File

@ -1,8 +1,6 @@
pub const APP_ID: &str = "com.github.pikaos-linux.pikadrivers"; pub const APP_ID: &str = "com.github.pikaos-linux.pikadrivers";
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const APP_ICON: &str = "com.github.pikaos-linux.pikadrivers"; pub const APP_ICON: &str = "com.github.pikaos-linux.pikadrivers";
pub const APP_NAME: &str = "PikaOS Driver Manager";
pub const APP_DEV: &str = "Cosmo";
pub const APP_GITHUB: &str = "https://github.com/PikaOS-Linux/pkg-pika-drivers"; pub const APP_GITHUB: &str = "https://github.com/PikaOS-Linux/pkg-pika-drivers";
pub const DRIVER_DB_JSON_URL: &str = pub const DRIVER_DB_JSON_URL: &str =
"https://raw.githubusercontent.com/PikaOS-Linux/pkg-pika-drivers/main/driver-db.json"; "https://raw.githubusercontent.com/PikaOS-Linux/pkg-pika-drivers/main/driver-db.json";