summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-06-18 11:40:41 +0200
committerHans de Goede <hdegoede@redhat.com>2013-09-17 14:57:41 +0200
commit27d41d89a35c3c6b25f5c908d05c3365721e09bc (patch)
tree481b09d45814bb428d7a13f6a71c51c218dabe9b
parente3480dd3e55665e9e48a39a74fd7ee4e56bc0736 (diff)
cheese: Move camera_setup to cheese-preferences
cheese-preferences already keeps track of which cameras there are and is in control of selecting camera resolution and the source-device. This patch also makes it control of start / stop, thereby logical grouping all camera-control code in a single place. Having all camera control code in a single place makes dealing with various hotplug issues a lot easier. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/cheese-application.vala20
-rw-r--r--src/cheese-preferences.vala24
-rw-r--r--src/vapi/cheese-common.vapi2
3 files changed, 27 insertions, 19 deletions
diff --git a/src/cheese-application.vala b/src/cheese-application.vala
index 0b6689f..aa62a2e 100644
--- a/src/cheese-application.vala
+++ b/src/cheese-application.vala
@@ -158,8 +158,10 @@ public class Cheese.Application : Gtk.Application
main_window.key_press_event.connect (on_webcam_key_pressed);
main_window.show ();
- setup_camera ();
+ create_camera ();
preferences_dialog = new PreferencesDialog (camera);
+ preferences_dialog.camera_error.connect (main_window.show_error);
+ preferences_dialog.camera_play ();
var preferences = this.lookup_action ("preferences");
preferences.notify["enabled"].connect (on_preferences_enabled);
this.add_window (main_window);
@@ -267,7 +269,7 @@ public class Cheese.Application : Gtk.Application
/**
* Setup the camera listed in GSettings.
*/
- public void setup_camera ()
+ public void create_camera ()
{
var effects = this.lookup_action ("effects") as SimpleAction;
var mode = this.lookup_action ("mode") as SimpleAction;
@@ -281,19 +283,6 @@ public class Cheese.Application : Gtk.Application
settings.get_int ("photo-x-resolution"),
settings.get_int ("photo-y-resolution"));
- try
- {
- camera.setup (device);
- }
- catch (Error err)
- {
- video_preview.hide ();
- message ("Error during camera setup: %s\n", err.message);
- main_window.show_error (err.message);
-
- return;
- }
-
double value;
value = settings.get_double ("brightness");
@@ -322,7 +311,6 @@ public class Cheese.Application : Gtk.Application
camera.state_flags_changed.connect (on_camera_state_flags_changed);
main_window.set_camera (camera);
- camera.play ();
}
/**
diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala
index 44e3547..a73bb46 100644
--- a/src/cheese-preferences.vala
+++ b/src/cheese-preferences.vala
@@ -111,6 +111,28 @@ public class Cheese.PreferencesDialog : GLib.Object
}
/**
+ * Signal raised when there is an error with the camera device
+ */
+ public signal void camera_error (string? error);
+
+ /**
+ * Start playing video from the camera
+ */
+ public void camera_play ()
+ {
+ try
+ {
+ camera.setup (null);
+ camera.play ();
+ camera_changed ();
+ }
+ catch (Error err)
+ {
+ camera_error (err.message);
+ }
+ }
+
+ /**
* Set up combo box cell renderers.
*/
private void setup_combo_box_models ()
@@ -161,8 +183,6 @@ public class Cheese.PreferencesDialog : GLib.Object
source_combo.sensitive = false;
devices.foreach(add_camera_device);
-
- camera_changed ();
}
/**
diff --git a/src/vapi/cheese-common.vapi b/src/vapi/cheese-common.vapi
index 26e12a2..cd8a71c 100644
--- a/src/vapi/cheese-common.vapi
+++ b/src/vapi/cheese-common.vapi
@@ -49,7 +49,7 @@ namespace Cheese
public void toggle_effects_pipeline (bool active);
public void connect_effect_texture (Cheese.Effect effect, Clutter.Texture texture);
public void set_video_format (Cheese.VideoFormat format);
- public void setup (string udi) throws GLib.Error;
+ public void setup (string? udi) throws GLib.Error;
public void start_video_recording (string filename);
public void stop ();
public void stop_video_recording ();