From 9c3a53204ad5c951d65e05d5d12e812f3fa62c24 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 10 Oct 2014 13:00:25 +0100 Subject: Refactor setup_camera() in CheeseWidget Remove superfluous prototype. Use GSettings convenience getters. Reduce scope of some variables. --- libcheese/cheese-widget.c | 98 ++++++++++++++++++++++++----------------------- 1 file 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 -- cgit v1.2.3