[cheese/videobalance] Make balance widget more generic
- From: Filippo Argiolas <fargiolas src gnome org>
- To: svn-commits-list gnome org
- Subject: [cheese/videobalance] Make balance widget more generic
- Date: Thu, 23 Apr 2009 12:31:31 -0400 (EDT)
commit 238172087b3e5d8f8665763df8b8d0dcda1cd254
Author: Filippo Argiolas <filippo argiolas gmail com>
Date: Thu Apr 23 17:12:34 2009 +0200
Make balance widget more generic
Rename BrightnessScale to BalanceScale and add a dynamic property name so
the same widget can be reused to control all balance properties just
passing the correspondent property name at construction.
---
src/Makefile.am | 4 +-
src/cheese-prefs-balance-scale.c | 225 +++++++++++++++++++++++++++++++++++
src/cheese-prefs-balance-scale.h | 57 +++++++++
src/cheese-prefs-brightness-scale.c | 205 -------------------------------
src/cheese-prefs-brightness-scale.h | 59 ---------
src/cheese-prefs-dialog.c | 5 +-
src/cheese-prefs-dialog.h | 1 +
src/cheese-webcam.c | 11 +-
src/cheese-webcam.h | 6 +-
src/cheese-window.c | 2 +-
10 files changed, 299 insertions(+), 276 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 622b146..afe1b90 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,8 +48,8 @@ cheese_SOURCES = \
cheese-prefs-dialog-widgets.c \
cheese-prefs-resolution-combo.h \
cheese-prefs-resolution-combo.c \
- cheese-prefs-brightness-scale.c \
- cheese-prefs-brightness-scale.h \
+ cheese-prefs-balance-scale.c \
+ cheese-prefs-balance-scale.h \
cheese-prefs-dialog.c \
cheese-prefs-dialog.h \
cheese-flash.h \
diff --git a/src/cheese-prefs-balance-scale.c b/src/cheese-prefs-balance-scale.c
new file mode 100644
index 0000000..235a184
--- /dev/null
+++ b/src/cheese-prefs-balance-scale.c
@@ -0,0 +1,225 @@
+/*
+ * Copyright © 2009 Filippo Argiolas <filippo argiolas gmail com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string.h>
+#include <glib.h>
+
+#include "cheese-webcam.h"
+#include "cheese-prefs-widget.h"
+#include "cheese-prefs-balance-scale.h"
+
+#define STEPS 20.0
+
+enum
+{
+ PROP_0,
+ PROP_PROPERTY_NAME,
+ PROP_GCONF_KEY,
+ PROP_WEBCAM
+};
+
+typedef struct CheesePrefsBalanceScalePrivate
+{
+ CheeseWebcam *webcam;
+ gchar *property_name;
+ gchar *gconf_key;
+ gboolean has_been_synchronized; /* Make sure we don't synchronize if client
+ * sets webcam on construction. */
+} CheesePrefsBalanceScalePrivate;
+
+#define CHEESE_PREFS_BALANCE_SCALE_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_PREFS_BALANCE_SCALE, \
+ CheesePrefsBalanceScalePrivate))
+
+G_DEFINE_TYPE (CheesePrefsBalanceScale, cheese_prefs_balance_scale, CHEESE_TYPE_PREFS_WIDGET);
+
+static void
+cheese_prefs_balance_scale_init (CheesePrefsBalanceScale *self)
+{
+ CheesePrefsBalanceScalePrivate *priv = CHEESE_PREFS_BALANCE_SCALE_GET_PRIVATE (self);
+
+ priv->property_name = NULL;
+ priv->gconf_key = NULL;
+ priv->has_been_synchronized = FALSE;
+}
+
+static void
+cheese_prefs_balance_scale_finalize (GObject *object)
+{
+ CheesePrefsBalanceScale *self = CHEESE_PREFS_BALANCE_SCALE (object);
+ CheesePrefsBalanceScalePrivate *priv = CHEESE_PREFS_BALANCE_SCALE_GET_PRIVATE (self);
+
+ g_free (priv->property_name);
+ g_free (priv->gconf_key);
+
+ G_OBJECT_CLASS (cheese_prefs_balance_scale_parent_class)->finalize (object);
+}
+
+static void
+cheese_prefs_balance_scale_value_changed (GtkRange *scale, CheesePrefsBalanceScale *self)
+{
+ CheesePrefsBalanceScalePrivate *priv = CHEESE_PREFS_BALANCE_SCALE_GET_PRIVATE (self);
+ gdouble value = gtk_range_get_value (scale);
+ cheese_webcam_set_balance_property (priv->webcam, priv->property_name, value);
+
+ g_object_set (CHEESE_PREFS_WIDGET (self)->gconf, priv->gconf_key, value, NULL);
+
+ cheese_prefs_widget_notify_changed (CHEESE_PREFS_WIDGET (self));
+}
+
+static void
+cheese_prefs_balance_scale_synchronize (CheesePrefsWidget *prefs_widget)
+{
+ CheesePrefsBalanceScale *self = CHEESE_PREFS_BALANCE_SCALE (prefs_widget);
+ CheesePrefsBalanceScalePrivate *priv = CHEESE_PREFS_BALANCE_SCALE_GET_PRIVATE (self);
+
+ GtkWidget *scale;
+ GtkAdjustment *adj;
+ gdouble min, max, def;
+ gdouble stored_value;
+
+ g_object_get (prefs_widget, "widget", &scale, NULL);
+
+ cheese_webcam_get_balance_property_range (priv->webcam,
+ priv->property_name, &min, &max, &def);
+
+ adj = GTK_ADJUSTMENT (gtk_adjustment_new (def, min, max, (max - min)/STEPS, 0.0, 0.0));
+ gtk_range_set_adjustment (GTK_RANGE (scale), adj);
+
+ g_object_get (CHEESE_PREFS_WIDGET (self)->gconf, priv->gconf_key, &stored_value, NULL);
+
+ gtk_range_set_value (GTK_RANGE (scale), stored_value);
+
+ /* Disconnect to prevent a whole bunch of changed notifications */
+ g_signal_handlers_disconnect_by_func (scale, cheese_prefs_balance_scale_value_changed, prefs_widget);
+
+ g_signal_connect (G_OBJECT (scale), "value-changed",
+ G_CALLBACK (cheese_prefs_balance_scale_value_changed),
+ self);
+}
+
+static void
+cheese_prefs_balance_scale_set_property (GObject *object, guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ CheesePrefsBalanceScalePrivate *priv = CHEESE_PREFS_BALANCE_SCALE_GET_PRIVATE (object);
+
+ switch (prop_id)
+ {
+ case PROP_PROPERTY_NAME:
+ priv->property_name = g_value_dup_string (value);
+ break;
+ case PROP_GCONF_KEY:
+ priv->gconf_key = g_value_dup_string (value);
+ break;
+ case PROP_WEBCAM:
+ priv->webcam = CHEESE_WEBCAM (g_value_get_object (value));
+ if (priv->has_been_synchronized)
+ cheese_prefs_balance_scale_synchronize (CHEESE_PREFS_WIDGET (object));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+cheese_prefs_balance_scale_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ CheesePrefsBalanceScalePrivate *priv = CHEESE_PREFS_BALANCE_SCALE_GET_PRIVATE (object);
+
+ g_return_if_fail (CHEESE_IS_PREFS_BALANCE_SCALE (object));
+
+ switch (prop_id)
+ {
+ case PROP_PROPERTY_NAME:
+ g_value_set_string (value, priv->property_name);
+ break;
+ case PROP_GCONF_KEY:
+ g_value_set_string (value, priv->gconf_key);
+ break;
+ case PROP_WEBCAM:
+ g_value_set_object (value, priv->webcam);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+cheese_prefs_balance_scale_class_init (CheesePrefsBalanceScaleClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ CheesePrefsWidgetClass *parent_class = CHEESE_PREFS_WIDGET_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CheesePrefsBalanceScalePrivate));
+
+ object_class->finalize = cheese_prefs_balance_scale_finalize;
+ object_class->set_property = cheese_prefs_balance_scale_set_property;
+ object_class->get_property = cheese_prefs_balance_scale_get_property;
+ parent_class->synchronize = cheese_prefs_balance_scale_synchronize;
+
+ g_object_class_install_property (object_class,
+ PROP_PROPERTY_NAME,
+ g_param_spec_string ("property_name",
+ "",
+ "Property this widget will control in the videobalance element",
+ "",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_GCONF_KEY,
+ g_param_spec_string ("gconf_key",
+ "",
+ "GConf key for balance",
+ "",
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_WEBCAM,
+ g_param_spec_object ("webcam",
+ "webcam",
+ "Webcam object",
+ CHEESE_TYPE_WEBCAM,
+ G_PARAM_READWRITE));
+}
+
+CheesePrefsBalanceScale *
+cheese_prefs_balance_scale_new (GtkWidget *scale,
+ CheeseWebcam *webcam,
+ const gchar *property,
+ const gchar *gconf_key)
+{
+ CheesePrefsBalanceScale *self;
+ CheesePrefsBalanceScalePrivate *priv;
+
+ self = g_object_new (CHEESE_TYPE_PREFS_BALANCE_SCALE,
+ "widget", scale,
+ "webcam", webcam,
+ "property_name", property,
+ "gconf_key", gconf_key,
+ NULL);
+
+ priv = CHEESE_PREFS_BALANCE_SCALE_GET_PRIVATE (self);
+
+ return self;
+}
diff --git a/src/cheese-prefs-balance-scale.h b/src/cheese-prefs-balance-scale.h
new file mode 100644
index 0000000..fda4a78
--- /dev/null
+++ b/src/cheese-prefs-balance-scale.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2009 Filippo Argiolas <filippo argiolas gmail com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _CHEESE_PREFS_BALANCE_SCALE_H_
+#define _CHEESE_PREFS_BALANCE_SCALE_H_
+
+#include <glib-object.h>
+#include "cheese-prefs-widget.h"
+#include "cheese-webcam.h"
+
+G_BEGIN_DECLS
+
+#define CHEESE_TYPE_PREFS_BALANCE_SCALE (cheese_prefs_balance_scale_get_type ())
+#define CHEESE_PREFS_BALANCE_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_PREFS_BALANCE_SCALE, \
+ CheesePrefsBalanceScale))
+#define CHEESE_PREFS_BALANCE_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_PREFS_BALANCE_SCALE, \
+ CheesePrefsBalanceScaleClass))
+#define CHEESE_IS_PREFS_BALANCE_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_PREFS_BALANCE_SCALE))
+#define CHEESE_IS_PREFS_BALANCE_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_PREFS_BALANCE_SCALE))
+#define CHEESE_PREFS_BALANCE_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_PREFS_BALANCE_SCALE, CheesePrefsBalanceScaleClass))
+
+typedef struct _CheesePrefsBalanceScaleClass CheesePrefsBalanceScaleClass;
+typedef struct _CheesePrefsBalanceScale CheesePrefsBalanceScale;
+
+struct _CheesePrefsBalanceScaleClass
+{
+ CheesePrefsWidgetClass parent_class;
+};
+
+struct _CheesePrefsBalanceScale
+{
+ CheesePrefsWidget parent_instance;
+};
+
+GType cheese_prefs_balance_scale_get_type (void) G_GNUC_CONST;
+CheesePrefsBalanceScale *cheese_prefs_balance_scale_new (GtkWidget *scale,
+ CheeseWebcam *webcam,
+ const gchar *property,
+ const gchar *balance_key);
+
+#endif /* _CHEESE_PREFS_BALANCE_SCALE_H_ */
diff --git a/src/cheese-prefs-brightness-scale.c b/src/cheese-prefs-brightness-scale.c
deleted file mode 100644
index 09b06a9..0000000
--- a/src/cheese-prefs-brightness-scale.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright © 2008 James Liggett <jrliggett cox net>
- * Copyright © 2008 Ryan Zeigler <zeiglerr gmail com>
- * Copyright © 2008 daniel g. siegel <dgsiegel gmail com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <string.h>
-#include <glib.h>
-
-#include "cheese-webcam.h"
-#include "cheese-prefs-widget.h"
-#include "cheese-prefs-brightness-scale.h"
-
-#define STEPS 20.0
-
-enum
-{
- PROP_0,
- PROP_BRIGHTNESS_KEY,
- PROP_WEBCAM
-};
-
-typedef struct CheesePrefsBrightnessScalePrivate
-{
- gchar *brightness_key;
- CheeseWebcam *webcam;
- gboolean has_been_synchronized; /* Make sure we don't synchronize if client
- * sets webcam on construction. */
-} CheesePrefsBrightnessScalePrivate;
-
-#define CHEESE_PREFS_BRIGHTNESS_SCALE_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_PREFS_BRIGHTNESS_SCALE, \
- CheesePrefsBrightnessScalePrivate))
-
-G_DEFINE_TYPE (CheesePrefsBrightnessScale, cheese_prefs_brightness_scale, CHEESE_TYPE_PREFS_WIDGET);
-
-static void
-cheese_prefs_brightness_scale_init (CheesePrefsBrightnessScale *self)
-{
- CheesePrefsBrightnessScalePrivate *priv = CHEESE_PREFS_BRIGHTNESS_SCALE_GET_PRIVATE (self);
- priv->brightness_key = NULL;
- priv->has_been_synchronized = FALSE;
-}
-
-static void
-cheese_prefs_brightness_scale_finalize (GObject *object)
-{
- CheesePrefsBrightnessScale *self = CHEESE_PREFS_BRIGHTNESS_SCALE (object);
- CheesePrefsBrightnessScalePrivate *priv = CHEESE_PREFS_BRIGHTNESS_SCALE_GET_PRIVATE (self);
-
- g_free (priv->brightness_key);
-
- G_OBJECT_CLASS (cheese_prefs_brightness_scale_parent_class)->finalize (object);
-}
-
-static void
-cheese_prefs_brightness_scale_value_changed (GtkRange *scale, CheesePrefsBrightnessScale *self)
-{
- CheesePrefsBrightnessScalePrivate *priv = CHEESE_PREFS_BRIGHTNESS_SCALE_GET_PRIVATE (self);
- gdouble value = gtk_range_get_value (scale);
- cheese_webcam_set_brightness (priv->webcam, value);
-
- g_object_set (CHEESE_PREFS_WIDGET (self)->gconf, priv->brightness_key, value, NULL);
-
- cheese_prefs_widget_notify_changed (CHEESE_PREFS_WIDGET (self));
-}
-
-static void
-cheese_prefs_brightness_scale_synchronize (CheesePrefsWidget *prefs_widget)
-{
- CheesePrefsBrightnessScale *self = CHEESE_PREFS_BRIGHTNESS_SCALE (prefs_widget);
- CheesePrefsBrightnessScalePrivate *priv = CHEESE_PREFS_BRIGHTNESS_SCALE_GET_PRIVATE (self);
-
- GtkWidget *scale;
- GtkAdjustment *adj;
- gdouble min, max, def;
- gdouble stored_value;
-
- g_object_get (prefs_widget, "widget", &scale, NULL);
-
- cheese_webcam_get_brightness_range (priv->webcam, &min, &max, &def);
-
- adj = GTK_ADJUSTMENT (gtk_adjustment_new (def, min, max, (max - min)/STEPS, 0.0, 0.0));
- gtk_range_set_adjustment (GTK_RANGE (scale), adj);
-
- g_object_get (CHEESE_PREFS_WIDGET (self)->gconf, priv->brightness_key, &stored_value, NULL);
-
- gtk_range_set_value (GTK_RANGE (scale), stored_value);
-
- /* Disconnect to prevent a whole bunch of changed notifications */
- g_signal_handlers_disconnect_by_func (scale, cheese_prefs_brightness_scale_value_changed, prefs_widget);
-
- g_signal_connect (G_OBJECT (scale), "value-changed",
- G_CALLBACK (cheese_prefs_brightness_scale_value_changed),
- self);
-}
-
-static void
-cheese_prefs_brightness_scale_set_property (GObject *object, guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- CheesePrefsBrightnessScalePrivate *priv = CHEESE_PREFS_BRIGHTNESS_SCALE_GET_PRIVATE (object);
-
- switch (prop_id)
- {
- case PROP_BRIGHTNESS_KEY:
- priv->brightness_key = g_value_dup_string (value);
- break;
- case PROP_WEBCAM:
- priv->webcam = CHEESE_WEBCAM (g_value_get_object (value));
- if (priv->has_been_synchronized)
- cheese_prefs_brightness_scale_synchronize (CHEESE_PREFS_WIDGET (object));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-cheese_prefs_brightness_scale_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- CheesePrefsBrightnessScalePrivate *priv = CHEESE_PREFS_BRIGHTNESS_SCALE_GET_PRIVATE (object);
-
- g_return_if_fail (CHEESE_IS_PREFS_BRIGHTNESS_SCALE (object));
-
- switch (prop_id)
- {
- case PROP_BRIGHTNESS_KEY:
- g_value_set_string (value, priv->brightness_key);
- break;
- case PROP_WEBCAM:
- g_value_set_object (value, priv->webcam);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-cheese_prefs_brightness_scale_class_init (CheesePrefsBrightnessScaleClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- CheesePrefsWidgetClass *parent_class = CHEESE_PREFS_WIDGET_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (CheesePrefsBrightnessScalePrivate));
-
- object_class->finalize = cheese_prefs_brightness_scale_finalize;
- object_class->set_property = cheese_prefs_brightness_scale_set_property;
- object_class->get_property = cheese_prefs_brightness_scale_get_property;
- parent_class->synchronize = cheese_prefs_brightness_scale_synchronize;
-
- g_object_class_install_property (object_class,
- PROP_BRIGHTNESS_KEY,
- g_param_spec_string ("brightness_key",
- "",
- "GConf key for brightness",
- "",
- G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_WEBCAM,
- g_param_spec_object ("webcam",
- "webcam",
- "Webcam object",
- CHEESE_TYPE_WEBCAM,
- G_PARAM_READWRITE));
-}
-
-CheesePrefsBrightnessScale *
-cheese_prefs_brightness_scale_new (GtkWidget *scale,
- CheeseWebcam *webcam,
- const gchar *brightness_key)
-{
- CheesePrefsBrightnessScale *self;
- CheesePrefsBrightnessScalePrivate *priv;
-
- self = g_object_new (CHEESE_TYPE_PREFS_BRIGHTNESS_SCALE,
- "widget", scale,
- "webcam", webcam,
- "brightness_key", brightness_key,
- NULL);
-
- priv = CHEESE_PREFS_BRIGHTNESS_SCALE_GET_PRIVATE (self);
-
- return self;
-}
diff --git a/src/cheese-prefs-brightness-scale.h b/src/cheese-prefs-brightness-scale.h
deleted file mode 100644
index a5ed5e5..0000000
--- a/src/cheese-prefs-brightness-scale.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright © 2008 James Liggett <jrliggett cox net>
- * Copyright © 2008 Ryan Zeigler <zeiglerr gmail com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _CHEESE_PREFS_BRIGHTNESS_SCALE_H_
-#define _CHEESE_PREFS_BRIGHTNESS_SCALE_H_
-
-#include <glib-object.h>
-#include "cheese-prefs-widget.h"
-#include "cheese-webcam.h"
-
-G_BEGIN_DECLS
-
-#define CHEESE_TYPE_PREFS_BRIGHTNESS_SCALE (cheese_prefs_brightness_scale_get_type ())
-#define CHEESE_PREFS_BRIGHTNESS_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_PREFS_BRIGHTNESS_SCALE, \
- CheesePrefsBrightnessScale))
-#define CHEESE_PREFS_BRIGHTNESS_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_PREFS_BRIGHTNESS_SCALE, \
- CheesePrefsBrightnessScaleClass))
-#define CHEESE_IS_PREFS_BRIGHTNESS_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_PREFS_BRIGHTNESS_SCALE))
-#define CHEESE_IS_PREFS_BRIGHTNESS_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_PREFS_BRIGHTNESS_SCALE))
-#define CHEESE_PREFS_BRIGHTNESS_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_PREFS_BRIGHTNESS_SCALE, CheesePrefsBrightnessScaleClass))
-
-typedef struct _CheesePrefsBrightnessScaleClass CheesePrefsBrightnessScaleClass;
-typedef struct _CheesePrefsBrightnessScale CheesePrefsBrightnessScale;
-
-struct _CheesePrefsBrightnessScaleClass
-{
- CheesePrefsWidgetClass parent_class;
-};
-
-struct _CheesePrefsBrightnessScale
-{
- CheesePrefsWidget parent_instance;
-};
-
-GType cheese_prefs_brightness_scale_get_type (void) G_GNUC_CONST;
-CheesePrefsBrightnessScale *cheese_prefs_brightness_scale_new (GtkWidget *scale,
- CheeseWebcam *webcam,
- const gchar *brightness_key);
-
-char *cheese_prefs_brightness_scale_get_selected_webcam (CheesePrefsBrightnessScale *webcam);
-
-#endif /* _CHEESE_PREFS_BRIGHTNESS_SCALE_H_ */
diff --git a/src/cheese-prefs-dialog.c b/src/cheese-prefs-dialog.c
index 9b5c6c0..2173cec 100644
--- a/src/cheese-prefs-dialog.c
+++ b/src/cheese-prefs-dialog.c
@@ -128,8 +128,9 @@ cheese_prefs_dialog_setup_widgets (CheesePrefsDialog *prefs_dialog)
prefs_dialog);
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, webcam_widget);
- brightness_widget = CHEESE_PREFS_WIDGET (cheese_prefs_brightness_scale_new (prefs_dialog->brightness_scale,
- prefs_dialog->webcam,"gconf_prop_brightness"));
+ brightness_widget = CHEESE_PREFS_WIDGET (cheese_prefs_balance_scale_new (prefs_dialog->brightness_scale,
+ prefs_dialog->webcam, "brightness",
+ "gconf_prop_brightness"));
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, brightness_widget);
diff --git a/src/cheese-prefs-dialog.h b/src/cheese-prefs-dialog.h
index 9c27b68..d12b905 100644
--- a/src/cheese-prefs-dialog.h
+++ b/src/cheese-prefs-dialog.h
@@ -28,6 +28,7 @@
#include "cheese-prefs-dialog-widgets.h"
#include "cheese-prefs-resolution-combo.h"
#include "cheese-prefs-webcam-combo.h"
+#include "cheese-prefs-balance-scale.h"
void cheese_prefs_dialog_run (GtkWidget *parent, CheeseGConf *gconf, CheeseWebcam *webcam);
diff --git a/src/cheese-webcam.c b/src/cheese-webcam.c
index d22d242..7c8c57a 100644
--- a/src/cheese-webcam.c
+++ b/src/cheese-webcam.c
@@ -1719,8 +1719,9 @@ cheese_webcam_get_current_video_format (CheeseWebcam *webcam)
}
void
-cheese_webcam_get_brightness_range (CheeseWebcam *webcam,
- gdouble *min, gdouble *max, gdouble *def)
+cheese_webcam_get_balance_property_range (CheeseWebcam *webcam,
+ gchar *property,
+ gdouble *min, gdouble *max, gdouble *def)
{
CheeseWebcamPrivate *priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
GParamSpec *pspec;
@@ -1730,7 +1731,7 @@ cheese_webcam_get_brightness_range (CheeseWebcam *webcam,
*def = 0.0;
pspec = g_object_class_find_property (
- G_OBJECT_GET_CLASS (G_OBJECT (priv->video_balance)), "brightness");
+ G_OBJECT_GET_CLASS (G_OBJECT (priv->video_balance)), property);
g_return_if_fail (pspec != NULL);
@@ -1740,9 +1741,9 @@ cheese_webcam_get_brightness_range (CheeseWebcam *webcam,
}
void
-cheese_webcam_set_brightness (CheeseWebcam *webcam, gdouble value)
+cheese_webcam_set_balance_property (CheeseWebcam *webcam, gchar *property, gdouble value)
{
CheeseWebcamPrivate *priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
- g_object_set (G_OBJECT (priv->video_balance), "brightness", value, NULL);
+ g_object_set (G_OBJECT (priv->video_balance), property, value, NULL);
}
diff --git a/src/cheese-webcam.h b/src/cheese-webcam.h
index 45b5fa1..e2a11e6 100644
--- a/src/cheese-webcam.h
+++ b/src/cheese-webcam.h
@@ -119,8 +119,10 @@ gboolean cheese_webcam_switch_webcam_device (CheeseWebcam *webcam);
GArray * cheese_webcam_get_video_formats (CheeseWebcam *webcam);
void cheese_webcam_set_video_format (CheeseWebcam *webcam,
CheeseVideoFormat *format);
-void cheese_webcam_get_brightness_range (CheeseWebcam *webcam, gdouble *min, gdouble *max, gdouble *def);
-void cheese_webcam_set_brightness (CheeseWebcam *webcam, gdouble value);
+void cheese_webcam_get_balance_property_range (CheeseWebcam *webcam,
+ gchar *property,
+ gdouble *min, gdouble *max, gdouble *def);
+void cheese_webcam_set_balance_property (CheeseWebcam *webcam, gchar *property, gdouble value);
G_END_DECLS
#endif /* __CHEESE_WEBCAM_H__ */
diff --git a/src/cheese-window.c b/src/cheese-window.c
index 0ed7c7a..91b81a6 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -1912,7 +1912,7 @@ setup_camera (CheeseWindow *cheese_window)
cheese_webcam_set_effect (cheese_window->webcam,
cheese_effect_chooser_get_selection (CHEESE_EFFECT_CHOOSER (cheese_window->effect_chooser)));
- cheese_webcam_set_brightness (cheese_window->webcam, brightness);
+ cheese_webcam_set_balance_property (cheese_window->webcam, "brightness", brightness);
cheese_webcam_play (cheese_window->webcam);
gdk_threads_enter ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]