[gnome-boxes/wip/ui-files: 1/5] Move Wizard widget setup to .ui files



commit da6d9e660c2aa19c1d9860e966edd6c457e31053
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Jan 4 15:23:31 2014 +0000

    Move Wizard widget setup to .ui files
    
    This is not exactly complete since Wizard seems to also setup Topbar
    and Sidebar widgets. Hopefully we can remove that as part of a similar
    change to those classes soon.

 data/gnome-boxes.gresource.xml |    3 +
 data/icons/Makefile.am         |    6 -
 data/ui/wizard-source.ui       |    2 +
 data/ui/wizard-summary.ui      |   12 ++
 data/ui/wizard.ui              |  316 ++++++++++++++++++++++++++++++++
 po/POTFILES.in                 |    1 +
 src/wizard-source.vala         |    7 +-
 src/wizard.vala                |  389 ++++++++++++++--------------------------
 8 files changed, 475 insertions(+), 261 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 3f7c824..67fdb49 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -3,11 +3,14 @@
   <gresource prefix="/org/gnome/Boxes">
     <file>gtk-style.css</file>
     <file>icons/boxes-arrow.svg</file>
+    <file>icons/boxes-create.png</file>
     <file>icons/boxes-dark.png</file>
     <file>icons/boxes-gray.png</file>
     <file preprocess="xml-stripblanks">ui/unattended-setup-box.ui</file>
+    <file preprocess="xml-stripblanks">ui/wizard.ui</file>
     <file preprocess="xml-stripblanks">ui/wizard-media-entry.ui</file>
     <file preprocess="xml-stripblanks">ui/wizard-scrolled.ui</file>
     <file preprocess="xml-stripblanks">ui/wizard-source.ui</file>
+    <file preprocess="xml-stripblanks">ui/wizard-summary.ui</file>
   </gresource>
 </gresources>
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index af1aaf8..96713ef 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -17,13 +17,7 @@ noinst_DATA =                                        \
        gnome-boxes.svg                         \
        $(NULL)
 
-imagesdir = $(datadir)/gnome-boxes/pixmaps
-images_DATA =                                  \
-       boxes-create.png                        \
-       $(NULL)
-
 EXTRA_DIST =                                   \
-       $(images_DATA)                          \
        $(public_icons)                         \
        $(noinst_DATA)                          \
        $(NULL)
diff --git a/data/ui/wizard-source.ui b/data/ui/wizard-source.ui
index 3f6d7d9..193eef3 100644
--- a/data/ui/wizard-source.ui
+++ b/data/ui/wizard-source.ui
@@ -4,6 +4,8 @@
   <template class="BoxesWizardSource" parent="GtkNotebook">
     <property name="visible">True</property>
     <property name="show-tabs">False</property>
+    <property name="hexpand">True</property>
+    <property name="halign">center</property>
     <signal name="switch-page" handler="on_switch_page"/>
     <style>
       <class name="boxes-source-nb"/>
