[gnome-boxes] wizard: start simple source URL



commit b60fccda125935936da4dd4903b9ec1f6e3b1e08
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Wed Oct 19 01:51:30 2011 +0200

    wizard: start simple source URL

 data/gtk-style.css     |    5 ++
 data/icons/Makefile.am |    4 +
 src/app.vala           |   15 +----
 src/machine.vala       |    2 +-
 src/util.vala          |   30 +++++++++
 src/wizard.vala        |  164 ++++++++++++++++++++++++++++++++++++++++++++++-
 6 files changed, 201 insertions(+), 19 deletions(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index b8d2951..1e9b8e1 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -20,6 +20,11 @@
     font-weight: bold;
 }
 
+.boxes-source-label {
+    font-size: 11;
+    font-weight: bold;
+}
+
 .boxes-continue {
     background-image: -gtk-gradient (linear,
                                      left top, left bottom,
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index deecfb1..64b0c89 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -17,7 +17,11 @@ noinst_DATA =					\
 	gnome-boxes.svg				\
 	$(NULL)
 
+imagesdir = $(datadir)/gnome-boxes/pixmaps
+images_DATA = boxes-create.png
+
 EXTRA_DIST =					\
+	$(images_DATA)				\
 	$(public_icons)				\
 	$(noinst_DATA)				\
 	$(NULL)
diff --git a/src/app.vala b/src/app.vala
index bc2d626..35a48ca 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -87,20 +87,7 @@ private class Boxes.App: Boxes.UI {
         embed.show ();
         window.add (embed);
         stage = embed.get_stage () as Clutter.Stage;
-
-        var style = new Gtk.StyleContext ();
-        var path = new Gtk.WidgetPath ();
-        path.append_type (typeof (Gtk.Window));
-        style.set_path (path);
-        style.add_class ("boxes-bg");
-        var gdk_rgba = style.get_background_color (0);
-        Clutter.Color color = {
-            (uint8) (gdk_rgba.red * 255).clamp (0, 255),
-            (uint8) (gdk_rgba.green * 255).clamp (0, 255),
-            (uint8) (gdk_rgba.blue * 255).clamp (0, 255),
-            (uint8) (gdk_rgba.alpha * 255).clamp (0, 255)
-        };
-        stage.set_color (color);
+        stage.set_color (gdk_rgba_to_clutter_color (get_boxes_bg_color ()));
 
         state = new Clutter.State ();
         state.set_duration (null, null, duration);
diff --git a/src/machine.vala b/src/machine.vala
index fae1af1..4f2cc32 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -86,7 +86,7 @@ private class Boxes.Machine: Boxes.CollectionItem {
             });
         } else {
             if (screenshot_id != 0)
-                Source.remove (screenshot_id);
+                GLib.Source.remove (screenshot_id);
             screenshot_id = 0;
         }
     }
diff --git a/src/util.vala b/src/util.vala
index 39b6b19..ff5a25b 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -17,6 +17,10 @@ namespace Boxes {
         return Path.build_filename (get_pkgdata (), "style", file_name);
     }
 
