[gnome-boxes] Don't show usb properties if no usb support
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Don't show usb properties if no usb support
- Date: Wed, 14 Nov 2012 16:26:55 +0000 (UTC)
commit cfde2d768bccad86ffb0eedd87d590c946ba5d96
Author: Alexander Larsson <alexl redhat com>
Date: Mon Nov 5 17:12:31 2012 +0100
Don't show usb properties if no usb support
If usb redirection support is not configured in the VM, don't
add usb-related options.
Also, rename usb swich label to something more descriptive.
https://bugzilla.gnome.org/show_bug.cgi?id=672268
src/i-properties-provider.vala | 3 ++-
src/libvirt-machine.vala | 22 ++++++++++++++++++++++
src/spice-display.vala | 12 +++++++-----
3 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/src/i-properties-provider.vala b/src/i-properties-provider.vala
index 2cb1e9e..e9c88cb 100644
--- a/src/i-properties-provider.vala
+++ b/src/i-properties-provider.vala
@@ -55,7 +55,8 @@ private delegate void PropertySizeChanged (Boxes.Property property, uint64 value
[Flags]
public enum PropertyCreationFlag {
- NONE = 0
+ NONE = 0,
+ NO_USB = 1<<0
}
private interface Boxes.IPropertiesProvider: GLib.Object {
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 4cd11cb..1d6c2f0 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -331,6 +331,28 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
if (display != null)
add_string_property (ref list, _("Protocol"), display.protocol);
break;
+
+ case PropertiesPage.DEVICES:
+ bool has_usb_redir = false;
+ // We look at the INACTIVE config here, because we want to show the usb
+ // widgetry if usb has been added already but we have not rebooted
+ try {
+ var inactive_config = domain.get_config (GVir.DomainXMLFlags.INACTIVE);
+ foreach (var device in inactive_config.get_devices ()) {
+ if (device is GVirConfig.DomainRedirdev) {
+ has_usb_redir = true;
+ break;
+ }
+ }
+ } catch (GLib.Error error) {
+ warning ("Failed to fetch configuration for domain '%s': %s", domain.get_name (), error.message);
+ }
+
+ if (!has_usb_redir)
+ flags |= PropertyCreationFlag.NO_USB;
+ }
+
+ break;
}
if (display != null)
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 0173599..7ed52f0 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -202,11 +202,13 @@ private class Boxes.SpiceDisplay: Boxes.Display {
break;
case PropertiesPage.DEVICES:
- var toggle = new Gtk.Switch ();
- gtk_session.bind_property ("auto-usbredir", toggle, "active",
- BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
- toggle.halign = Gtk.Align.START;
- add_property (ref list, _("USB redirection"), toggle);
+ if (!(PropertyCreationFlag.NO_USB in flags)) {
+ var toggle = new Gtk.Switch ();
+ gtk_session.bind_property ("auto-usbredir", toggle, "active",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
+ toggle.halign = Gtk.Align.START;
+ add_property (ref list, _("Redirect new USB devices"), toggle);
+ }
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]