diff --git a/data/ui/wizard-summary.ui b/data/ui/wizard-summary.ui
new file mode 100644
index 0000000..c400465
--- /dev/null
+++ b/data/ui/wizard-summary.ui
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.9 -->
+  <template class="BoxesWizardSummary" parent="GtkGrid">
+    <property name="visible">True</property>
+    <property name="row-spacing">10</property>
+    <property name="column-spacing">20</property>
+    <style>
+      <class name="boxes-bg"/>
+    </style>
+  </template>
+</interface>
diff --git a/data/ui/wizard.ui b/data/ui/wizard.ui
new file mode 100644
index 0000000..79911d7
--- /dev/null
+++ b/data/ui/wizard.ui
@@ -0,0 +1,316 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.9 -->
+  <template class="BoxesWizard" parent="GtkNotebook">
+    <property name="visible">True</property>
+    <property name="show-tabs">False</property>
+    <property name="margin">15</property>
+    <property name="width-request">500</property>
+    <style>
+      <class name="boxes-bg"/>
+    </style>
+
+    <!-- Introduction -->
+    <child>
+      <object class="GtkBox" id="intro_hbox">
+        <property name="visible">True</property>
+        <property name="orientation">horizontal</property>
+        <property name="spacing">10</property>
+        <property name="halign">center</property>
+
+        <child>
+          <object class="GtkImage" id="intro_image">
+            <property name="visible">True</property>
+            <property name="resource">/org/gnome/Boxes/icons/boxes-create.png</property>
+          </object>
+        </child>
+
+        <child>
+          <object class="GtkLabel" id="intro_label">
+            <property name="visible">True</property>
+            <property name="wrap">True</property>
+            <!-- Work around clutter size allocation issue (bz#677260) -->
+            <property name="max-width-chars">40</property>
+            <property name="use-markup">True</property>
+            <property name="label" translatable="yes">Creating a Box will allow you to use another operating 
system directly from your existing login.
+
+You may connect to an existing machine &lt;b&gt;&lt;i&gt;over the network&lt;/i&gt;&lt;/b&gt; or create a 
&lt;b&gt;&lt;i&gt;virtual machine&lt;/i&gt;&lt;/b&gt; that runs locally on your own.</property>
+            <property name="use-markup">True</property>
+            <style>
+              <class name="boxes-wizard-label"/>
+            </style>
+          </object>
+        </child>
+      </object>
+    </child>
+
+    <!-- Source -->
+    <child>
+      <object class="GtkBox" id="source_vbox">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">30</property>
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+
+        <child>
+          <object class="GtkLabel" id="instruction_label">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Insert operating system installation media or select a 
source below</property>
+            <property name="wrap">True</property>
+            <property name="xalign">0.0</property>
+            <style>
+              <class name="boxes-wizard-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+          </packing>
+        </child>
+
+        <child>
+          <object class="BoxesWizardSource" id="wizard_source">
+            <property name="visible">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+          </packing>
+        </child>
+
+        <child>
+          <object class="GtkLabel" id="trademark_label">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Any trademarks shown above are used merely for 
identification of software products you have already obtained and are the property of their respective 
owners.</property>
+            <property name="wrap">True</property>
+            <property name="max-width-chars">50</property>
+            <style>
+              <class name="boxes-logo-notice-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+
+    <!-- Preparation -->
+    <child>
+      <object class="GtkBox" id="prep_vbox">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">30</property>
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+
+        <child>
+          <object class="GtkLabel" id="preparing_label">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Preparing to create new box</property>
+            <property name="wrap">True</property>
+            <property name="xalign">0.0</property>
+            <style>
+              <class name="boxes-wizard-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+          </packing>
+        </child>
+
+        <child>
+          <object class="GtkBox" id="prep_hbox">
+            <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <property name="spacing">10</property>
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+
+            <child>
+              <object class="GtkImage" id="installer_image">
+                <property name="visible">True</property>
+                <property name="icon-name">media-optical</property>
+                <property name="icon-size">0</property>
+                <property name="pixel-size">128</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+              </packing>
+            </child>
+
+            <child>
+              <object class="GtkBox" id="prep_inner_vbox">
+                <property name="visible">True</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">10</property>
+                <property name="valign">center</property>
+                <property name="homogeneous">True</property>
+                <child>
+                  <object class="GtkLabel" id="prep_media_label">
+                    <property name="ellipsize">end</property>
+                    <property name="halign">start</property>
+                    <style>
+                      <class name="boxes-wizard-media-os-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="GtkLabel" id="prep_status_label">
+                    <property name="visible">True</property>
+                    <property name="halign">start</property>
+                    <style>
+                      <class name="boxes-wizard-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="GtkProgressBar" id="prep_progress">
+                    <property name="visible">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+
+    <!-- Setup -->
+    <child>
+      <object class="GtkBox" id="setup_box">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">0</property>
+        <property name="valign">center</property>
+        <property name="halign">center</property>
+      </object>
+    </child>
+
+    <!-- Review -->
+    <child>
+      <object class="GtkBox" id="review_box">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">0</property>
+        <property name="valign">fill</property>
+        <property name="halign">fill</property>
+
+        <child>
+          <!-- FIXME: We shouldn't need this box but for some weird unknown
+               reason, toggling the visibility of the infobar itself doesn't
+               exactly work. The bar remains visible even after setting
+               visibility to 'false' but its only visible as a line. Likely
+               some bug in clutter-gtk but I failed to reproduce it outside
+               Boxes. :( -->
+          <object class="GtkBox" id="nokvm_box">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">0</property>
+
+            <child>
+              <object class="GtkInfoBar" id="nokvm_infobar">
+                <property name="halign">fill</property>
+                <property name="spacing">0</property>
+                <property name="message-type">warning</property>
+
+                <child internal-child="content_area">
+                  <object class="GtkContainer" id="nokvm_container">
+                    <child>
+                      <object class="GtkImage" id="nokvm_image">
+                        <property name="visible">True</property>
+                        <property name="icon-name">dialog-warning</property>
+                        <property name="icon-size">3</property>
+                      </object>
+                    </child>
+
+                    <child>
+                      <object class="GtkLabel" id="nokvm_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Virtualization extensions are unavailable 
on your system. If your system is recent (post 2008), check your BIOS settings to enable them.</property>
+                        <property name="wrap">True</property>
+                        <property name="halign">start</property>
+                        <property name="hexpand">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+          </packing>
+        </child>
+
+        <child>
+          <object class="GtkBox" id="review_vbox">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">30</property>
+            <property name="valign">center</property>
+            <property name="halign">center</property>
+
+            <child>
+              <object class="GtkLabel" id="review_label">
+                <property name="visible">True</property>
+                <property name="xalign">0.0</property>
+                <property name="wrap">True</property>
+                <property name="width-chars">30</property>
+                <style>
+                  <class name="boxes-wizard-label"/>
+                </style>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+              </packing>
+            </child>
+
+            <child>
+              <object class="BoxesWizardSummary" id="summary"/>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+              </packing>
+            </child>
+
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+          </packing>
+        </child>
+
+      </object>
+    </child>
+
+  </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6ee20ac..ce30237 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@ data/gnome-boxes.desktop.in.in
 [type: gettext/ini]data/gnome-boxes-search-provider.ini.in
 data/org.gnome.boxes.gschema.xml.in
 [type: gettext/glade]data/ui/unattended-setup-box.ui
+[type: gettext/glade]data/ui/wizard.ui
 [type: gettext/glade]data/ui/wizard-media-entry.ui
 [type: gettext/glade]data/ui/wizard-scrolled.ui
 [type: gettext/glade]data/ui/wizard-source.ui
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 19c76e9..3cb2c0f 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -128,11 +128,10 @@ private class Boxes.WizardSource: Gtk.Notebook {
 
     private Gtk.Box media_vbox;
 
-    private MediaManager media_manager;
-
-    public WizardSource (MediaManager media_manager) {
-        this.media_manager = media_manager;
+    public MediaManager media_manager;
 
+    construct {
+        media_manager = MediaManager.get_instance ();
         main_vbox.grab_focus ();
 
         media_scrolled.setup (5);
diff --git a/src/wizard.vala b/src/wizard.vala
index 56e0413..d31cf08 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -10,29 +10,43 @@ private enum Boxes.WizardPage {
     LAST,
 }
 
-private class Boxes.Wizard: GLib.Object, Boxes.UI {
-    public Clutter.Actor actor { get { return gtk_actor; } }
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard.ui")]
+private class Boxes.Wizard: Gtk.Notebook, Boxes.UI {
+    public Clutter.Actor actor {
+        get {
+            return gtk_actor;
+        }
+    }
+    private GtkClutter.Actor gtk_actor;
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
 
-    private GtkClutter.Actor gtk_actor;
     private GenericArray<Gtk.Label> steps;
-    private Gtk.Notebook notebook;
     private Gtk.Button cancel_button;
     private Gtk.Button back_button;
     private Gtk.Button next_button;
     private Gtk.Button continue_button;
     private Gtk.Button create_button;
     private Gtk.SizeGroup toolbar_sizegroup;
+    private CollectionSource? source;
+
+    [GtkChild]
     private Boxes.WizardSource wizard_source;
+    [GtkChild]
     private WizardSummary summary;
-    private CollectionSource? source;
+    [GtkChild]
     private Gtk.ProgressBar prep_progress;
+    [GtkChild]
     private Gtk.Label prep_media_label;
+    [GtkChild]
     private Gtk.Label prep_status_label;
+    [GtkChild]
     private Gtk.Box setup_box;
+    [GtkChild]
     private Gtk.Label review_label;
+    [GtkChild]
     private Gtk.Box nokvm_box;
+    [GtkChild]
     private Gtk.Image installer_image;
 
     private MediaManager media_manager;
@@ -41,92 +55,87 @@ private class Boxes.Wizard: GLib.Object, Boxes.UI {
     protected Machine? machine { get; set; }
     private LibvirtMachine? libvirt_machine { get { return (machine as LibvirtMachine); } }
 
-    private WizardPage _page;
-    private WizardPage page {
-        get { return _page; }
-        set {
-            back_button.sensitive = value != WizardPage.INTRODUCTION;
-
-            var forwards = value > page;
-
-            switch (value) {
-            case WizardPage.INTRODUCTION:
-                create_button.visible = false;
-                continue_button.visible = true;
-                next_button = continue_button;
-                next_button.sensitive = true;
-                next_button.grab_focus (); // FIXME: doesn't work?!
-                break;
+    public override void switch_page (Gtk.Widget page_widget, uint page_num) {
+        if (cancel_button == null) {
+            // page is set to INTRODUCTION by GtkBuilder during construction (before even construct is 
called) and
+            // therefore none of the state we access below is available to us (nor it could be before this 
object
+            // exists).
+            base.switch_page (page_widget, page_num);
 
-            case WizardPage.SOURCE:
-                // reset page to notify deeply widgets states
-                wizard_source.page = wizard_source.page;
-                break;
-            }
+            return;
+        }
 
-            if (forwards) {
-                switch (value) {
-                case WizardPage.SOURCE:
-                    wizard_source.selected = null;
-                    wizard_source.page = SourcePage.MAIN;
-                    break;
+        back_button.sensitive = page_num != WizardPage.INTRODUCTION;
 
-                case WizardPage.PREPARATION:
-                    if (!prepare ())
-                        return;
-                    break;
+        var forwards = page_num > page;
 
-                case WizardPage.SETUP:
-                    if (!setup ())
-                        return;
-                    break;
+        switch (page_num) {
+        case WizardPage.INTRODUCTION:
+            create_button.visible = false;
+            continue_button.visible = true;
+            next_button = continue_button;
+            next_button.sensitive = true;
+            next_button.grab_focus (); // FIXME: doesn't work?!
+            break;
 
-                case WizardPage.REVIEW:
-                    continue_button.visible = false;
-                    create_button.visible = true;
-                    next_button = create_button;
-                    next_button.sensitive = false;
-
-                    review.begin ((obj, result) => {
-                        next_button.sensitive = true;
-                        if (!review.end (result))
-                            page = page - 1;
-                    });
-                    break;
+        case WizardPage.SOURCE:
+            // reset page to notify deeply widgets states
+            wizard_source.page = wizard_source.page;
+            break;
+        }
 
-                case WizardPage.LAST:
-                    create.begin ((obj, result) => {
-                       if (create.end (result))
-                          App.app.set_state (UIState.COLLECTION);
-                       else
-                          App.app.notificationbar.display_error (_("Box creation failed"));
-                    });
+        if (forwards) {
+            switch (page_num) {
+            case WizardPage.SOURCE:
+                wizard_source.selected = null;
+                wizard_source.page = SourcePage.MAIN;
+                break;
+
+            case WizardPage.PREPARATION:
+                if (!prepare ())
                     return;
-                }
-            } else {
-                switch (page) {
+                break;
+
+            case WizardPage.SETUP:
+                if (!setup ())
+                    return;
+                break;
+
+            case WizardPage.REVIEW:
+                continue_button.visible = false;
+                create_button.visible = true;
+                next_button = create_button;
+                next_button.sensitive = false;
+
+                review.begin ((obj, result) => {
+                    next_button.sensitive = true;
+                    if (!review.end (result))
+                        page = page - 1;
+                });
+                break;
+            }
+        } else {
+            switch (page) {
                 case WizardPage.REVIEW:
                     create_button.visible = false;
                     continue_button.visible = true;
                     next_button = continue_button;
                     destroy_machine ();
                     break;
-                }
             }
+        }
 
-            if (skip_page (value))
-                return;
-
-            _page = value;
-            notebook.set_current_page (value);
+        if (skip_page ((WizardPage) page_num))
+            return;
 
-            for (var i = 0; i < steps.length; i++) {
-                var label = steps.get (i);
-                label.get_style_context ().remove_class ("boxes-wizard-current-page-label");
-            }
+        base.switch_page (page_widget, page_num);
 
-            steps.get (page).get_style_context ().add_class ("boxes-wizard-current-page-label");
+        for (var i = 0; i < steps.length; i++) {
+            var label = steps.get (i);
+            label.get_style_context ().remove_class ("boxes-wizard-current-page-label");
         }
+
+        steps.get (page).get_style_context ().add_class ("boxes-wizard-current-page-label");
     }
 
     construct {
@@ -172,7 +181,6 @@ private class Boxes.Wizard: GLib.Object, Boxes.UI {
     }
 
     public Wizard () {
-        wizard_source = new Boxes.WizardSource (media_manager);
         wizard_source.notify["page"].connect(wizard_source_update_next);
         wizard_source.notify["selected"].connect(wizard_source_update_next);
         wizard_source.url_entry.changed.connect (wizard_source_update_next);
@@ -182,6 +190,9 @@ private class Boxes.Wizard: GLib.Object, Boxes.UI {
             page = WizardPage.PREPARATION;
         });
 
+        // Changing page to something other than INTRODUCTION here so that Gtk.Notebook doesn't ignore us 
setting
+        // it to INTRODUCTION later (also read the comment in switch_page method above).
+        page = WizardPage.PREPARATION;
         setup_ui ();
     }
 
@@ -482,9 +493,7 @@ private class Boxes.Wizard: GLib.Object, Boxes.UI {
         return true;
     }
 
-    private void add_step (Gtk.Widget widget, string title, WizardPage page) {
-        notebook.append_page (widget, null);
-
+    private void add_step (string title, WizardPage page) {
         /* sidebar */
         var vbox = App.app.sidebar.notebook.get_nth_page (Boxes.SidebarPage.WIZARD) as Gtk.Box;
 
@@ -541,12 +550,13 @@ private class Boxes.Wizard: GLib.Object, Boxes.UI {
     }
 
     private void setup_ui () {
-        notebook = new Gtk.Notebook ();
-        notebook.margin = 15;
-        notebook.width_request = 500;
-        notebook.show_tabs = false;
-        notebook.get_style_context ().add_class ("boxes-bg");
-        gtk_actor = new GtkClutter.Actor.with_contents (notebook);
+        add_step (_("Introduction"), WizardPage.INTRODUCTION);
+        add_step (_("Source Selection"), WizardPage.SOURCE);
+        add_step (_("Preparation"), WizardPage.PREPARATION);
+        add_step (_("Setup"), WizardPage.SETUP);
+        add_step (_("Review"), WizardPage.REVIEW);
+
+        gtk_actor = new GtkClutter.Actor.with_contents (this);
         gtk_actor.get_widget ().get_style_context ().add_class ("boxes-bg");
         gtk_actor.name = "wizard";
         gtk_actor.opacity = 0;
@@ -555,129 +565,8 @@ private class Boxes.Wizard: GLib.Object, Boxes.UI {
         gtk_actor.x_expand = true;
         gtk_actor.y_expand = true;
 
-        /* Introduction */
-        var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
-        hbox.halign = Gtk.Align.CENTER;
-        add_step (hbox, _("Introduction"), WizardPage.INTRODUCTION);
-        hbox.add (new Gtk.Image.from_file (get_pixmap ("boxes-create.png")));
-        var label = new Gtk.Label (null);
-        label.get_style_context ().add_class ("boxes-wizard-label");
-        label.set_markup (_("Creating a Box will allow you to use another operating system directly from 
your existing login.\n\nYou may connect to an existing machine <b><i>over the network</i></b> or create a 
<b><i>virtual machine</i></b> that runs locally on your own."));
-        label.wrap = true;
-        // Work around clutter size allocation issue (bz#677260)
-        label.width_chars = 30;
-        label.max_width_chars = 40;
-        hbox.add (label);
-        hbox.show_all ();
-
-        /* Source */
-        var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 30);
-        vbox.valign = Gtk.Align.CENTER;
-        vbox.halign = Gtk.Align.CENTER;
-        add_step (vbox, _("Source Selection"), WizardPage.SOURCE);
-        label = new Gtk.Label (_("Insert operating system installation media or select a source below"));
-        label.get_style_context ().add_class ("boxes-wizard-label");
-        label.wrap = true;
-        label.xalign = 0.0f;
-        vbox.pack_start (label, false, false);
-        vbox.pack_start (wizard_source, false, false);
-        wizard_source.hexpand = true;
-        wizard_source.halign = Gtk.Align.CENTER;
-        label = new Gtk.Label (_("Any trademarks shown above are used merely for identification of software 
products you have already obtained and are the property of their respective owners."));
-        label.get_style_context ().add_class ("boxes-logo-notice-label");
-        label.wrap = true;
-        label.max_width_chars = 50;
-        vbox.pack_start (label, false, false);
-        vbox.show_all ();
-
-        /* Preparation */
-        vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 30);
-        vbox.valign = Gtk.Align.CENTER;
-        vbox.halign = Gtk.Align.CENTER;
-        add_step (vbox, _("Preparation"), WizardPage.PREPARATION);
-        label = new Gtk.Label (_("Preparing to create new box"));
-        label.get_style_context ().add_class ("boxes-wizard-label");
-        label.wrap = true;
-        label.xalign = 0.0f;
-        vbox.pack_start (label, false, false);
-
-        hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
-        hbox.valign = Gtk.Align.CENTER;
-        hbox.halign = Gtk.Align.CENTER;
-        vbox.pack_start (hbox, true, true);
-
-        installer_image = new Gtk.Image.from_icon_name ("media-optical", 0);
-        installer_image.pixel_size = 128;
-        hbox.pack_start (installer_image, false, false);
-        var prep_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
-        prep_vbox.homogeneous = true;
-        prep_vbox.valign = Gtk.Align.CENTER;
-        hbox.pack_start (prep_vbox, true, true);
-        prep_media_label = new Gtk.Label (null);
-        prep_media_label.get_style_context ().add_class ("boxes-wizard-media-os-label");
-        prep_media_label.set_ellipsize (Pango.EllipsizeMode.END);
-        prep_media_label.halign = Gtk.Align.START;
-        prep_vbox.pack_start (prep_media_label, false, false);
-        prep_status_label = new Gtk.Label (null);
-        prep_status_label.get_style_context ().add_class ("boxes-wizard-label");
-        prep_status_label.halign = Gtk.Align.START;
-        prep_vbox.pack_start (prep_status_label, false, false);
-        prep_progress = new Gtk.ProgressBar ();
-        prep_vbox.pack_start (prep_progress, false, false);
-        vbox.show_all ();
-
-        /* Setup */
-        setup_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
-        setup_box.valign = Gtk.Align.CENTER;
-        setup_box.halign = Gtk.Align.CENTER;
-        add_step (setup_box, _("Setup"), WizardPage.SETUP);
-        setup_box.show_all ();
-
-        /* Review */
-        vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
-        vbox.valign = Gtk.Align.FILL;
-        vbox.halign = Gtk.Align.FILL;
-        add_step (vbox, _("Review"), WizardPage.REVIEW);
-
-        var nokvm_infobar = new Gtk.InfoBar ();
-        nokvm_infobar.halign = Gtk.Align.FILL;
-        nokvm_infobar.spacing = 10;
-        var container = nokvm_infobar.get_content_area () as Gtk.Container;
-        var image = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.LARGE_TOOLBAR);
-        container.add (image);
-        label = new Gtk.Label (_("Virtualization extensions are unavailable on your system. If your system 
is recent (post 2008), check your BIOS settings to enable them."));
-        label.wrap = true;
-        label.halign = Gtk.Align.START;
-        label.hexpand = true;
-        container.add (label);
-        nokvm_infobar.message_type = Gtk.MessageType.WARNING;
-        // FIXME: We shouldn't need this box but for some weird unknown reason,
-        // toggling the visibility of the infobar itself doesn't exactly work.
-        // The bar remains visible even after setting visibility to 'false' but
-        // its only visible as a line. Likely some bug in clutter-gtk but I
-        // failed to reproduce it outside Boxes. :(
-        nokvm_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
-        nokvm_box.pack_start (nokvm_infobar, false, false);
-        vbox.pack_start (nokvm_box, false, false);
-
-        var review_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 30);
-        review_vbox.valign = Gtk.Align.CENTER;
-        review_vbox.halign = Gtk.Align.CENTER;
-        vbox.pack_start (review_vbox , true, true);
-
-        review_label = new Gtk.Label (null);
-        review_label.get_style_context ().add_class ("boxes-wizard-label");
-        review_label.xalign = 0.0f;
-        review_label.wrap = true;
-        review_label.width_chars = 30;
-        review_vbox.pack_start (review_label, false, false);
-
-        summary = new WizardSummary ();
-        review_vbox.pack_start (summary.widget, true, true);
-        vbox.show_all ();
-
         /* topbar */
-        hbox = App.app.topbar.notebook.get_nth_page (Boxes.TopbarPage.WIZARD) as Gtk.Box;
+        var hbox = App.app.topbar.notebook.get_nth_page (Boxes.TopbarPage.WIZARD) as Gtk.Box;
 
         var toolbar = new Gtk.HeaderBar ();
         toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
@@ -724,12 +613,16 @@ private class Boxes.Wizard: GLib.Object, Boxes.UI {
         create_button.get_style_context ().add_class ("boxes-continue");
         toolbar.pack_end (create_button);
         create_button.clicked.connect (() => {
-            page = page + 1;
+            create.begin ((obj, result) => {
+            if (create.end (result))
+                App.app.set_state (UIState.COLLECTION);
+            else
+                App.app.notificationbar.display_error (_("Box creation failed"));
+            });
         });
         toolbar_sizegroup.add_widget (create_button);
 
         hbox.show_all ();
-        notebook.show_all ();
     }
 
     public void open_with_uri (string uri, bool skip_review_for_live = true) {
@@ -765,62 +658,56 @@ private class Boxes.Wizard: GLib.Object, Boxes.UI {
             machine = null;
         }
     }
+}
 
-    private class WizardSummary: GLib.Object {
-        public delegate void CustomizeFunc ();
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-summary.ui")]
+private class Boxes.WizardSummary: Gtk.Grid {
+    public delegate void CustomizeFunc ();
 
-        public Gtk.Widget widget { get { return grid; } }
-        private Gtk.Grid grid;
-        private int current_row;
+    private int current_row;
 
-        public WizardSummary () {
-            grid = new Gtk.Grid ();
-            grid.row_spacing = 10;
-            grid.column_spacing = 20;
-            current_row = 0;
+    construct {
+        current_row = 0;
+    }
 
-            clear ();
-        }
+    public void add_property (string name, string? value) {
+        if (value == null)
+            return;
 
-        public void add_property (string name, string? value) {
-            if (value == null)
-                return;
+        var label_name = new Gtk.Label (name);
+        label_name.get_style_context ().add_class ("boxes-wizard-summary-prop-name-label");
+        label_name.xalign = 1.0f;
+        attach (label_name, 0, current_row, 1, 1);
 
-            var label_name = new Gtk.Label (name);
-            label_name.get_style_context ().add_class ("boxes-wizard-summary-prop-name-label");
-            label_name.xalign = 1.0f;
-            grid.attach (label_name, 0, current_row, 1, 1);
+        var label_value = new Gtk.Label (value);
+        label_value.get_style_context ().add_class ("boxes-wizard-summary-prop-value-label");
+        label_value.set_ellipsize (Pango.EllipsizeMode.END);
+        label_value.set_max_width_chars (32);
+        label_value.xalign = 0.0f;
+        attach (label_value, 1, current_row, 1, 1);
 
-            var label_value = new Gtk.Label (value);
-            label_value.get_style_context ().add_class ("boxes-wizard-summary-prop-value-label");
-            label_value.set_ellipsize (Pango.EllipsizeMode.END);
-            label_value.set_max_width_chars (32);
-            label_value.xalign = 0.0f;
-            grid.attach (label_value, 1, current_row, 1, 1);
+        current_row += 1;
+        show_all ();
+    }
 
-            current_row += 1;
-            grid.show_all ();
-        }
+    public void append_customize_button (CustomizeFunc customize_func) {
+        // there is nothing to customize if review page is empty
+        if (current_row == 0)
+            return;
 
-        public void append_customize_button (CustomizeFunc customize_func) {
-            // there is nothing to customize if review page is empty
-            if (current_row == 0)
-                return;
+        var button = new Gtk.Button.with_mnemonic (_("C_ustomize..."));
+        button.get_style_context ().add_class ("boxes-wizard-summary-customize-button");
+        attach (button, 2, current_row - 1, 1, 1);
+        button.show ();
 
-            var button = new Gtk.Button.with_mnemonic (_("C_ustomize..."));
-            button.get_style_context ().add_class ("boxes-wizard-summary-customize-button");
-            grid.attach (button, 2, current_row - 1, 1, 1);
-            button.show ();
+        button.clicked.connect (() => { customize_func (); });
+    }
 
-            button.clicked.connect (() => { customize_func (); });
+    public void clear () {
+        foreach (var child in get_children ()) {
+            remove (child);
         }
 
-        public void clear () {
-            foreach (var child in grid.get_children ()) {
-                grid.remove (child);
-            }
-
-            current_row = 0;
-        }
+        current_row = 0;
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]