Mercurial > audlegacy-plugins
comparison src/cdaudio/configure.c @ 12:3da1b8942b8b trunk
[svn] - remove src/Input src/Output src/Effect src/General src/Visualization src/Container
author | nenolod |
---|---|
date | Mon, 18 Sep 2006 03:14:20 -0700 |
parents | src/Input/cdaudio/configure.c@0ad4849f6219 |
children | d58221dfced1 |
comparison
equal
deleted
inserted
replaced
11:cff1d04026ae | 12:3da1b8942b8b |
---|---|
1 /* BMP - Cross-platform multimedia player | |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 */ | |
21 | |
22 #include "cdaudio.h" | |
23 | |
24 #include <glib.h> | |
25 #include <glib/gi18n.h> | |
26 #include <glib/gprintf.h> | |
27 #include <string.h> | |
28 | |
29 #include <unistd.h> | |
30 #include <fcntl.h> | |
31 #include <errno.h> | |
32 #include <sys/stat.h> | |
33 | |
34 #include <audacious/configdb.h> | |
35 #include <audacious/titlestring.h> | |
36 | |
37 | |
38 #define GET_TB(b) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b)) | |
39 #define SET_TB(b) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b), TRUE) | |
40 | |
41 struct driveconfig { | |
42 GtkWidget *device, *directory; | |
43 GtkWidget *mixer_oss, *mixer_drive; | |
44 GtkWidget *remove_button; | |
45 GtkWidget *dae; | |
46 }; | |
47 | |
48 static GList *drives; | |
49 | |
50 static GtkWidget *cdda_configure_win; | |
51 static GtkWidget *cdi_name, *cdi_name_override; | |
52 static GtkWidget *cdi_use_cddb, *cdi_cddb_server, *cdi_use_cdin, | |
53 *cdi_cdin_server; | |
54 | |
55 void cdda_cddb_show_server_dialog(GtkWidget * w, gpointer data); | |
56 void cdda_cddb_show_network_window(GtkWidget * w, gpointer data); | |
57 void cdda_cddb_set_server(const char *new_server); | |
58 | |
59 static GtkWidget *configurewin_add_drive(struct driveinfo *drive, | |
60 gpointer nb); | |
61 | |
62 static void | |
63 cdda_configurewin_ok_cb(GtkWidget * w, gpointer data) | |
64 { | |
65 ConfigDb *db; | |
66 struct driveinfo *drive; | |
67 GList *node; | |
68 gint olddrives, ndrives, i; | |
69 | |
70 olddrives = g_list_length(cdda_cfg.drives); | |
71 for (node = cdda_cfg.drives; node; node = node->next) { | |
72 drive = node->data; | |
73 g_free(drive->device); | |
74 g_free(drive->directory); | |
75 g_free(drive); | |
76 } | |
77 g_list_free(cdda_cfg.drives); | |
78 cdda_cfg.drives = NULL; | |
79 | |
80 for (node = drives; node; node = node->next) { | |
81 struct driveconfig *config = node->data; | |
82 const gchar *tmp; | |
83 | |
84 drive = g_new0(struct driveinfo, 1); | |
85 drive->device = | |
86 g_strdup(gtk_entry_get_text(GTK_ENTRY(config->device))); | |
87 | |
88 tmp = gtk_entry_get_text(GTK_ENTRY(config->directory)); | |
89 // if (strlen(tmp) < 2 || tmp[strlen(tmp) - 1] == '/') | |
90 drive->directory = g_strdup(tmp); | |
91 // else | |
92 // drive->directory = g_strconcat(tmp, "/", NULL); | |
93 | |
94 // drive->directory = "CD_AUDIO"; | |
95 | |
96 if (GET_TB(config->mixer_oss)) | |
97 drive->mixer = CDDA_MIXER_OSS; | |
98 else if (GET_TB(config->mixer_drive)) | |
99 drive->mixer = CDDA_MIXER_DRIVE; | |
100 else | |
101 drive->mixer = CDDA_MIXER_NONE; | |
102 if (GET_TB(config->dae)) | |
103 drive->dae = CDDA_READ_DAE; | |
104 else | |
105 drive->dae = CDDA_READ_ANALOG; | |
106 | |
107 cdda_cfg.drives = g_list_append(cdda_cfg.drives, drive); | |
108 } | |
109 | |
110 cdda_cfg.title_override = GET_TB(cdi_name_override); | |
111 g_free(cdda_cfg.name_format); | |
112 cdda_cfg.name_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(cdi_name))); | |
113 | |
114 cdda_cfg.use_cddb = GET_TB(cdi_use_cddb); | |
115 cdda_cddb_set_server(gtk_entry_get_text(GTK_ENTRY(cdi_cddb_server))); | |
116 | |
117 cdda_cfg.use_cdin = GET_TB(cdi_use_cdin); | |
118 if (strcmp | |
119 (cdda_cfg.cdin_server, | |
120 gtk_entry_get_text(GTK_ENTRY(cdi_cdin_server)))) { | |
121 g_free(cdda_cfg.cdin_server); | |
122 cdda_cfg.cdin_server = | |
123 g_strdup(gtk_entry_get_text(GTK_ENTRY(cdi_cdin_server))); | |
124 } | |
125 | |
126 db = bmp_cfg_db_open(); | |
127 | |
128 drive = cdda_cfg.drives->data; | |
129 bmp_cfg_db_set_string(db, "CDDA", "device", drive->device); | |
130 bmp_cfg_db_set_string(db, "CDDA", "directory", drive->directory); | |
131 // bmp_cfg_db_set_string(db, "CDDA", "directory", "CD_AUDIO"); | |
132 bmp_cfg_db_set_int(db, "CDDA", "mixer", drive->mixer); | |
133 bmp_cfg_db_set_int(db, "CDDA", "readmode", drive->dae); | |
134 | |
135 /* bmp_cfg_db_set_bool(db, "CDDA", "use_oss_mixer", cdda_cfg.use_oss_mixer); */ | |
136 | |
137 for (node = cdda_cfg.drives->next, i = 1; node; node = node->next, i++) { | |
138 char label[20]; | |
139 drive = node->data; | |
140 | |
141 sprintf(label, "device%d", i); | |
142 bmp_cfg_db_set_string(db, "CDDA", label, drive->device); | |
143 | |
144 sprintf(label, "directory%d", i); | |
145 // bmp_cfg_db_set_string(db, "CDDA", label, "CD_AUDIO"); | |
146 bmp_cfg_db_set_string(db, "CDDA", label, drive->directory); | |
147 | |
148 sprintf(label, "mixer%d", i); | |
149 bmp_cfg_db_set_int(db, "CDDA", label, drive->mixer); | |
150 | |
151 sprintf(label, "readmode%d", i); | |
152 bmp_cfg_db_set_int(db, "CDDA", label, drive->dae); | |
153 } | |
154 | |
155 ndrives = g_list_length(cdda_cfg.drives); | |
156 | |
157 for (i = ndrives; i < olddrives; i++) | |
158 /* FIXME: Clear old entries */ ; | |
159 | |
160 bmp_cfg_db_set_int(db, "CDDA", "num_drives", ndrives); | |
161 | |
162 bmp_cfg_db_set_bool(db, "CDDA", "title_override", | |
163 cdda_cfg.title_override); | |
164 bmp_cfg_db_set_string(db, "CDDA", "name_format", cdda_cfg.name_format); | |
165 bmp_cfg_db_set_bool(db, "CDDA", "use_cddb", cdda_cfg.use_cddb); | |
166 bmp_cfg_db_set_string(db, "CDDA", "cddb_server", cdda_cfg.cddb_server); | |
167 bmp_cfg_db_set_int(db, "CDDA", "cddb_protocol_level", | |
168 cdda_cfg.cddb_protocol_level); | |
169 bmp_cfg_db_set_bool(db, "CDDA", "use_cdin", cdda_cfg.use_cdin); | |
170 bmp_cfg_db_set_string(db, "CDDA", "cdin_server", cdda_cfg.cdin_server); | |
171 bmp_cfg_db_close(db); | |
172 } | |
173 | |
174 static void | |
175 configurewin_close(GtkButton * w, gpointer data) | |
176 { | |
177 GList *node; | |
178 | |
179 for (node = drives; node; node = node->next) | |
180 g_free(node->data); | |
181 g_list_free(drives); | |
182 drives = NULL; | |
183 | |
184 gtk_widget_destroy(cdda_configure_win); | |
185 } | |
186 | |
187 static void | |
188 toggle_set_sensitive_cb(GtkToggleButton * w, gpointer data) | |
189 { | |
190 gboolean set = gtk_toggle_button_get_active(w); | |
191 gtk_widget_set_sensitive(GTK_WIDGET(data), set); | |
192 } | |
193 | |
194 static void | |
195 configurewin_add_page(GtkButton * w, gpointer data) | |
196 { | |
197 GtkNotebook *nb = GTK_NOTEBOOK(data); | |
198 GtkWidget *box = configurewin_add_drive(NULL, nb); | |
199 gchar *label = g_strdup_printf(_("Drive %d"), g_list_length(drives)); | |
200 | |
201 gtk_widget_show_all(box); | |
202 gtk_notebook_append_page(GTK_NOTEBOOK(nb), box, gtk_label_new(label)); | |
203 g_free(label); | |
204 } | |
205 | |
206 static void | |
207 redo_nb_labels(GtkNotebook * nb) | |
208 { | |
209 gint i; | |
210 GtkWidget *child; | |
211 | |
212 for (i = 0; (child = gtk_notebook_get_nth_page(nb, i)) != NULL; i++) { | |
213 gchar *label = g_strdup_printf(_("Drive %d"), i + 1); | |
214 | |
215 gtk_notebook_set_tab_label_text(nb, child, label); | |
216 g_free(label); | |
217 } | |
218 } | |
219 | |
220 | |
221 static void | |
222 configurewin_remove_page(GtkButton * w, gpointer data) | |
223 { | |
224 GList *node; | |
225 GtkNotebook *nb = GTK_NOTEBOOK(data); | |
226 gtk_notebook_remove_page(nb, gtk_notebook_get_current_page(nb)); | |
227 for (node = drives; node; node = node->next) { | |
228 struct driveconfig *drive = node->data; | |
229 | |
230 if (GTK_WIDGET(w) == drive->remove_button) { | |
231 if (node->next) | |
232 redo_nb_labels(nb); | |
233 drives = g_list_remove(drives, drive); | |
234 g_free(drive); | |
235 break; | |
236 } | |
237 } | |
238 if (g_list_length(drives) == 1) { | |
239 struct driveconfig *drive = drives->data; | |
240 gtk_widget_set_sensitive(drive->remove_button, FALSE); | |
241 } | |
242 } | |
243 | |
244 | |
245 static void | |
246 configurewin_check_drive(GtkButton * w, gpointer data) | |
247 { | |
248 struct driveconfig *drive = data; | |
249 GtkWidget *window, *vbox, *label, *bbox, *closeb; | |
250 const gchar *device, *directory; | |
251 gint fd, dae_track = -1; | |
252 GString *str = g_string_new(""); | |
253 struct stat stbuf; | |
254 | |
255 device = gtk_entry_get_text(GTK_ENTRY(drive->device)); | |
256 directory = gtk_entry_get_text(GTK_ENTRY(drive->directory)); | |
257 | |
258 if ((fd = open(device, CDOPENFLAGS) < 0)) | |
259 g_string_sprintfa(str, _("Failed to open device %s\n" | |
260 "Error: %s\n\n"), device, strerror(errno)); | |
261 else { | |
262 cdda_disc_toc_t toc; | |
263 close(fd); | |
264 if (!cdda_get_toc(&toc, device)) | |
265 g_string_append(str, | |
266 _("Failed to read \"Table of Contents\"" | |
267 "\nMaybe no disc in the drive?\n\n")); | |
268 else { | |
269 gint i, data = 0; | |
270 g_string_sprintfa(str, _("Device %s OK.\n" | |
271 "Disc has %d tracks"), device, | |
272 toc.last_track - toc.first_track + 1); | |
273 for (i = toc.first_track; i <= toc.last_track; i++) | |
274 if (toc.track[i].flags.data_track) | |
275 data++; | |
276 else if (dae_track < 0) | |
277 dae_track = i; | |
278 if (data > 0) | |
279 g_string_sprintfa(str, _(" (%d data tracks)"), data); | |
280 g_string_sprintfa(str, _("\nTotal length: %d:%d\n"), | |
281 toc.leadout.minute, toc.leadout.second); | |
282 #ifdef CDDA_HAS_READAUDIO | |
283 if (dae_track == -1) | |
284 g_string_sprintfa(str, | |
285 _("Digital audio extraction " | |
286 "not tested as the disc has " | |
287 "no audio tracks\n")); | |
288 else { | |
289 gint fd = open(device, CDOPENFLAGS); | |
290 gint start, end, fr; | |
291 gchar buffer[CD_FRAMESIZE_RAW]; | |
292 start = LBA(toc.track[dae_track]); | |
293 | |
294 if (dae_track == toc.last_track) | |
295 end = LBA(toc.leadout); | |
296 else | |
297 end = LBA(toc.track[dae_track + 1]); | |
298 fr = read_audio_data(fd, start + (end - start) / 2, | |
299 1, buffer); | |
300 if (fr > 0) | |
301 g_string_sprintfa(str, | |
302 _("Digital audio extraction " | |
303 "test: OK\n\n")); | |
304 else | |
305 g_string_sprintfa(str, | |
306 _("Digital audio extraction " | |
307 "test failed: %s\n\n"), | |
308 strerror(-fr)); | |
309 } | |
310 #else | |
311 g_string_sprintfa(str, "\n"); | |
312 #endif | |
313 } | |
314 } | |
315 if (stat(directory, &stbuf) < 0) { | |
316 g_string_sprintfa(str, _("Failed to check directory %s\n" | |
317 "Error: %s"), directory, strerror(errno)); | |
318 } | |
319 else { | |
320 if (!S_ISDIR(stbuf.st_mode)) | |
321 g_string_sprintfa(str, | |
322 _("Error: %s exist, but is not a directory"), | |
323 directory); | |
324 else | |
325 g_string_sprintfa(str, _("Directory %s OK."), directory); | |
326 } | |
327 | |
328 | |
329 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
330 gtk_window_set_transient_for(GTK_WINDOW(window), | |
331 GTK_WINDOW(cdda_configure_win)); | |
332 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
333 vbox = gtk_vbox_new(FALSE, 10); | |
334 gtk_container_add(GTK_CONTAINER(window), vbox); | |
335 label = gtk_label_new(str->str); | |
336 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
337 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
338 | |
339 bbox = gtk_hbutton_box_new(); | |
340 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD); | |
341 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
342 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
343 | |
344 closeb = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
345 GTK_WIDGET_SET_FLAGS(closeb, GTK_CAN_DEFAULT); | |
346 g_signal_connect_swapped(G_OBJECT(closeb), "clicked", | |
347 G_CALLBACK(gtk_widget_destroy), | |
348 GTK_OBJECT(window)); | |
349 gtk_box_pack_start(GTK_BOX(bbox), closeb, TRUE, TRUE, 0); | |
350 gtk_widget_grab_default(closeb); | |
351 | |
352 g_string_free(str, TRUE); | |
353 | |
354 gtk_widget_show_all(window); | |
355 } | |
356 | |
357 static GtkWidget * | |
358 configurewin_add_drive(struct driveinfo *drive, gpointer nb) | |
359 { | |
360 GtkWidget *vbox, *bbox, *dev_frame, *dev_table, *dev_label; | |
361 GtkWidget *dev_dir_label, *check_btn; | |
362 GtkWidget *volume_frame, *volume_box, *volume_none; | |
363 GtkWidget *readmode_frame, *readmode_box, *readmode_analog; | |
364 struct driveconfig *d = g_new0(struct driveconfig, 1); | |
365 | |
366 vbox = gtk_vbox_new(FALSE, 5); | |
367 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); | |
368 | |
369 dev_frame = gtk_frame_new(_("Device:")); | |
370 gtk_box_pack_start(GTK_BOX(vbox), dev_frame, FALSE, FALSE, 0); | |
371 dev_table = gtk_table_new(2, 2, FALSE); | |
372 gtk_container_set_border_width(GTK_CONTAINER(dev_table), 5); | |
373 gtk_container_add(GTK_CONTAINER(dev_frame), dev_table); | |
374 gtk_table_set_row_spacings(GTK_TABLE(dev_table), 5); | |
375 gtk_table_set_col_spacings(GTK_TABLE(dev_table), 5); | |
376 | |
377 dev_label = gtk_label_new_with_mnemonic(_("_Device:")); | |
378 gtk_misc_set_alignment(GTK_MISC(dev_label), 1.0, 0.5); | |
379 gtk_table_attach(GTK_TABLE(dev_table), dev_label, 0, 1, 0, 1, | |
380 GTK_FILL, 0, 0, 0); | |
381 | |
382 d->device = gtk_entry_new(); | |
383 gtk_label_set_mnemonic_widget(GTK_LABEL(dev_label), d->device); | |
384 gtk_table_attach(GTK_TABLE(dev_table), d->device, 1, 2, 0, 1, | |
385 GTK_FILL | GTK_EXPAND, 0, 0, 0); | |
386 | |
387 dev_dir_label = gtk_label_new_with_mnemonic(_("Dir_ectory:")); | |
388 gtk_misc_set_alignment(GTK_MISC(dev_dir_label), 1.0, 0.5); | |
389 gtk_table_attach(GTK_TABLE(dev_table), dev_dir_label, 0, 1, 1, 2, | |
390 GTK_FILL, 0, 0, 0); | |
391 | |
392 | |
393 d->directory = gtk_entry_new(); | |
394 gtk_label_set_mnemonic_widget(GTK_LABEL(dev_dir_label), d->directory); | |
395 gtk_table_attach(GTK_TABLE(dev_table), d->directory, 1, 2, 1, 2, | |
396 GTK_FILL | GTK_EXPAND, 0, 0, 0); | |
397 | |
398 | |
399 readmode_frame = gtk_frame_new(_("Play mode:")); | |
400 gtk_box_pack_start(GTK_BOX(vbox), readmode_frame, FALSE, FALSE, 0); | |
401 | |
402 readmode_box = gtk_vbox_new(5, FALSE); | |
403 gtk_container_add(GTK_CONTAINER(readmode_frame), readmode_box); | |
404 | |
405 readmode_analog = gtk_radio_button_new_with_label(NULL, _("Analog")); | |
406 gtk_box_pack_start(GTK_BOX(readmode_box), readmode_analog, FALSE, | |
407 FALSE, 0); | |
408 | |
409 d->dae = | |
410 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON | |
411 (readmode_analog), | |
412 _ | |
413 ("Digital audio extraction")); | |
414 gtk_box_pack_start(GTK_BOX(readmode_box), d->dae, FALSE, FALSE, 0); | |
415 #ifndef CDDA_HAS_READAUDIO | |
416 gtk_widget_set_sensitive(readmode_frame, FALSE); | |
417 #endif | |
418 | |
419 /* | |
420 * Volume config | |
421 */ | |
422 | |
423 volume_frame = gtk_frame_new(_("Volume control:")); | |
424 gtk_box_pack_start(GTK_BOX(vbox), volume_frame, FALSE, FALSE, 0); | |
425 | |
426 volume_box = gtk_vbox_new(5, FALSE); | |
427 gtk_container_add(GTK_CONTAINER(volume_frame), volume_box); | |
428 | |
429 volume_none = gtk_radio_button_new_with_label(NULL, _("No mixer")); | |
430 gtk_box_pack_start(GTK_BOX(volume_box), volume_none, FALSE, FALSE, 0); | |
431 | |
432 d->mixer_drive = | |
433 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON | |
434 (volume_none), | |
435 _("CDROM drive")); | |
436 gtk_box_pack_start(GTK_BOX(volume_box), d->mixer_drive, FALSE, FALSE, 0); | |
437 | |
438 d->mixer_oss = | |
439 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON | |
440 (volume_none), | |
441 _("OSS mixer")); | |
442 gtk_box_pack_start(GTK_BOX(volume_box), d->mixer_oss, FALSE, FALSE, 0); | |
443 | |
444 g_signal_connect(G_OBJECT(readmode_analog), "toggled", | |
445 G_CALLBACK(toggle_set_sensitive_cb), volume_frame); | |
446 #ifndef HAVE_OSS | |
447 gtk_widget_set_sensitive(d->mixer_oss, FALSE); | |
448 #endif | |
449 if (drive) { | |
450 gtk_entry_set_text(GTK_ENTRY(d->device), drive->device); | |
451 gtk_entry_set_text(GTK_ENTRY(d->directory), drive->directory); | |
452 if (drive->mixer == CDDA_MIXER_DRIVE) | |
453 SET_TB(d->mixer_drive); | |
454 else if (drive->mixer == CDDA_MIXER_OSS) | |
455 SET_TB(d->mixer_oss); | |
456 if (drive->dae == CDDA_READ_DAE) | |
457 SET_TB(d->dae); | |
458 } | |
459 | |
460 bbox = gtk_hbutton_box_new(); | |
461 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
462 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD); | |
463 | |
464 check_btn = gtk_button_new_with_label(_("Check drive...")); | |
465 GTK_WIDGET_SET_FLAGS(check_btn, GTK_CAN_DEFAULT); | |
466 gtk_box_pack_start_defaults(GTK_BOX(bbox), check_btn); | |
467 g_signal_connect(G_OBJECT(check_btn), "clicked", | |
468 G_CALLBACK(configurewin_check_drive), d); | |
469 | |
470 d->remove_button = gtk_button_new_with_label(_("Remove drive")); | |
471 GTK_WIDGET_SET_FLAGS(d->remove_button, GTK_CAN_DEFAULT); | |
472 gtk_box_pack_start_defaults(GTK_BOX(bbox), d->remove_button); | |
473 g_signal_connect(G_OBJECT(d->remove_button), "clicked", | |
474 G_CALLBACK(configurewin_remove_page), nb); | |
475 | |
476 | |
477 if (drives == NULL) | |
478 gtk_widget_set_sensitive(d->remove_button, FALSE); | |
479 else { | |
480 struct driveconfig *tmp = drives->data; | |
481 gtk_widget_set_sensitive(tmp->remove_button, TRUE); | |
482 } | |
483 | |
484 drives = g_list_append(drives, d); | |
485 | |
486 return vbox; | |
487 } | |
488 | |
489 void | |
490 cdda_configure(void) | |
491 { | |
492 GtkWidget *vbox, *notebook; | |
493 GtkWidget *dev_vbox, *dev_notebook, *add_drive, *add_bbox; | |
494 GtkWidget *cdi_vbox; | |
495 GtkWidget *cdi_cddb_frame, *cdi_cddb_vbox, *cdi_cddb_hbox; | |
496 GtkWidget *cdi_cddb_server_hbox, *cdi_cddb_server_label; | |
497 GtkWidget *cdi_cddb_server_list, *cdi_cddb_debug_win; | |
498 GtkWidget *cdi_cdin_frame, *cdi_cdin_vbox; | |
499 GtkWidget *cdi_cdin_server_hbox, *cdi_cdin_server_label; | |
500 GtkWidget *cdi_name_frame, *cdi_name_vbox, *cdi_name_hbox; | |
501 GtkWidget *cdi_name_label, *cdi_desc; | |
502 GtkWidget *cdi_name_enable_vbox; | |
503 GtkWidget *bbox, *ok, *cancel; | |
504 | |
505 GList *node; | |
506 gint i = 1; | |
507 | |
508 if (cdda_configure_win) | |
509 return; | |
510 | |
511 cdda_configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
512 g_signal_connect(G_OBJECT(cdda_configure_win), "destroy", | |
513 G_CALLBACK(gtk_widget_destroyed), &cdda_configure_win); | |
514 gtk_window_set_title(GTK_WINDOW(cdda_configure_win), | |
515 _("CD Audio Player Configuration")); | |
516 gtk_window_set_type_hint(GTK_WINDOW(cdda_configure_win), | |
517 GDK_WINDOW_TYPE_HINT_DIALOG); | |
518 gtk_window_set_resizable(GTK_WINDOW(cdda_configure_win), FALSE); | |
519 gtk_window_set_position(GTK_WINDOW(cdda_configure_win), | |
520 GTK_WIN_POS_MOUSE); | |
521 gtk_container_border_width(GTK_CONTAINER(cdda_configure_win), 10); | |
522 | |
523 vbox = gtk_vbox_new(FALSE, 10); | |
524 gtk_container_add(GTK_CONTAINER(cdda_configure_win), vbox); | |
525 | |
526 notebook = gtk_notebook_new(); | |
527 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); | |
528 | |
529 /* | |
530 * Device config | |
531 */ | |
532 dev_vbox = gtk_vbox_new(FALSE, 5); | |
533 gtk_container_set_border_width(GTK_CONTAINER(dev_vbox), 5); | |
534 | |
535 dev_notebook = gtk_notebook_new(); | |
536 gtk_notebook_set_scrollable(GTK_NOTEBOOK(dev_notebook), TRUE); | |
537 gtk_box_pack_start(GTK_BOX(dev_vbox), dev_notebook, FALSE, FALSE, 0); | |
538 | |
539 for (node = cdda_cfg.drives; node; node = node->next) { | |
540 struct driveinfo *drive = node->data; | |
541 gchar *label = g_strdup_printf(_("Drive %d"), i++); | |
542 GtkWidget *w; | |
543 | |
544 w = configurewin_add_drive(drive, dev_notebook); | |
545 gtk_notebook_append_page(GTK_NOTEBOOK(dev_notebook), w, | |
546 gtk_label_new(label)); | |
547 g_free(label); | |
548 | |
549 } | |
550 | |
551 add_bbox = gtk_hbutton_box_new(); | |
552 gtk_box_pack_start(GTK_BOX(dev_vbox), add_bbox, FALSE, FALSE, 0); | |
553 add_drive = gtk_button_new_with_label(_("Add drive")); | |
554 g_signal_connect(G_OBJECT(add_drive), "clicked", | |
555 G_CALLBACK(configurewin_add_page), dev_notebook); | |
556 GTK_WIDGET_SET_FLAGS(add_drive, GTK_CAN_DEFAULT); | |
557 gtk_box_pack_start(GTK_BOX(add_bbox), add_drive, FALSE, FALSE, 0); | |
558 | |
559 | |
560 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dev_vbox, | |
561 gtk_label_new(_("Device"))); | |
562 | |
563 /* | |
564 * CD Info config | |
565 */ | |
566 cdi_vbox = gtk_vbox_new(FALSE, 5); | |
567 gtk_container_set_border_width(GTK_CONTAINER(cdi_vbox), 5); | |
568 | |
569 | |
570 /* CDDB */ | |
571 cdi_cddb_frame = gtk_frame_new(_("CDDB:")); | |
572 gtk_box_pack_start(GTK_BOX(cdi_vbox), cdi_cddb_frame, FALSE, FALSE, 0); | |
573 | |
574 cdi_cddb_vbox = gtk_vbox_new(FALSE, 10); | |
575 gtk_container_border_width(GTK_CONTAINER(cdi_cddb_vbox), 5); | |
576 gtk_container_add(GTK_CONTAINER(cdi_cddb_frame), cdi_cddb_vbox); | |
577 | |
578 cdi_cddb_hbox = gtk_hbox_new(FALSE, 10); | |
579 gtk_container_border_width(GTK_CONTAINER(cdi_cddb_hbox), 0); | |
580 gtk_box_pack_start(GTK_BOX(cdi_cddb_vbox), | |
581 cdi_cddb_hbox, FALSE, FALSE, 0); | |
582 cdi_use_cddb = gtk_check_button_new_with_label(_("Use CDDB")); | |
583 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cdi_use_cddb), | |
584 cdda_cfg.use_cddb); | |
585 gtk_box_pack_start(GTK_BOX(cdi_cddb_hbox), cdi_use_cddb, FALSE, FALSE, 0); | |
586 cdi_cddb_server_list = gtk_button_new_with_label(_("Get server list")); | |
587 gtk_box_pack_end(GTK_BOX(cdi_cddb_hbox), cdi_cddb_server_list, FALSE, | |
588 FALSE, 0); | |
589 cdi_cddb_debug_win = gtk_button_new_with_label(_("Show network window")); | |
590 g_signal_connect(G_OBJECT(cdi_cddb_debug_win), "clicked", | |
591 G_CALLBACK(cdda_cddb_show_network_window), NULL); | |
592 gtk_box_pack_end(GTK_BOX(cdi_cddb_hbox), cdi_cddb_debug_win, FALSE, | |
593 FALSE, 0); | |
594 | |
595 cdi_cddb_server_hbox = gtk_hbox_new(FALSE, 5); | |
596 gtk_box_pack_start(GTK_BOX(cdi_cddb_vbox), | |
597 cdi_cddb_server_hbox, FALSE, FALSE, 0); | |
598 | |
599 cdi_cddb_server_label = gtk_label_new(_("CDDB server:")); | |
600 gtk_box_pack_start(GTK_BOX(cdi_cddb_server_hbox), | |
601 cdi_cddb_server_label, FALSE, FALSE, 0); | |
602 | |
603 cdi_cddb_server = gtk_entry_new(); | |
604 gtk_entry_set_text(GTK_ENTRY(cdi_cddb_server), cdda_cfg.cddb_server); | |
605 gtk_box_pack_start(GTK_BOX(cdi_cddb_server_hbox), cdi_cddb_server, | |
606 TRUE, TRUE, 0); | |
607 g_signal_connect(G_OBJECT(cdi_cddb_server_list), "clicked", | |
608 G_CALLBACK(cdda_cddb_show_server_dialog), | |
609 cdi_cddb_server); | |
610 | |
611 /* | |
612 * CDindex | |
613 */ | |
614 cdi_cdin_frame = gtk_frame_new(_("CD Index:")); | |
615 gtk_box_pack_start(GTK_BOX(cdi_vbox), cdi_cdin_frame, FALSE, FALSE, 0); | |
616 | |
617 cdi_cdin_vbox = gtk_vbox_new(FALSE, 10); | |
618 gtk_container_border_width(GTK_CONTAINER(cdi_cdin_vbox), 5); | |
619 gtk_container_add(GTK_CONTAINER(cdi_cdin_frame), cdi_cdin_vbox); | |
620 | |
621 cdi_use_cdin = gtk_check_button_new_with_label(_("Use CD Index")); | |
622 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cdi_use_cdin), | |
623 cdda_cfg.use_cdin); | |
624 gtk_box_pack_start(GTK_BOX(cdi_cdin_vbox), cdi_use_cdin, FALSE, FALSE, 0); | |
625 | |
626 cdi_cdin_server_hbox = gtk_hbox_new(FALSE, 5); | |
627 gtk_box_pack_start(GTK_BOX(cdi_cdin_vbox), cdi_cdin_server_hbox, FALSE, | |
628 FALSE, 0); | |
629 | |
630 cdi_cdin_server_label = gtk_label_new(_("CD Index server:")); | |
631 gtk_box_pack_start(GTK_BOX(cdi_cdin_server_hbox), | |
632 cdi_cdin_server_label, FALSE, FALSE, 0); | |
633 | |
634 cdi_cdin_server = gtk_entry_new(); | |
635 gtk_entry_set_text(GTK_ENTRY(cdi_cdin_server), cdda_cfg.cdin_server); | |
636 gtk_box_pack_start(GTK_BOX(cdi_cdin_server_hbox), cdi_cdin_server, | |
637 TRUE, TRUE, 0); | |
638 #ifndef WITH_CDINDEX | |
639 gtk_widget_set_sensitive(cdi_cdin_frame, FALSE); | |
640 #endif | |
641 | |
642 /* | |
643 * Track names | |
644 */ | |
645 cdi_name_frame = gtk_frame_new(_("Track names:")); | |
646 gtk_box_pack_start(GTK_BOX(cdi_vbox), cdi_name_frame, FALSE, FALSE, 0); | |
647 | |
648 cdi_name_vbox = gtk_vbox_new(FALSE, 10); | |
649 gtk_container_add(GTK_CONTAINER(cdi_name_frame), cdi_name_vbox); | |
650 gtk_container_border_width(GTK_CONTAINER(cdi_name_vbox), 5); | |
651 cdi_name_override = | |
652 gtk_check_button_new_with_label(_("Override generic titles")); | |
653 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cdi_name_override), | |
654 cdda_cfg.title_override); | |
655 gtk_box_pack_start(GTK_BOX(cdi_name_vbox), cdi_name_override, FALSE, | |
656 FALSE, 0); | |
657 | |
658 cdi_name_enable_vbox = gtk_vbox_new(FALSE, 10); | |
659 gtk_container_add(GTK_CONTAINER(cdi_name_vbox), cdi_name_enable_vbox); | |
660 gtk_widget_set_sensitive(cdi_name_enable_vbox, cdda_cfg.title_override); | |
661 g_signal_connect(G_OBJECT(cdi_name_override), "toggled", | |
662 G_CALLBACK(toggle_set_sensitive_cb), | |
663 cdi_name_enable_vbox); | |
664 | |
665 cdi_name_hbox = gtk_hbox_new(FALSE, 5); | |
666 gtk_box_pack_start(GTK_BOX(cdi_name_enable_vbox), cdi_name_hbox, FALSE, | |
667 FALSE, 0); | |
668 cdi_name_label = gtk_label_new(_("Name format:")); | |
669 gtk_box_pack_start(GTK_BOX(cdi_name_hbox), cdi_name_label, FALSE, | |
670 FALSE, 0); | |
671 cdi_name = gtk_entry_new(); | |
672 gtk_entry_set_text(GTK_ENTRY(cdi_name), cdda_cfg.name_format); | |
673 gtk_box_pack_start(GTK_BOX(cdi_name_hbox), cdi_name, TRUE, TRUE, 0); | |
674 | |
675 cdi_desc = xmms_titlestring_descriptions("patn", 2); | |
676 gtk_box_pack_start(GTK_BOX(cdi_name_enable_vbox), cdi_desc, FALSE, | |
677 FALSE, 0); | |
678 | |
679 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), cdi_vbox, | |
680 gtk_label_new(_("CD Info"))); | |
681 | |
682 bbox = gtk_hbutton_box_new(); | |
683 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
684 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
685 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
686 | |
687 | |
688 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
689 g_signal_connect(G_OBJECT(cancel), "clicked", | |
690 G_CALLBACK(configurewin_close), NULL); | |
691 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
692 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
693 | |
694 ok = gtk_button_new_from_stock(GTK_STOCK_OK); | |
695 g_signal_connect(G_OBJECT(ok), "clicked", | |
696 G_CALLBACK(cdda_configurewin_ok_cb), NULL); | |
697 g_signal_connect(G_OBJECT(ok), "clicked", | |
698 G_CALLBACK(configurewin_close), NULL); | |
699 GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT); | |
700 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0); | |
701 gtk_widget_grab_default(ok); | |
702 | |
703 | |
704 gtk_widget_show_all(cdda_configure_win); | |
705 } |