[cheese/videobalance] Implement saturation control



commit cb8a8ec8889bc4b4e79ecc088187464c3a333f95
Author: Filippo Argiolas <filippo argiolas gmail com>
Date:   Thu Apr 23 17:53:48 2009 +0200

    Implement saturation control
    
    Actually implement the widget for saturation adjustment, add its
    gconf property and the correspondent schema
---
 data/cheese.schemas.in    |   13 +++++++++++++
 src/cheese-gconf.c        |   20 ++++++++++++++++++++
 src/cheese-gconf.h        |    1 +
 src/cheese-prefs-dialog.c |   15 +++++++++++++--
 src/cheese-window.c       |    3 +++
 5 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/data/cheese.schemas.in b/data/cheese.schemas.in
index 4c5379e..f772111 100644
--- a/data/cheese.schemas.in
+++ b/data/cheese.schemas.in
@@ -76,6 +76,7 @@
 				<long>Adjusts brightness level of the picture coming from the webcam</long>
 			</locale>
     </schema>
+
 		<schema>
 			<key>/schemas/apps/cheese/contrast</key>
 			<applyto>/apps/cheese/contrast</applyto>
@@ -88,6 +89,18 @@
 			</locale>
     </schema>
 
+		<schema>
+			<key>/schemas/apps/cheese/saturation</key>
+			<applyto>/apps/cheese/saturation</applyto>
+			<owner>cheese</owner>
+			<type>float</type>
+			<default>1</default>
+			<locale name="C">
+				<short>Picture saturation</short>
+				<long>Adjusts saturation level of the picture coming from the webcam</long>
+			</locale>
+    </schema>
+
     <schema>
 			<key>/schemas/apps/cheese/video_path</key>
 			<applyto>/apps/cheese/video_path</applyto>
diff --git a/src/cheese-gconf.c b/src/cheese-gconf.c
index 08c22be..2ed05aa 100644
--- a/src/cheese-gconf.c
+++ b/src/cheese-gconf.c
@@ -123,6 +123,11 @@ cheese_gconf_get_property (GObject *object, guint prop_id, GValue *value,
                                                          CHEESE_GCONF_PREFIX "/contrast",
                                                          NULL));
       break;
+    case GCONF_PROP_SATURATION:
+      g_value_set_double (value, gconf_client_get_float (priv->client,
+                                                         CHEESE_GCONF_PREFIX "/saturation",
+                                                         NULL));
+      break;
     case GCONF_PROP_VIDEO_PATH:
       g_value_set_string (value, gconf_client_get_string (priv->client,
                                                           CHEESE_GCONF_PREFIX "/video_path",
@@ -235,6 +240,12 @@ cheese_gconf_set_property (GObject *object, guint prop_id, const GValue *value,
                               g_value_get_double (value),
                               NULL);
       break;
+    case GCONF_PROP_SATURATION:
+      gconf_client_set_float (priv->client,
+                              CHEESE_GCONF_PREFIX "/saturation",
+                              g_value_get_double (value),
+                              NULL);
+      break;
     case GCONF_PROP_VIDEO_PATH:
       gconf_client_set_string (priv->client,
                                CHEESE_GCONF_PREFIX "/video_path",
@@ -336,6 +347,15 @@ cheese_gconf_class_init (CheeseGConfClass *klass)
                                                         1.0,
                                                         G_PARAM_READWRITE));
 
+  g_object_class_install_property (object_class, GCONF_PROP_SATURATION,
+                                   g_param_spec_double ("gconf_prop_saturation",
+                                                        NULL,
+                                                        NULL,
+                                                        0,
+                                                        G_MAXFLOAT,
+                                                        1.0,
+                                                        G_PARAM_READWRITE));
+
   g_object_class_install_property (object_class, GCONF_PROP_VIDEO_PATH,
                                    g_param_spec_string ("gconf_prop_video_path",
                                                         NULL,
diff --git a/src/cheese-gconf.h b/src/cheese-gconf.h
index 647aaea..ae81319 100644
--- a/src/cheese-gconf.h
+++ b/src/cheese-gconf.h
@@ -49,6 +49,7 @@ enum
   GCONF_PROP_Y_RESOLUTION,
   GCONF_PROP_BRIGHTNESS,
   GCONF_PROP_CONTRAST,
+  GCONF_PROP_SATURATION,
   GCONF_PROP_VIDEO_PATH,
   GCONF_PROP_PHOTO_PATH,
   GCONF_PROP_ENABLE_DELETE
diff --git a/src/cheese-prefs-dialog.c b/src/cheese-prefs-dialog.c
index e3ac2ec..3670f04 100644
--- a/src/cheese-prefs-dialog.c
+++ b/src/cheese-prefs-dialog.c
@@ -27,6 +27,7 @@ typedef struct
   GtkWidget *webcam_combo_box;
   GtkWidget *brightness_scale;
   GtkWidget *contrast_scale;
+  GtkWidget *saturation_scale;
 
   GtkWidget *parent;
   CheeseWebcam *webcam;
@@ -59,7 +60,9 @@ cheese_prefs_dialog_create_dialog (CheesePrefsDialog *prefs_dialog)
   prefs_dialog->brightness_scale = GTK_WIDGET (gtk_builder_get_object (builder,
                                                                        "brightness_scale"));
   prefs_dialog->contrast_scale = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                                       "contrast_scale"));
+																																		 "contrast_scale"));
+  prefs_dialog->saturation_scale = GTK_WIDGET (gtk_builder_get_object (builder,
+																																			 "saturation_scale"));
 
   gtk_window_set_transient_for (GTK_WINDOW (prefs_dialog->cheese_prefs_dialog),
                                 GTK_WINDOW (prefs_dialog->parent));
