cheese/0010-cheese-preferences-Cleanly-handle-going-from-1-0-dev.patch
2013-09-18 10:48:12 +02:00

67 lines
2.3 KiB
Diff

From 0c841182b61efe48e98c6d2dea1f8c7ab7f464ef Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 19 Jun 2013 17:29:28 +0200
Subject: [PATCH 10/11] cheese-preferences: Cleanly handle going from 1 -> 0
devices
Cleanly handle going from 1 -> 0 devices and going from 1 -> 0 -> 1 devices.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
src/cheese-preferences.vala | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala
index 6e0bbd5..fc72435 100644
--- a/src/cheese-preferences.vala
+++ b/src/cheese-preferences.vala
@@ -278,13 +278,13 @@ public class Cheese.PreferencesDialog : GLib.Object
[CCode (instance_pos = -1)]
public void on_source_change (Gtk.ComboBox combo)
{
- // TODO: Handle going from 1 to 0 devices, cleanly!
- return_if_fail (camera.num_camera_devices > 0);
-
TreeIter iter;
Cheese.CameraDevice dev;
string dev_node;
+ if (combo.get_active () == -1)
+ return;
+
combo.get_active_iter (out iter);
combo.model.get (iter, 1, out dev);
dev_node = dev.get_device_node ();
@@ -570,16 +570,20 @@ public class Cheese.PreferencesDialog : GLib.Object
private void remove_camera_device (TreeIter iter,
Cheese.CameraDevice device)
{
- unowned GLib.PtrArray devices = camera.get_camera_devices ();
-
- // Check if the camera that we want to remove, is the active one
- if (device.device_node == camera_device_node)
+ if (camera.num_camera_devices == 0) /* Last camera gone? */
{
- if (devices.len > 0)
- set_new_available_camera_device (iter);
- else
- this.dialog.hide();
+ ListStore resolution_model = new ListStore (2, typeof (string),
+ typeof (Cheese.VideoFormat));
+ photo_resolution_combo.model = resolution_model;
+ video_resolution_combo.model = resolution_model;
+ camera_device_node = "";
+ camera_error(_("No device found"));
}
+ else if (device.device_node == camera_device_node)
+ {
+ set_new_available_camera_device (iter);
+ }
+
camera_model.remove (iter);
if (camera_model.iter_n_children (null) <= 1)
--
1.8.3.1