[gnome-boxes] machine: is_on() now a property
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] machine: is_on() now a property
- Date: Tue, 7 Jul 2015 17:32:58 +0000 (UTC)
commit 03316ae271787a29c2b8e6a2a7eacc348280a50c
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Jul 6 09:20:15 2015 +0200
machine: is_on() now a property
This is needed to make how the machine's state is checked, consistent.
https://bugzilla.gnome.org/show_bug.cgi?id=752007
src/libvirt-machine-properties.vala | 4 ++--
src/libvirt-machine.vala | 2 +-
src/machine.vala | 14 ++++++++------
src/properties.vala | 2 +-
src/vm-creator.vala | 2 +-
5 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 1164362..235aa56 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -106,7 +106,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
var list = new List<Boxes.Property> ();
// the wizard may want to modify display properties, before connect_display()
- if (machine.is_on () && machine.display == null)
+ if (machine.is_on && machine.display == null)
try {
machine.update_display ();
} catch (GLib.Error e) {
@@ -479,7 +479,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
property.changed.connect (on_ram_changed);
machine.notify["state"].connect (() => {
- if (!machine.is_on ())
+ if (!machine.is_on)
property.reboot_required = false;
});
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index c8ce457..d6aa843 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -645,7 +645,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
}
public string? get_ip_address () {
- if (system_virt_connection == null || !is_on ())
+ if (system_virt_connection == null || is_on)
return null;
var mac = get_mac_address ();
diff --git a/src/machine.vala b/src/machine.vala
index b07e98a..e0e8186 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -40,6 +40,14 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
}
}
+ public bool is_on {
+ get {
+ return state == MachineState.RUNNING ||
+ state == MachineState.PAUSED ||
+ state == MachineState.SLEEPING;
+ }
+ }
+
private ulong show_id;
private ulong hide_id;
private ulong disconnected_id;
@@ -385,12 +393,6 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
info = null;
}
- public bool is_on () {
- return state == MachineState.RUNNING ||
- state == MachineState.PAUSED ||
- state == MachineState.SLEEPING;
- }
-
private void save_pixbuf_as_screenshot (Gdk.Pixbuf? pixbuf) {
try {
pixbuf.save (get_screenshot_filename (), "png");
diff --git a/src/properties.vala b/src/properties.vala
index 16d701f..712de4e 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -77,7 +77,7 @@ private class Boxes.Properties: Gtk.Notebook, Boxes.UI {
}
var machine = window.current_item as Machine;
- if (reboot_required && (machine.is_on () || machine.state == Machine.MachineState.SAVED)) {
+ if (reboot_required && (machine.is_on || machine.state == Machine.MachineState.SAVED)) {
var message = _("Changes require restart of '%s'.").printf (machine.name);
window.notificationbar.display_for_action (message, _("_Restart"), () => {
machine.restart ();
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index c17b2c0..04f34fc 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -121,7 +121,7 @@ private class Boxes.VMCreator {
private void on_machine_state_changed (GLib.Object object, GLib.ParamSpec? pspec = null) {
var machine = object as LibvirtMachine;
- if (machine.is_on ())
+ if (machine.is_on)
return;
if (machine.deleted) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]