[cheese/gsettings-vala] checked all settings and made them work and check on start



commit f66b1d79633bde5490b2a8568f0a3e110fe84fa4
Author: daniel g. siegel <dgsiegel gnome org>
Date:   Thu Nov 11 01:18:18 2010 +0100

    checked all settings and made them work and check on start

 data/org.gnome.Cheese.gschema.xml |    2 +-
 libcheese/cheese-camera.c         |    4 ++-
 src/cheese-countdown.vala         |    8 +++---
 src/cheese-preferences.vala       |   39 +++++++++++++++++++---------------
 src/cheese-window.vala            |   42 ++++++++++++++++++++++++++++--------
 5 files changed, 62 insertions(+), 33 deletions(-)
---
diff --git a/data/org.gnome.Cheese.gschema.xml b/data/org.gnome.Cheese.gschema.xml
index ffb322d..0e4dedb 100644
--- a/data/org.gnome.Cheese.gschema.xml
+++ b/data/org.gnome.Cheese.gschema.xml
@@ -15,7 +15,7 @@
       </description>
       <default>true</default>
     </key>
-    
+
     <key name='camera' type='s'>
       <summary>Camera device string indicator</summary>
       <description>
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index 33fd77f..ced9a4f 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -788,6 +788,7 @@ cheese_camera_element_from_effect (CheeseCamera *camera, CheeseEffect *effect)
   {
     g_error_free (err);
     g_warning ("Error with effect filter %s. Ignored", name);
+    return NULL;
   }
   g_free (effects_pipeline_desc);
 
@@ -800,7 +801,8 @@ cheese_camera_set_effect (CheeseCamera *camera, CheeseEffect *effect)
   GstElement *effect_filter;
 
   effect_filter = cheese_camera_element_from_effect (camera, effect);
-  cheese_camera_change_effect_filter (camera, effect_filter);
+  if (effect_filter != NULL)
+    cheese_camera_change_effect_filter (camera, effect_filter);
 }
 
 void
diff --git a/src/cheese-countdown.vala b/src/cheese-countdown.vala
index 1dd426e..98dc51e 100644
--- a/src/cheese-countdown.vala
+++ b/src/cheese-countdown.vala
@@ -39,7 +39,7 @@ internal class Cheese.Countdown : GLib.Object
   private static Clutter.Animation anim;
 
   public bool running;
-  
+
   public Countdown (Clutter.Text countdown_actor)
   {
     this.countdown_actor = countdown_actor;
@@ -56,7 +56,7 @@ internal class Cheese.Countdown : GLib.Object
     if (this.current_value <= 0)
     {
       this.completed_callback ();
-	  running = false;
+        running = false;
       return;
     }
     this.countdown_actor.text = this.current_value.to_string ();
@@ -70,7 +70,7 @@ internal class Cheese.Countdown : GLib.Object
   {
     this.completed_callback = completed_callback;
     this.current_value      = COUNTDOWN_START;
-	running = true;
+      running = true;
     countdown_actor.show ();
     fade_in ();
   }
@@ -79,6 +79,6 @@ internal class Cheese.Countdown : GLib.Object
   {
     countdown_actor.hide ();
     SignalHandler.disconnect (anim, signal_id);
-	running = false;
+      running = false;
   }
 }
diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala
index 66bb623..9fa99b2 100644
--- a/src/cheese-preferences.vala
+++ b/src/cheese-preferences.vala
@@ -65,32 +65,32 @@ public class Cheese.PreferencesDialog : GLib.Object
 
     this.dialog = (Gtk.Dialog)builder.get_object ("cheese_prefs_dialog");
 
-    this.brightness_adjustment = (Gtk.Adjustment)builder.get_object ("brightness_adjustment");
-    this.contrast_adjustment   = (Gtk.Adjustment)builder.get_object ("contrast_adjustment");
-    this.hue_adjustment        = (Gtk.Adjustment)builder.get_object ("hue_adjustment");
-    this.saturation_adjustment = (Gtk.Adjustment)builder.get_object ("saturation_adjustment");
+    this.brightness_adjustment = (Gtk.Adjustment) builder.get_object ("brightness_adjustment");
+    this.contrast_adjustment   = (Gtk.Adjustment) builder.get_object ("contrast_adjustment");
+    this.hue_adjustment        = (Gtk.Adjustment) builder.get_object ("hue_adjustment");
+    this.saturation_adjustment = (Gtk.Adjustment) builder.get_object ("saturation_adjustment");
 
     /* Here instead of in cheese-prefs.ui because of https://bugzilla.gnome.org/show_bug.cgi?id=624443 */
 
-    this.brightness_scale = (Gtk.Scale)builder.get_object ("brightness_scale");
-    this.contrast_scale   = (Gtk.Scale)builder.get_object ("contrast_scale");
-    this.hue_scale        = (Gtk.Scale)builder.get_object ("hue_scale");
-    this.saturation_scale = (Gtk.Scale)builder.get_object ("saturation_scale");
+    this.brightness_scale = (Gtk.Scale) builder.get_object ("brightness_scale");
+    this.contrast_scale   = (Gtk.Scale) builder.get_object ("contrast_scale");
+    this.hue_scale        = (Gtk.Scale) builder.get_object ("hue_scale");
+    this.saturation_scale = (Gtk.Scale) builder.get_object ("saturation_scale");
 
     this.brightness_scale.add_mark (0, Gtk.PositionType.BOTTOM, null);
     this.contrast_scale.add_mark (1, Gtk.PositionType.BOTTOM, null);
     this.hue_scale.add_mark (0, Gtk.PositionType.BOTTOM, null);
     this.saturation_scale.add_mark (1, Gtk.PositionType.BOTTOM, null);
 
