[gnome-boxes] wizard: Don't reuse the same installer media
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] wizard: Don't reuse the same installer media
- Date: Tue, 26 Feb 2013 14:13:36 +0000 (UTC)
commit b4968918d8949eea8734d6dbf0252d26ac46c692
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Feb 21 18:10:39 2013 +0200
wizard: Don't reuse the same installer media
Currently it't not possible to launch multiple installations off the
same installer media (if chosen from media menu). This patch fixes the
issue by treating the original media user selected as template and
creating new media for each installation.
https://bugzilla.gnome.org/show_bug.cgi?id=694428
src/media-manager.vala | 64 ++++++++++++++++++++++++------------------------
src/wizard-source.vala | 15 +++++++++--
2 files changed, 44 insertions(+), 35 deletions(-)
---
diff --git a/src/media-manager.vala b/src/media-manager.vala
index 090c54b..670823c 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -124,6 +124,38 @@ private class Boxes.MediaManager : Object {
return list;
}
+ public async InstallerMedia create_installer_media_from_media
+ (InstallerMedia media,
+ InstallerRecognized? on_installer_recognized = null,
+ ActivityProgress progress = new ActivityProgress (),
+ Cancellable? cancellable = null) throws GLib.Error {
+ if (media.os == null)
+ return media;
+
+ if (on_installer_recognized != null)
+ on_installer_recognized (media.os_media, media.os);
+
+ progress.progress = 0.5;
+
+ var install_scripts = media.os.get_install_script_list ();
+ var filter = new Filter ();
+ filter.add_constraint (INSTALL_SCRIPT_PROP_PROFILE, INSTALL_SCRIPT_PROFILE_DESKTOP);
+ install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as InstallScriptList;
+
+ InstallerMedia install_media;
+ if (install_scripts.get_length () > 0) {
+ var unattended_progress = progress.add_child_activity (0.5);
+ unattended_progress.bind_property ("info", progress, "info");
+
+ install_media = yield new UnattendedInstaller.from_media (media, install_scripts,
unattended_progress);
+ } else
+ install_media = media;
+
+ progress.progress = 1.0;
+
+ return install_media;
+ }
+
private MediaManager () {
client = new GUdev.Client ({"block"});
os_db = new OSDatabase ();
@@ -156,36 +188,4 @@ private class Boxes.MediaManager : Object {
return yield create_installer_media_from_media (media);
}
-
- private async InstallerMedia create_installer_media_from_media
- (InstallerMedia media,
- InstallerRecognized? on_installer_recognized = null,
- ActivityProgress progress = new ActivityProgress (),
- Cancellable? cancellable = null) throws GLib.Error {
- if (media.os == null)
- return media;
-
- if (on_installer_recognized != null)
- on_installer_recognized (media.os_media, media.os);
-
- progress.progress = 0.5;
-
- var install_scripts = media.os.get_install_script_list ();
- var filter = new Filter ();
- filter.add_constraint (INSTALL_SCRIPT_PROP_PROFILE, INSTALL_SCRIPT_PROFILE_DESKTOP);
- install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as InstallScriptList;
-
- InstallerMedia install_media;
- if (install_scripts.get_length () > 0) {
- var unattended_progress = progress.add_child_activity (0.5);
- unattended_progress.bind_property ("info", progress, "info");
-
- install_media = yield new UnattendedInstaller.from_media (media, install_scripts,
unattended_progress);
- } else
- install_media = media;
-
- progress.progress = 1.0;
-
- return install_media;
- }
}
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 0f450c1..10c784a 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -221,9 +221,7 @@ private class Boxes.WizardSource: GLib.Object {
private void add_media_entry (InstallerMedia media) {
var hbox = add_entry (media_vbox, () => {
- install_media = media;
- uri = media.device_file;
- url_entry.activate ();
+ on_media_selected.begin (media);
return true;
}, 15, 5, media.device_file);
@@ -325,4 +323,15 @@ private class Boxes.WizardSource: GLib.Object {
return ret;
}
+
+ private async void on_media_selected (InstallerMedia media) {
+ try {
+ install_media = yield media_manager.create_installer_media_from_media (media);
+ uri = media.device_file;
+ url_entry.activate ();
+ } catch (GLib.Error error) {
+ // This is unlikely to happen since media we use as template should have already done most async
work
+ warning ("Failed to setup installation media '%s': %s", media.device_file, error.message);
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]