25
25
GtkWidget *cheese_prefs_dialog;
26
26
GtkWidget *resolution_combo_box;
27
GtkWidget *webcam_combo_box;
27
GtkWidget *camera_combo_box;
28
28
GtkWidget *brightness_scale;
29
29
GtkWidget *contrast_scale;
30
30
GtkWidget *saturation_scale;
58
58
"cheese_prefs_dialog"));
59
59
prefs_dialog->resolution_combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
60
60
"resolution_combo_box"));
61
prefs_dialog->webcam_combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
61
prefs_dialog->camera_combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
63
63
prefs_dialog->brightness_scale = GTK_WIDGET (gtk_builder_get_object (builder,
64
64
"brightness_scale"));
65
65
prefs_dialog->contrast_scale = GTK_WIDGET (gtk_builder_get_object (builder,
80
80
cheese_prefs_dialog_on_resolution_changed (CheesePrefsWidget *widget, gpointer user_data)
83
CheeseVideoFormat *current_format;
84
83
CheeseVideoFormat *new_format;
86
g_object_get (widget, "webcam", &webcam, NULL);
88
current_format = cheese_webcam_get_current_video_format (webcam);
89
new_format = cheese_prefs_resolution_combo_get_selected_format (CHEESE_PREFS_RESOLUTION_COMBO (widget));
91
if (new_format != current_format)
92
cheese_webcam_set_video_format (webcam, new_format);
85
g_object_get (widget, "camera", &camera, NULL);
87
new_format = cheese_prefs_resolution_combo_get_selected_format (CHEESE_PREFS_RESOLUTION_COMBO (widget));
88
cheese_camera_set_video_format (camera, new_format);
96
92
cheese_prefs_dialog_on_device_changed (CheesePrefsWidget *widget, CheesePrefsDialog *prefs_dialog)
99
95
char *new_device_name;
100
96
char *old_device_name;
102
g_object_get (widget, "webcam", &webcam, NULL);
103
g_object_get (webcam, "device_name", &old_device_name, NULL);
98
g_object_get (widget, "camera", &camera, NULL);
99
g_object_get (camera, "device_name", &old_device_name, NULL);
105
new_device_name = cheese_prefs_webcam_combo_get_selected_webcam (CHEESE_PREFS_WEBCAM_COMBO (widget));
106
g_object_set (webcam, "device_name", new_device_name, NULL);
101
new_device_name = cheese_prefs_camera_combo_get_selected_camera (CHEESE_PREFS_CAMERA_COMBO (widget));
102
g_object_set (camera, "device_name", new_device_name, NULL);
107
103
g_free (new_device_name);
108
if (!cheese_webcam_switch_webcam_device (webcam))
104
if (!cheese_camera_switch_camera_device (camera))
110
g_warning ("Couldn't change webcam device.");
106
g_warning ("Couldn't change camera device.");
112
108
/* Revert to default device */
113
g_object_set (webcam, "device_name", old_device_name, NULL);
109
g_object_set (camera, "device_name", old_device_name, NULL);
115
111
cheese_prefs_dialog_widgets_synchronize (prefs_dialog->widgets);
116
112
g_free (old_device_name);
120
116
cheese_prefs_dialog_setup_widgets (CheesePrefsDialog *prefs_dialog)
122
118
CheesePrefsWidget *resolution_widget;
123
CheesePrefsWidget *webcam_widget;
119
CheesePrefsWidget *camera_widget;
124
120
CheesePrefsWidget *brightness_widget;
125
121
CheesePrefsWidget *contrast_widget;
126
122
CheesePrefsWidget *saturation_widget;
139
135
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, resolution_widget);
141
webcam_widget = CHEESE_PREFS_WIDGET (cheese_prefs_webcam_combo_new (prefs_dialog->webcam_combo_box,
142
prefs_dialog->webcam,
143
"gconf_prop_webcam"));
137
camera_widget = CHEESE_PREFS_WIDGET (cheese_prefs_camera_combo_new (prefs_dialog->camera_combo_box,
138
prefs_dialog->camera,
139
"gconf_prop_camera"));
145
g_signal_connect (G_OBJECT (webcam_widget), "changed",
141
g_signal_connect (G_OBJECT (camera_widget), "changed",
146
142
G_CALLBACK (cheese_prefs_dialog_on_device_changed),
148
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, webcam_widget);
144
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, camera_widget);
150
146
brightness_widget = CHEESE_PREFS_WIDGET (cheese_prefs_balance_scale_new (prefs_dialog->brightness_scale,
151
prefs_dialog->webcam, "brightness",
147
prefs_dialog->camera, "brightness",
152
148
"gconf_prop_brightness"));
154
150
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, brightness_widget);
156
152
contrast_widget = CHEESE_PREFS_WIDGET (cheese_prefs_balance_scale_new (prefs_dialog->contrast_scale,
157
prefs_dialog->webcam, "contrast",
153
prefs_dialog->camera, "contrast",
158
154
"gconf_prop_contrast"));
160
156
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, contrast_widget);
162
158
saturation_widget = CHEESE_PREFS_WIDGET (cheese_prefs_balance_scale_new (prefs_dialog->saturation_scale,
163
prefs_dialog->webcam, "saturation",
159
prefs_dialog->camera, "saturation",
164
160
"gconf_prop_saturation"));
166
162
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, saturation_widget);
168
164
hue_widget = CHEESE_PREFS_WIDGET (cheese_prefs_balance_scale_new (prefs_dialog->hue_scale,
169
prefs_dialog->webcam, "hue",
165
prefs_dialog->camera, "hue",
170
166
"gconf_prop_hue"));
172
168
cheese_prefs_dialog_widgets_add (prefs_dialog->widgets, hue_widget);
195
191
g_free (prefs_dialog);
195
cheese_prefs_dialog_response (GtkDialog *dialog,
197
CheesePrefsDialog *prefs_dialog)
199
cheese_prefs_dialog_destroy_dialog (prefs_dialog);
199
cheese_prefs_dialog_run (GtkWidget *parent, CheeseGConf *gconf, CheeseWebcam *webcam)
203
cheese_prefs_dialog_run (GtkWidget *parent, CheeseGConf *gconf, CheeseCamera *camera)
201
205
CheesePrefsDialog *prefs_dialog;
203
207
prefs_dialog = g_new0 (CheesePrefsDialog, 1);
205
209
prefs_dialog->parent = parent;
206
prefs_dialog->webcam = webcam;
210
prefs_dialog->camera = camera;
207
211
prefs_dialog->widgets = cheese_prefs_dialog_widgets_new (gconf);
209
213
cheese_prefs_dialog_create_dialog (prefs_dialog);
210
214
cheese_prefs_dialog_setup_widgets (prefs_dialog);
212
gtk_dialog_run (GTK_DIALOG (prefs_dialog->cheese_prefs_dialog));
214
cheese_prefs_dialog_destroy_dialog (prefs_dialog);
216
gtk_widget_show (prefs_dialog->cheese_prefs_dialog);
217
g_signal_connect (G_OBJECT (prefs_dialog->cheese_prefs_dialog), "response",
218
G_CALLBACK (cheese_prefs_dialog_response), prefs_dialog);