From a516ebb4dc16631c62ce4f1149e0ca75a63dc570 Mon Sep 17 00:00:00 2001
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
Date: Thu, 1 Dec 2011 00:59:42 +0200
Subject: [PATCH] Handle non-pure live & unknown media like pure live

Handle live+installer and unknown media just like pure live media.

https://bugzilla.gnome.org/show_bug.cgi?id=665254
---
 src/installer-media.vala      |    2 ++
 src/unattended-installer.vala |    2 +-
 src/vm-creator.vala           |   13 +++++++------
 src/wizard.vala               |   25 +++++++++++--------------
 4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/installer-media.vala b/src/installer-media.vala
index 217ba1c..4fc9999 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -11,6 +11,8 @@ private class Boxes.InstallerMedia : Object {
     public string mount_point;
     public bool from_image;
 
+    public bool live { get { return os_media == null || os_media.live; } }
+
     public static async InstallerMedia instantiate (string       path,
                                                     OSDatabase   os_db,
                                                     Client       client,
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index acce378..89e65f3 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -110,7 +110,7 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
         table.attach_defaults (label, 1, 2, 0, 1);
 
         express_toggle = new Gtk.Switch ();
-        express_toggle.active = os_media.installer;
+        express_toggle.active = !os_media.live;
         express_toggle.halign = Gtk.Align.START;
         express_toggle.valign = Gtk.Align.CENTER;
         table.attach_defaults (express_toggle, 2, 3, 0, 1);
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index 0bf8074..ca0d2d6 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -43,18 +43,19 @@ private class Boxes.VMCreator {
         var config = new GVirConfig.Domain.from_xml (xml);
 
         Domain domain;
-        if (install_media.os_media.installer) {
+        if (install_media.live)
+            // We create a (initially) transient domain for live and unknown media
+            domain = connection.start_domain (config, 0);
+        else {
             domain = connection.create_domain (config);
             domain.start (0);
             config = domain.get_config (0);
-        } else
-            // We create a transient domain for media w/o an installer
-            domain = connection.start_domain (config, 0);
+        }
 
         ulong id = 0;
         id = domain.stopped.connect (() => {
             if (!guest_installed_os (volume, install_media)) {
-                if (install_media.os_media.installer)
+                if (!install_media.live)
                     try {
                         domain.start (0);
                     } catch (GLib.Error error) {
@@ -64,7 +65,7 @@ private class Boxes.VMCreator {
                 return;
             }
 
-            if (post_install_setup (domain, config, install_media.os_media.installer))
+            if (post_install_setup (domain, config, !install_media.live))
                 domain.disconnect (id);
         });
 
diff --git a/src/wizard.vala b/src/wizard.vala
index 8e7d566..9a48742 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -227,28 +227,25 @@ private class Boxes.Wizard: Boxes.UI {
         foreach (var child in setup_vbox.get_children ())
             setup_vbox.remove (child);
 
-        if (install_media == null || !(install_media is UnattendedInstaller)) {
+        var skip_to = page;
+        if (install_media == null || install_media.live)
+            // No setup or review required for unknown and live media
+            skip_to = WizardPage.LAST;
+        else if (!(install_media is UnattendedInstaller))
             // Nothing to do so just skip to the next page but let the current page change complete first
+            skip_to = page + 1;
+
+        if (skip_to != page)
             Idle.add (() => {
-                page = page + 1;
+                page = skip_to;
 
                 return false;
             });
-
-            return;
-        }
-
-        if (install_media.os_media.installer) {
+        else {
             var installer = install_media as UnattendedInstaller;
             installer.populate_setup_vbox (setup_vbox);
             setup_vbox.show_all ();
-        } else
-            // No setup or review required for pure (no installer) live medias
-            Idle.add (() => {
-                page = WizardPage.LAST;
-
-                return false;
-            });
+        }
     }
 
     private void review () {
-- 
1.7.7.3