@@ -111,7 +114,8 @@ cheese_prefs_dialog_setup_widgets (CheesePrefsDialog *prefs_dialog)
   CheesePrefsWidget *resolution_widget;
   CheesePrefsWidget *webcam_widget;
   CheesePrefsWidget *brightness_widget;
-  CheesePrefsWidget *contrast_widget;
+	CheesePrefsWidget *contrast_widget;
+  CheesePrefsWidget *saturation_widget;
 
   resolution_widget = CHEESE_PREFS_WIDGET (cheese_prefs_resolution_combo_new (prefs_dialog->resolution_combo_box,
                                                                               prefs_dialog->webcam,
@@ -144,6 +148,13 @@ cheese_prefs_dialog_setup_widgets (CheesePrefsDialog *prefs_dialog)
 
   cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, contrast_widget);
 
+	saturation_widget = CHEESE_PREFS_WIDGET (cheese_prefs_balance_scale_new (prefs_dialog->saturation_scale,
+																																					 prefs_dialog->webcam, "saturation",
+																																					 "gconf_prop_saturation"));
+
+  cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, saturation_widget);
+
+
   cheese_prefs_dialog_widgets_synchronize (prefs_dialog->widgets);
 }
 
diff --git a/src/cheese-window.c b/src/cheese-window.c
index 9e16025..5ec2352 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -1854,6 +1854,7 @@ setup_camera (CheeseWindow *cheese_window)
   int        y_resolution;
   gdouble    brightness;
   gdouble    contrast;
+  gdouble    saturation;
   GtkWidget *message_area;
 
   GError *error;
@@ -1864,6 +1865,7 @@ setup_camera (CheeseWindow *cheese_window)
                 "gconf_prop_webcam", &webcam_device,
                 "gconf_prop_brightness", &brightness,
                 "gconf_prop_contrast", &contrast,
+                "gconf_prop_saturation", &saturation,
                 NULL);
 
   gdk_threads_enter ();
@@ -1917,6 +1919,7 @@ setup_camera (CheeseWindow *cheese_window)
 
   cheese_webcam_set_balance_property (cheese_window->webcam, "brightness", brightness);
   cheese_webcam_set_balance_property (cheese_window->webcam, "contrast", contrast);
+  cheese_webcam_set_balance_property (cheese_window->webcam, "saturation", saturation);
 
   cheese_webcam_play (cheese_window->webcam);
   gdk_threads_enter ();



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