+    private string get_pixmap (string? file_name = null) {
+        return Path.build_filename (get_pkgdata (), "pixmaps", file_name);
+    }
+
     private string get_pkgcache (string? file_name = null) {
         var dir = Path.build_filename (Environment.get_user_cache_dir (), Config.PACKAGE_TARNAME);
 
@@ -31,6 +35,32 @@ namespace Boxes {
         return Path.build_filename (dir, file_name);
     }
 
+    private Clutter.Color gdk_rgba_to_clutter_color (Gdk.RGBA gdk_rgba) {
+        Clutter.Color color = {
+            (uint8) (gdk_rgba.red * 255).clamp (0, 255),
+            (uint8) (gdk_rgba.green * 255).clamp (0, 255),
+            (uint8) (gdk_rgba.blue * 255).clamp (0, 255),
+            (uint8) (gdk_rgba.alpha * 255).clamp (0, 255)
+        };
+
+        return color;
+    }
+
+    private Gdk.RGBA get_boxes_bg_color () {
+        var style = new Gtk.StyleContext ();
+        var path = new Gtk.WidgetPath ();
+        path.append_type (typeof (Gtk.Window));
+        style.set_path (path);
+        style.add_class ("boxes-bg");
+        return style.get_background_color (0);
+    }
+
+    private Gdk.Color get_color (string desc) {
+        Gdk.Color color;
+        Gdk.Color.parse (desc, out color);
+        return color;
+    }
+
     private void tree_view_activate_on_single_click (Gtk.TreeView tree_view, bool should_activate) {
         var id = tree_view.get_data<ulong> ("boxes-tree-view-activate");
 
diff --git a/src/wizard.vala b/src/wizard.vala
index 1494702..ebfa565 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -10,6 +10,137 @@ private enum Boxes.WizardPage {
     LAST,
 }
 
+private enum Boxes.SourcePage {
+    MAIN,
+    URL,
+    FILE,
+
+    LAST,
+}
+
+public delegate void ClickedFunc ();
+
+private class Boxes.Source: GLib.Object {
+    public Gtk.Widget widget { get { return notebook; } }
+    private SourcePage _page;
+    public SourcePage page {
+        get { return _page; }
+        set {
+            _page = value;
+            notebook.set_current_page (page);
+        }
+    }
+
+    private Gtk.Notebook notebook;
+
+    public Source () {
+        notebook = new Gtk.Notebook ();
+        notebook.show_tabs = false;
+
+        /* main page */
+        var vbox = new Gtk.VBox (false, 10);
+        vbox.margin_top = vbox.margin_bottom = 20;
+        notebook.append_page (vbox, null);
+
+        var hbox = add_entry (vbox, () => { page = SourcePage.URL; });
+        var label = new Gtk.Label (_("Enter URL"));
+        label.xalign = 0.0f;
+        hbox.pack_start (label, true, true);
+        var next = new Gtk.Label ("â");
+        hbox.pack_start (next, false, false);
+
+        var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
+        separator.height_request = 5;
+        vbox.pack_start (separator, false, false);
+
+        hbox = add_entry (vbox, () => { page = SourcePage.FILE; });
+        label = new Gtk.Label (_("Select a file"));
+        label.xalign = 0.0f;
+        hbox.pack_start (label, true, true);
+        next = new Gtk.Label ("â");
+        hbox.pack_start (next, false, false);
+
+        /* URL page */
+        vbox = new Gtk.VBox (false, 10);
+        vbox.margin_top = vbox.margin_bottom = 20;
+        notebook.append_page (vbox, null);
+
+        hbox = add_entry (vbox, () => { page = SourcePage.MAIN; });
+        var prev = new Gtk.Label ("â");
+        hbox.pack_start (prev, false, false);
+        label = new Gtk.Label (_("Enter URL"));
+        label.get_style_context ().add_class ("boxes-source-label");
+        hbox.pack_start (label, true, true);
+        separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
+        separator.height_request = 5;
+        vbox.pack_start (separator, false, false);
+        hbox = add_entry (vbox);
+        var entry = new Gtk.Entry ();
+        hbox.add (entry);
+        hbox = add_entry (vbox);
+        var image = new Gtk.Image.from_icon_name ("network-workgroup", 0);
+        // var image = new Gtk.Image.from_icon_name ("krfb", 0);
+        image.pixel_size = 96;
+        hbox.pack_start (image, false, false);
+        label = new Gtk.Label (null);
+        label.xalign = 0.0f;
+        label.set_markup (_("<b>Desktop Access</b>\n\nWill add boxes for all systems available from this account."));
+        label.set_use_markup (true);
+        label.wrap = true;
+        hbox.pack_start (label, true, true);
+
+        notebook.show_all ();
+    }
+
+    private Gtk.HBox add_entry (Gtk.VBox vbox, ClickedFunc? clicked = null) {
+        var ebox = new Gtk.EventBox ();
+        var hbox = new Gtk.HBox (false, 20);
+        ebox.add (hbox);
+        vbox.pack_start (ebox, false, false);
+        hbox.margin_left = hbox.margin_right = 20;
+        if (clicked != null) {
+            ebox.add_events (Gdk.EventMask.BUTTON_PRESS_MASK);
+            ebox.button_press_event.connect (() => {
+                clicked ();
+                return true;
+            });
+        }
+
+        return hbox;
+    }
+}
+
+private class Boxes.WizardSummary: GLib.Object {
+    public Gtk.Widget widget { get { return table; } }
+    private Gtk.Table table;
+    private uint current_row;
+
+    public WizardSummary () {
+        table = new Gtk.Table (1, 2, false);
+        table.margin = 20;
+        table.row_spacing = 20;
+        table.column_spacing = 20;
+        var label = new Gtk.Label (_("Will create a new box with the following properties:"));
+        label.xalign = 0.0f;
+        table.attach_defaults (label, 0, 2, 0, 1);
+        current_row = 1;
+    }
+
+    public void add_property (string name, string value) {
+        var label = new Gtk.Label (name);
+        label.modify_fg (Gtk.StateType.NORMAL, get_color ("grey"));
+        label.xalign = 1.0f;
+        table.attach_defaults (label, 0, 1, current_row, current_row + 1);
+
+        label = new Gtk.Label (value);
+        label.modify_fg (Gtk.StateType.NORMAL, get_color ("white"));
+        label.xalign = 0.0f;
+        table.attach_defaults (label, 1, 2, current_row, current_row + 1);
+
+        current_row += 1;
+    }
+}
+
 private class Boxes.Wizard: Boxes.UI {
     public override Clutter.Actor actor { get { return gtk_actor; } }
 
@@ -19,6 +150,8 @@ private class Boxes.Wizard: Boxes.UI {
     private Gtk.Notebook notebook;
     private Gtk.Button back_button;
     private Gtk.Button next_button;
+    private Boxes.Source source;
+    private Boxes.WizardSummary summary;
 
     private WizardPage _page;
     private WizardPage page {
@@ -28,6 +161,11 @@ private class Boxes.Wizard: Boxes.UI {
                 app.go_back ();
             }
 
+            if (skip_page (value)) {
+                page = value > page ? value + 1 : value - 1;
+                return;
+            }
+
             _page = value;
             notebook.set_current_page (value);
 
@@ -49,6 +187,7 @@ private class Boxes.Wizard: Boxes.UI {
     construct {
         steps = new GenericArray<Gtk.Label> ();
         steps.length = WizardPage.LAST;
+        source = new Boxes.Source ();
     }
 
     public Wizard (App app) {
@@ -73,15 +212,24 @@ private class Boxes.Wizard: Boxes.UI {
         steps.set (page, la);
     }
 
+    private bool skip_page (Boxes.WizardPage page) {
+        if (Boxes.WizardPage.SOURCE < page < Boxes.WizardPage.REVIEW &&
+            this.source.page == Boxes.SourcePage.URL)
+            return true;
+        return false;
+    }
+
     private void setup_ui () {
         notebook = new Gtk.Notebook ();
         notebook.show_tabs = false;
+        notebook.get_style_context ().add_class ("boxes-bg");
         gtk_actor = new GtkClutter.Actor.with_contents (notebook);
 
         /* Introduction */
         var hbox = new Gtk.HBox (false, 10);
+        hbox.margin_right = 20;
         add_step (hbox, _("Introduction"), WizardPage.INTRODUCTION);
-        hbox.add (new Gtk.Image.from_stock ("gtk-dialog-warning", Gtk.IconSize.DIALOG));
+        hbox.add (new Gtk.Image.from_file (get_pixmap ("boxes-create.png")));
         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);
@@ -90,8 +238,13 @@ private class Boxes.Wizard: Boxes.UI {
         hbox.show_all ();
 
         /* Source */
-        var vbox = new Gtk.VBox (false, 10);
+        var vbox = new Gtk.VBox (false, 20);
+        vbox.margin = 15;
         add_step (vbox, _("Source Selection"), WizardPage.SOURCE);
+        la = new Gtk.Label (_("Insert operating system installation media or select a source below"));
+        la.wrap = true;
+        vbox.pack_start (la, false, false);
+        vbox.pack_start (source.widget, false, false);
         vbox.show_all ();
 
         /* Preparation */
@@ -107,6 +260,9 @@ private class Boxes.Wizard: Boxes.UI {
         /* Review */
         vbox = new Gtk.VBox (false, 10);
         add_step (vbox, _("Review"), WizardPage.REVIEW);
+        summary = new Boxes.WizardSummary ();
+        summary.add_property (_("Hostname"), "foobar");
+        vbox.pack_start (summary.widget, false, false);
         vbox.show_all ();
 
         /* topbar */
@@ -129,13 +285,13 @@ private class Boxes.Wizard: Boxes.UI {
         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;
+            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;
+            page = page + 1;
         });
         next_button.get_style_context ().add_class ("boxes-continue");
 



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