summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-06-19 17:29:28 +0200
committerHans de Goede <hdegoede@redhat.com>2013-09-17 14:57:42 +0200
commit0c841182b61efe48e98c6d2dea1f8c7ab7f464ef (patch)
treefa1a325b733d3380a4ab206a80826b66d8ce1d03
parentedaf892e8fdcf2ceb956e8dc0a41c928c3fff13f (diff)
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>
-rw-r--r--src/cheese-preferences.vala26
1 files 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)