-    this.resolution_combo = (Gtk.ComboBox)builder.get_object ("resolution_combo_box");
-    this.source_combo     = (Gtk.ComboBox)builder.get_object ("camera_combo_box");
+    this.resolution_combo = (Gtk.ComboBox) builder.get_object ("resolution_combo_box");
+    this.source_combo     = (Gtk.ComboBox) builder.get_object ("camera_combo_box");
 
-    this.burst_repeat_spin = (Gtk.SpinButton)builder.get_object ("burst_repeat");
-    this.burst_delay_spin  = (Gtk.SpinButton)builder.get_object ("burst_delay");
+    this.burst_repeat_spin = (Gtk.SpinButton) builder.get_object ("burst_repeat");
+    this.burst_delay_spin  = (Gtk.SpinButton) builder.get_object ("burst_delay");
+
+    this.countdown_check  = (Gtk.CheckButton) builder.get_object ("countdown");
+    this.flash_check  = (Gtk.CheckButton) builder.get_object ("flash");
 
-	this.countdown_check  = (Gtk.CheckButton)builder.get_object ("countdown");
-	this.flash_check  = (Gtk.CheckButton)builder.get_object ("flash");
-	
     setup_combo_box_models ();
     initialize_camera_devices ();
     initialize_values_from_settings ();
@@ -120,11 +120,13 @@ public class Cheese.PreferencesDialog : GLib.Object
     ListStore             camera_model = new ListStore (2, typeof (string), typeof (Cheese.CameraDevice));
 
     source_combo.model = camera_model;
+    if (devices.len <= 1)
+      source_combo.sensitive = false;
 
     for (int i = 0; i < devices.len; i++)
     {
       TreeIter iter;
-      dev = (Cheese.CameraDevice)devices.index (i);
+      dev = (Cheese.CameraDevice) devices.index (i);
       camera_model.append (out iter);
       camera_model.set (iter,
                         0, dev.get_name () + " (" + dev.get_device_file () + " )",
@@ -135,6 +137,7 @@ public class Cheese.PreferencesDialog : GLib.Object
       }
     }
 
+    settings.set_string("camera", camera.get_selected_device ().get_device_file ());
     setup_resolutions_for_device (camera.get_selected_device ());
   }
 
@@ -158,6 +161,8 @@ public class Cheese.PreferencesDialog : GLib.Object
           camera.get_current_video_format ().height == format.height)
       {
         resolution_combo.set_active_iter (iter);
+        settings.set_int("x-resolution", format.width);
+        settings.set_int("y-resolution", format.height);
       }
     }
   }
@@ -203,7 +208,7 @@ public class Cheese.PreferencesDialog : GLib.Object
     camera.set_video_format (format);
 
     settings.set_int("x-resolution", format.width);
-    settings.set_int("x-resolution", format.height);
+    settings.set_int("y-resolution", format.height);
   }
 
   [CCode (instance_pos = -1)]
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 0d0434e..bce24bf 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -867,8 +867,8 @@ public class Cheese.MainWindow : Gtk.Window
 
       for (int i = 0; i <= effects_manager.effects.size / EFFECTS_PER_PAGE; i++)
       {
-		  Clutter.TableLayout table_layout = new TableLayout();
-		Clutter.Box grid = new Clutter.Box (table_layout);
+        Clutter.TableLayout table_layout = new TableLayout();
+        Clutter.Box grid = new Clutter.Box (table_layout);
         effects_grids.add (grid);
 
         table_layout.column_spacing = 20;
@@ -915,12 +915,12 @@ public class Cheese.MainWindow : Gtk.Window
                   "y-align", Clutter.BinAlignment.END, null
                   );
 
-		Clutter.TableLayout table_layout = (Clutter.TableLayout)effects_grids[i / EFFECTS_PER_PAGE].layout_manager;
+        Clutter.TableLayout table_layout = (Clutter.TableLayout)effects_grids[i / EFFECTS_PER_PAGE].layout_manager;
         table_layout.pack (
-			(Clutter.Actor)box,
-			(i % EFFECTS_PER_PAGE) % 3,
-			(i % EFFECTS_PER_PAGE) / 3
-			);
+          (Clutter.Actor)box,
+          (i % EFFECTS_PER_PAGE) % 3,
+          (i % EFFECTS_PER_PAGE) / 3
+        );
       }
 
       setup_effects_page_switch_sensitivity ();
@@ -1098,17 +1098,19 @@ public class Cheese.MainWindow : Gtk.Window
     set_mode (MediaMode.PHOTO);
     setup_effects_selector ();
 
-    if (settings.get_boolean ("fullscreen"))
-      fullscreen_action.active = true;
-
     toggle_camera_actions_sensitivities (false);
 
     this.key_release_event.connect (on_key_release);
+
+    if (settings.get_boolean ("fullscreen"))
+      fullscreen_action.active = true;
   }
 
   public void setup_camera (string ? uri)
   {
     string device;
+    Effect effect;
+    double value;
 
     if (uri != null && uri.length > 0)
       device = uri;
@@ -1133,6 +1135,26 @@ public class Cheese.MainWindow : Gtk.Window
       return;
     }
 
+    effect = effects_manager.get_effect (settings.get_string ("selected-effect"));
+    if (effect != null)
+      camera.set_effect (effect);
+
+    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_changed.connect (camera_state_changed);
     camera.play ();
   }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]