[gnome-boxes] Split a few classes in seperate file



commit 43a559a310b4ac87fad7bb4f8218468d7e98de0b
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Wed Oct 26 19:26:27 2011 +0200

    Split a few classes in seperate file

 src/Makefile.am            |    9 ++-
 src/collection-source.vala |   63 ++++++++++++++
 src/collection.vala        |   62 -------------
 src/libvirt-machine.vala   |  135 +++++++++++++++++++++++++++++
 src/machine.vala           |  171 -------------------------------------
 src/spice-machine.vala     |   38 ++++++++
 src/wizard-source.vala     |  107 +++++++++++++++++++++++
 src/wizard.vala            |  204 +++++++++++---------------------------------
 8 files changed, 399 insertions(+), 390 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0da1a0d..13f5098 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,20 +26,25 @@ bin_PROGRAMS = gnome-boxes
 
 gnome_boxes_SOURCES =				\
 	app.vala				\
-	ui.vala				\
-	display-page.vala				\
+	collection-source.vala			\
 	collection-view.vala			\
 	collection.vala				\
+	display-page.vala			\
 	display.vala				\
+	libvirt-machine.vala			\
 	machine.vala				\
 	main.vala				\
 	sidebar.vala				\
 	spice-display.vala			\
+	spice-machine.vala			\
 	topbar.vala				\
+	ui.vala					\
 	util.vala				\
 	vnc-display.vala			\
+	wizard-source.vala			\
 	wizard.vala				\
 	$(NULL)
+
 BUILT_SOURCES = dirs.h
 gnome_boxes_LDADD = $(BOXES_LIBS)
 gnome_boxes_CFLAGS = $(BOXES_CFLAGS)
diff --git a/src/collection-source.vala b/src/collection-source.vala
new file mode 100644
index 0000000..4c5fe10
--- /dev/null
+++ b/src/collection-source.vala
@@ -0,0 +1,63 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+private class Boxes.CollectionSource: GLib.Object {
+    private KeyFile keyfile;
+    public string? name {
+        owned get { return get_string ("source", "name"); }
+        set { keyfile.set_string ("source", "name", value); }
+    }
+    public string? source_type {
+        owned get { return get_string ("source", "type"); }
+        set { keyfile.set_string ("source", "type", value); }
+    }
+    public string? uri {
+        owned get { return get_string ("source", "uri"); }
+        set { keyfile.set_string ("source", "uri", value); }
+    }
+
+    private string? _filename;
+    public string? filename {
+        get {
+            if (_filename == null)
+                _filename = make_filename (name);
+            return _filename;
+        }
+        set { _filename = value; }
+    }
+
+    private bool has_file;
+
+    construct {
+        keyfile = new KeyFile ();
+    }
+
+    public CollectionSource (string name, string source_type, string uri) {
+        this.name = name;
+        this.source_type = source_type;
+        this.uri = uri;
+    }
+
+    public CollectionSource.with_file (string filename) throws GLib.Error {
+        this.filename = filename;
+        has_file = true;
+        load ();
+    }
+
+    private void load () throws GLib.Error {
+        keyfile.load_from_file (get_pkgconfig_source (filename),
+                                KeyFileFlags.KEEP_COMMENTS | KeyFileFlags.KEEP_TRANSLATIONS);
+    }
+
+    public void save () {
+        keyfile_save (keyfile, get_pkgconfig_source (filename), has_file);
+        has_file = true;
+    }
+
+    private string? get_string (string group, string key) {
+        try {
+            return keyfile.get_string (group, key);
+        } catch (GLib.KeyFileError error) {
+            return null;
+        }
+    }
+}
diff --git a/src/collection.vala b/src/collection.vala
index 4a6e217..481281f 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -24,68 +24,6 @@ private class Boxes.Collection: GLib.Object {
     }
 }
 
