[gnome-boxes] properties: Tame the 'Reboot required' notifications
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] properties: Tame the 'Reboot required' notifications
- Date: Tue, 11 Feb 2014 13:40:18 +0000 (UTC)
commit a35b2d0cfe5717f211c71a53c4bbd7ef3a67590a
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Feb 11 13:28:33 2014 +0000
properties: Tame the 'Reboot required' notifications
Instead of annoying user with these notifications each time they make a
change, lets just show it once when user is done changing all the
properties. Notification is only shown if any of the properties changed
needs a restart to be in effect.
https://bugzilla.gnome.org/show_bug.cgi?id=710300
src/libvirt-machine-properties.vala | 16 +++-------------
src/properties.vala | 22 +++++++++++++++++++---
2 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 7e20d81..685cb55 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -39,7 +39,6 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
// This will take effect only after next reboot
machine.domain.set_config (config);
- notify_reboot_required ();
}
private void try_enable_smartcard () throws GLib.Error {
@@ -49,7 +48,6 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
// This will take effect only after next reboot
machine.domain.set_config (config);
- notify_reboot_required ();
}
private string collect_logs () {
@@ -234,6 +232,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
try_enable_usb_redir ();
machine.update_domain_config ();
property.refresh_properties ();
+ property.reboot_required = true;
} catch (GLib.Error error) {
warning ("Failed to enable usb");
}
@@ -251,6 +250,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
try_enable_smartcard ();
machine.update_domain_config ();
property.refresh_properties ();
+ property.reboot_required = true;
} catch (GLib.Error error) {
warning ("Failed to enable smartcard");
}
@@ -441,7 +441,6 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
config.set ("current-memory", ram);
machine.domain.set_config (config);
debug ("RAM changed to %llu KiB", ram);
- notify_reboot_required ();
} catch (GLib.Error error) {
warning ("Failed to change RAM of box '%s' to %llu KiB: %s",
machine.domain.get_name (),
@@ -449,21 +448,12 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
error.message);
}
- if (machine.is_on ())
- update_ram_property (property);
+ update_ram_property (property);
return false;
};
}
- private void notify_reboot_required () {
- if (!machine.is_on () && machine.state != Machine.MachineState.SAVED)
- return;
-
- var message = _("Changes require restart of '%s'. Attempt restart?").printf (machine.name);
- App.app.notificationbar.display_for_action (message, _("_Yes"), machine.restart);
- }
-
private SizeProperty? add_storage_property (ref List<Boxes.Property> list) {
if (machine.importing || machine.storage_volume == null)
return null;
diff --git a/src/properties.vala b/src/properties.vala
index 434a332..e2f9100 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -91,9 +91,15 @@ private class Boxes.Properties: Gtk.Notebook, Boxes.UI {
show_all ();
}
- public void flush_changes () {
- foreach (var property in properties)
+ public bool flush_changes () {
+ var reboot_required = false;
+
+ foreach (var property in properties) {
property.flush ();
+ reboot_required |= property.reboot_required;
+ }
+
+ return reboot_required;
}
}
@@ -188,9 +194,19 @@ private class Boxes.Properties: Gtk.Notebook, Boxes.UI {
populate ();
} else if (previous_ui_state == UIState.PROPERTIES) {
+ var reboot_required = false;
+
for (var i = 0; i < PropertiesPage.LAST; i++) {
var page = get_data<PageWidget> (@"boxes-property-$i");
- page.flush_changes ();
+ reboot_required |= page.flush_changes ();
+ }
+
+ var machine = App.app.current_item as Machine;
+ if (reboot_required && (machine.is_on () || machine.state == Machine.MachineState.SAVED)) {
+ var message = _("Changes require restart of '%s'. Attempt restart?").printf (machine.name);
+ App.app.notificationbar.display_for_action (message, _("_Yes"), () => {
+ machine.restart ();
+ });
}
if (restore_fullscreen) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]