[gnome-boxes] wizard: Introduce download_media ()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] wizard: Introduce download_media ()
- Date: Fri, 1 Aug 2014 14:09:48 +0000 (UTC)
commit eb9f11aa313cacc9fae311a49ec5c5cc642cb0e4
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date: Mon Jul 14 17:48:02 2014 +0200
wizard: Introduce download_media ()
This adds a function to download media via HTTP or HTTPS protocol from
the internet. Functions of other objects used here were gradually
introduced with the parent commits of this.
https://bugzilla.gnome.org/show_bug.cgi?id=729026
src/wizard.vala | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/wizard.vala b/src/wizard.vala
index 8531784..53cd7ad 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -12,6 +12,8 @@ private enum Boxes.WizardPage {
[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard.ui")]
private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
+ private const double DOWNLOAD_PROGRESS_SCALE = 0.95;
+ private const double PREPARE_PROGRESS_SCALE = 0.05;
private const string[] page_names = { "introduction", "source", "preparation", "setup", "review" };
public UIState previous_ui_state { get; protected set; }
@@ -562,6 +564,33 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
return false;
}
+ private async void download_media (string uri, ActivityProgress progress) {
+ var download_progress = progress.add_child_activity (DOWNLOAD_PROGRESS_SCALE);
+ prep_status_label.label = _("Downloading media...");
+
+ try {
+ var cache_path = yield Downloader.fetch_media (uri, download_progress, prepare_cancellable);
+ prepare_downloaded_media (cache_path, progress);
+ } catch (GLib.IOError.CANCELLED e) {
+ debug ("Cancelled downloading media '%s'!", uri);
+ page = WizardPage.SOURCE;
+ } catch (GLib.Error e) {
+ warning ("Failed downloading media '%s'! %s", uri, e.message);
+ App.window.notificationbar.display_error (_("Download failed."));
+ page = WizardPage.SOURCE;
+ } finally {
+ prepare_cancellable = null;
+ }
+ }
+
+ private void prepare_downloaded_media (string cache_path, ActivityProgress progress) {
+ cleanup ();
+
+ // Relaunch prepare with local URI
+ wizard_source.uri = "file://" + cache_path;
+ prepare (progress);
+ }
+
public void setup_ui () {
cancel_button = App.window.topbar.wizard_toolbar.cancel_btn;
cancel_button.clicked.connect (() => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]