mirror of
https://github.com/arabianq/rpmi.git
synced 2026-06-19 04:53:33 +00:00
Compare commits
8 Commits
2590c72f14
...
v1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 1008c37163 | |||
| 6feb4c02c1 | |||
| f5b85085fb | |||
| c5b04a8970 | |||
| 8e5195d233 | |||
| cedeb89d2f | |||
| 49b879d874 | |||
| 6f043f8222 |
Generated
+692
-518
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "egui_rpm_installer"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
edition = "2024"
|
||||
authors = ["arabianq"]
|
||||
description = "Simple graphical utility that installs/upgrades/removes .rpm files built with Rust and EGUI."
|
||||
@@ -15,16 +15,16 @@ name = "rpmi"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
egui = { version = "0.33.3", default-features = false, features = [
|
||||
egui = { version = "0.34.3", default-features = false, features = [
|
||||
"default_fonts",
|
||||
] }
|
||||
eframe = { version = "0.33.3", default-features = false, features = [
|
||||
eframe = { version = "0.34.3", default-features = false, features = [
|
||||
"default_fonts",
|
||||
"glow",
|
||||
"wayland",
|
||||
"x11",
|
||||
] }
|
||||
rpm = { version = "0.18.4", default-features = false, features = [] }
|
||||
rpm = { version = "0.25.1", default-features = false, features = [] }
|
||||
|
||||
[profile.release]
|
||||
strip = true
|
||||
|
||||
+5
-11
@@ -43,8 +43,7 @@ pub fn get_package_state(pkg: &rpm::Package) -> PackageState {
|
||||
|
||||
let child_stdout = child.stdout.take().expect("Couldn't take stdout");
|
||||
|
||||
for line in BufReader::new(child_stdout).lines() {
|
||||
if let Ok(line) = line {
|
||||
for line in BufReader::new(child_stdout).lines().map_while(Result::ok) {
|
||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||
|
||||
if parts.len() != 3 {
|
||||
@@ -78,12 +77,11 @@ pub fn get_package_state(pkg: &rpm::Package) -> PackageState {
|
||||
return PackageState::NewVersion(package_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
child.kill().ok();
|
||||
child.wait().ok();
|
||||
|
||||
return PackageState::NewPackage;
|
||||
PackageState::NewPackage
|
||||
}
|
||||
|
||||
pub fn dnf_start_action(
|
||||
@@ -117,20 +115,16 @@ pub fn dnf_start_action(
|
||||
|
||||
let stdout_thread = thread::spawn(move || {
|
||||
let stdout_lines = BufReader::new(child_stdout).lines();
|
||||
for line in stdout_lines {
|
||||
if let Ok(line) = line {
|
||||
for line in stdout_lines.map_while(Result::ok) {
|
||||
stdout_tx.send(line).ok();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let stderr_thread = thread::spawn(move || {
|
||||
let stderr_lines = BufReader::new(child_stderr).lines();
|
||||
for line in stderr_lines {
|
||||
if let Ok(line) = line {
|
||||
for line in stderr_lines.map_while(Result::ok) {
|
||||
stderr_tx.send(line).ok();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
while let Ok(None) = child.try_wait() {
|
||||
@@ -148,5 +142,5 @@ pub fn dnf_start_action(
|
||||
child.wait().ok();
|
||||
});
|
||||
|
||||
return (action_thread, rx);
|
||||
(action_thread, rx)
|
||||
}
|
||||
|
||||
+13
-12
@@ -4,7 +4,7 @@ use crate::utils::*;
|
||||
|
||||
use eframe::{App, CreationContext, Frame, HardwareAcceleration, NativeOptions, run_native};
|
||||
use egui::{
|
||||
Align, Button, CentralPanel, Color32, Context, Direction, FontFamily, Label, Layout, RichText,
|
||||
Align, Button, CentralPanel, Color32, Direction, FontFamily, Label, Layout, RichText,
|
||||
ScrollArea, TextWrapMode, Ui, Vec2, ViewportBuilder,
|
||||
text::{LayoutJob, TextFormat, TextWrapping},
|
||||
};
|
||||
@@ -57,12 +57,11 @@ impl Application {
|
||||
fn get_package_state(&mut self) -> JoinHandle<()> {
|
||||
let pkg_state_shared = self.pkg_state_shared.clone();
|
||||
let pkg = self.pkg.clone();
|
||||
let thread = thread::spawn(move || {
|
||||
thread::spawn(move || {
|
||||
let pkg_state = get_package_state(&pkg);
|
||||
let mut guard = pkg_state_shared.lock().unwrap();
|
||||
*guard = Some(pkg_state);
|
||||
});
|
||||
return thread;
|
||||
})
|
||||
}
|
||||
|
||||
fn start_process(&mut self) {
|
||||
@@ -105,7 +104,7 @@ impl Application {
|
||||
} else {
|
||||
let mut value_layout_job = LayoutJob {
|
||||
wrap: TextWrapping {
|
||||
max_rows: max_rows,
|
||||
max_rows,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -165,7 +164,7 @@ impl Application {
|
||||
add_info_entry(
|
||||
ui,
|
||||
"Architecture",
|
||||
&self.pkg.metadata.get_arch().unwrap_or("-"),
|
||||
self.pkg.metadata.get_arch().unwrap_or("-"),
|
||||
1,
|
||||
false,
|
||||
);
|
||||
@@ -179,28 +178,28 @@ impl Application {
|
||||
add_info_entry(
|
||||
ui,
|
||||
"Summary ",
|
||||
&self.pkg.metadata.get_summary().unwrap_or("-"),
|
||||
self.pkg.metadata.get_summary().unwrap_or("-"),
|
||||
3,
|
||||
false,
|
||||
);
|
||||
add_info_entry(
|
||||
ui,
|
||||
"URL ",
|
||||
&self.pkg.metadata.get_url().unwrap_or("-"),
|
||||
self.pkg.metadata.get_url().unwrap_or("-"),
|
||||
1,
|
||||
true,
|
||||
);
|
||||
add_info_entry(
|
||||
ui,
|
||||
"License ",
|
||||
&self.pkg.metadata.get_license().unwrap_or("-"),
|
||||
self.pkg.metadata.get_license().unwrap_or("-"),
|
||||
2,
|
||||
false,
|
||||
);
|
||||
add_info_entry(
|
||||
ui,
|
||||
"Description ",
|
||||
&self.pkg.metadata.get_description().unwrap_or("-"),
|
||||
self.pkg.metadata.get_description().unwrap_or("-"),
|
||||
5,
|
||||
false,
|
||||
);
|
||||
@@ -283,7 +282,7 @@ impl Application {
|
||||
}
|
||||
|
||||
impl App for Application {
|
||||
fn update(&mut self, ctx: &Context, _: &mut Frame) {
|
||||
fn logic(&mut self, _ctx: &egui::Context, _frame: &mut Frame) {
|
||||
if let Some(process_thread) = &self.process_thread
|
||||
&& let Some(process_rx) = &self.process_rx
|
||||
{
|
||||
@@ -300,8 +299,10 @@ impl App for Application {
|
||||
self.process_log.push('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CentralPanel::default().show(ctx, |ui| {
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut Frame) {
|
||||
CentralPanel::default().show_inside(ui, |ui| {
|
||||
if self.pkg_state.is_none() {
|
||||
if self.pkg_state_loading_thread.is_none() {
|
||||
self.pkg_state_loading_thread = Some(self.get_package_state());
|
||||
|
||||
Reference in New Issue
Block a user