[cheese/videobalance] Implement hue control



commit c158ba6e49145796a808bcaa901aae0cb5a639b8
Author: Filippo Argiolas <filippo argiolas gmail com>
Date:   Thu Apr 23 18:30:08 2009 +0200

    Implement hue control
    
    Actually implement the widget for hue adjustment, add its
    gconf property and the correspondent schema
---
 data/cheese.schemas.in    |   12 ++++++++++++
 src/cheese-gconf.c        |   25 +++++++++++++++++++++++++
 src/cheese-gconf.h        |    1 +
 src/cheese-prefs-dialog.c |   10 ++++++++++
 src/cheese-window.c       |    3 +++
 5 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/data/cheese.schemas.in b/data/cheese.schemas.in
index f772111..9b04aa0 100644
--- a/data/cheese.schemas.in
+++ b/data/cheese.schemas.in
@@ -101,6 +101,18 @@
 			</locale>
     </schema>
 
+		<schema>
+			<key>/schemas/apps/cheese/hue</key>
+			<applyto>/apps/cheese/hue</applyto>
+			<owner>cheese</owner>
+			<type>float</type>
+			<default>0</default>
+			<locale name="C">
+				<short>Picture hue</short>
+				<long>Adjusts hue 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 0f3aed6..2e058d5 100644
--- a/src/cheese-gconf.c
+++ b/src/cheese-gconf.c
@@ -143,6 +143,16 @@ cheese_gconf_get_property (GObject *object, guint prop_id, GValue *value,
                                                            CHEESE_GCONF_PREFIX "/saturation",
                                                            NULL));
       break;
+    case GCONF_PROP_HUE:
+      if (!gconf_client_get (priv->client,
+                             CHEESE_GCONF_PREFIX "/hue",
+                             NULL))
+        g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value);
+      else
+        g_value_set_double (value, gconf_client_get_float (priv->client,
+                                                           CHEESE_GCONF_PREFIX "/hue",
+                                                           NULL));
+      break;
     case GCONF_PROP_VIDEO_PATH:
       g_value_set_string (value, gconf_client_get_string (priv->client,
                                                           CHEESE_GCONF_PREFIX "/video_path",
@@ -261,6 +271,12 @@ cheese_gconf_set_property (GObject *object, guint prop_id, const GValue *value,
                               g_value_get_double (value),
                               NULL);
       break;
+    case GCONF_PROP_HUE:
+      gconf_client_set_float (priv->client,
+                              CHEESE_GCONF_PREFIX "/hue",
+                              g_value_get_double (value),
+                              NULL);
+      break;
     case GCONF_PROP_VIDEO_PATH:
       gconf_client_set_string (priv->client,
                                CHEESE_GCONF_PREFIX "/video_path",
@@ -371,6 +387,15 @@ cheese_gconf_class_init (CheeseGConfClass *klass)
                                                         1.0,
                                                         G_PARAM_READWRITE));
 
+  g_object_class_install_property (object_class, GCONF_PROP_HUE,
+                                   g_param_spec_double ("gconf_prop_hue",
+                                                        NULL,
+                                                        NULL,
+                                                        -G_MAXFLOAT,
+                                                        G_MAXFLOAT,
+                                                        0.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 ae81319..4086169 100644
--- a/src/cheese-gconf.h
+++ b/src/cheese-gconf.h
@@ -50,6 +50,7 @@ enum
   GCONF_PROP_BRIGHTNESS,
   GCONF_PROP_CONTRAST,
   GCONF_PROP_SATURATION,
+  GCONF_PROP_HUE,
   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 3670f04..52b265d 100644
--- a/src/cheese-prefs-dialog.c
+++ b/src/cheese-prefs-dialog.c
@@ -28,6 +28,7 @@ typedef struct
   GtkWidget *brightness_scale;
   GtkWidget *contrast_scale;
   GtkWidget *saturation_scale;
+  GtkWidget *hue_scale;
 
   GtkWidget *parent;
   CheeseWebcam *webcam;
@@ -63,6 +64,8 @@ cheese_prefs_dialog_create_dialog (CheesePrefsDialog *prefs_dialog)
 																																		 "contrast_scale"));
   prefs_dialog->saturation_scale = GTK_WIDGET (gtk_builder_get_object (builder,
 																																			 "saturation_scale"));
+  prefs_dialog->hue_scale = GTK_WIDGET (gtk_builder_get_object (builder,
+																																"hue_scale"));
 
   gtk_window_set_transient_for (GTK_WINDOW (prefs_dialog->cheese_prefs_dialog),
                                 GTK_WINDOW (prefs_dialog->parent));
@@ -116,6 +119,7 @@ cheese_prefs_dialog_setup_widgets (CheesePrefsDialog *prefs_dialog)
   CheesePrefsWidget *brightness_widget;
 	CheesePrefsWidget *contrast_widget;
   CheesePrefsWidget *saturation_widget;
+  CheesePrefsWidget *hue_widget;
 
   resolution_widget = CHEESE_PREFS_WIDGET (cheese_prefs_resolution_combo_new (prefs_dialog->resolution_combo_box,
                                                                               prefs_dialog->webcam,
@@ -154,6 +158,12 @@ cheese_prefs_dialog_setup_widgets (CheesePrefsDialog *prefs_dialog)
 
   cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, saturation_widget);
 
+	hue_widget = CHEESE_PREFS_WIDGET (cheese_prefs_balance_scale_new (prefs_dialog->hue_scale,
+																																		prefs_dialog->webcam, "hue",
+																																		"gconf_prop_hue"));
+
+  cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, hue_widget);
+
 
   cheese_prefs_dialog_widgets_synchronize (prefs_dialog->widgets);
 }
diff --git a/src/cheese-window.c b/src/cheese-window.c
index 5ec2352..40ff9b0 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -1855,6 +1855,7 @@ setup_camera (CheeseWindow *cheese_window)
   gdouble    brightness;
   gdouble    contrast;
   gdouble    saturation;
+  gdouble    hue;
   GtkWidget *message_area;
 
   GError *error;
@@ -1866,6 +1867,7 @@ setup_camera (CheeseWindow *cheese_window)
                 "gconf_prop_brightness", &brightness,
                 "gconf_prop_contrast", &contrast,
                 "gconf_prop_saturation", &saturation,
+                "gconf_prop_hue", &hue,
                 NULL);
 
   gdk_threads_enter ();
@@ -1920,6 +1922,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_set_balance_property (cheese_window->webcam, "hue", hue);
 
   cheese_webcam_play (cheese_window->webcam);
   gdk_threads_enter ();



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