[gnome-boxes] spice-display: Simplify USB devices code a bit



commit c835b7c1c659e8a8d4799c1a3cf165ff366f0d7b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Feb 20 17:17:31 2015 +0000

    spice-display: Simplify USB devices code a bit

 src/spice-display.vala |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/spice-display.vala b/src/spice-display.vala
index f0f9e8f..001516a 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -287,27 +287,28 @@ private class Boxes.SpiceDisplay: Boxes.Display {
             if (PropertyCreationFlag.NO_USB in flags || !Config.HAVE_USBREDIR|| !connected)
                 break;
 
-            bool found_dev = false;
-            Boxes.Property usb_property = null;
             try {
                 var manager = UsbDeviceManager.get (session);
                 var devs = get_usb_devices (manager);
 
+                if (devs.length <= 0)
+                    return list;
+
                 devs.sort ( (a, b) => {
                     string str_a = a.get_description ("    %1$s %2$s");
                     string str_b = b.get_description ("    %1$s %2$s");
 
                     return strcmp (str_a, str_b);
                 });
+
+                var usb_property = add_property (ref list, _("USB devices"), new Gtk.Label (""));
+
                 for (int i = 0; i < devs.length; i++) {
                     var dev = devs[i];
 
                     var dev_toggle = new Gtk.Switch ();
                     dev_toggle.halign =  Gtk.Align.START;
 
-                    if (!found_dev)
-                        usb_property = add_property (ref list, _("USB devices"), new Gtk.Label (""));
-                    found_dev = true;
                     usb_property = add_property (ref list, dev.get_description ("    %1$s %2$s"), 
dev_toggle);
                     dev_toggle.active = manager.is_device_connected (dev);
 
@@ -333,9 +334,6 @@ private class Boxes.SpiceDisplay: Boxes.Display {
                     });
                 }
 
-                if (usb_property == null)
-                    break;
-
                 manager.device_added.connect ((manager, dev) => {
                     usb_property.refresh_properties ();
                 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]