-private class Boxes.CollectionSource: GLib.Object {
-    private KeyFile keyfile;
-    public string? name {
-        owned get { return get_string ("source", "name"); }
-        set { keyfile.set_string ("source", "name", value); }
-    }
-    public string? source_type {
-        owned get { return get_string ("source", "type"); }
-        set { keyfile.set_string ("source", "type", value); }
-    }
-    public string? uri {
-        owned get { return get_string ("source", "uri"); }
-        set { keyfile.set_string ("source", "uri", value); }
-    }
-
-    private string? _filename;
-    public string? filename {
-        get {
-            if (_filename == null)
-                _filename = make_filename (name);
-            return _filename;
-        }
-        set { _filename = value; }
-    }
-
-    private bool has_file;
-
-    construct {
-        keyfile = new KeyFile ();
-    }
-
-    public CollectionSource (string name, string source_type, string uri) {
-        this.name = name;
-        this.source_type = source_type;
-        this.uri = uri;
-    }
-
-    public CollectionSource.with_file (string filename) throws GLib.Error {
-        this.filename = filename;
-        has_file = true;
-        load ();
-    }
-
-    private void load () throws GLib.Error {
-        keyfile.load_from_file (get_pkgconfig_source (filename),
-                                KeyFileFlags.KEEP_COMMENTS | KeyFileFlags.KEEP_TRANSLATIONS);
-    }
-
-    public void save () {
-        keyfile_save (keyfile, get_pkgconfig_source (filename), has_file);
-        has_file = true;
-    }
-
-    private string? get_string (string group, string key) {
-        try {
-            return keyfile.get_string (group, key);
-        } catch (GLib.KeyFileError error) {
-            return null;
-        }
-    }
-}
-
 private class Boxes.Category: GLib.Object {
     public string name;
 
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
new file mode 100644
index 0000000..8135b49
--- /dev/null
+++ b/src/libvirt-machine.vala
@@ -0,0 +1,135 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using GVir;
+
+private class Boxes.LibvirtMachine: Boxes.Machine {
+    public GVir.Domain domain;
+    public GVir.Connection connection;
+    public DomainState state {
+        get {
+            try {
+                return domain.get_info ().state;
+            } catch (GLib.Error error) {
+                return DomainState.NONE;
+            }
+        }
+    }
+
+    public override void disconnect_display () {
+        if (_connect_display == false)
+            return;
+
+        _connect_display = false;
+        app.display_page.remove_display ();
+        update_display ();
+    }
+
+    private ulong started_id;
+    public override void connect_display () {
+        if (_connect_display == true)
+            return;
+
+        if (state != DomainState.RUNNING) {
+            if (started_id != 0)
+                return;
+
+            if (state == DomainState.PAUSED) {
+                started_id = domain.resumed.connect (() => {
+                    domain.disconnect (started_id);
+                    started_id = 0;
+                    connect_display ();
+                });
+                try {
+                    domain.resume ();
+                } catch (GLib.Error error) {
+                    warning (error.message);
+                }
+            } else if (state != DomainState.RUNNING) {
+                started_id = domain.started.connect (() => {
+                    domain.disconnect (started_id);
+                    started_id = 0;
+                    connect_display ();
+                });
+                try {
+                    domain.start (0);
+                } catch (GLib.Error error) {
+                    warning (error.message);
+                }
+            }
+        }
+
+        _connect_display = true;
+        update_display ();
+    }
+
+    public LibvirtMachine (CollectionSource source, Boxes.App app,
+                           GVir.Connection connection, GVir.Domain domain) {
+        base (source, app, domain.get_name ());
+
+        this.connection = connection;
+        this.domain = domain;
+
+        set_screenshot_enable (true);
+    }
+
+    private void update_display () {
+        string type, gport, socket, ghost;
+
+        try {
+            var xmldoc = domain.get_config (0).doc;
+            type = extract_xpath (xmldoc, "string(/domain/devices/graphics/@type)", true);
+            gport = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@port)");
+            socket = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@socket)");
+            ghost = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@listen)");
+        } catch (GLib.Error error) {
+            warning (error.message);
+            return;
+        }
+
+        if (display != null)
+            display.disconnect_it ();
+
+        switch (type) {
+        case "spice":
+            display = new SpiceDisplay (ghost, int.parse (gport));
+            break;
+
+        case "vnc":
+            display = new VncDisplay (ghost, int.parse (gport));
+            break;
+
+        default:
+            warning ("unsupported display of type " + type);
+            break;
+        }
+    }
+
+    public override string get_screenshot_prefix () {
+        return domain.get_uuid ();
+    }
+
+    public override bool is_running () {
+        return state == DomainState.RUNNING;
+    }
+
+    public override async bool take_screenshot () throws GLib.Error {
+        if (state != DomainState.RUNNING &&
+            state != DomainState.PAUSED)
+            return true;
+
+        var stream = connection.get_stream (0);
+        var file_name = get_screenshot_filename ();
+        var file = File.new_for_path (file_name);
+        var output_stream = yield file.replace_async (null, false, FileCreateFlags.REPLACE_DESTINATION);
+        var input_stream = stream.get_input_stream ();
+        domain.screenshot (stream, 0, 0);
+
+        var buffer = new uint8[65535];
+        ssize_t length = 0;
+        do {
+            length = yield input_stream.read_async (buffer);
+            yield output_stream_write (output_stream, buffer[0:length]);
+        } while (length > 0);
+
+        return true;
+    }
+}
diff --git a/src/machine.vala b/src/machine.vala
index 188c37a..3107932 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -2,7 +2,6 @@
 using Clutter;
 using Gdk;
 using Gtk;
