Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 40 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions gtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cascade = "1.0"
crossbeam-channel = "0.5"
dbus = "0.9"
dbus-udisks2 = { git = "https://github.com/pop-os/dbus-udisks2" }
digest = "0.9"
digest = "0.10"
futures = "0.3"
gdk = "0.13"
gdk-pixbuf = "0.9"
Expand All @@ -29,12 +29,13 @@ gtk = { version = "0.9", features = ["v3_22"] }
hex-view = "0.1"
iso9660 = { git = "https://github.com/ids1024/iso9660-rs" }
libc = "0.2"
md-5 = "0.9"
md-5 = "0.10"
pango = "0.9"
parking_lot = "0.11"
popsicle = { path = ".." }
pwd = "1"
sha2 = "0.9"
sha2 = "0.10"
sha-1 = { version = "0.10", features = ["asm"] }
sys-mount = "1"
async-std = "1.3"
i18n-embed = { version = "0.12.0", features = ["fluent-system", "desktop-requester"] }
Expand Down
5 changes: 4 additions & 1 deletion gtk/src/app/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::hash::hasher;
use crossbeam_channel::{Receiver, Sender};
use dbus_udisks2::{DiskDevice, Disks, UDisks2};
use md5::Md5;
use sha1::Sha1;
use sha2::Sha256;
use std::collections::HashMap;
use std::io;
Expand Down Expand Up @@ -44,6 +45,7 @@ pub fn background_thread(events_tx: Sender<UiEvent>, events_rx: Receiver<Backgro
let result = match kind {
"MD5" => hasher::<Md5>(&path),
"SHA256" => hasher::<Sha256>(&path),
"SHA1" => hasher::<Sha1>(&path),
_ => Err(io::Error::new(
io::ErrorKind::InvalidInput,
"hash kind not supported",
Expand All @@ -62,7 +64,8 @@ pub fn background_thread(events_tx: Sender<UiEvent>, events_rx: Receiver<Backgro
// Fetch the current list of USB devices from popsicle.
match refresh_devices() {
Ok(devices) => {
let new_device_paths: Vec<_> = devices.iter().map(|d| d.drive.path.clone()).collect();
let new_device_paths: Vec<_> =
devices.iter().map(|d| d.drive.path.clone()).collect();
if new_device_paths != device_paths {
device_paths = new_device_paths;
let _ = events_tx.send(UiEvent::RefreshDevices(devices));
Expand Down
10 changes: 5 additions & 5 deletions gtk/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ impl GtkUi {
context: &'static str,
) -> Result<T, ()> {
result.ok_or_else(|| {
self.content
.error_view
.view
.description
.set_text(&format!("{}: {}", context, fl!("no-value-found")));
self.content.error_view.view.description.set_text(&format!(
"{}: {}",
context,
fl!("no-value-found")
));
self.switch_to(state, ActiveView::Error);
})
}
Expand Down
3 changes: 2 additions & 1 deletion gtk/src/app/signals/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ fn set_hash_widget(state: &State, ui: &GtkUi) {
let path = state.image_path.borrow();
let kind = match hash.get_active() {
Some(1) => "SHA256",
Some(2) => "MD5",
Some(2) => "SHA1",
Some(3) => "MD5",
_ => return,
};

Expand Down
27 changes: 20 additions & 7 deletions gtk/src/app/signals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::misc;
use atomic::Atomic;
use crossbeam_channel::TryRecvError;
use gtk::{self, prelude::*};
use iso9660::ISO9660;
use std::fmt::Write;
use std::fs::File;
use iso9660::ISO9660;
use std::sync::atomic::Ordering;
use std::sync::{Arc, Mutex};
use std::time::Instant;
Expand Down Expand Up @@ -89,7 +89,11 @@ impl App {
None
};

ui.content.image_view.set_image(&path, image_size, warning.as_ref().map(|x| x.as_str()));
ui.content.image_view.set_image(
&path,
image_size,
warning.as_ref().map(|x| x.as_str()),
);
ui.content.image_view.set_hash_sensitive(true);
ui.header.next.set_sensitive(true);

Expand Down Expand Up @@ -235,7 +239,10 @@ impl App {

let sum: u64 = prev_values.iter().skip(1).sum();
let per_second = sum / 3;
label.set_label(&format!("{}/s", bytesize::to_string(per_second, true)));
label.set_label(&format!(
"{}/s",
bytesize::to_string(per_second, true)
));
}
}

Expand Down Expand Up @@ -294,11 +301,15 @@ impl App {
description.set_text(&desc);
list.hide();
} else {
ui.content.summary_view.view.topic.set_text(&fl!("flashing-completed-with-errors"));
ui.content
.summary_view
.view
.topic
.set_text(&fl!("flashing-completed-with-errors"));

let mut desc = fl!(
"partial-flash",
number = {ntasks - errors.len()},
number = { ntasks - errors.len() },
total = ntasks
);

Expand All @@ -309,8 +320,10 @@ impl App {
description.set_markup(&desc);

for (device, why) in errors {
let device = gtk::Label::new(Some(&misc::device_label(&device)));
let why = gtk::Label::new(Some(format!("{}", why).as_str()));
let device =
gtk::Label::new(Some(&misc::device_label(&device)));
let why =
gtk::Label::new(Some(format!("{}", why).as_str()));
why.get_style_context().add_class("bold");

let container = cascade! {
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/app/views/devices.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::View;
use crate::fl;
use crate::misc;
use super::View;
use dbus_udisks2::DiskDevice;
use gtk;
use gtk::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/app/views/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::fl;
use super::View;
use crate::fl;

pub struct ErrorView {
pub view: View,
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/app/views/flashing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::fl;
use super::View;
use crate::fl;
use gtk::*;

pub struct FlashView {
Expand Down
9 changes: 5 additions & 4 deletions gtk/src/app/views/images.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::fl;
use super::View;
use crate::fl;
use bytesize;
use gtk::*;
use gtk::prelude::*;
use gtk::*;
use pango::{AttrList, Attribute, EllipsizeMode};
use std::path::Path;

Expand Down Expand Up @@ -57,6 +57,7 @@ impl ImageView {
ComboBoxText::new();
..append_text(&fl!("none"));
..append_text("SHA256");
..append_text("SHA1");
..append_text("MD5");
..set_active(Some(0));
..set_sensitive(false);
Expand All @@ -83,7 +84,7 @@ impl ImageView {
hash.connect_changed(move |combo_box| {
let sensitive = match combo_box.get_active_text() {
Some(text) if text.as_str() != "None" => true,
_ => false
_ => false,
};
hash_label_clone.set_sensitive(sensitive);
check_clone.set_sensitive(sensitive);
Expand Down Expand Up @@ -151,7 +152,7 @@ impl ImageView {
let size_str = bytesize::to_string(size, true);
let mut label: String = match path.file_name() {
Some(name) => format!("<b>{}</b>\n{}", name.to_string_lossy(), size_str),
None => format!("<b>{}</b>", fl!("cannot-select-directories"))
None => format!("<b>{}</b>", fl!("cannot-select-directories")),
};

if let Some(warning) = warning {
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/app/views/summary.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::fl;
use super::View;
use crate::fl;
use gtk::*;

pub struct SummaryView {
Expand Down