No Network Page
This commit is contained in:
parent
f82b897d1a
commit
c888b2ebd7
@ -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
|
||||||
|
2
Makefile
2
Makefile
@ -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
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::*;
|
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,76 +118,95 @@ 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 data = reqwest::blocking::get(DRIVER_DB_JSON_URL)
|
let check_internet_connection_cli = Command::new("ping")
|
||||||
.unwrap()
|
.arg("ppa.pika-os.com")
|
||||||
.text()
|
.arg("-c 1")
|
||||||
.unwrap();
|
.output()
|
||||||
|
.expect("failed to execute process");
|
||||||
|
|
||||||
let (drive_hws_sender, drive_hws_receiver) = async_channel::unbounded();
|
if check_internet_connection_cli.status.success() {
|
||||||
let drive_hws_sender = drive_hws_sender.clone();
|
content_box.append(&loading_box);
|
||||||
// The long running operation runs now in a separate thread
|
let data = reqwest::blocking::get(DRIVER_DB_JSON_URL)
|
||||||
gio::spawn_blocking(clone!(@strong data => move || {
|
.unwrap()
|
||||||
let mut driver_package_array: Vec<DriverPackage> = Vec::new();
|
.text()
|
||||||
println!("Parsing Downloaded driver DB...");
|
.unwrap();
|
||||||
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
|
let (drive_hws_sender, drive_hws_receiver) = async_channel::unbounded();
|
||||||
if let serde_json::Value::Array(drivers) = &res["drivers"] {
|
let drive_hws_sender = drive_hws_sender.clone();
|
||||||
for driver in drivers {
|
// The long running operation runs now in a separate thread
|
||||||
if Path::new("/tmp/run-pkdm-detect.sh").exists() {
|
gio::spawn_blocking(clone!(@strong data => move || {
|
||||||
fs::remove_file("/tmp/run-pkdm-detect.sh").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt");
|
let mut driver_package_array: Vec<DriverPackage> = Vec::new();
|
||||||
}
|
println!("Parsing Downloaded driver DB...");
|
||||||
fs::write("/tmp/run-pkdm-detect.sh", "#! /bin/bash\nset -e\n".to_owned() + driver["detection"].as_str().to_owned().unwrap()).expect("Unable to write file");
|
let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse");
|
||||||
let _ = cmd!("chmod", "+x", "/tmp/run-pkdm-detect.sh").read();
|
if let serde_json::Value::Array(drivers) = &res["drivers"] {
|
||||||
let result = cmd!("/tmp/run-pkdm-detect.sh").stdout_capture().read();
|
for driver in drivers {
|
||||||
if result.is_ok() {
|
if Path::new("/tmp/run-pkdm-detect.sh").exists() {
|
||||||
let driver_name = driver["driver"].as_str().to_owned().unwrap().to_string();
|
fs::remove_file("/tmp/run-pkdm-detect.sh").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt");
|
||||||
let driver_device = result.unwrap();
|
}
|
||||||
let driver_icon = driver["icon"].as_str().to_owned().unwrap().to_string();
|
fs::write("/tmp/run-pkdm-detect.sh", "#! /bin/bash\nset -e\n".to_owned() + driver["detection"].as_str().to_owned().unwrap()).expect("Unable to write file");
|
||||||
let driver_experimental = driver["experimental"].as_bool().unwrap();
|
let _ = cmd!("chmod", "+x", "/tmp/run-pkdm-detect.sh").read();
|
||||||
let command_version_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh")
|
let result = cmd!("/tmp/run-pkdm-detect.sh").stdout_capture().read();
|
||||||
.args(["version", &driver_name])
|
if result.is_ok() {
|
||||||
.output()
|
let driver_name = driver["driver"].as_str().to_owned().unwrap().to_string();
|
||||||
.unwrap();
|
let driver_device = result.unwrap();
|
||||||
let command_description_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh")
|
let driver_icon = driver["icon"].as_str().to_owned().unwrap().to_string();
|
||||||
.args(["description", &driver_name])
|
let driver_experimental = driver["experimental"].as_bool().unwrap();
|
||||||
.output()
|
let command_version_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh")
|
||||||
.unwrap();
|
.args(["version", &driver_name])
|
||||||
let found_driver_package = DriverPackage {
|
.output()
|
||||||
driver: driver_name,
|
.unwrap();
|
||||||
version: String::from_utf8(command_version_label.stdout)
|
let command_description_label = Command::new("/usr/lib/pika/drivers/generate_package_info.sh")
|
||||||
.unwrap()
|
.args(["description", &driver_name])
|
||||||
.trim()
|
.output()
|
||||||
.to_string(),
|
.unwrap();
|
||||||
device: driver_device,
|
let found_driver_package = DriverPackage {
|
||||||
description: String::from_utf8(command_description_label.stdout)
|
driver: driver_name,
|
||||||
.unwrap()
|
version: String::from_utf8(command_version_label.stdout)
|
||||||
.trim()
|
.unwrap()
|
||||||
.to_string(),
|
.trim()
|
||||||
icon: driver_icon,
|
.to_string(),
|
||||||
experimental: driver_experimental,
|
device: driver_device,
|
||||||
};
|
description: String::from_utf8(command_description_label.stdout)
|
||||||
driver_package_array.push(found_driver_package)
|
.unwrap()
|
||||||
|
.trim()
|
||||||
|
.to_string(),
|
||||||
|
icon: driver_icon,
|
||||||
|
experimental: driver_experimental,
|
||||||
|
};
|
||||||
|
driver_package_array.push(found_driver_package)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//driver_array.sort_by(|a, b| b.cmp(a))
|
||||||
//driver_array.sort_by(|a, b| b.cmp(a))
|
driver_package_array.sort_by(|a, b| b.cmp(a));
|
||||||
driver_package_array.sort_by(|a, b| b.cmp(a));
|
|
||||||
|
|
||||||
drive_hws_sender
|
drive_hws_sender
|
||||||
.send_blocking(driver_package_array)
|
.send_blocking(driver_package_array)
|
||||||
.expect("channel needs to be open.")
|
.expect("channel needs to be open.")
|
||||||
}));
|
}));
|
||||||
|
|
||||||
window.present();
|
window.present();
|
||||||
|
|
||||||
let drive_hws_main_context = MainContext::default();
|
let drive_hws_main_context = MainContext::default();
|
||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
drive_hws_main_context.spawn_local(
|
drive_hws_main_context.spawn_local(
|
||||||
clone!(@weak content_box, @weak loading_box, @strong data => async move {
|
clone!(@weak content_box, @weak loading_box, @strong data => async move {
|
||||||
while let Ok(drive_hws_state) = drive_hws_receiver.recv().await {
|
while let Ok(drive_hws_state) = drive_hws_receiver.recv().await {
|
||||||
get_drivers(&content_box, &loading_box, drive_hws_state, &window);
|
get_drivers(&content_box, &loading_box, drive_hws_state, &window);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
} 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");
|
||||||
|
|
||||||
|
@ -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";
|
||||||
|
Loading…
Reference in New Issue
Block a user