[gnome-boxes/wip/show-ip: 4/9] machine: Add virtual update_info()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/show-ip: 4/9] machine: Add virtual update_info()
- Date: Fri, 3 Jul 2015 17:35:17 +0000 (UTC)
commit 08b243839c075ad7e31282b237603a13af2c3f53
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Jul 3 18:05:23 2015 +0100
machine: Add virtual update_info()
In commit b1aaa70, we consolidated the setting of 'info' to some extent
by ensuring the this property is only set by
LibvirtMachine.update_info(). This patch takes that effort further by
making LibvirtMachine.update_info() a virtual method of the base Machine
class.
This also implies that Machine no longer keep the existing status string
and instead of concatenating new strings, it simply overrides it. This
is the right thing to do IMO since no critical information is kept in
this property and so far we haven't had the need to keep two different
pieces of information at the same time in it.
https://bugzilla.gnome.org/show_bug.cgi?id=744004
src/libvirt-machine.vala | 7 ++++++-
src/machine.vala | 15 ++++++++++++---
2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index b885bfc..4d0832d 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -662,7 +662,12 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
connecting_cancellable.disconnect (cancelled_id);
}
- private void update_info () {
+ protected override void update_info () {
+ base.update_info ();
+
+ if (info != null)
+ return;
+
if (VMConfigurator.is_install_config (domain_config))
info = _("Installing…");
else if (VMConfigurator.is_live_config (domain_config))
diff --git a/src/machine.vala b/src/machine.vala
index fc9a19e..b05243b 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -254,21 +254,23 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
return Boxes.get_screenshot_filename (config.uuid);
}
+ private bool saving;
public async void save () throws GLib.Error {
if (state == Machine.MachineState.SAVED) {
debug ("Not saving '%s' since it's already in saved state.", name);
return;
}
- var info = this.info;
- this.info = (info != null)? info + "\n" : "";
- this.info += _("Saving…");
+ saving = true;
+ update_info ();
try {
yield save_real ();
} finally {
this.info = info;
}
+ saving = false;
+ update_info ();
}
public void schedule_autosave () {
@@ -368,6 +370,13 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
config.save ();
}
+ protected virtual void update_info () {
+ if (saving)
+ info = _("Saving…");
+ else
+ info = null;
+ }
+
public bool is_running () {
return state == MachineState.RUNNING;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]