[gnome-boxes] display-config: save last-seen-name
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] display-config: save last-seen-name
- Date: Mon, 13 Aug 2012 12:20:23 +0000 (UTC)
commit 9253b50dcbce22377e63a7f6f52b172409998e17
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Sat Aug 4 14:53:05 2012 +0200
display-config: save last-seen-name
We will use this value when doing offline searches, to avoid having to
connect to all the brokers and introspecting their box to find out
their name. This is mostly a cache, and in case of remote-display, it
is even redundant, but that doesn't matter much.
https://bugzilla.gnome.org/show_bug.cgi?id=681246
src/collection-source.vala | 2 ++
src/display-config.vala | 13 +++++++++++--
src/libvirt-machine.vala | 2 +-
src/remote-machine.vala | 2 +-
4 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/collection-source.vala b/src/collection-source.vala
index e7ef13f..43de3e3 100644
--- a/src/collection-source.vala
+++ b/src/collection-source.vala
@@ -7,6 +7,8 @@ private interface Boxes.IConfig {
protected abstract bool has_file { get; set; }
public void save () {
+ // FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=681191
+ // avoid writing if the keyfile is not modified
keyfile_save (keyfile, get_user_pkgconfig_source (filename), has_file);
has_file = true;
}
diff --git a/src/display-config.vala b/src/display-config.vala
index 9e9cfc6..bcffc7d 100644
--- a/src/display-config.vala
+++ b/src/display-config.vala
@@ -17,17 +17,26 @@ private class Boxes.DisplayConfig: GLib.Object, Boxes.IConfig {
private string group;
+ public string? last_seen_name {
+ owned get { return get_string (group, "last-seen-name"); }
+ private set { keyfile.set_string (group, "last-seen-name", value); }
+ }
+
public string[]? categories {
owned get { return get_string_list (group, "categories"); }
set { keyfile.set_string_list (group, "categories", value); }
}
- public DisplayConfig (CollectionSource source, string? subgroup = null) {
+ public DisplayConfig (CollectionSource source, string last_seen_name, string? subgroup = null) {
this.source = source;
-
this.group = "display";
if (subgroup != null)
this.group += " " + subgroup;
+
+ if (this.last_seen_name != last_seen_name) {
+ this.last_seen_name = last_seen_name;
+ save ();
+ }
}
public void add_category (string category) {
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 1589b78..4b3b35c 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -87,7 +87,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
base (source, item_name);
debug ("new libvirt machine: " + domain.get_name ());
- this.config = new DisplayConfig (source, domain.get_uuid ());
+ this.config = new DisplayConfig (source, this.name, domain.get_uuid ());
this.connection = connection;
this.domain = domain;
diff --git a/src/remote-machine.vala b/src/remote-machine.vala
index 84e02a2..e7393a3 100644
--- a/src/remote-machine.vala
+++ b/src/remote-machine.vala
@@ -9,7 +9,7 @@ private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IPropertiesProvider {
// assume the remote is running for now
state = MachineState.RUNNING;
- config = new DisplayConfig (source);
+ config = new DisplayConfig (source, this.name);
source.bind_property ("name", this, "name", BindingFlags.DEFAULT);
load_screenshot ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]