ab12a32
From edaf892e8fdcf2ceb956e8dc0a41c928c3fff13f Mon Sep 17 00:00:00 2001
9b94ca0
From: Hans de Goede <hdegoede@redhat.com>
9b94ca0
Date: Wed, 19 Jun 2013 16:47:41 +0200
ab12a32
Subject: [PATCH 09/11] cheese-preferences: Simplify remove_camera_device
9b94ca0
9b94ca0
Now that we cache the device-node for the active camera, remove_camera_device
9b94ca0
and its callers can be simplified.
9b94ca0
9b94ca0
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
9b94ca0
---
9b94ca0
 src/cheese-preferences.vala | 19 ++++++-------------
9b94ca0
 1 file changed, 6 insertions(+), 13 deletions(-)
9b94ca0
9b94ca0
diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala
ab12a32
index c46a1a5..6e0bbd5 100644
9b94ca0
--- a/src/cheese-preferences.vala
9b94ca0
+++ b/src/cheese-preferences.vala
ab12a32
@@ -506,12 +506,6 @@ public class Cheese.PreferencesDialog : GLib.Object
9b94ca0
       TreeIter iter;
9b94ca0
       camera_model.get_iter_first (out iter);
9b94ca0
 
9b94ca0
-      // Combobox active element.
9b94ca0
-      TreeIter active_iter;
9b94ca0
-      Cheese.CameraDevice active_device;
9b94ca0
-      source_combo.get_active_iter (out active_iter);
9b94ca0
-      camera_model.get (active_iter, 1, out active_device, -1);
9b94ca0
-
9b94ca0
       // Find which device was removed.
9b94ca0
       bool device_removed = false;
9b94ca0
       devices.foreach ((device) =>
ab12a32
@@ -523,7 +517,7 @@ public class Cheese.PreferencesDialog : GLib.Object
9b94ca0
         // Found the device that was removed.
9b94ca0
         if (strcmp (old_device.device_node, new_device.device_node) != 0)
9b94ca0
         {
9b94ca0
-            remove_camera_device (iter, new_device, active_device);
9b94ca0
+            remove_camera_device (iter, new_device);
9b94ca0
             device_removed = true;
9b94ca0
             // Remember, this is from the anonymous function!
9b94ca0
             return;
ab12a32
@@ -536,7 +530,7 @@ public class Cheese.PreferencesDialog : GLib.Object
9b94ca0
       {
9b94ca0
         Cheese.CameraDevice old_device;
9b94ca0
         camera_model.get (iter, 1, out old_device, -1);
9b94ca0
-        remove_camera_device (iter, old_device, active_device);
9b94ca0
+        remove_camera_device (iter, old_device);
9b94ca0
       }
9b94ca0
     }
9b94ca0
   }
ab12a32
@@ -571,16 +565,15 @@ public class Cheese.PreferencesDialog : GLib.Object
9b94ca0
    * Remove the supplied camera device from the device combo box model.
9b94ca0
    *
9b94ca0
    * @param iter the iterator of the device to remove
9b94ca0
-   * @param device_node the device to remove from the combo box model
9b94ca0
-   * @param active_device_node the currently-active camera device
9b94ca0
+   * @param device the device to remove from the combo box model
9b94ca0
    */
9b94ca0
-  private void remove_camera_device (TreeIter iter, Cheese.CameraDevice device_node,
9b94ca0
-                             Cheese.CameraDevice active_device_node)
9b94ca0
+  private void remove_camera_device (TreeIter iter,
9b94ca0
+                                     Cheese.CameraDevice device)
9b94ca0
   {
9b94ca0
       unowned GLib.PtrArray devices = camera.get_camera_devices ();
9b94ca0
 
9b94ca0
       // Check if the camera that we want to remove, is the active one
9b94ca0
-      if (strcmp (device_node.device_node, active_device_node.device_node) == 0)
9b94ca0
+      if (device.device_node == camera_device_node)
9b94ca0
       {
9b94ca0
         if (devices.len > 0)
9b94ca0
           set_new_available_camera_device (iter);
9b94ca0
-- 
9b94ca0
1.8.3.1
9b94ca0