[gnome-boxes] Add Machine:stay-on-display
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Add Machine:stay-on-display
- Date: Mon, 30 Jul 2012 17:14:25 +0000 (UTC)
commit 3cdd3bee2967eeca8ad57d8fda93db0da9bc51e6
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Thu Jul 19 19:00:28 2012 +0200
Add Machine:stay-on-display
Learn to stay on display UI state after disconnection.
This is a simplified version of
https://bugzilla.gnome.org/show_bug.cgi?id=677101
https://bugzilla.gnome.org/show_bug.cgi?id=680293
src/libvirt-machine.vala | 57 ++++++++++++++++++++++++---------------------
src/machine.vala | 4 ++-
2 files changed, 33 insertions(+), 28 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index b617c01..a94ec94 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -14,38 +14,30 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
set { source.set_boolean ("source", "save-on-quit", value); }
}
- private ulong started_id;
+ private bool _connect_display;
+ public override void disconnect_display () {
+ stay_on_display = false;
+
+ base.disconnect_display ();
+
+ _connect_display = false;
+ }
+
public override void connect_display () {
- if (display != null)
+ if (_connect_display)
return;
- if (state != MachineState.RUNNING) {
- if (started_id != 0)
- return;
-
- if (state == MachineState.PAUSED) {
- started_id = domain.resumed.connect (() => {
- domain.disconnect (started_id);
- started_id = 0;
- connect_display ();
- });
- try {
+ _connect_display = true;
+ try {
+ if (state != MachineState.RUNNING) {
+ if (state == MachineState.PAUSED) {
domain.resume ();
- } catch (GLib.Error error) {
- warning (error.message);
- }
- } else {
- started_id = domain.started.connect (() => {
- domain.disconnect (started_id);
- started_id = 0;
- connect_display ();
- });
- try {
+ } else {
domain.start (0);
- } catch (GLib.Error error) {
- warning (error.message);
}
}
+ } catch (GLib.Error error) {
+ warning (error.message);
}
update_display ();
@@ -78,7 +70,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
stats_cancellable = new Cancellable ();
}
- public void update_domain_config () {
+ private void update_domain_config () {
try {
domain_config = domain.get_config (GVir.DomainXMLFlags.NONE);
@@ -89,6 +81,14 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
}
}
+ private void reconnect_display () {
+ if (!_connect_display)
+ return;
+
+ disconnect_display ();
+ connect_display ();
+ }
+
public LibvirtMachine (CollectionSource source,
GVir.Connection connection,
GVir.Domain domain) throws GLib.Error {
@@ -125,7 +125,10 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
state = MachineState.UNKNOWN;
}
- domain.started.connect (() => { state = MachineState.RUNNING; });
+ domain.started.connect (() => {
+ state = MachineState.RUNNING;
+ reconnect_display ();
+ });
domain.suspended.connect (() => { state = MachineState.PAUSED; });
domain.resumed.connect (() => { state = MachineState.RUNNING; });
domain.stopped.connect (() => { state = MachineState.STOPPED; });
diff --git a/src/machine.vala b/src/machine.vala
index b31d7ac..92f8219 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -9,6 +9,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
public Boxes.CollectionSource source;
public Boxes.DisplayConfig config;
public Gdk.Pixbuf? pixbuf { get; set; }
+ public bool stay_on_display;
private ulong show_id;
private ulong hide_id;
@@ -81,7 +82,8 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
disconnected_id = _display.disconnected.connect (() => {
message (@"display $name disconnected");
- App.app.ui_state = Boxes.UIState.COLLECTION;
+ if (!stay_on_display)
+ App.app.ui_state = Boxes.UIState.COLLECTION;
});
need_password_id = _display.notify["need-password"].connect (() => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]