[gnome-boxes] machine: Add unschedule_autosave()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] machine: Add unschedule_autosave()
- Date: Wed, 12 Nov 2014 14:46:23 +0000 (UTC)
commit 5ccfbef9cc63f1e84d89149319039bc94d285764
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Nov 11 20:48:28 2014 +0000
machine: Add unschedule_autosave()
Add a method to unschedule a previously scheduled autosave.
https://bugzilla.gnome.org/show_bug.cgi?id=694931
src/machine.vala | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/machine.vala b/src/machine.vala
index d8ba8b1..fe925ce 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -34,6 +34,8 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
private string username;
private string password;
+ private uint autosave_timeout_id;
+
public Cancellable connecting_cancellable { get; protected set; }
public enum MachineState {
@@ -255,17 +257,27 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
}
public void schedule_autosave () {
- if (!can_save)
+ if (!can_save || autosave_timeout_id != 0)
return;
debug ("Scheduling autosave for '%s'", name);
- Timeout.add_seconds (AUTOSAVE_TIMEOUT, () => {
+ autosave_timeout_id = Timeout.add_seconds (AUTOSAVE_TIMEOUT, () => {
try_save.begin ();
+ autosave_timeout_id = 0;
return false;
});
}
+ public void unschedule_autosave () {
+ if (autosave_timeout_id == 0)
+ return;
+
+ debug ("Unscheduling autosave for '%s'", name);
+ Source.remove (autosave_timeout_id);
+ autosave_timeout_id = 0;
+ }
+
protected virtual async void save_real () throws GLib.Error {
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]