[gnome-boxes] Use static App.app rather than passing around app



commit ab8f3347c5c4c692886e6239317575d57fba4e0b
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jun 7 18:56:42 2012 +0200

    Use static App.app rather than passing around app
    
    This is really a global object, use it as such.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677274

 src/app.vala             |   22 +++++++-------
 src/collection-view.vala |   36 +++++++++++------------
 src/collection.vala      |    4 +--
 src/display-page.vala    |   33 ++++++++++------------
 src/libvirt-machine.vala |    9 ++---
 src/machine.vala         |   70 ++++++++++++++++++++++-----------------------
 src/notificationbar.vala |   11 ++----
 src/properties.vala      |   21 ++++++--------
 src/remote-machine.vala  |    6 ++--
 src/selectionbar.vala    |   21 ++++++--------
 src/sidebar.vala         |   16 ++++------
 src/topbar.vala          |   23 ++++++--------
 src/vm-creator.vala      |   24 +++++++--------
 src/wizard-source.vala   |    6 +--
 src/wizard.vala          |   28 ++++++++----------
 15 files changed, 150 insertions(+), 180 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 9965a2d..0447683 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -120,7 +120,7 @@ private class Boxes.App: Boxes.UI {
 
             application.set_app_menu (menu);
 
-            collection = new Collection (this);
+            collection = new Collection ();
             duration = settings.get_int ("animation-duration");
             setup_ui ();
 
@@ -175,7 +175,7 @@ private class Boxes.App: Boxes.UI {
             return machine; // Already added
 
         try {
-            machine = new LibvirtMachine (source, this, connection, domain);
+            machine = new LibvirtMachine (source, connection, domain);
             collection.add_item (machine);
             domain.set_data<LibvirtMachine> ("machine", machine);
         } catch (GLib.Error error) {
@@ -239,7 +239,7 @@ private class Boxes.App: Boxes.UI {
 
         case "vnc":
         case "spice":
-            var machine = new RemoteMachine (source, this);
+            var machine = new RemoteMachine (source);
             collection.add_item (machine);
             break;
 
@@ -362,7 +362,7 @@ private class Boxes.App: Boxes.UI {
         embed = new GtkClutter.Embed ();
         notebook.append_page (embed, null);
 
-        display_page = new DisplayPage (this);
+        display_page = new DisplayPage ();
         notebook.append_page (display_page.widget, null);
 
         stage = embed.get_stage () as Clutter.Stage;
@@ -377,13 +377,13 @@ private class Boxes.App: Boxes.UI {
         stage.set_layout_manager (stage_bin);
         stage.name = "boxes-stage";
 
-        sidebar = new Sidebar (this);
-        view = new CollectionView (this, sidebar.category);
-        topbar = new Topbar (this);
-        notificationbar = new Notificationbar (this);
-        selectionbar = new Selectionbar (this);
-        wizard = new Wizard (this);
-        properties = new Properties (this);
+        sidebar = new Sidebar ();
+        view = new CollectionView (sidebar.category);
+        topbar = new Topbar ();
+        notificationbar = new Notificationbar ();
+        selectionbar = new Selectionbar ();
+        wizard = new Wizard ();
+        properties = new Properties ();
 
         var vbox_actor = new Clutter.Actor ();
         vbox_actor.name = "top-vbox";
diff --git a/src/collection-view.vala b/src/collection-view.vala
index eb2c519..98e0892 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -4,7 +4,6 @@ using Clutter;
 private class Boxes.CollectionView: Boxes.UI {
     public override Clutter.Actor actor { get { return gtkactor; } }
 
-    private App app;
     private GtkClutter.Actor gtkactor;
 
     private Category _category;
@@ -28,13 +27,12 @@ private class Boxes.CollectionView: Boxes.UI {
         set { icon_view.visible = value; }
     }
 
-    public CollectionView (App app, Category category) {
-        this.app = app;
+    public CollectionView (Category category) {
         this.category = category;
 
         setup_view ();
-        app.notify["selection-mode"].connect (() => {
-            var mode = app.selection_mode ? Gtk.SelectionMode.MULTIPLE : Gtk.SelectionMode.SINGLE;
+        App.app.notify["selection-mode"].connect (() => {
+            var mode = App.app.selection_mode ? Gtk.SelectionMode.MULTIPLE : Gtk.SelectionMode.SINGLE;
             icon_view.set_selection_mode (mode);
         });
     }
@@ -45,35 +43,35 @@ private class Boxes.CollectionView: Boxes.UI {
         case UIState.COLLECTION:
             opacity = 255;
             icon_view.unselect_all ();
-            if (app.current_item != null)
-                actor_remove (app.current_item.actor);
+            if (App.app.current_item != null)
+                actor_remove (App.app.current_item.actor);
             break;
 
         case UIState.CREDS:
-            var actor = app.current_item.actor;
-            app.overlay_bin.add (actor,
-                                 Clutter.BinAlignment.FIXED,
-                                 Clutter.BinAlignment.FIXED);
+            var actor = App.app.current_item.actor;
+            App.app.overlay_bin.add (actor,
+                                     Clutter.BinAlignment.FIXED,
+                                     Clutter.BinAlignment.FIXED);
 
             // TODO: How do I get the icon coords from the iconview?
             Clutter.ActorBox box = { 20, 20, 20 + Machine.SCREENSHOT_WIDTH, 20 + Machine.SCREENSHOT_HEIGHT};
             actor.allocate (box, 0);
             actor.min_width = actor.natural_width = Machine.SCREENSHOT_WIDTH * 2;
-            app.overlay_bin.set_alignment (actor,
-                                           Clutter.BinAlignment.CENTER,
-                                           Clutter.BinAlignment.CENTER);
+            App.app.overlay_bin.set_alignment (actor,
+                                               Clutter.BinAlignment.CENTER,
+                                               Clutter.BinAlignment.CENTER);
             break;
 
         case UIState.PROPERTIES:
-            var item_actor = app.current_item.actor;
+            var item_actor = App.app.current_item.actor;
             item_actor.hide ();
             break;
         }
 
         fade_actor (actor, opacity);
 
-        if (app.current_item != null)
-            app.current_item.ui_state = ui_state;
+        if (App.app.current_item != null)
+            App.app.current_item.ui_state = ui_state;
     }
 
     public void update_item_visible (CollectionItem item) {
@@ -193,10 +191,10 @@ private class Boxes.CollectionView: Boxes.UI {
         icon_view.set_selection_mode (Gtk.SelectionMode.SINGLE);
         icon_view.item_activated.connect ((view, path) => {
             var item = get_item_for_path (path);
-            app.select_item (item);
+            App.app.select_item (item);
         });
         icon_view.selection_changed.connect (() => {
-            app.notify_property ("selected-items");
+            App.app.notify_property ("selected-items");
         });
         var pixbuf_renderer = new Gtk.CellRendererPixbuf ();
         pixbuf_renderer.xalign = 0.5f;
diff --git a/src/collection.vala b/src/collection.vala
index a4e328f..9cea481 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -5,7 +5,6 @@ private abstract class Boxes.CollectionItem: Boxes.UI {
 }
 
 private class Boxes.Collection: GLib.Object {
-    private Boxes.App app;
     public signal void item_added (CollectionItem item);
     public signal void item_removed (CollectionItem item);
 
@@ -15,8 +14,7 @@ private class Boxes.Collection: GLib.Object {
         items = new GenericArray<CollectionItem> ();
     }
 
-    public Collection (Boxes.App app) {
-        this.app = app;
+    public Collection () {
     }
 
     public void add_item (CollectionItem item) {
diff --git a/src/display-page.vala b/src/display-page.vala
index 67c32da..6556f73 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -8,7 +8,7 @@ private class Boxes.DisplayToolbar: Gtk.Toolbar {
     }
     private Label label;
 
-    public DisplayToolbar (Boxes.App app) {
+    public DisplayToolbar () {
         icon_size = IconSize.MENU;
         get_style_context ().add_class (STYLE_CLASS_MENUBAR);
         set_show_arrow (false);
@@ -38,7 +38,7 @@ private class Boxes.DisplayToolbar: Gtk.Toolbar {
         back.add (new Image.from_icon_name ("go-previous-symbolic",
                                             IconSize.MENU));
         back.get_style_context ().add_class ("raised");
-        back.clicked.connect ((button) => { app.ui_state = UIState.COLLECTION; });
+        back.clicked.connect ((button) => { App.app.ui_state = UIState.COLLECTION; });
         left_box.pack_start (back, false, false, 0);
 
         /* center title - unfortunately, metacity doesn't even center its
@@ -55,14 +55,14 @@ private class Boxes.DisplayToolbar: Gtk.Toolbar {
         btn.add (new Image.from_icon_name ("view-fullscreen-symbolic",
                                            IconSize.MENU));
         btn.get_style_context ().add_class ("raised");
-        btn.clicked.connect ((button) => { app.fullscreen = !app.fullscreen; });
+        btn.clicked.connect ((button) => { App.app.fullscreen = !App.app.fullscreen; });
         right_box.pack_start (btn, false, false, 0);
 
         var props = new Button ();
         props.add (new Image.from_icon_name ("utilities-system-monitor-symbolic",
                                              IconSize.MENU));
         props.get_style_context ().add_class ("raised");
-        props.clicked.connect ((button) => { app.ui_state = UIState.PROPERTIES; });
+        props.clicked.connect ((button) => { App.app.ui_state = UIState.PROPERTIES; });
         right_box.pack_start (props, false, false, 0);
     }
 }
@@ -71,7 +71,6 @@ private class Boxes.DisplayPage: GLib.Object {
     public Widget widget { get { return overlay; } }
 
     private Overlay overlay;
-    private Boxes.App app;
     private EventBox event_box;
     private Box box;
     private DisplayToolbar overlay_toolbar;
@@ -86,14 +85,12 @@ private class Boxes.DisplayPage: GLib.Object {
     private ulong display_can_grab_id;
     private ulong display_grabbed_id;
 
-    public DisplayPage (Boxes.App app) {
-        this.app = app;
-
+    public DisplayPage () {
         event_box = new EventBox ();
         event_box.set_events (EventMask.POINTER_MOTION_MASK | EventMask.SCROLL_MASK);
         event_box.above_child = true;
         event_box.event.connect ((event) => {
-            if (app.fullscreen && event.type == EventType.MOTION_NOTIFY) {
+            if (App.app.fullscreen && event.type == EventType.MOTION_NOTIFY) {
                 var y = event.motion.y;
                 if (y <= 0) {
                     toolbar_event_stop ();
@@ -107,7 +104,7 @@ private class Boxes.DisplayPage: GLib.Object {
                         set_overlay_toolbar_visible (true);
                 } else if (y > 5 && toolbar_hide_id == 0) {
                     toolbar_event_stop ();
-                    toolbar_hide_id = Timeout.add (app.duration, () => {
+                    toolbar_hide_id = Timeout.add (App.app.duration, () => {
                         set_overlay_toolbar_visible (false);
                         toolbar_hide_id = 0;
                         return false;
@@ -124,14 +121,14 @@ private class Boxes.DisplayPage: GLib.Object {
             return false;
         });
 
-        toolbar = new DisplayToolbar (app);
+        toolbar = new DisplayToolbar ();
 
         box = new Box (Orientation.VERTICAL, 0);
         box.pack_start (toolbar, false, false, 0);
         box.pack_start (event_box, true, true, 0);
 
         overlay = new Overlay ();
-        app.window.window_state_event.connect ((event) => {
+        App.app.window.window_state_event.connect ((event) => {
             update_toolbar_visible ();
 
             return false;
@@ -139,7 +136,7 @@ private class Boxes.DisplayPage: GLib.Object {
         overlay.margin = 0;
         overlay.add (box);
 
-        overlay_toolbar = new DisplayToolbar (app);
+        overlay_toolbar = new DisplayToolbar ();
         overlay_toolbar.set_valign (Gtk.Align.START);
 
         overlay.add_overlay (overlay_toolbar);
@@ -149,16 +146,16 @@ private class Boxes.DisplayPage: GLib.Object {
     public void get_size (out int width, out int height) {
         int tb_height;
 
-        app.window.get_size (out width, out height);
+        App.app.window.get_size (out width, out height);
 
-        if (!app.fullscreen) {
+        if (!App.app.fullscreen) {
             toolbar.get_preferred_height (null, out tb_height);
             height -= tb_height;
         }
     }
 
      private void update_toolbar_visible() {
-         if (app.fullscreen && !can_grab_mouse)
+         if (App.app.fullscreen && !can_grab_mouse)
              toolbar.visible = false;
          else
              toolbar.visible = true;
@@ -186,11 +183,11 @@ private class Boxes.DisplayPage: GLib.Object {
     }
 
     public void show () {
-        app.notebook.page = Boxes.AppPage.DISPLAY;
+        App.app.notebook.page = Boxes.AppPage.DISPLAY;
     }
 
     public void update_title () {
-        var machine = app.current_item as Boxes.Machine;
+        var machine = App.app.current_item as Boxes.Machine;
         return_if_fail (machine != null);
 
         var title = machine.name;
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 9f991ec..f37444b 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -17,7 +17,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         if (display == null)
             return;
 
-        app.display_page.remove_display ();
+        App.app.display_page.remove_display ();
         display.disconnect_it ();
         display = null;
     }
@@ -97,10 +97,9 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
     }
 
     public LibvirtMachine (CollectionSource source,
-                           Boxes.App app,
                            GVir.Connection connection,
                            GVir.Domain domain) throws GLib.Error {
-        base (source, app, domain.get_name ());
+        base (source, domain.get_name ());
 
         debug ("new libvirt machine: " + name);
         this.config = new DisplayConfig (source, domain.get_uuid ());
@@ -383,7 +382,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
             }
 
             try {
-                if (connection == app.default_connection) {
+                if (connection == App.app.default_connection) {
                     var volume = get_storage_volume (connection, domain, null);
                     if (volume != null)
                         volume.delete (0);
@@ -481,7 +480,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
             }
         };
         var message = _("Changes require restart of '%s'. Attempt restart?").printf (name);
-        app.notificationbar.display_for_action (message, Gtk.Stock.YES, (owned) reboot);
+        App.app.notificationbar.display_for_action (message, Gtk.Stock.YES, (owned) reboot);
     }
 
     private void add_storage_property (ref List list) {
diff --git a/src/machine.vala b/src/machine.vala
index e15a6bb..29ac004 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -5,7 +5,6 @@ using Gtk;
 
 private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesProvider {
     public override Clutter.Actor actor { get { return machine_actor.actor; } }
-    public Boxes.App app;
     public MachineActor machine_actor;
     public Boxes.CollectionSource source;
     public Boxes.DisplayConfig config;
@@ -58,11 +57,11 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
                 return;
 
             show_id = _display.show.connect ((id) => {
-                app.ui_state = Boxes.UIState.DISPLAY;
-                Timeout.add (app.duration, () => {
+                App.app.ui_state = Boxes.UIState.DISPLAY;
+                Timeout.add (App.app.duration, () => {
                     try {
                         var widget = display.get_display (0);
-                        app.display_page.show_display (display, widget);
+                        App.app.display_page.show_display (display, widget);
                         widget.grab_focus ();
                     } catch (Boxes.Error error) {
                         warning (error.message);
@@ -73,12 +72,12 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
             });
 
             hide_id = _display.hide.connect ((id) => {
-                app.display_page.remove_display ();
+                App.app.display_page.remove_display ();
             });
 
             disconnected_id = _display.disconnected.connect (() => {
                 message (@"display $name disconnected");
-                app.ui_state = Boxes.UIState.COLLECTION;
+                App.app.ui_state = Boxes.UIState.COLLECTION;
             });
 
             need_password_id = _display.notify["need-password"].connect (() => {
@@ -93,16 +92,15 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
         }
     }
 
-    public Machine (Boxes.CollectionSource source, Boxes.App app, string name) {
-        this.app = app;
+    public Machine (Boxes.CollectionSource source, string name) {
         this.name = name;
         this.source = source;
 
         pixbuf = draw_fallback_vm ();
         machine_actor = new MachineActor (this);
 
-        ui_state_id = app.notify["ui-state"].connect (() => {
-            if (app.ui_state == UIState.DISPLAY)
+        ui_state_id = App.app.notify["ui-state"].connect (() => {
+            if (App.app.ui_state == UIState.DISPLAY)
                 set_screenshot_enable (false);
             else
                 set_screenshot_enable (true);
@@ -114,7 +112,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
             if (screenshot_id != 0)
                 return;
             update_screenshot.begin ();
-            var interval = app.settings.get_int ("screenshot-interval");
+            var interval = App.app.settings.get_int ("screenshot-interval");
             screenshot_id = Timeout.add_seconds (interval, () => {
                 update_screenshot.begin ();
 
@@ -244,7 +242,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
 
         set_screenshot_enable (false);
         if (ui_state_id != 0) {
-            app.disconnect (ui_state_id);
+            App.app.disconnect (ui_state_id);
             ui_state_id = 0;
         }
     }
@@ -269,7 +267,7 @@ private class Boxes.MachineActor: Boxes.UI {
 
     ~MachineActor() {
         if (track_screenshot_id != 0)
-            machine.app.properties.screenshot_placeholder.disconnect (track_screenshot_id);
+            App.app.properties.screenshot_placeholder.disconnect (track_screenshot_id);
     }
 
     public MachineActor (Machine machine) {
@@ -359,8 +357,8 @@ private class Boxes.MachineActor: Boxes.UI {
         int width, height;
         int x, y;
 
-        machine.app.display_page.get_size (out width, out height);
-        machine.app.window.get_size (out window_width, out window_height);
+        App.app.display_page.get_size (out width, out height);
+        App.app.window.get_size (out window_width, out window_height);
         x = window_width - width;
         y = window_height - height;
 
@@ -372,33 +370,33 @@ private class Boxes.MachineActor: Boxes.UI {
         case UIState.DISPLAY:
             gtk_vbox.hide ();
             if (previous_ui_state == UIState.CREDS) {
-                machine.app.overlay_bin.set_alignment (actor,
-                                                       Clutter.BinAlignment.FILL,
-                                                       Clutter.BinAlignment.FILL);
+                App.app.overlay_bin.set_alignment (actor,
+                                                   Clutter.BinAlignment.FILL,
+                                                   Clutter.BinAlignment.FILL);
             } else {
                 if (display != null) {
                     // zoom in, back from properties
 
-                    machine.app.properties.screenshot_placeholder.disconnect (track_screenshot_id);
+                    App.app.properties.screenshot_placeholder.disconnect (track_screenshot_id);
                     track_screenshot_id = 0;
 
-                    machine.app.overlay_bin.set_alignment (display,
-                                                           Clutter.BinAlignment.FILL,
-                                                           Clutter.BinAlignment.FILL);
+                    App.app.overlay_bin.set_alignment (display,
+                                                       Clutter.BinAlignment.FILL,
+                                                       Clutter.BinAlignment.FILL);
 
                     /* Todo: No good way to get the end of the transision yet? */
-                    Timeout.add (machine.app.duration, () => {
+                    Timeout.add (App.app.duration, () => {
                             var widget = display.contents;
                             display.contents = null;
                             display.destroy ();
                             display = null;
                             // FIXME: enable grabs
                             machine.display.set_enable_inputs (widget, true);
-                            machine.app.display_page.show_display (machine.display, widget);
+                            App.app.display_page.show_display (machine.display, widget);
                             return false;
                         });
                 } else
-                    machine.app.display_page.show ();
+                    App.app.display_page.show ();
             }
             break;
 
@@ -409,13 +407,13 @@ private class Boxes.MachineActor: Boxes.UI {
             break;
 
         case UIState.PROPERTIES:
-            var widget = machine.app.display_page.remove_display ();
+            var widget = App.app.display_page.remove_display ();
             machine.display.set_enable_inputs (widget, false);
             display = new GtkClutter.Actor.with_contents (widget);
             display.name = "properties-thumbnail";
-            machine.app.overlay_bin.add (display,
-                                         Clutter.BinAlignment.FILL,
-                                         Clutter.BinAlignment.FILL);
+            App.app.overlay_bin.add (display,
+                                     Clutter.BinAlignment.FILL,
+                                     Clutter.BinAlignment.FILL);
 
             Clutter.ActorBox box = { 0, 0,  width, height};
             display.allocate (box, 0);
@@ -423,15 +421,15 @@ private class Boxes.MachineActor: Boxes.UI {
 
             // Temporarily hide toolbar in fullscreen so that the the animation
             // actor doesn't get pushed down before zooming to the sidebar
-            if (machine.app.fullscreen)
-                machine.app.topbar.actor.hide ();
+            if (App.app.fullscreen)
+                App.app.topbar.actor.hide ();
 
-            track_screenshot_id = machine.app.properties.screenshot_placeholder.size_allocate.connect ( (alloc) => {
+            track_screenshot_id = App.app.properties.screenshot_placeholder.size_allocate.connect ( (alloc) => {
                 Idle.add_full (Priority.HIGH, () => {
-                    machine.app.topbar.actor.show ();
-                    machine.app.overlay_bin.set_alignment (display,
-                                                           Clutter.BinAlignment.FIXED,
-                                                           Clutter.BinAlignment.FIXED);
+                    App.app.topbar.actor.show ();
+                    App.app.overlay_bin.set_alignment (display,
+                                                       Clutter.BinAlignment.FIXED,
+                                                       Clutter.BinAlignment.FIXED);
                     display.x = alloc.x;
                     display.y = alloc.y;
                     display.width = alloc.width;
diff --git a/src/notificationbar.vala b/src/notificationbar.vala
index 531ed18..e9460a4 100644
--- a/src/notificationbar.vala
+++ b/src/notificationbar.vala
@@ -10,7 +10,6 @@ private class Boxes.Notificationbar: GLib.Object {
 
     public GtkClutter.Actor gtk_actor;
     public Revealer revealer;
-    private App app;
     private InfoBar info_bar;
     private Label message_label;
     private Button ok_button;
@@ -18,9 +17,7 @@ private class Boxes.Notificationbar: GLib.Object {
     private uint timeout_id;
     private ulong response_id;
 
-    public Notificationbar (App app) {
-        this.app = app;
-
+    public Notificationbar () {
         setup_action_notify ();
     }
 
@@ -84,12 +81,12 @@ private class Boxes.Notificationbar: GLib.Object {
     }
 
     private void add_timeout () {
-        if (!app.window.is_active) {
+        if (!App.app.window.is_active) {
             // Don't timeout before user gets a chance to see's the notification
             ulong active_id = 0;
-            active_id = app.window.notify["is-active"].connect (() => {
+            active_id = App.app.window.notify["is-active"].connect (() => {
                 add_timeout ();
-                app.window.disconnect (active_id);
+                App.app.window.disconnect (active_id);
             });
 
             return;
diff --git a/src/properties.vala b/src/properties.vala
index 2b17f52..738c717 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -15,7 +15,6 @@ private class Boxes.Properties: Boxes.UI {
 
     public Gtk.Widget screenshot_placeholder;
     private GtkClutter.Actor gtk_actor;
-    private Boxes.App app;
     private Gtk.Notebook notebook;
     private Gtk.ToolButton back;
     private Gtk.Label toolbar_label;
@@ -89,9 +88,7 @@ private class Boxes.Properties: Boxes.UI {
         }
     }
 
-    public Properties (App app) {
-        this.app = app;
-
+    public Properties () {
         setup_ui ();
     }
 
@@ -107,11 +104,11 @@ private class Boxes.Properties: Boxes.UI {
         for (var i = 0; i < PropertiesPage.LAST; i++)
             notebook.remove_page (-1);
 
-        if (app.current_item == null)
+        if (App.app.current_item == null)
             return;
 
         for (var i = 0; i < PropertiesPage.LAST; i++) {
-            var machine = app.current_item as Machine;
+            var machine = App.app.current_item as Machine;
             var page = new PageWidget (i, machine);
             notebook.append_page (page.widget, null);
 
@@ -121,7 +118,7 @@ private class Boxes.Properties: Boxes.UI {
 
         tree_view.get_selection ().select_path (new Gtk.TreePath.from_string ("0"));
 
-        var machine = app.current_item as LibvirtMachine;
+        var machine = App.app.current_item as LibvirtMachine;
         if (machine != null) {
             stats_id = machine.stats_updated.connect (() => {
                 cpu.points = machine.cpu_stats;
@@ -140,7 +137,7 @@ private class Boxes.Properties: Boxes.UI {
         gtk_actor.opacity = 0;
 
         /* topbar */
-        var hbox = app.topbar.notebook.get_nth_page (Boxes.TopbarPage.PROPERTIES) as Gtk.HBox;
+        var hbox = App.app.topbar.notebook.get_nth_page (Boxes.TopbarPage.PROPERTIES) as Gtk.HBox;
 
         var toolbar = new Toolbar ();
         toolbar.set_valign (Align.CENTER);
@@ -158,14 +155,14 @@ private class Boxes.Properties: Boxes.UI {
         box.add (toolbar_label);
         back = new ToolButton (box, null);
         back.get_style_context ().add_class ("raised");
-        back.clicked.connect ((button) => { app.ui_state = UIState.DISPLAY; });
+        back.clicked.connect ((button) => { App.app.ui_state = UIState.DISPLAY; });
         toolbar.insert (back, 0);
         hbox.pack_start (toolbar_box, true, true, 0);
 
         hbox.show_all ();
 
         /* sidebar */
-        var vbox = app.sidebar.notebook.get_nth_page (Boxes.SidebarPage.PROPERTIES) as Gtk.VBox;
+        var vbox = App.app.sidebar.notebook.get_nth_page (Boxes.SidebarPage.PROPERTIES) as Gtk.VBox;
 
         tree_view = new Gtk.TreeView ();
         var selection = tree_view.get_selection ();
@@ -225,13 +222,13 @@ private class Boxes.Properties: Boxes.UI {
     public override void ui_state_changed () {
         uint opacity = 0;
         if (stats_id != 0) {
-            app.current_item.disconnect (stats_id);
+            App.app.current_item.disconnect (stats_id);
             stats_id = 0;
         }
 
         switch (ui_state) {
         case UIState.PROPERTIES:
-            toolbar_label_bind = app.current_item.bind_property ("name", toolbar_label, "label", BindingFlags.SYNC_CREATE);
+            toolbar_label_bind = App.app.current_item.bind_property ("name", toolbar_label, "label", BindingFlags.SYNC_CREATE);
             populate ();
             opacity = 255;
             break;
diff --git a/src/remote-machine.vala b/src/remote-machine.vala
index 2282946..77196b9 100644
--- a/src/remote-machine.vala
+++ b/src/remote-machine.vala
@@ -3,8 +3,8 @@ using Gtk;
 
 private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
 
-    public RemoteMachine (CollectionSource source, Boxes.App app) {
-        base (source, app, source.name);
+    public RemoteMachine (CollectionSource source) {
+        base (source, source.name);
 
         // assume the remote is running for now
         state = MachineState.RUNNING;
@@ -38,7 +38,7 @@ private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
         if (display == null)
             return;
 
-        app.display_page.remove_display ();
+        App.app.display_page.remove_display ();
 
         if (display != null) {
             try {
diff --git a/src/selectionbar.vala b/src/selectionbar.vala
index 7f87c4b..4a18c78 100644
--- a/src/selectionbar.vala
+++ b/src/selectionbar.vala
@@ -6,15 +6,12 @@ private class Boxes.Selectionbar: GLib.Object {
     public Clutter.Actor actor { get { return gtk_actor; } }
     public static const float spacing = 60.0f;
 
-    private App app;
     private GtkClutter.Actor gtk_actor;
     private Gtk.Toolbar toolbar;
     private Gtk.ToggleToolButton favorite_btn;
     private Gtk.ToggleToolButton remove_btn;
 
-    public Selectionbar (App app) {
-        this.app = app;
-
+    public Selectionbar () {
         toolbar = new Gtk.Toolbar ();
         toolbar.show_arrow = false;
         toolbar.icon_size = Gtk.IconSize.LARGE_TOOLBAR;
@@ -27,7 +24,7 @@ private class Boxes.Selectionbar: GLib.Object {
         toolbar.insert (favorite_btn, 0);
         favorite_btn.icon_name = "emblem-favorite-symbolic";
         favorite_btn.clicked.connect (() => {
-           foreach (var item in app.selected_items) {
+           foreach (var item in App.app.selected_items) {
                var machine = item as Machine;
                if (machine != null)
                    machine.config.add_category ("favourite");
@@ -41,26 +38,26 @@ private class Boxes.Selectionbar: GLib.Object {
         toolbar.insert (remove_btn, 2);
         remove_btn.icon_name = "edit-delete-symbolic";
         remove_btn.clicked.connect (() => {
-            app.remove_selected_items ();
+            App.app.remove_selected_items ();
         });
         toolbar.show_all ();
 
         actor.reactive = true;
 
-        app.notify["selection-mode"].connect (() => {
+        App.app.notify["selection-mode"].connect (() => {
             update_visible ();
         });
 
-        app.notify["selected-items"].connect (() => {
+        App.app.notify["selected-items"].connect (() => {
             update_visible ();
         });
     }
 
     private void update_visible () {
-        if (!app.selection_mode)
+        if (!App.app.selection_mode)
             visible = false;
         else
-            visible = app.selected_items.length () > 0;
+            visible = App.app.selected_items.length () > 0;
     }
 
     private bool visible {
@@ -74,12 +71,12 @@ private class Boxes.Selectionbar: GLib.Object {
     private void show () {
         actor.show ();
         actor.queue_redraw ();
-        actor.animate (Clutter.AnimationMode.LINEAR, app.duration,
+        actor.animate (Clutter.AnimationMode.LINEAR, App.app.duration,
                        "opacity", 255);
     }
 
     private void hide () {
-        var anim = actor.animate (Clutter.AnimationMode.LINEAR, app.duration,
+        var anim = actor.animate (Clutter.AnimationMode.LINEAR, App.app.duration,
                                   "opacity", 0);
         anim.completed.connect (() => {
             actor.hide ();
diff --git a/src/sidebar.vala b/src/sidebar.vala
index b255927..ccaf2ca 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -16,7 +16,6 @@ private class Boxes.Sidebar: Boxes.UI {
     public TreeView user_tree_view;
     public Category category;
 
-    private App app;
     private uint width;
 
     private GtkClutter.Actor gtk_actor; // the sidebar box
@@ -34,8 +33,7 @@ private class Boxes.Sidebar: Boxes.UI {
         return selectable;
     }
 
-    public Sidebar (App app) {
-        this.app = app;
+    public Sidebar () {
         width = 200;
 
         setup_sidebar ();
@@ -44,17 +42,17 @@ private class Boxes.Sidebar: Boxes.UI {
     public override void ui_state_changed () {
         switch (ui_state) {
         case UIState.COLLECTION:
-            app.sidebar_revealer.unreveal ();
+            App.app.sidebar_revealer.unreveal ();
             notebook.page = SidebarPage.COLLECTION;
             break;
 
 		default:
-            app.sidebar_revealer.unreveal ();
+            App.app.sidebar_revealer.unreveal ();
 			break;
 
         case UIState.WIZARD:
         case UIState.PROPERTIES:
-            app.sidebar_revealer.reveal ();
+            App.app.sidebar_revealer.reveal ();
             notebook.page = ui_state == UIState.WIZARD ? SidebarPage.WIZARD : SidebarPage.PROPERTIES;
             break;
         }
@@ -93,7 +91,7 @@ private class Boxes.Sidebar: Boxes.UI {
 
             if (selectable) {
                 this.category = category;
-                app.set_category (category);
+                App.app.set_category (category);
             }
 
             (treeview == default_tree_view ? user_tree_view : default_tree_view).get_selection ().unselect_all ();
@@ -121,7 +119,7 @@ private class Boxes.Sidebar: Boxes.UI {
         var listmodel = user_tree_view.get_model () as Gtk.ListStore;
 
         listmodel.clear ();
-        foreach (var collection in app.settings.get_strv ("collections"))
+        foreach (var collection in App.app.settings.get_strv ("collections"))
             list_append (listmodel, new Category (_(collection)));
     }
 
@@ -167,7 +165,7 @@ private class Boxes.Sidebar: Boxes.UI {
         vbox.pack_end (create, false, false, 0);
         create.show ();
         create.clicked.connect (() => {
-            app.ui_state = UIState.WIZARD;
+            App.app.ui_state = UIState.WIZARD;
         });
 
         /* SidebarPage.WIZARD */
diff --git a/src/topbar.vala b/src/topbar.vala
index 78d8326..b584f41 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -13,7 +13,6 @@ private class Boxes.Topbar: Boxes.UI {
     public override Clutter.Actor actor { get { return gtk_actor; } }
     public Gtk.Label label;
 
-    private App app;
     public const uint height = 50;
 
     private GtkClutter.Actor gtk_actor; // the topbar box
@@ -27,12 +26,10 @@ private class Boxes.Topbar: Boxes.UI {
     private Gtk.Button new_btn;
     private Gtk.Label selection_label;
 
-    public Topbar (App app) {
-        this.app = app;
-
+    public Topbar () {
         setup_topbar ();
 
-        app.notify["selected-items"].connect (() => {
+        App.app.notify["selected-items"].connect (() => {
             update_selection_label ();
         });
     }
@@ -58,7 +55,7 @@ private class Boxes.Topbar: Boxes.UI {
         back_btn.valign = Gtk.Align.CENTER;
         back_btn.icon_name =  "go-previous-symbolic";
         back_btn.get_style_context ().add_class ("raised");
-        back_btn.clicked.connect ((button) => { app.ui_state = UIState.COLLECTION; });
+        back_btn.clicked.connect ((button) => { App.app.ui_state = UIState.COLLECTION; });
         toolbar_start.insert (back_btn, 0);
 
         new_btn = new Gtk.Button.with_label (_("New"));
@@ -67,7 +64,7 @@ private class Boxes.Topbar: Boxes.UI {
         var tool_item = new Gtk.ToolItem ();
         tool_item.child = new_btn;
         tool_item.valign = Gtk.Align.CENTER;
-        new_btn.clicked.connect ((button) => { app.ui_state = UIState.WIZARD; });
+        new_btn.clicked.connect ((button) => { App.app.ui_state = UIState.WIZARD; });
         toolbar_start.insert (tool_item, 1);
 
         label = new Gtk.Label ("");
@@ -95,11 +92,11 @@ private class Boxes.Topbar: Boxes.UI {
         select_btn.valign = Gtk.Align.CENTER;
         select_btn.clicked.connect (() => {
             notebook.page = TopbarPage.SELECTION;
-            app.selection_mode = true;
+            App.app.selection_mode = true;
         });
         update_select_btn_sensitivity ();
-        app.collection.item_added.connect (update_select_btn_sensitivity);
-        app.collection.item_removed.connect (update_select_btn_sensitivity);
+        App.app.collection.item_added.connect (update_select_btn_sensitivity);
+        App.app.collection.item_removed.connect (update_select_btn_sensitivity);
         toolbar_end.insert (select_btn, 1);
 
         toolbar_end.set_show_arrow (false);
@@ -131,7 +128,7 @@ private class Boxes.Topbar: Boxes.UI {
         toolbar_selection.insert (cancel_btn, 1);
         cancel_btn.clicked.connect (() => {
             select_btn.active = false;
-            app.selection_mode = false;
+            App.app.selection_mode = false;
             notebook.page = TopbarPage.COLLECTION;
         });
 
@@ -151,11 +148,11 @@ private class Boxes.Topbar: Boxes.UI {
     }
 
     private void update_select_btn_sensitivity () {
-        select_btn.sensitive = app.collection.items.length != 0;
+        select_btn.sensitive = App.app.collection.items.length != 0;
     }
 
     private void update_selection_label () {
-        var items = app.selected_items.length ();
+        var items = App.app.selected_items.length ();
         if (items > 0)
             selection_label.set_markup ("<b>" + ngettext ("%d selected", "%d selected", items).printf (items) + "</b>");
         else
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index 8eaa8ba..9be5ab2 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -4,16 +4,14 @@ using Osinfo;
 using GVir;
 
 private class Boxes.VMCreator {
-    private App app;
-    private Connection? connection { get { return app.default_connection; } }
+    private Connection? connection { get { return App.app.default_connection; } }
     private VMConfigurator configurator;
     private ulong stopped_id;
 
-    public VMCreator (App app) {
+    public VMCreator () {
         configurator = new VMConfigurator ();
-        this.app = app;
 
-        app.collection.item_added.connect (on_item_added);
+        App.app.collection.item_added.connect (on_item_added);
     }
 
     private void on_item_added (Collection collection, CollectionItem item) {
@@ -46,9 +44,9 @@ private class Boxes.VMCreator {
         if (connection == null) {
             // Wait for needed libvirt connection
             ulong handler = 0;
-            handler = app.notify["default-connection"].connect (() => {
+            handler = App.app.notify["default-connection"].connect (() => {
                 create_and_launch_vm.callback ();
-                app.disconnect (handler);
+                App.app.disconnect (handler);
             });
 
             yield;
@@ -70,18 +68,18 @@ private class Boxes.VMCreator {
         var domain = connection.create_domain (config);
         domain.start (0);
 
-        var machine = app.add_domain (app.default_source, app.default_connection, domain);
+        var machine = App.app.add_domain (App.app.default_source, App.app.default_connection, domain);
 
         if (machine != null && fullscreen) {
             ulong signal_id = 0;
 
-            signal_id = app.notify["ui-state"].connect (() => {
-                if (app.ui_state != UIState.COLLECTION)
+            signal_id = App.app.notify["ui-state"].connect (() => {
+                if (App.app.ui_state != UIState.COLLECTION)
                     return;
 
-                app.select_item (machine);
-                app.fullscreen = true;
-                app.disconnect (signal_id);
+                App.app.select_item (machine);
+                App.app.fullscreen = true;
+                App.app.disconnect (signal_id);
 
                 return;
             });
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index d680bb9..9047295 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -85,10 +85,8 @@ private class Boxes.WizardSource: GLib.Object {
     public Gtk.Entry url_entry;
 
     private MediaManager media_manager;
-    private Boxes.App app;
 
-    public WizardSource (Boxes.App app, MediaManager media_manager) {
-        this.app = app;
+    public WizardSource (MediaManager media_manager) {
         this.media_manager = media_manager;
 
         notebook = new Gtk.Notebook ();
@@ -292,7 +290,7 @@ private class Boxes.WizardSource: GLib.Object {
 
     private void launch_file_selection_dialog () {
         var dialog = new Gtk.FileChooserDialog (_("Select a device or ISO file"),
-                                                app.window,
+                                                App.app.window,
                                                 Gtk.FileChooserAction.OPEN,
                                                 Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL,
                                                 Gtk.Stock.OPEN, Gtk.ResponseType.ACCEPT);
diff --git a/src/wizard.vala b/src/wizard.vala
index 6326188..25e24e8 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -14,7 +14,6 @@ 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;
@@ -71,9 +70,9 @@ private class Boxes.Wizard: Boxes.UI {
                     skip_review_for_live = false;
                     create.begin ((source, result) => {
                         if (create.end (result))
-                            app.ui_state = UIState.COLLECTION;
+                            App.app.ui_state = UIState.COLLECTION;
                         else
-                            app.notificationbar.display_error (_("Box creation failed!"));
+                            App.app.notificationbar.display_error (_("Box creation failed!"));
                     });
                     return;
                 }
@@ -104,10 +103,9 @@ private class Boxes.Wizard: Boxes.UI {
         media_manager = new MediaManager ();
     }
 
-    public Wizard (App app) {
-        this.app = app;
-        vm_creator = new VMCreator (app);
-        wizard_source = new Boxes.WizardSource (app, media_manager);
+    public Wizard () {
+        vm_creator = new VMCreator ();
+        wizard_source = new Boxes.WizardSource (media_manager);
         wizard_source.notify["page"].connect(() => {
             if (wizard_source.page == Boxes.SourcePage.MAIN)
                 next_button.sensitive = false;
@@ -161,7 +159,7 @@ private class Boxes.Wizard: Boxes.UI {
         }
 
         source.save ();
-        app.add_collection_source (source);
+        App.app.add_collection_source (source);
         return true;
     }
 
@@ -223,7 +221,7 @@ private class Boxes.Wizard: Boxes.UI {
             page = WizardPage.SETUP;
         } catch (IOError.CANCELLED cancel_error) { // We did this, so no warning!
         } catch (GLib.Error error) {
-            app.notificationbar.display_error (error.message);
+            App.app.notificationbar.display_error (error.message);
             page = WizardPage.SOURCE;
         }
     }
@@ -240,7 +238,7 @@ private class Boxes.Wizard: Boxes.UI {
             try {
                 prepare_for_location (this.wizard_source.uri);
             } catch (GLib.Error error) {
-                app.notificationbar.display_error (error.message);
+                App.app.notificationbar.display_error (error.message);
 
                 return false;
             }
@@ -271,7 +269,7 @@ private class Boxes.Wizard: Boxes.UI {
             try {
                 (install_media as UnattendedInstaller).check_needed_info ();
             } catch (UnattendedInstallerError.SETUP_INCOMPLETE error) {
-                app.notificationbar.display_error (error.message);
+                App.app.notificationbar.display_error (error.message);
 
                 return false;
             }
@@ -332,7 +330,7 @@ private class Boxes.Wizard: Boxes.UI {
         notebook.append_page (widget, null);
 
         /* sidebar */
-        var vbox = app.sidebar.notebook.get_nth_page (Boxes.SidebarPage.WIZARD) as Gtk.VBox;
+        var vbox = App.app.sidebar.notebook.get_nth_page (Boxes.SidebarPage.WIZARD) as Gtk.VBox;
 
         var label = new Gtk.Label (title);
         label.margin_left = 25;
@@ -487,7 +485,7 @@ private class Boxes.Wizard: Boxes.UI {
         vbox.show_all ();
 
         /* topbar */
-        hbox = app.topbar.notebook.get_nth_page (Boxes.TopbarPage.WIZARD) as Gtk.HBox;
+        hbox = App.app.topbar.notebook.get_nth_page (Boxes.TopbarPage.WIZARD) as Gtk.HBox;
 
         var toolbar = new Gtk.Toolbar ();
         toolbar.icon_size = Gtk.IconSize.MENU;
@@ -510,7 +508,7 @@ private class Boxes.Wizard: Boxes.UI {
         toolbar.insert (tool_item, 1);
         cancel.clicked.connect (() => {
             wizard_source.page = SourcePage.MAIN;
-            app.ui_state = UIState.COLLECTION;
+            App.app.ui_state = UIState.COLLECTION;
         });
 
         back_button = new Gtk.Button.from_stock (Gtk.Stock.GO_BACK);
@@ -537,7 +535,7 @@ private class Boxes.Wizard: Boxes.UI {
     }
 
     public void open_with_uri (string uri, bool skip_review_for_live = true) {
-        app.ui_state = UIState.WIZARD;
+        App.app.ui_state = UIState.WIZARD;
         this.skip_review_for_live = skip_review_for_live;
 
         page = WizardPage.SOURCE;



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