[gnome-boxes] Populate Wizard's 'Setup' step
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Populate Wizard's 'Setup' step
- Date: Sat, 5 Nov 2011 00:48:35 +0000 (UTC)
commit 022550cb4e971fa91dc82ed7e36f9beace6c7129
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Nov 3 19:49:41 2011 +0200
Populate Wizard's 'Setup' step
This patch only adds wigdgets for express installation but user input
is not yet acted upon.
src/unattended-installer.vala | 76 +++++++++++++++++++++++++++++++++++++++++
src/wizard.vala | 34 +++++++++++++++---
2 files changed, 105 insertions(+), 5 deletions(-)
---
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index b68435a..b514bf7 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -15,6 +15,12 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
private bool created_floppy;
+ protected Gtk.Label setup_label;
+ protected Gtk.HBox setup_hbox;
+ protected Gtk.Switch express_toggle;
+ protected Gtk.Entry username_entry;
+ protected Gtk.Entry password_entry;
+
public UnattendedInstaller.copy (InstallerMedia media,
string unattended_src_path,
string unattended_dest_name) throws GLib.Error {
@@ -27,6 +33,8 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
floppy_path = get_pkgcache (os.short_id + "-unattended.img");
this.unattended_src_path = unattended_src_path;
this.unattended_dest_name = unattended_dest_name;
+
+ setup_ui ();
}
public async void setup (Cancellable? cancellable) throws GLib.Error {
@@ -46,6 +54,74 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
}
}
+ public virtual void populate_setup_vbox (Gtk.VBox setup_vbox) {
+ setup_vbox.pack_start (setup_label, false, false);
+ setup_vbox.pack_start (setup_hbox, false, false);
+ }
+
+ protected virtual void setup_ui () {
+ setup_label = new Gtk.Label (_("Choose express install to automatically preconfigure the box with optimal settings."));
+ setup_label.halign = Gtk.Align.START;
+ setup_hbox = new Gtk.HBox (false, 20);
+ setup_hbox.valign = Gtk.Align.START;
+ setup_hbox.margin = 24;
+
+ var table = new Gtk.Table (3, 3, false);
+ setup_hbox.pack_start (table, false, false);
+ table.column_spacing = 10;
+ table.row_spacing = 10;
+
+ // First row
+ var label = new Gtk.Label (_("Express Install"));
+ label.halign = Gtk.Align.END;
+ label.valign = Gtk.Align.CENTER;
+ table.attach_defaults (label, 1, 2, 0, 1);
+
+ express_toggle = new Gtk.Switch ();
+ express_toggle.active = true;
+ express_toggle.halign = Gtk.Align.START;
+ express_toggle.valign = Gtk.Align.CENTER;
+ table.attach_defaults (express_toggle, 2, 3, 0, 1);
+ express_toggle.notify["active"].connect ((object, pspec) => {
+ foreach (var child in table.get_children ())
+ if (child != express_toggle)
+ child.sensitive = express_toggle.active;
+ });
+
+ // 2nd row (while user avatar spans over 2 rows)
+ var avatar_file = "/var/lib/AccountsService/icons/" + Environment.get_user_name ();
+ var file = File.new_for_path (avatar_file);
+ Gtk.Image avatar;
+ if (file.query_exists ())
+ avatar = new Gtk.Image.from_file (avatar_file);
+ else
+ avatar = new Gtk.Image.from_icon_name ("avatar-default", 0);
+ avatar.pixel_size = 128;
+ table.attach_defaults (avatar, 0, 1, 1, 3);
+
+ label = new Gtk.Label (_("Username"));
+ label.halign = Gtk.Align.END;
+ label.valign = Gtk.Align.CENTER;
+ table.attach_defaults (label, 1, 2, 1, 2);
+ username_entry = new Gtk.Entry ();
+ username_entry.text = Environment.get_user_name ();
+ username_entry.halign = Gtk.Align.START;
+ username_entry.valign = Gtk.Align.CENTER;
+ table.attach_defaults (username_entry, 2, 3, 1, 2);
+
+ // 3rd row
+ label = new Gtk.Label (_("Password"));
+ label.halign = Gtk.Align.END;
+ label.valign = Gtk.Align.CENTER;
+ table.attach_defaults (label, 1, 2, 2, 3);
+ password_entry = new Gtk.Entry ();
+ password_entry.visibility = false;
+ password_entry.text = "";
+ password_entry.halign = Gtk.Align.START;
+ password_entry.valign = Gtk.Align.CENTER;
+ table.attach_defaults (password_entry, 2, 3, 2, 3);
+ }
+
protected virtual void clean_up () throws GLib.Error {
if (!created_floppy)
return;
diff --git a/src/wizard.vala b/src/wizard.vala
index 978f29b..1cc567e 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -23,6 +23,7 @@ private class Boxes.Wizard: Boxes.UI {
private WizardSummary summary;
private CollectionSource? source;
private Gtk.ProgressBar prep_progress;
+ private Gtk.VBox setup_vbox;
private OSDatabase os_db;
private VMCreator vm_creator;
@@ -59,6 +60,10 @@ private class Boxes.Wizard: Boxes.UI {
}
break;
+ case WizardPage.SETUP:
+ setup ();
+ break;
+
case WizardPage.REVIEW:
review ();
break;
@@ -212,6 +217,26 @@ private class Boxes.Wizard: Boxes.UI {
prepare_for_location (this.wizard_source.uri);
}
+ private void setup () {
+ foreach (var child in setup_vbox.get_children ())
+ setup_vbox.remove (child);
+
+ if (install_media == null || !(install_media is UnattendedInstaller)) {
+ // Nothing to do so just skip to the next page but let the current page change complete first
+ Idle.add (() => {
+ page = page + 1;
+
+ return false;
+ });
+
+ return;
+ }
+
+ var installer = install_media as UnattendedInstaller;
+ installer.populate_setup_vbox (setup_vbox);
+ setup_vbox.show_all ();
+ }
+
private void review () {
summary.clear ();
@@ -323,7 +348,7 @@ private class Boxes.Wizard: Boxes.UI {
image.pixel_size = 128;
hbox.pack_start (image, false, false);
var prep_vbox = new Gtk.VBox (true, 20);
- prep_vbox.valign = Gtk.Align.CENTER;
+ prep_vbox.valign = Gtk.Align.START;
hbox.pack_start (prep_vbox, true, true);
label = new Gtk.Label (_("Analyzing installer media."));
label.halign = Gtk.Align.START;
@@ -333,10 +358,9 @@ private class Boxes.Wizard: Boxes.UI {
vbox.show_all ();
/* Setup */
- vbox = new Gtk.VBox (false, 30);
- add_step (vbox, _("Setup"), WizardPage.SETUP);
- vbox.margin = 40;
- vbox.show_all ();
+ setup_vbox = new Gtk.VBox (false, 30);
+ add_step (setup_vbox, _("Setup"), WizardPage.SETUP);
+ setup_vbox.margin = 40;
/* Review */
vbox = new Gtk.VBox (false, 30);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]