-using GVir;
 
 private abstract class Boxes.Machine: Boxes.CollectionItem {
     public override Clutter.Actor actor { get { return machine_actor.actor; } }
@@ -217,176 +216,6 @@ private abstract class Boxes.Machine: Boxes.CollectionItem {
     }
 }
 
-private class Boxes.LibvirtMachine: Boxes.Machine {
-    public GVir.Domain domain;
-    public GVir.Connection connection;
-    public DomainState state {
-        get {
-            try {
-                return domain.get_info ().state;
-            } catch (GLib.Error error) {
-                return DomainState.NONE;
-            }
-        }
-    }
-
-    public override void disconnect_display () {
-        if (_connect_display == false)
-            return;
-
-        _connect_display = false;
-        app.display_page.remove_display ();
-        update_display ();
-    }
-
-    private ulong started_id;
-    public override void connect_display () {
-        if (_connect_display == true)
-            return;
-
-        if (state != DomainState.RUNNING) {
-            if (started_id != 0)
-                return;
-
-            if (state == DomainState.PAUSED) {
-                started_id = domain.resumed.connect (() => {
-                    domain.disconnect (started_id);
-                    started_id = 0;
-                    connect_display ();
-                });
-                try {
-                    domain.resume ();
-                } catch (GLib.Error error) {
-                    warning (error.message);
-                }
-            } else if (state != DomainState.RUNNING) {
-                started_id = domain.started.connect (() => {
-                    domain.disconnect (started_id);
-                    started_id = 0;
-                    connect_display ();
-                });
-                try {
-                    domain.start (0);
-                } catch (GLib.Error error) {
-                    warning (error.message);
-                }
-            }
-        }
-
-        _connect_display = true;
-        update_display ();
-    }
-
-    public LibvirtMachine (CollectionSource source, Boxes.App app,
-                           GVir.Connection connection, GVir.Domain domain) {
-        base (source, app, domain.get_name ());
-
-        this.connection = connection;
-        this.domain = domain;
-
-        set_screenshot_enable (true);
-    }
-
-    private void update_display () {
-        string type, gport, socket, ghost;
-
-        try {
-            var xmldoc = domain.get_config (0).doc;
-            type = extract_xpath (xmldoc, "string(/domain/devices/graphics/@type)", true);
-            gport = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@port)");
-            socket = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@socket)");
-            ghost = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@listen)");
-        } catch (GLib.Error error) {
-            warning (error.message);
-            return;
-        }
-
-        if (display != null)
-            display.disconnect_it ();
-
-        switch (type) {
-        case "spice":
-            display = new SpiceDisplay (ghost, int.parse (gport));
-            break;
-
-        case "vnc":
-            display = new VncDisplay (ghost, int.parse (gport));
-            break;
-
-        default:
-            warning ("unsupported display of type " + type);
-            break;
-        }
-    }
-
-    public override string get_screenshot_prefix () {
-        return domain.get_uuid ();
-    }
-
-    public override bool is_running () {
-        return state == DomainState.RUNNING;
-    }
-
-    public override async bool take_screenshot () throws GLib.Error {
-        if (state != DomainState.RUNNING &&
-            state != DomainState.PAUSED)
-            return true;
-
-        var stream = connection.get_stream (0);
-        var file_name = get_screenshot_filename ();
-        var file = File.new_for_path (file_name);
-        var output_stream = yield file.replace_async (null, false, FileCreateFlags.REPLACE_DESTINATION);
-        var input_stream = stream.get_input_stream ();
-        domain.screenshot (stream, 0, 0);
-
-        var buffer = new uint8[65535];
-        ssize_t length = 0;
-        do {
-            length = yield input_stream.read_async (buffer);
-            yield output_stream_write (output_stream, buffer[0:length]);
-        } while (length > 0);
-
-        return true;
-    }
-}
-
-private class Boxes.SpiceMachine: Boxes.Machine {
-
-    public SpiceMachine (CollectionSource source, Boxes.App app) {
-        base (source, app, source.name);
-
-        update_screenshot.begin ();
-    }
-
-    public override void connect_display () {
-        if (_connect_display == true)
-            return;
-
-        display = new SpiceDisplay.with_uri (source.uri);
-        display.connect_it ();
-    }
-
-    public override void disconnect_display () {
-        _connect_display = false;
-
-        app.display_page.remove_display ();
-
-        if (display != null) {
-            display.disconnect_it ();
-            display = null;
-        }
-    }
-
-    public override string get_screenshot_prefix () {
-        return source.filename;
-    }
-
-    public override bool is_running () {
-        // assume the remote is running for now
-        return true;
-    }
-}
-
 private class Boxes.MachineActor: Boxes.UI {
     public override Clutter.Actor actor { get { return box; } }
     public Clutter.Box box;
diff --git a/src/spice-machine.vala b/src/spice-machine.vala
new file mode 100644
index 0000000..62c12ef
--- /dev/null
+++ b/src/spice-machine.vala
@@ -0,0 +1,38 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+private class Boxes.SpiceMachine: Boxes.Machine {
+
+    public SpiceMachine (CollectionSource source, Boxes.App app) {
+        base (source, app, source.name);
+
+        update_screenshot.begin ();
+    }
+
+    public override void connect_display () {
+        if (_connect_display == true)
+            return;
+
+        display = new SpiceDisplay.with_uri (source.uri);
+        display.connect_it ();
+    }
+
+    public override void disconnect_display () {
+        _connect_display = false;
+
+        app.display_page.remove_display ();
+
+        if (display != null) {
+            display.disconnect_it ();
+            display = null;
+        }
+    }
+
+    public override string get_screenshot_prefix () {
+        return source.filename;
+    }
+
+    public override bool is_running () {
+        // assume the remote is running for now
+        return true;
+    }
+}
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
new file mode 100644
index 0000000..8e7b84c
--- /dev/null
+++ b/src/wizard-source.vala
@@ -0,0 +1,107 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+private enum Boxes.SourcePage {
+    MAIN,
+    URL,
+    FILE,
+
+    LAST,
+}
+
+public delegate void ClickedFunc ();
+
+private class Boxes.WizardSource: 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);
+        }
+    }
+    public string uri {
+        get { return url_entry.get_text (); }
+    }
+
+    private Gtk.Notebook notebook;
+    private Gtk.Entry url_entry;
+
+    public WizardSource () {
+        notebook = new Gtk.Notebook ();
+        notebook.get_style_context ().add_class ("boxes-source-nb");
+        notebook.show_tabs = false;
+
+        /* main page */
+        var vbox = new Gtk.VBox (false, 10);
+        vbox.margin_top = vbox.margin_bottom = 15;
+        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 = 15;
+        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);
+        url_entry = new Gtk.Entry ();
+        hbox.add (url_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 ();
+        ebox.visible_window = false;
+        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;
+    }
+}
diff --git a/src/wizard.vala b/src/wizard.vala
index acfc3c6..d377b37 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -10,159 +10,6 @@ private enum Boxes.WizardPage {
     LAST,
 }
 
