No Network Page
This commit is contained in:
parent
f82b897d1a
commit
c888b2ebd7
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "pika-drivers"
|
||||
version = "0.4.4"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
2
Makefile
2
Makefile
@ -14,5 +14,5 @@ install:
|
||||
chmod 755 $(DESTDIR)/usr/lib/pika/drivers/*.sh
|
||||
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.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/
|
||||
|
5
locales/en_US.json
Normal file
5
locales/en_US.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"app_name": "PikaOS Driver Manager",
|
||||
"app_dev": "Cosmo",
|
||||
"loading_label_label": "Scanning for drivers..."
|
||||
}
|
@ -18,9 +18,9 @@ use std::process::Command;
|
||||
use users::*;
|
||||
|
||||
pub fn build_ui(app: &adw::Application) {
|
||||
gtk::glib::set_prgname(Some(APP_NAME));
|
||||
glib::set_application_name(APP_NAME);
|
||||
let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikadrivers");
|
||||
gtk::glib::set_prgname(Some(t!("app_name").to_string()));
|
||||
glib::set_application_name(&t!("app_name").to_string());
|
||||
let glib_settings = gio::Settings::new(APP_ID);
|
||||
|
||||
let content_box = gtk::Box::builder()
|
||||
.orientation(Orientation::Vertical)
|
||||
@ -59,7 +59,7 @@ pub fn build_ui(app: &adw::Application) {
|
||||
.build();
|
||||
|
||||
let loading_label = gtk::Label::builder()
|
||||
.label("Scanning for drivers...")
|
||||
.label(t!("loading_label_label"))
|
||||
.margin_top(20)
|
||||
.margin_bottom(20)
|
||||
.margin_start(20)
|
||||
@ -75,13 +75,13 @@ pub fn build_ui(app: &adw::Application) {
|
||||
loading_box.append(&loading_label);
|
||||
|
||||
let window = adw::ApplicationWindow::builder()
|
||||
.title(APP_NAME)
|
||||
.title(t!("app_name"))
|
||||
.application(app)
|
||||
.content(&content_box)
|
||||
.icon_name(APP_ICON)
|
||||
.default_width(glib_settings.int("window-width"))
|
||||
.default_height(glib_settings.int("window-height"))
|
||||
.width_request(900)
|
||||
.width_request(950)
|
||||
.height_request(500)
|
||||
.startup_id(APP_ID)
|
||||
.hide_on_close(true)
|
||||
@ -99,16 +99,15 @@ pub fn build_ui(app: &adw::Application) {
|
||||
|
||||
let credits_window = adw::AboutWindow::builder()
|
||||
.application_icon(APP_ICON)
|
||||
.application_name(APP_NAME)
|
||||
.application_name(t!("app_name"))
|
||||
.transient_for(&window)
|
||||
.version(VERSION)
|
||||
.hide_on_close(true)
|
||||
.developer_name(APP_DEV)
|
||||
.developer_name(t!("app_dev"))
|
||||
.issue_url(APP_GITHUB.to_owned() + "/issues")
|
||||
.build();
|
||||
|
||||
content_box.append(&window_title_bar);
|
||||
content_box.append(&loading_box);
|
||||
|
||||
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()));
|
||||
|
||||
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)
|
||||
.unwrap()
|
||||
.text()
|
||||
.unwrap();
|
||||
|
||||
let (drive_hws_sender, drive_hws_receiver) = async_channel::unbounded();
|
||||
let drive_hws_sender = drive_hws_sender.clone();
|
||||
// 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###"
|
||||
@ -226,12 +244,17 @@ fn get_drivers(
|
||||
.margin_bottom(20)
|
||||
.margin_start(20)
|
||||
.margin_end(20)
|
||||
.hexpand(true)
|
||||
.vexpand(true)
|
||||
.orientation(Orientation::Vertical)
|
||||
.halign(gtk::Align::Center)
|
||||
.valign(gtk::Align::Center)
|
||||
.build();
|
||||
|
||||
let main_scroll = gtk::ScrolledWindow::builder()
|
||||
.max_content_width(650)
|
||||
.min_content_width(300)
|
||||
.hscrollbar_policy(gtk::PolicyType::Never)
|
||||
.child(&main_box)
|
||||
.build();
|
||||
|
||||
@ -255,8 +278,6 @@ fn get_drivers(
|
||||
.label("Device: ".to_owned() + &device)
|
||||
.halign(gtk::Align::Center)
|
||||
.valign(gtk::Align::Center)
|
||||
.wrap(true)
|
||||
.wrap_mode(gtk::pango::WrapMode::Word)
|
||||
.build();
|
||||
device_label.add_css_class("deviceLabel");
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
pub const APP_ID: &str = "com.github.pikaos-linux.pikadrivers";
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
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 DRIVER_DB_JSON_URL: &str =
|
||||
"https://raw.githubusercontent.com/PikaOS-Linux/pkg-pika-drivers/main/driver-db.json";
|
||||
|
Loading…
Reference in New Issue
Block a user