Blob Blame History Raw
From d4288cd182064bca3bc3cd3d62c794737c9db426 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 7 Aug 2013 15:13:57 +0200
Subject: [PATCH 01/13] cheese: Don't allow changing the camera and/or its
 resolution while recording

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 src/cheese-application.vala |  1 +
 src/cheese-preferences.vala | 16 +++++++++++++++-
 src/cheese-window.vala      |  7 +++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/cheese-application.vala b/src/cheese-application.vala
index 4cbfa49..0f9f33d 100644
--- a/src/cheese-application.vala
+++ b/src/cheese-application.vala
@@ -160,6 +160,7 @@ public class Cheese.Application : Gtk.Application
             main_window.show ();
             setup_camera ();
             preferences_dialog = new PreferencesDialog (camera);
+            main_window.mode_change_changed.connect (preferences_dialog.enable_camera_controls);
             this.add_window (main_window);
         }
     }
diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala
index e078cbb..bad3c71 100644
--- a/src/cheese-preferences.vala
+++ b/src/cheese-preferences.vala
@@ -24,6 +24,7 @@ using Gtk;
 public class Cheese.PreferencesDialog : GLib.Object
 {
   private Cheese.Camera camera;
+  private bool camera_controls_sensitive;
 
   private GLib.Settings settings;
 
@@ -56,6 +57,7 @@ public class Cheese.PreferencesDialog : GLib.Object
   public PreferencesDialog (Cheese.Camera camera)
   {
     this.camera = camera;
+    this.camera_controls_sensitive = true;
 
     settings = new GLib.Settings ("org.gnome.Cheese");
 
@@ -499,7 +501,7 @@ public class Cheese.PreferencesDialog : GLib.Object
     if (camera.get_selected_device ().get_device_node () == dev.get_device_node ())
         source_combo.set_active_iter (iter);
 
-    if (camera_model.iter_n_children (null) > 1)
+    if (camera_model.iter_n_children (null) > 1 && camera_controls_sensitive)
       source_combo.sensitive = true;
   }
 
@@ -548,6 +550,18 @@ public class Cheese.PreferencesDialog : GLib.Object
   }
 
   /**
+   * Set camera controls sensitivity
+   */
+  public void enable_camera_controls (bool sensitive)
+  {
+    camera_controls_sensitive = sensitive;
+    photo_resolution_combo.sensitive = sensitive;
+    video_resolution_combo.sensitive = sensitive;
+    if (camera_model.iter_n_children (null) > 1)
+      source_combo.sensitive = sensitive;
+  }
+
+  /**
    * Show the dialog.
    */
   public void show ()
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index a406288..bc53b4e 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -373,6 +373,11 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
     }
 
     /**
+     * Signal raised when mode_change changes
+     */
+    public signal void mode_change_changed (bool enabled);
+
+    /**
      * Make the media capture mode actions sensitive.
      */
     private void enable_mode_change ()
@@ -381,6 +386,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
         mode.set_enabled (true);
         var effects = this.application.lookup_action ("effects") as SimpleAction;
         effects.set_enabled (true);
+        mode_change_changed (true);
     }
 
     /**
@@ -392,6 +398,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
         mode.set_enabled (false);
         var effects = this.application.lookup_action ("effects") as SimpleAction;
         effects.set_enabled (false);
+        mode_change_changed (false);
     }
 
   /**
-- 
1.8.3.1