[gnome-boxes] Start the wizard
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Start the wizard
- Date: Tue, 18 Oct 2011 13:20:17 +0000 (UTC)
commit ad006275dc40f305d574a13196748bfbc531937b
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Tue Oct 18 14:47:02 2011 +0200
Start the wizard
data/gtk-style.css | 14 ++++
src/Makefile.am | 1 +
src/app.vala | 18 ++++--
src/collection-view.vala | 8 +++
src/collection.vala | 5 ++
src/sidebar.vala | 30 ++++++++-
src/topbar.vala | 24 ++++++--
src/wizard.vala | 153 ++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 238 insertions(+), 15 deletions(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index 5f7781e..b8d2951 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -1,4 +1,5 @@
@define-color boxes_bg_color darker (@theme_bg_color);
+ define-color boxes_continue_color #5f8dd3;
#TopbarLabel {
font-size: 14;
@@ -12,3 +13,16 @@
.boxes-bg {
background-color: @boxes_bg_color;
}
+
+.boxes-step-label {
+ color: gray;
+ font-size: 11;
+ font-weight: bold;
+}
+
+.boxes-continue {
+ background-image: -gtk-gradient (linear,
+ left top, left bottom,
+ from (@boxes_continue_color),
+ to (darker (@boxes_continue_color)));
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 8b367dc..5935a97 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,6 +34,7 @@ gnome_boxes_SOURCES = \
spice-display.vala \
topbar.vala \
util.vala \
+ wizard.vala \
$(NULL)
BUILT_SOURCES = dirs.h
gnome_boxes_LDADD = $(BOXES_LIBS)
diff --git a/src/app.vala b/src/app.vala
index 0be7eac..bc2d626 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -27,19 +27,20 @@ private class Boxes.App: Boxes.UI {
public Clutter.State state;
public Clutter.Box box; // the whole app box
public CollectionItem current_item; // current object/vm manipulated
+ public Topbar topbar;
+ public Sidebar sidebar;
public static const uint duration = 555; // default to 1/2 for all transitions
public static GLib.Settings settings;
+ public Wizard wizard;
private Clutter.TableLayout box_table;
private Collection collection;
- private Sidebar sidebar;
- private Topbar topbar;
private CollectionView view;
public App () {
settings = new GLib.Settings ("org.gnome.boxes");
setup_ui ();
- collection = new Collection ();
+ collection = new Collection (this);
collection.item_added.connect ((item) => {
item.actor.set_reactive (true);
@@ -122,6 +123,7 @@ private class Boxes.App: Boxes.UI {
window.show ();
+ wizard = new Wizard (this);
ui_state = UIState.COLLECTION;
}
@@ -130,10 +132,14 @@ private class Boxes.App: Boxes.UI {
current_item = null;
}
+ public void go_create () {
+ ui_state = UIState.WIZARD;
+ }
+
public override void ui_state_changed () {
message ("Switching layout to %s".printf (ui_state.to_string ()));
- foreach (var o in new Boxes.UI[] { sidebar, topbar, view }) {
+ foreach (var o in new Boxes.UI[] { sidebar, topbar, view, wizard }) {
o.ui_state = ui_state;
}
@@ -149,7 +155,9 @@ private class Boxes.App: Boxes.UI {
case UIState.COLLECTION:
box.set_layout_manager (box_table);
state.set_state ("collection");
-
+ break;
+ case UIState.WIZARD:
+ box.set_layout_manager (box_table);
break;
default:
warning ("Unhandled UI state %s".printf (ui_state.to_string ()));
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 24dfc9c..f7da733 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -53,6 +53,8 @@ private class Boxes.CollectionView: Boxes.UI {
}
case UIState.COLLECTION:
+ actor_remove (app.wizard.actor);
+
if (app.current_item != null) {
actor_remove (app.current_item.actor);
add_item (app.current_item);
@@ -72,6 +74,12 @@ private class Boxes.CollectionView: Boxes.UI {
break;
+ case UIState.WIZARD:
+ over_boxes.pack (app.wizard.actor);
+ app.wizard.actor.add_constraint (new Clutter.BindConstraint (over_boxes, BindCoordinate.SIZE, 0));
+ actor_add (over_boxes, app.stage);
+ break;
+
default:
break;
}
diff --git a/src/collection.vala b/src/collection.vala
index 3e177e0..c7a6b6e 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -5,6 +5,7 @@ private abstract class Boxes.CollectionItem: Boxes.UI {
}
private class Boxes.Collection: GLib.Object {
+ private Boxes.App app;
public signal void item_added (CollectionItem item);
GenericArray<CollectionItem> items;
@@ -13,6 +14,10 @@ private class Boxes.Collection: GLib.Object {
items = new GenericArray<CollectionItem> ();
}
+ public Collection (Boxes.App app) {
+ this.app = app;
+ }
+
public void add_item (CollectionItem item) {
items.add (item);
item_added (item);
diff --git a/src/sidebar.vala b/src/sidebar.vala
index d1e016b..71e46c9 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -3,6 +3,11 @@ using Gtk;
using Gdk;
using Clutter;
+private enum Boxes.SidebarPage {
+ COLLECTION,
+ WIZARD,
+}
+
private class Boxes.Sidebar: Boxes.UI {
public override Clutter.Actor actor { get { return gtk_actor; } }
public Notebook notebook;
@@ -34,8 +39,17 @@ private class Boxes.Sidebar: Boxes.UI {
}
public override void ui_state_changed () {
- if (ui_state == UIState.DISPLAY)
+ switch (ui_state) {
+ case UIState.COLLECTION:
+ notebook.page = SidebarPage.COLLECTION;
+ break;
+ case UIState.DISPLAY:
actor_pin (actor);
+ break;
+ case UIState.WIZARD:
+ notebook.page = SidebarPage.WIZARD;
+ break;
+ }
}
private void list_append (ListStore listmodel,
@@ -57,8 +71,9 @@ private class Boxes.Sidebar: Boxes.UI {
notebook = new Gtk.Notebook ();
notebook.set_size_request ((int) width, 100);
+ /* SidebarPage.COLLECTION */
var vbox = new Gtk.VBox (false, 0);
- notebook.append_page (vbox, new Gtk.Label (""));
+ notebook.append_page (vbox, null);
tree_view = new Gtk.TreeView ();
tree_view.set_name ("MyTreeview");
@@ -80,9 +95,7 @@ private class Boxes.Sidebar: Boxes.UI {
});
vbox.pack_start (tree_view, true, true, 0);
- notebook.page = 0;
notebook.show_tabs = false;
- notebook.show_all ();
gtk_actor = new GtkClutter.Actor.with_contents (notebook);
app.box.pack (gtk_actor, "column", 0, "row", 1, "x-expand", false, "y-expand", true);
@@ -118,6 +131,15 @@ private class Boxes.Sidebar: Boxes.UI {
create.margin = 5;
vbox.pack_end (create, false, false, 0);
create.show ();
+ create.clicked.connect (() => {
+ app.go_create ();
+ });
+
+ /* SidebarPage.WIZARD */
+ vbox = new Gtk.VBox (false, 0);
+ notebook.append_page (vbox, null);
+
+ notebook.show_all ();
// FIXME: make it dynamic depending on sidebar size..:
app.state.set_key (null, "display", gtk_actor, "x", AnimationMode.EASE_OUT_QUAD, -(float) width, 0, 0);
diff --git a/src/topbar.vala b/src/topbar.vala
index 12481d4..e1bd33b 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -2,6 +2,11 @@
using Clutter;
using Gtk;
+public enum Boxes.TopbarPage {
+ COLLECTION,
+ WIZARD,
+}
+
private class Boxes.Topbar: Boxes.UI {
public override Clutter.Actor actor { get { return gtk_actor; } }
public Widget corner;
@@ -11,9 +16,8 @@ private class Boxes.Topbar: Boxes.UI {
private uint height;
private GtkClutter.Actor gtk_actor; // the topbar box
- private Notebook notebook;
+ public Notebook notebook;
- private HBox hbox;
private Toolbar toolbar_start;
private ToolButton spinner;
@@ -35,7 +39,9 @@ private class Boxes.Topbar: Boxes.UI {
"x-expand", true,
"y-expand", false);
- hbox = new Gtk.HBox (false, 0);
+ /* TopbarPage.COLLECTION */
+ var hbox = new Gtk.HBox (false, 0);
+ notebook.append_page (hbox, null);
hbox.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
corner = new Gtk.EventBox ();
@@ -69,8 +75,12 @@ private class Boxes.Topbar: Boxes.UI {
toolbar_end.set_show_arrow (false);
hbox.pack_start (toolbar_end, false, false, 0);
+ /* TopbarPage.WIZARD */
+ hbox = new Gtk.HBox (false, 0);
+ hbox.margin = 5;
notebook.append_page (hbox, null);
- notebook.page = 0;
+ hbox.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
+
notebook.show_tabs = false;
notebook.show_all ();
@@ -81,18 +91,20 @@ private class Boxes.Topbar: Boxes.UI {
public override void ui_state_changed () {
switch (ui_state) {
case UIState.COLLECTION:
+ notebook.page = TopbarPage.COLLECTION;
toolbar_start.hide ();
spinner.hide ();
break;
-
case UIState.CREDS:
toolbar_start.show ();
spinner.show ();
break;
-
case UIState.DISPLAY:
actor_pin (gtk_actor);
break;
+ case UIState.WIZARD:
+ notebook.page = TopbarPage.WIZARD;
+ break;
default:
break;
diff --git a/src/wizard.vala b/src/wizard.vala
new file mode 100644
index 0000000..1494702
--- /dev/null
+++ b/src/wizard.vala
@@ -0,0 +1,153 @@
+// This file is part of GNOME Boxes. License: LGPLv2
+
+private enum Boxes.WizardPage {
+ INTRODUCTION,
+ SOURCE,
+ PREPARATION,
+ SETUP,
+ REVIEW,
+
+ LAST,
+}
+
+private class Boxes.Wizard: Boxes.UI {
+ public override Clutter.Actor actor { get { return gtk_actor; } }
+
+ private GtkClutter.Actor gtk_actor;
+ private Boxes.App app;
+ private GenericArray<Gtk.Label> steps;
+ private Gtk.Notebook notebook;
+ private Gtk.Button back_button;
+ private Gtk.Button next_button;
+
+ private WizardPage _page;
+ private WizardPage page {
+ get { return _page; }
+ set {
+ if (value == WizardPage.LAST) {
+ app.go_back ();
+ }
+
+ _page = value;
+ notebook.set_current_page (value);
+
+ for (var i = 0; i < steps.length; i++) {
+ var label = steps.get (i);
+ label.modify_fg (Gtk.StateType.NORMAL, null);
+ }
+
+ /* highlight in white current page label */
+ Gdk.Color white;
+ Gdk.Color.parse ("white", out white);
+ steps.get (page).modify_fg (Gtk.StateType.NORMAL, white);
+
+ back_button.set_sensitive (page != WizardPage.INTRODUCTION);
+ next_button.set_label (page != WizardPage.REVIEW ? _("Continue") : _("Create"));
+ }
+ }
+
+ construct {
+ steps = new GenericArray<Gtk.Label> ();
+ steps.length = WizardPage.LAST;
+ }
+
+ public Wizard (App app) {
+ this.app = app;
+
+ setup_ui ();
+ }
+
+ private void add_step (Gtk.Widget widget, string label, WizardPage page) {
+ notebook.append_page (widget, null);
+
+ /* sidebar */
+ var vbox = app.sidebar.notebook.get_nth_page (Boxes.SidebarPage.WIZARD) as Gtk.VBox;
+
+ var la = new Gtk.Label (label);
+ la.margin_left = 25;
+ la.get_style_context ().add_class ("boxes-step-label");
+ la.set_halign (Gtk.Align.START);
+ vbox.pack_start (la, false, false, 10);
+
+ vbox.show_all ();
+ steps.set (page, la);
+ }
+
+ private void setup_ui () {
+ notebook = new Gtk.Notebook ();
+ notebook.show_tabs = false;
+ gtk_actor = new GtkClutter.Actor.with_contents (notebook);
+
+ /* Introduction */
+ var hbox = new Gtk.HBox (false, 10);
+ add_step (hbox, _("Introduction"), WizardPage.INTRODUCTION);
+ hbox.add (new Gtk.Image.from_stock ("gtk-dialog-warning", Gtk.IconSize.DIALOG));
+ var la = new Gtk.Label (null);
+ la.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."));
+ la.set_use_markup (true);
+ la.wrap = true;
+ hbox.add (la);
+ hbox.show_all ();
+
+ /* Source */
+ var vbox = new Gtk.VBox (false, 10);
+ add_step (vbox, _("Source Selection"), WizardPage.SOURCE);
+ vbox.show_all ();
+
+ /* Preparation */
+ vbox = new Gtk.VBox (false, 10);
+ add_step (vbox, _("Preparation"), WizardPage.PREPARATION);
+ vbox.show_all ();
+
+ /* Setup */
+ vbox = new Gtk.VBox (false, 10);
+ add_step (vbox, _("Setup"), WizardPage.SETUP);
+ vbox.show_all ();
+
+ /* Review */
+ vbox = new Gtk.VBox (false, 10);
+ add_step (vbox, _("Review"), WizardPage.REVIEW);
+ vbox.show_all ();
+
+ /* topbar */
+ hbox = app.topbar.notebook.get_nth_page (Boxes.TopbarPage.WIZARD) as Gtk.HBox;
+
+ la = new Gtk.Label (_("Create a Box"));
+ la.name = "TopbarLabel";
+ la.margin_left = 20;
+ la.set_halign (Gtk.Align.START);
+ hbox.pack_start (la, true, true, 0);
+
+ var hbox_end = new Gtk.HBox (false, 0);
+ hbox.pack_start (hbox_end, false, false, 0);
+ hbox_end.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
+ var cancel = new Gtk.Button.from_stock (Gtk.Stock.CANCEL);
+ hbox_end.pack_start (cancel, false, false, 15);
+ cancel.clicked.connect (() => {
+ app.go_back ();
+ });
+ back_button = new Gtk.Button.from_stock (Gtk.Stock.GO_BACK);
+ hbox_end.pack_start (back_button, false, false, 5);
+ back_button.clicked.connect (() => {
+ page = page - 1;
+ });
+
+ next_button = new Gtk.Button.with_label (_("Continue"));
+ hbox_end.pack_start (next_button, false, false, 0);
+ next_button.clicked.connect (() => {
+ page = page + 1;
+ });
+ next_button.get_style_context ().add_class ("boxes-continue");
+
+ hbox.show_all ();
+ notebook.show_all ();
+ }
+
+ public override void ui_state_changed () {
+ switch (ui_state) {
+ case UIState.WIZARD:
+ page = WizardPage.INTRODUCTION;
+ break;
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]