diff options
author | David King <amigadave@amigadave.com> | 2014-10-10 13:00:25 +0100 |
---|---|---|
committer | David King <amigadave@amigadave.com> | 2014-10-13 20:58:50 +0100 |
commit | 9c3a53204ad5c951d65e05d5d12e812f3fa62c24 (patch) | |
tree | 9c952b48c990eafcb536571670e38ec4b550e062 | |
parent | 2b1e92e852ff30848eded46f2db2c39f69de00a2 (diff) |
Refactor setup_camera() in CheeseWidget
Remove superfluous prototype. Use GSettings convenience getters. Reduce
scope of some variables.
-rw-r--r-- | libcheese/cheese-widget.c | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/libcheese/cheese-widget.c b/libcheese/cheese-widget.c index a0d5f046..110fa445 100644 --- a/libcheese/cheese-widget.c +++ b/libcheese/cheese-widget.c @@ -68,8 +68,6 @@ struct _CheeseWidgetPrivate G_DEFINE_TYPE_WITH_PRIVATE (CheeseWidget, cheese_widget, GTK_TYPE_NOTEBOOK); -void setup_camera (CheeseWidget *widget); - static GdkPixbuf * cheese_widget_load_pixbuf (GtkWidget *widget, const char *icon_name, @@ -294,54 +292,58 @@ webcam_state_changed (CheeseCamera *camera, GstState state, } } -void +static void setup_camera (CheeseWidget *widget) { - CheeseWidgetPrivate *priv = widget->priv; - gchar *webcam_device = NULL; - gint x_resolution; - gint y_resolution; - gdouble brightness; - gdouble contrast; - gdouble saturation; - gdouble hue; - - g_settings_get (priv->settings, "photo-x-resolution", "i", &x_resolution); - g_settings_get (priv->settings, "photo-y-resolution", "i", &y_resolution); - g_settings_get (priv->settings, "camera", "s", &webcam_device); - g_settings_get (priv->settings, "brightness", "d", &brightness); - g_settings_get (priv->settings, "contrast", "d", &contrast); - g_settings_get (priv->settings, "saturation", "d", &saturation); - g_settings_get (priv->settings, "hue", "d", &hue); - - priv->webcam = cheese_camera_new (CLUTTER_TEXTURE (priv->texture), - webcam_device, - x_resolution, - y_resolution); - - g_free (webcam_device); - - cheese_camera_setup (priv->webcam, NULL, &priv->error); - - gtk_spinner_stop (GTK_SPINNER (priv->spinner)); - - if (priv->error != NULL) - { - cheese_widget_set_problem_page (CHEESE_WIDGET (widget), "error"); - } - else - { - cheese_camera_set_balance_property (priv->webcam, "brightness", brightness); - cheese_camera_set_balance_property (priv->webcam, "contrast", contrast); - cheese_camera_set_balance_property (priv->webcam, "saturation", saturation); - cheese_camera_set_balance_property (priv->webcam, "hue", hue); - priv->state = CHEESE_WIDGET_STATE_READY; - g_object_notify_by_pspec (G_OBJECT (widget), properties[PROP_STATE]); - g_signal_connect (priv->webcam, "state-flags-changed", - G_CALLBACK (webcam_state_changed), widget); - cheese_camera_play (priv->webcam); - gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), WEBCAM_PAGE); - } + CheeseWidgetPrivate *priv = widget->priv; + gchar *webcam_device; + gint x_resolution; + gint y_resolution; + + x_resolution = g_settings_get_int (priv->settings, "photo-x-resolution"); + y_resolution = g_settings_get_int (priv->settings, "photo-y-resolution"); + webcam_device = g_settings_get_string (priv->settings, "camera"); + + priv->webcam = cheese_camera_new (CLUTTER_TEXTURE (priv->texture), + webcam_device, x_resolution, + y_resolution); + + g_free (webcam_device); + + cheese_camera_setup (priv->webcam, NULL, &priv->error); + + gtk_spinner_stop (GTK_SPINNER (priv->spinner)); + + if (priv->error != NULL) + { + cheese_widget_set_problem_page (CHEESE_WIDGET (widget), "error"); + } + else + { + gdouble brightness; + gdouble contrast; + gdouble saturation; + gdouble hue; + + brightness = g_settings_get_double (priv->settings, "brightness"); + contrast = g_settings_get_double (priv->settings, "contrast"); + saturation = g_settings_get_double (priv->settings, "saturation"); + hue = g_settings_get_double (priv->settings, "hue"); + + cheese_camera_set_balance_property (priv->webcam, "brightness", + brightness); + cheese_camera_set_balance_property (priv->webcam, "contrast", contrast); + cheese_camera_set_balance_property (priv->webcam, "saturation", + saturation); + cheese_camera_set_balance_property (priv->webcam, "hue", hue); + + priv->state = CHEESE_WIDGET_STATE_READY; + g_object_notify_by_pspec (G_OBJECT (widget), properties[PROP_STATE]); + g_signal_connect (priv->webcam, "state-flags-changed", + G_CALLBACK (webcam_state_changed), widget); + cheese_camera_play (priv->webcam); + gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), WEBCAM_PAGE); + } } static void |