-private enum Boxes.SourcePage {
-    MAIN,
-    URL,
-    FILE,
-
-    LAST,
-}
-
-public delegate void ClickedFunc ();
-
-private class Boxes.WizardSource: 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);
-        }
-    }
-    public string uri {
-        get { return url_entry.get_text (); }
-    }
-
-    private Gtk.Notebook notebook;
-    private Gtk.Entry url_entry;
-
-    public WizardSource () {
-        notebook = new Gtk.Notebook ();
-        notebook.get_style_context ().add_class ("boxes-source-nb");
-        notebook.show_tabs = false;
-
-        /* main page */
-        var vbox = new Gtk.VBox (false, 10);
-        vbox.margin_top = vbox.margin_bottom = 15;
-        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 = 15;
-        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);
-        url_entry = new Gtk.Entry ();
-        hbox.add (url_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 ();
-        ebox.visible_window = false;
-        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 = 10;
-        table.column_spacing = 20;
-
-        clear ();
-    }
-
-    public void add_property (string name, string? value) {
-        if (value == null)
-            return;
-
-        var label_name = new Gtk.Label (name);
-        label_name.modify_fg (Gtk.StateType.NORMAL, get_color ("grey"));
-        label_name.xalign = 1.0f;
-        table.attach_defaults (label_name, 0, 1, current_row, current_row + 1);
-
-        var label_value = new Gtk.Label (value);
-        label_value.modify_fg (Gtk.StateType.NORMAL, get_color ("white"));
-        label_value.xalign = 0.0f;
-        table.attach_defaults (label_value, 1, 2, current_row, current_row + 1);
-
-        current_row += 1;
-        table.show_all ();
-    }
-
-    public void clear () {
-        foreach (var child in table.get_children ()) {
-            table.remove (child);
-        }
-
-        table.resize (1, 2);
-
-        var label = new Gtk.Label (_("Will create a new box with the following properties:"));
-        label.margin_bottom = 10;
-        label.xalign = 0.0f;
-        table.attach_defaults (label, 0, 2, 0, 1);
-        current_row = 1;
-    }
-}
-
 private class Boxes.Wizard: Boxes.UI {
     public override Clutter.Actor actor { get { return gtk_actor; } }
 
@@ -173,7 +20,7 @@ private class Boxes.Wizard: Boxes.UI {
     private Gtk.Button back_button;
     private Gtk.Button next_button;
     private Boxes.WizardSource wizard_source;
-    private Boxes.WizardSummary summary;
+    private WizardSummary summary;
     private CollectionSource? source;
 
     private WizardPage _page;
@@ -347,7 +194,7 @@ private class Boxes.Wizard: Boxes.UI {
         /* Review */
         vbox = new Gtk.VBox (false, 10);
         add_step (vbox, _("Review"), WizardPage.REVIEW);
-        summary = new Boxes.WizardSummary ();
+        summary = new WizardSummary ();
         vbox.pack_start (summary.widget, false, false);
         vbox.show_all ();
 
@@ -392,4 +239,51 @@ private class Boxes.Wizard: Boxes.UI {
             break;
         }
     }
+
+    private class 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 = 10;
+            table.column_spacing = 20;
+
+            clear ();
+        }
+
+        public void add_property (string name, string? value) {
+            if (value == null)
+                return;
+
+            var label_name = new Gtk.Label (name);
+            label_name.modify_fg (Gtk.StateType.NORMAL, get_color ("grey"));
+            label_name.xalign = 1.0f;
+            table.attach_defaults (label_name, 0, 1, current_row, current_row + 1);
+
+            var label_value = new Gtk.Label (value);
+            label_value.modify_fg (Gtk.StateType.NORMAL, get_color ("white"));
+            label_value.xalign = 0.0f;
+            table.attach_defaults (label_value, 1, 2, current_row, current_row + 1);
+
+            current_row += 1;
+            table.show_all ();
+        }
+
+        public void clear () {
+            foreach (var child in table.get_children ()) {
+                table.remove (child);
+            }
+
+            table.resize (1, 2);
+
+            var label = new Gtk.Label (_("Will create a new box with the following properties:"));
+            label.margin_bottom = 10;
+            label.xalign = 0.0f;
+            table.attach_defaults (label, 0, 2, 0, 1);
+            current_row = 1;
+        }
+    }
 }



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