Skip to content

Commit

Permalink
* added product licence #6
Browse files Browse the repository at this point in the history
* added desktop notification, if window is not focused #9

* fixed: handle canceling authentication #7
* fixed: disk label, if removable devices couldn't be found #4
  • Loading branch information
artemanufrij committed Jul 25, 2017
1 parent bf5264a commit 71d9115
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
3 changes: 2 additions & 1 deletion data/com.github.artemanufrij.imageburner.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<!-- Copyright 2017 Artem Anufrij <artem.anufrij@live.de> -->
<component type="desktop">
<id>com.github.artemanufrij.imageburner.desktop</id>
<metadata_license>CC0</metadata_license>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0+</project_license>
<name>Image Burner</name>
<summary>A simple image burner</summary>
<description>
Expand Down
2 changes: 1 addition & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ namespace Imageburner {
}

mainwindow = new MainWindow ();
mainwindow.set_application(this);
}

}
}

Expand Down
30 changes: 22 additions & 8 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace Imageburner {

public class MainWindow : Gtk.Window {
public class MainWindow : Gtk.ApplicationWindow {

Gtk.Grid content;
Gtk.Button open_image;
Expand All @@ -42,6 +42,7 @@ namespace Imageburner {
Gtk.Grid device_container;

Granite.Widgets.Toast app_notification;
Notification desktop_notification;

Gtk.Button flash_start;
Gtk.Grid flash_container;
Expand Down Expand Up @@ -109,9 +110,6 @@ namespace Imageburner {
public MainWindow () {
this.title = _("Image Burner");
this.resizable = false;
this.destroy.connect (() => {
Gtk.main_quit ();
});

this.build_ui ();

Expand All @@ -133,8 +131,22 @@ namespace Imageburner {
this.image_container.sensitive = true;
this.device_container.sensitive = true;
this.flash_container.sensitive = true;
app_notification.title = _("%s was written onto %s").printf (selected_image.get_basename (), selected_device.drive.get_name ());
app_notification.send_notification ();

var message = _("%s was written onto %s").printf (selected_image.get_basename (), selected_device.drive.get_name ());

if (is_active) {
app_notification.title = message;
app_notification.send_notification ();
} else {
desktop_notification.set_body (message);
application.send_notification ("notify.app", desktop_notification);
}
});
burner.canceled.connect (() => {
bar.visible = false;
this.image_container.sensitive = true;
this.device_container.sensitive = true;
this.flash_container.sensitive = true;
});
burner.progress.connect ((val) => {
debug ("percent: %f", val);
Expand All @@ -146,7 +158,7 @@ namespace Imageburner {
});

devices.init ();
Gtk.main ();
present ();
}

private void build_ui () {
Expand All @@ -163,6 +175,8 @@ namespace Imageburner {
overlay.add (content);
overlay.add_overlay (app_notification);

desktop_notification = new Notification (_("Finished"));

build_image_area ();

build_device_area ();
Expand Down Expand Up @@ -236,7 +250,7 @@ namespace Imageburner {
});
device_container.attach (select_device, 0, 3, 1, 1);

device_name = new Gtk.Label ("");
device_name = new Gtk.Label (("<i>%s</i>").printf(_("No removable devices found…")));
device_name.use_markup = true;
device_container.attach (device_name, 0, 2, 1, 1);

Expand Down
23 changes: 19 additions & 4 deletions src/Objects/DiskBurner.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,29 @@ namespace Imageburner {
}
}

private DiskBurner () {
private DiskBurner () {}

construct {
this.is_running = false;
this.begin.connect (() => {
this.is_running = true;
debug ("begin");
});
this.finished.connect (() => {
this.is_running = false;
debug ("end");
debug ("finished");
});
this.canceled.connect (() => {
this.is_running = false;
debug ("canceled");
});
}

public bool is_running {get;set;}

public signal void begin ();
public signal void finished ();
public signal void canceled ();
public signal void progress (double percent);

File current_image;
Expand Down Expand Up @@ -96,8 +103,9 @@ namespace Imageburner {

IOChannel error = new IOChannel.unix_new (standard_error);
error.add_watch (IOCondition.IN | IOCondition.HUP, (channel, condition) => {
if (condition == IOCondition.HUP)
if (condition == IOCondition.HUP) {
return false;
}

try {
string line;
Expand All @@ -121,7 +129,14 @@ namespace Imageburner {

ChildWatch.add (child_pid, (pid, status) => {
Process.close_pid (pid);
finished ();

if (last_progress > 0) {
finished ();
} else {
canceled ();
}

last_progress = 0;
});

begin ();
Expand Down

0 comments on commit 71d9115

Please sign in to comment.