[cheese] Make the preferences dialog work again
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Make the preferences dialog work again
- Date: Mon, 25 Jun 2012 21:42:03 +0000 (UTC)
commit 65e5112e0a68ee53f16ac37cad7c99bc97a2ddb6
Author: David King <amigadave amigadave com>
Date: Mon Jun 25 21:31:39 2012 +0100
Make the preferences dialog work again
Move the Cheese.Camera to Cheese.Main and use the same camera in
Cheese.MainWindow and Cheese.PreferencesDialog. Setup the Camera in
Cheese.Main.
src/cheese-main.vala | 92 ++++++++++++++++++++++++++++++++++++++++++-
src/cheese-preferences.vala | 4 +-
src/cheese-window.vala | 89 ++++++++++++------------------------------
3 files changed, 117 insertions(+), 68 deletions(-)
---
diff --git a/src/cheese-main.vala b/src/cheese-main.vala
index 3c2705d..513c02c 100644
--- a/src/cheese-main.vala
+++ b/src/cheese-main.vala
@@ -33,6 +33,7 @@ public class Cheese.Main : Gtk.Application
static MainWindow main_window;
+ private Camera camera;
private PreferencesDialog preferences_dialog;
private const GLib.ActionEntry action_entries[] = {
@@ -120,8 +121,9 @@ public class Cheese.Main : Gtk.Application
if (fullscreen)
main_window.set_startup_fullscreen_mode ();
- main_window.show ();
- main_window.setup_camera (device);
+ main_window.show ();
+ setup_camera (device);
+ preferences_dialog = new PreferencesDialog (camera);
}
}
@@ -207,6 +209,92 @@ public class Cheese.Main : Gtk.Application
}
/**
+ * Setup the camera listed in GSettings.
+ *
+ * @param uri the uri of the device node to setup, or null
+ */
+ public void setup_camera (string? uri)
+ {
+ var settings = new GLib.Settings ("org.gnome.Cheese");
+ string device;
+ double value;
+
+ if (uri != null && uri.length > 0)
+ {
+ device = uri;
+ }
+ else
+ {
+ device = settings.get_string ("camera");
+ }
+
+ var video_preview = main_window.get_video_preview ();
+ camera = new Camera (video_preview, device,
+ settings.get_int ("photo-x-resolution"),
+ settings.get_int ("photo-y-resolution"));
+
+ try
+ {
+ camera.setup (device);
+ }
+ catch (Error err)
+ {
+ video_preview.hide ();
+ warning ("Error: %s\n", err.message);
+ //error_layer.text = err.message;
+ //error_layer.show ();
+
+ //toggle_camera_actions_sensitivities (false);
+ return;
+ }
+
+ value = settings.get_double ("brightness");
+ if (value != 0.0)
+ {
+ camera.set_balance_property ("brightness", value);
+ }
+
+ value = settings.get_double ("contrast");
+ if (value != 1.0)
+ {
+ camera.set_balance_property ("contrast", value);
+ }
+
+ value = settings.get_double ("hue");
+ if (value != 0.0)
+ {
+ camera.set_balance_property ("hue", value);
+ }
+
+ value = settings.get_double ("saturation");
+ if (value != 1.0)
+ {
+ camera.set_balance_property ("saturation", value);
+ }
+
+ camera.state_flags_changed.connect (on_camera_state_flags_changed);
+ main_window.set_camera (camera);
+ camera.play ();
+ }
+
+ /**
+ * Handle the camera state changing.
+ *
+ * @param new_state the new Cheese.Camera state
+ */
+ private void on_camera_state_flags_changed (Gst.State new_state)
+ {
+ switch (new_state)
+ {
+ case Gst.State.PLAYING:
+ main_window.camera_state_change_playing ();
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
* Update the current capture mode in the main window and preferences
* dialog.
*
diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala
index fdd87c3..d4d5501 100644
--- a/src/cheese-preferences.vala
+++ b/src/cheese-preferences.vala
@@ -53,11 +53,11 @@ public class Cheese.PreferencesDialog : GLib.Object
private MediaMode current_mode;
- public PreferencesDialog (Cheese.Camera camera, GLib.Settings settings)
+ public PreferencesDialog (Cheese.Camera camera)
{
this.camera = camera;
- this.settings = settings;
+ settings = new GLib.Settings ("org.gnome.Cheese");
Gtk.Builder builder = new Gtk.Builder ();
try
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index e1c1faf..26f5524 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -1305,23 +1305,22 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
}
}
- /**
- * Update the UI based on state changes of the camera.
- *
- * @param new_state the new Cheese.Camera state
- */
- private void camera_state_changed (Gst.State new_state)
- {
- if (new_state == Gst.State.PLAYING)
+ /**
+ * Update the UI when the camera starts playing.
+ */
+ public void camera_state_change_playing ()
{
- if (!is_camera_actions_sensitive)
- toggle_camera_actions_sensitivities (true);
+ if (!is_camera_actions_sensitive)
+ {
+ toggle_camera_actions_sensitivities (true);
+ }
- Effect effect = effects_manager.get_effect (settings.get_string ("selected-effect"));
- if (effect != null)
- camera.set_effect (effect);
+ Effect effect = effects_manager.get_effect (settings.get_string ("selected-effect"));
+ if (effect != null)
+ {
+ camera.set_effect (effect);
+ }
}
- }
/**
* Set wide mode active when started from the command line (and do not change
@@ -1471,59 +1470,11 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
this.key_release_event.connect (on_key_release);
}
- /**
- * Setup the camera listed in GSettings.
- *
- * @param uri the uri of the device node to setup, or null
- */
- public void setup_camera (string ? uri)
- {
- string device;
- double value;
-
- if (uri != null && uri.length > 0)
- device = uri;
- else
- device = settings.get_string ("camera");
-
- camera = new Camera (video_preview,
- device,
- settings.get_int ("photo-x-resolution"),
- settings.get_int ("photo-y-resolution"));
- try {
- camera.setup (device);
- }
- catch (Error err)
+ public Clutter.Texture get_video_preview ()
{
- video_preview.hide ();
- warning ("Error: %s\n", err.message);
- error_layer.text = err.message;
- error_layer.show ();
-
- toggle_camera_actions_sensitivities (false);
- return;
+ return video_preview;
}
- value = settings.get_double ("brightness");
- if (value != 0.0)
- camera.set_balance_property ("brightness", value);
-
- value = settings.get_double ("contrast");
- if (value != 1.0)
- camera.set_balance_property ("contrast", value);
-
- value = settings.get_double ("hue");
- if (value != 0.0)
- camera.set_balance_property ("hue", value);
-
- value = settings.get_double ("saturation");
- if (value != 1.0)
- camera.set_balance_property ("saturation", value);
-
- camera.state_flags_changed.connect (camera_state_changed);
- camera.play ();
- }
-
/**
* Setup the thumbview thumbnail monitors.
*/
@@ -1566,4 +1517,14 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
break;
}
}
+
+ /**
+ * Set the camera.
+ *
+ * @param camera the camera to set
+ */
+ public void set_camera (Camera camera)
+ {
+ this.camera = camera;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]