summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-06-18 11:59:55 +0200
committerHans de Goede <hdegoede@redhat.com>2013-09-17 14:57:41 +0200
commita1805cadf3e6f7396a323c26e391cd91c28c829f (patch)
treef903c50b3196183165c8a3bf7726e4ebc938b04f
parent27d41d89a35c3c6b25f5c908d05c3365721e09bc (diff)
cheese: Properly deal with going from 0 -> 1 devices
Before this patch cheese showed a "No device found" message when started without any devices connected, and would keep showing this after the user plugged in a webcam. The new cam also could not be selected from the preferences dialog. After this patch cheese will automatically switch to showing video from a newly plugged in webcam (when it had no devices before). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/cheese-application.vala1
-rw-r--r--src/cheese-preferences.vala28
2 files changed, 26 insertions, 3 deletions
diff --git a/src/cheese-application.vala b/src/cheese-application.vala
index aa62a2e..fbb1145 100644
--- a/src/cheese-application.vala
+++ b/src/cheese-application.vala
@@ -368,6 +368,7 @@ public class Cheese.Application : Gtk.Application
mode.set_enabled (false);
shoot.set_enabled (false);
+ preferences_dialog.camera_stop ();
main_window.camera_state_change_null ();
break;
default:
diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala
index a73bb46..06929f5 100644
--- a/src/cheese-preferences.vala
+++ b/src/cheese-preferences.vala
@@ -24,6 +24,8 @@ using Gtk;
public class Cheese.PreferencesDialog : GLib.Object
{
private Cheese.Camera camera;
+ private bool camera_is_setup;
+ private bool camera_is_playing;
private GLib.Settings settings;
@@ -122,8 +124,16 @@ public class Cheese.PreferencesDialog : GLib.Object
{
try
{
- camera.setup (null);
- camera.play ();
+ if (!camera_is_setup)
+ {
+ camera.setup (null);
+ camera_is_setup = true;
+ }
+ if (!camera_is_playing)
+ {
+ camera.play ();
+ camera_is_playing = true;
+ }
camera_changed ();
}
catch (Error err)
@@ -133,6 +143,14 @@ public class Cheese.PreferencesDialog : GLib.Object
}
/**
+ * Call this when the gstreamer pipe transitions to NULL
+ */
+ public void camera_stop ()
+ {
+ camera_is_playing = false;
+ }
+
+ /**
* Set up combo box cell renderers.
*/
private void setup_combo_box_models ()
@@ -268,7 +286,7 @@ public class Cheese.PreferencesDialog : GLib.Object
combo.model.get (iter, 1, out dev);
camera.set_device_by_device_node (dev.get_device_node ());
camera.switch_camera_device ();
- camera_changed ();
+ camera_play ();
}
/**
@@ -529,6 +547,7 @@ public class Cheese.PreferencesDialog : GLib.Object
{
TreeIter iter;
Cheese.CameraDevice dev = (Cheese.CameraDevice) device;
+ bool was_empty = camera_model.iter_n_children (null) == 0;
camera_model.append (out iter);
camera_model.set (iter,
@@ -537,6 +556,9 @@ public class Cheese.PreferencesDialog : GLib.Object
if (camera_model.iter_n_children (null) > 1)
source_combo.sensitive = true;
+
+ if (was_empty)
+ source_combo.set_active_iter (iter);
}
/**