[gnome-boxes] app-window: Move connect_to() from App
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] app-window: Move connect_to() from App
- Date: Fri, 8 Aug 2014 16:21:43 +0000 (UTC)
commit c88fd651f5df4b94b8a6e900f54549c57b2ebece
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Jul 16 09:52:16 2014 +0200
app-window: Move connect_to() from App
Allows to connect the current item to its window, so it should be part of
AppWindow as 'current-item' is moving from App to it.
This is needed to drop the use of AppWindow singleton and therefore to
make multiple windows possible.
https://bugzilla.gnome.org/show_bug.cgi?id=732098
src/app-window.vala | 17 +++++++++++++++++
src/app.vala | 22 +++++-----------------
2 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index c5459ba..6892831 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -11,6 +11,9 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
public CollectionItem current_item { get; set; } // current object/vm manipulated
+ public GLib.Binding status_bind { get; set; }
+ public ulong got_error_id { get; set; }
+
[CCode (notify = false)]
public bool fullscreened {
get { return WindowState.FULLSCREEN in get_window ().get_state (); }
@@ -165,6 +168,20 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
}
}
+ public void connect_to (Machine machine) {
+ current_item = machine;
+
+ // Track machine status in toobar
+ status_bind = machine.bind_property ("status", topbar, "status", BindingFlags.SYNC_CREATE);
+
+ got_error_id = machine.got_error.connect ( (message) => {
+ notificationbar.display_error (message);
+ });
+
+ if (App.app.ui_state != UIState.CREDS)
+ App.app.set_state (UIState.CREDS); // Start the CREDS state
+ }
+
[GtkCallback]
public bool on_key_pressed (Widget widget, Gdk.EventKey event) {
var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
diff --git a/src/app.vala b/src/app.vala
index 42e257e..7651511 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -39,8 +39,8 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
public GVir.Connection default_connection { owned get { return LibvirtBroker.get_default
().get_connection ("QEMU Session"); } }
public CollectionSource default_source { get { return sources.get ("QEMU Session"); } }
- private GLib.Binding status_bind;
- private ulong got_error_id;
+ public GLib.Binding status_bind { get; set; }
+ public ulong got_error_id { get; set; }
public App () {
application_id = "org.gnome.Boxes";
@@ -167,6 +167,8 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
window = new Boxes.AppWindow (this);
window.setup_ui ();
bind_property ("current-item", window, "current-item", BindingFlags.BIDIRECTIONAL);
+ bind_property ("status-bind", window, "status-bind", BindingFlags.BIDIRECTIONAL);
+ bind_property ("got-error-id", window, "got-error-id", BindingFlags.BIDIRECTIONAL);
set_state (UIState.COLLECTION);
window.present ();
@@ -523,20 +525,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
delete_machines_undoable ((owned) selected_items, message);
}
- public void connect_to (Machine machine) {
- current_item = machine;
-
- // Track machine status in toobar
- status_bind = machine.bind_property ("status", window.topbar, "status", BindingFlags.SYNC_CREATE);
-
- got_error_id = machine.got_error.connect ( (message) => {
- window.notificationbar.display_error (message);
- });
-
- if (ui_state != UIState.CREDS)
- set_state (UIState.CREDS); // Start the CREDS state
- }
-
public void select_item (CollectionItem item) {
if (ui_state == UIState.COLLECTION && !selection_mode) {
current_item = item;
@@ -544,7 +532,7 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
if (current_item is Machine) {
var machine = current_item as Machine;
- connect_to (machine);
+ window.connect_to (machine);
} else
warning ("unknown item, fix your code");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]