[gnome-boxes/gnome-3-14] libvirt-machine-props: Ensure name change is saved
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/gnome-3-14] libvirt-machine-props: Ensure name change is saved
- Date: Mon, 27 Oct 2014 18:39:53 +0000 (UTC)
commit 391a128585e876b8695799875aedb152dd284362
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Oct 24 15:31:37 2014 +0100
libvirt-machine-props: Ensure name change is saved
The two different UI components (name property and toolbar title) that
can be used to change the name of machine were using two different
methods to do so and hence changing the name from toolbar title wasn't
getting the name change saved.
This patch unifies the method to change the name and ensures that change
of name is saved.
https://bugzilla.gnome.org/show_bug.cgi?id=736096
src/libvirt-machine-properties.vala | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 07a6d2c..657875a 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -11,26 +11,22 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
this.machine = machine;
machine.notify["name"].connect (() => {
- try_change_name (machine.name);
+ save_machine_name_change ();
});
}
- private bool try_change_name (string name) {
- if (machine.name == name)
- return false;
-
+ private bool save_machine_name_change () {
try {
var config = machine.domain.get_config (GVir.DomainXMLFlags.INACTIVE);
// Te use libvirt "title" for free form user name
- config.title = name;
+ config.title = machine.name;
// This will take effect only after next reboot, but we use pending/inactive config for name and
title
machine.domain.set_config (config);
- machine.name = name;
return true;
} catch (GLib.Error error) {
- warning ("Failed to change title of box '%s' to '%s': %s",
- machine.domain.get_name (), name, error.message);
+ warning ("Failed to save change of title of box from '%s' to '%s': %s",
+ machine.domain.get_name (), machine.name, error.message);
return false;
}
}
@@ -121,7 +117,12 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
var property = add_string_property (ref list, _("Name"), machine.name);
property.editable = true;
property.changed.connect ((property, name) => {
- return try_change_name (name);
+ machine.name = name;
+
+ // Its unlikely that machine name change fails and even if it
+ // does, name is still changed in the UI at least (it just
+ // doesn't get saved).
+ return true;
});
var name_property = property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]