[gnome-boxes] Dynamically refresh USB devices properties
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Dynamically refresh USB devices properties
- Date: Tue, 5 Mar 2013 16:08:47 +0000 (UTC)
commit d4a4400deb241432addfdc00ca00bb9c65ada2ea
Author: Christophe Fergeau <cfergeau redhat com>
Date: Tue Mar 5 13:14:17 2013 +0100
Dynamically refresh USB devices properties
Currently, when an USB device is plugged/unplugged, if the user
is looking at the devices property page of a box, the list of devices
does not automatically add/remove the new device.
The IPropertiesProvider interface does not provide an easy way to
dynamically add/remove properties, however given one property,
it's possible to trigger a refresh of the whole property page by
emitting the Property::refresh-properties signal.
This commit uses the 'automatic USB redirection' property to trigger
a page refresh as it will always be present when USB redirection is
supported.
https://bugzilla.gnome.org/show_bug.cgi?id=695207
src/spice-display.vala | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 250c3f7..63a08e3 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -285,7 +285,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
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);
+ Boxes.Property usb_property = add_property (ref list, _("Redirect new USB devices"), toggle);
if (connected) {
bool found_dev = false;
@@ -323,6 +323,19 @@ private class Boxes.SpiceDisplay: Boxes.Display {
}
});
}
+ manager.device_added.connect ((manager, dev) => {
+ usb_property.refresh_properties ();
+ });
+ manager.device_removed.connect ((manager, dev) => {
+ Idle.add (() => {
+ // FIXME: This is done in an idle to workaround a bug in spice-gtk 0.18
where calling
+ // UsbDeviceManager.get_devices() from the "device-removed" signal callback
will
+ // return a list of devices which still contains the removed device.
+ // This is fixed in spice-gtk by 09124ecc50.
+ usb_property.refresh_properties ();
+ return false;
+ });
+ });
} catch (GLib.Error error) {
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]