Mercurial > audlegacy-plugins
annotate src/filewriter/filewriter.c @ 1101:661777673349 trunk
[svn] - pulse: convert to plugin API v2
author | nenolod |
---|---|
date | Thu, 24 May 2007 23:37:12 -0700 |
parents | 91f6c4647bae |
children | 0eddd8516e32 |
rev | line source |
---|---|
984 | 1 /* FileWriter-Plugin |
2 * (C) copyright 2007 merging of Disk Writer and Out-Lame by Michael Färber | |
3 * | |
4 * Original Out-Lame-Plugin: | |
5 * (C) copyright 2002 Lars Siebold <khandha5@gmx.net> | |
6 * (C) copyright 2006-2007 porting to audacious by Yoshiki Yazawa <yaz@cc.rim.or.jp> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
21 */ | |
22 | |
23 #include "filewriter.h" | |
24 #include "plugins.h" | |
25 | |
26 static GtkWidget *configure_win = NULL, *configure_vbox; | |
27 static GtkWidget *path_hbox, *path_label, *path_dirbrowser; | |
28 static GtkWidget *configure_bbox, *configure_ok, *configure_cancel; | |
29 | |
30 static GtkWidget *fileext_hbox, *fileext_label, *fileext_combo, *plugin_button; | |
1000 | 31 |
32 enum fileext_t | |
33 { | |
34 WAV = 0, | |
35 #ifdef FILEWRITER_MP3 | |
36 MP3, | |
37 #endif | |
38 #ifdef FILEWRITER_VORBIS | |
39 VORBIS, | |
40 #endif | |
41 #ifdef FILEWRITER_FLAC | |
42 FLAC, | |
43 #endif | |
44 FILEEXT_MAX | |
45 }; | |
46 | |
984 | 47 static gint fileext = WAV; |
1000 | 48 static gchar *fileext_str[] = |
49 { | |
50 "wav", | |
51 #ifdef FILEWRITER_MP3 | |
52 "mp3", | |
53 #endif | |
54 #ifdef FILEWRITER_VORBIS | |
55 "ogg", | |
56 #endif | |
57 #ifdef FILEWRITER_FLAC | |
58 "flac" | |
59 #endif | |
60 }; | |
61 | |
984 | 62 static FileWriter plugin; |
63 | |
64 static GtkWidget *saveplace_hbox, *saveplace; | |
65 static gboolean save_original = TRUE; | |
66 | |
67 static GtkWidget *filenamefrom_hbox, *filenamefrom_label, *filenamefrom_toggle; | |
68 static gboolean filenamefromtags = TRUE; | |
69 | |
70 static GtkWidget *use_suffix_toggle = NULL; | |
71 static gboolean use_suffix = FALSE; | |
72 | |
73 static GtkWidget *prependnumber_toggle; | |
74 static gboolean prependnumber = FALSE; | |
75 | |
76 static gchar *file_path = NULL; | |
77 | |
78 static void file_init(void); | |
79 static void file_about(void); | |
80 static gint file_open(AFormat fmt, gint rate, gint nch); | |
81 static void file_write(void *ptr, gint length); | |
82 static void file_close(void); | |
83 static void file_flush(gint time); | |
84 static void file_pause(short p); | |
85 static gint file_free(void); | |
86 static gint file_playing(void); | |
87 static gint file_get_written_time(void); | |
88 static gint file_get_output_time(void); | |
89 static void file_configure(void); | |
90 | |
91 OutputPlugin file_op = | |
92 { | |
93 NULL, | |
94 NULL, | |
1076 | 95 "FileWriter Plugin", |
984 | 96 file_init, |
97 NULL, | |
98 file_about, | |
99 file_configure, | |
100 NULL, | |
101 NULL, | |
102 file_open, | |
103 file_write, | |
104 file_close, | |
105 file_flush, | |
106 file_pause, | |
107 file_free, | |
108 file_playing, | |
109 file_get_output_time, | |
110 file_get_written_time, | |
111 NULL | |
112 }; | |
113 | |
1076 | 114 OutputPlugin *file_oplist[] = { &file_op, NULL }; |
115 | |
116 DECLARE_PLUGIN(filewriter, NULL, NULL, file_oplist, NULL, NULL, NULL, NULL); | |
984 | 117 |
118 static void set_plugin(void) | |
119 { | |
120 if (fileext < 0 || fileext >= FILEEXT_MAX) | |
121 fileext = 0; | |
122 | |
123 if (fileext == WAV) | |
124 plugin = wav_plugin; | |
1000 | 125 #ifdef FILEWRITER_MP3 |
984 | 126 if (fileext == MP3) |
127 plugin = mp3_plugin; | |
1000 | 128 #endif |
129 #ifdef FILEWRITER_VORBIS | |
986 | 130 if (fileext == VORBIS) |
131 plugin = vorbis_plugin; | |
1000 | 132 #endif |
133 #ifdef FILEWRITER_FLAC | |
991 | 134 if (fileext == FLAC) |
135 plugin = flac_plugin; | |
1000 | 136 #endif |
984 | 137 } |
138 | |
139 static void file_init(void) | |
140 { | |
141 ConfigDb *db; | |
142 | |
143 db = bmp_cfg_db_open(); | |
144 bmp_cfg_db_get_int(db, "filewriter", "fileext", &fileext); | |
145 bmp_cfg_db_get_string(db, "filewriter", "file_path", &file_path); | |
146 bmp_cfg_db_get_bool(db, "filewriter", "save_original", &save_original); | |
147 bmp_cfg_db_get_bool(db, "filewriter", "use_suffix", &use_suffix); | |
148 bmp_cfg_db_get_bool(db, "filewriter", "filenamefromtags", &filenamefromtags); | |
149 bmp_cfg_db_get_bool(db, "filewriter", "prependnumber", &prependnumber); | |
150 bmp_cfg_db_close(db); | |
151 | |
152 if (!file_path) | |
153 file_path = g_strdup(g_get_home_dir()); | |
154 | |
155 set_plugin(); | |
156 if (plugin.init) | |
157 plugin.init(); | |
158 } | |
159 | |
160 void file_about(void) | |
161 { | |
162 static GtkWidget *dialog; | |
163 | |
164 if (dialog != NULL) | |
165 return; | |
166 | |
167 dialog = xmms_show_message("About FileWriter-Plugin", | |
168 "FileWriter-Plugin\n\n" | |
169 "This program is free software; you can redistribute it and/or modify\n" | |
170 "it under the terms of the GNU General Public License as published by\n" | |
171 "the Free Software Foundation; either version 2 of the License, or\n" | |
172 "(at your option) any later version.\n" | |
173 "\n" | |
174 "This program is distributed in the hope that it will be useful,\n" | |
175 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" | |
176 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" | |
177 "GNU General Public License for more details.\n" | |
178 "\n" | |
179 "You should have received a copy of the GNU General Public License\n" | |
180 "along with this program; if not, write to the Free Software\n" | |
181 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\n" | |
182 "USA.", "Ok", FALSE, NULL, NULL); | |
183 gtk_signal_connect(GTK_OBJECT(dialog), "destroy", | |
184 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog); | |
185 } | |
186 | |
187 static gint file_open(AFormat fmt, gint rate, gint nch) | |
188 { | |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
189 gchar *filename = NULL, *temp = NULL; |
984 | 190 gint pos; |
1004
be2d04b2bd28
[svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents:
1000
diff
changeset
|
191 gint rv; |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
192 Playlist *playlist; |
984 | 193 |
194 if (xmms_check_realtime_priority()) | |
195 { | |
196 xmms_show_message(_("Error"), | |
197 _("You cannot use the FileWriter plugin\n" | |
198 "when you're running in realtime mode."), | |
199 _("OK"), FALSE, NULL, NULL); | |
200 return 0; | |
201 } | |
202 | |
203 input.format = fmt; | |
204 input.frequency = rate; | |
205 input.channels = nch; | |
206 | |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
207 playlist = playlist_get_active(); |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
208 if(!playlist) |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
209 return 0; |
984 | 210 |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
211 pos = playlist_get_position(playlist); |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
212 tuple = playlist_get_tuple(playlist, pos); |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
213 if(!tuple) |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
214 return 0; |
984 | 215 |
216 if (filenamefromtags) | |
217 { | |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
218 gchar *utf8 = xmms_get_titlestring(xmms_get_gentitle_format(), tuple); |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
219 |
984 | 220 g_strchomp(utf8); //chop trailing ^J --yaz |
221 | |
222 filename = g_locale_from_utf8(utf8, -1, NULL, NULL, NULL); | |
223 g_free(utf8); | |
224 while (filename != NULL && (temp = strchr(filename, '/')) != NULL) | |
225 *temp = '-'; | |
226 } | |
227 if (filename == NULL) | |
228 { | |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
229 filename = g_strdup(tuple->file_name); |
984 | 230 if (!use_suffix) |
231 if ((temp = strrchr(filename, '.')) != NULL) | |
232 *temp = '\0'; | |
233 } | |
234 if (filename == NULL) | |
235 filename = g_strdup_printf("aud-%d", pos); | |
236 | |
237 | |
238 if (prependnumber) | |
239 { | |
240 gint number; | |
241 if (tuple && tuple->track_number) | |
242 number = tuple->track_number; | |
243 else | |
244 number = pos + 1; | |
245 | |
246 temp = g_strdup_printf("%.02d %s", number, filename); | |
247 g_free(filename); | |
248 filename = temp; | |
249 } | |
250 | |
251 gchar *directory; | |
252 if (save_original) | |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
253 directory = g_strdup(tuple->file_path); |
984 | 254 else |
255 directory = g_strdup(file_path); | |
256 | |
257 temp = g_strdup_printf("%s/%s.%s", | |
258 directory, filename, fileext_str[fileext]); | |
259 g_free(directory); | |
260 g_free(filename); | |
261 filename = temp; | |
262 | |
263 output_file = vfs_fopen(filename, "w"); | |
264 g_free(filename); | |
265 | |
266 if (!output_file) | |
267 return 0; | |
268 | |
1004
be2d04b2bd28
[svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents:
1000
diff
changeset
|
269 rv = plugin.open(); |
be2d04b2bd28
[svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents:
1000
diff
changeset
|
270 |
be2d04b2bd28
[svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents:
1000
diff
changeset
|
271 return rv; |
984 | 272 } |
273 | |
274 static void convert_buffer(gpointer buffer, gint length) | |
275 { | |
276 gint i; | |
277 | |
278 if (input.format == FMT_S8) | |
279 { | |
280 guint8 *ptr1 = buffer; | |
281 gint8 *ptr2 = buffer; | |
282 | |
283 for (i = 0; i < length; i++) | |
284 *(ptr1++) = *(ptr2++) ^ 128; | |
285 } | |
286 if (input.format == FMT_S16_BE) | |
287 { | |
288 gint16 *ptr = buffer; | |
289 | |
290 for (i = 0; i < length >> 1; i++, ptr++) | |
291 *ptr = GUINT16_SWAP_LE_BE(*ptr); | |
292 } | |
293 if (input.format == FMT_S16_NE) | |
294 { | |
295 gint16 *ptr = buffer; | |
296 | |
297 for (i = 0; i < length >> 1; i++, ptr++) | |
298 *ptr = GINT16_TO_LE(*ptr); | |
299 } | |
300 if (input.format == FMT_U16_BE) | |
301 { | |
302 gint16 *ptr1 = buffer; | |
303 guint16 *ptr2 = buffer; | |
304 | |
305 for (i = 0; i < length >> 1; i++, ptr2++) | |
306 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768); | |
307 } | |
308 if (input.format == FMT_U16_LE) | |
309 { | |
310 gint16 *ptr1 = buffer; | |
311 guint16 *ptr2 = buffer; | |
312 | |
313 for (i = 0; i < length >> 1; i++, ptr2++) | |
314 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768); | |
315 } | |
316 if (input.format == FMT_U16_NE) | |
317 { | |
318 gint16 *ptr1 = buffer; | |
319 guint16 *ptr2 = buffer; | |
320 | |
321 for (i = 0; i < length >> 1; i++, ptr2++) | |
322 *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768); | |
323 } | |
324 } | |
325 | |
326 static void file_write(void *ptr, gint length) | |
327 { | |
328 AFormat new_format; | |
329 int new_frequency, new_channels; | |
330 EffectPlugin *ep; | |
331 | |
332 new_format = input.format; | |
333 new_frequency = input.frequency; | |
334 new_channels = input.channels; | |
335 | |
336 ep = get_current_effect_plugin(); | |
337 if ( effects_enabled() && ep && ep->query_format ) { | |
338 ep->query_format(&new_format,&new_frequency,&new_channels); | |
339 } | |
340 | |
341 if ( effects_enabled() && ep && ep->mod_samples ) { | |
342 length = ep->mod_samples(&ptr,length, | |
343 input.format, | |
344 input.frequency, | |
345 input.channels ); | |
346 } | |
347 | |
348 if (input.format == FMT_S8 || input.format == FMT_S16_BE || | |
349 input.format == FMT_U16_LE || input.format == FMT_U16_BE || | |
350 input.format == FMT_U16_NE) | |
351 convert_buffer(ptr, length); | |
352 #ifdef WORDS_BIGENDIAN | |
353 if (input.format == FMT_S16_NE) | |
354 convert_buffer(ptr, length); | |
355 #endif | |
356 | |
357 plugin.write(ptr, length); | |
358 } | |
359 | |
360 static void file_close(void) | |
361 { | |
362 plugin.close(); | |
363 | |
364 if (output_file) | |
365 { | |
366 written = 0; | |
367 vfs_fclose(output_file); | |
368 } | |
369 output_file = NULL; | |
370 } | |
371 | |
372 static void file_flush(gint time) | |
373 { | |
374 if (time < 0) | |
375 return; | |
376 | |
377 file_close(); | |
378 file_open(input.format, input.frequency, input.channels); | |
379 | |
380 offset = time; | |
381 } | |
382 | |
383 static void file_pause(short p) | |
384 { | |
385 } | |
386 | |
387 static gint file_free(void) | |
388 { | |
389 return plugin.free(); | |
390 } | |
391 | |
392 static gint file_playing(void) | |
393 { | |
394 return plugin.playing(); | |
395 } | |
396 | |
397 static gint file_get_written_time(void) | |
398 { | |
399 return plugin.get_written_time(); | |
400 } | |
401 | |
402 static gint file_get_output_time(void) | |
403 { | |
404 return file_get_written_time(); | |
405 } | |
406 | |
407 static void configure_ok_cb(gpointer data) | |
408 { | |
409 ConfigDb *db; | |
410 | |
411 fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo)); | |
412 | |
413 g_free(file_path); | |
414 file_path = g_strdup(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(path_dirbrowser))); | |
415 | |
416 use_suffix = | |
417 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_suffix_toggle)); | |
418 | |
419 prependnumber = | |
420 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prependnumber_toggle)); | |
421 | |
422 db = bmp_cfg_db_open(); | |
423 bmp_cfg_db_set_int(db, "filewriter", "fileext", fileext); | |
424 bmp_cfg_db_set_string(db, "filewriter", "file_path", file_path); | |
425 bmp_cfg_db_set_bool(db, "filewriter", "save_original", save_original); | |
426 bmp_cfg_db_set_bool(db, "filewriter", "filenamefromtags", filenamefromtags); | |
427 bmp_cfg_db_set_bool(db, "filewriter", "use_suffix", use_suffix); | |
428 bmp_cfg_db_set_bool(db, "filewriter", "prependnumber", prependnumber); | |
429 | |
430 bmp_cfg_db_close(db); | |
431 | |
432 gtk_widget_destroy(configure_win); | |
433 if (path_dirbrowser) | |
434 gtk_widget_destroy(path_dirbrowser); | |
435 } | |
436 | |
437 static void fileext_cb(GtkWidget *combo, gpointer data) | |
438 { | |
439 fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo)); | |
440 set_plugin(); | |
441 | |
442 gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL); | |
443 } | |
444 | |
445 static void plugin_configure_cb(GtkWidget *button, gpointer data) | |
446 { | |
447 if (plugin.configure) | |
448 plugin.configure(); | |
449 } | |
450 | |
451 | |
452 static void saveplace_original_cb(GtkWidget *button, gpointer data) | |
453 { | |
454 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
455 { | |
456 gtk_widget_set_sensitive(path_hbox, FALSE); | |
457 save_original = TRUE; | |
458 } | |
459 } | |
460 | |
461 static void saveplace_custom_cb(GtkWidget *button, gpointer data) | |
462 { | |
463 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
464 { | |
465 gtk_widget_set_sensitive(path_hbox, TRUE); | |
466 save_original = FALSE; | |
467 } | |
468 } | |
469 | |
470 static void filenamefromtags_cb(GtkWidget *button, gpointer data) | |
471 { | |
472 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
473 { | |
474 gtk_widget_set_sensitive(use_suffix_toggle, FALSE); | |
475 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), FALSE); | |
476 use_suffix = FALSE; | |
477 filenamefromtags = TRUE; | |
478 } | |
479 } | |
480 | |
481 static void filenamefromfilename_cb(GtkWidget *button, gpointer data) | |
482 { | |
483 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
484 { | |
485 gtk_widget_set_sensitive(use_suffix_toggle, TRUE); | |
486 filenamefromtags = FALSE; | |
487 } | |
488 } | |
489 | |
490 | |
491 static void configure_destroy(void) | |
492 { | |
493 if (path_dirbrowser) | |
494 gtk_widget_destroy(path_dirbrowser); | |
495 } | |
496 | |
497 static void file_configure(void) | |
498 { | |
499 GtkTooltips *use_suffix_tooltips; | |
500 | |
501 if (!configure_win) | |
502 { | |
503 configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
504 | |
505 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", | |
506 GTK_SIGNAL_FUNC(configure_destroy), NULL); | |
507 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", | |
508 GTK_SIGNAL_FUNC(gtk_widget_destroyed), | |
509 &configure_win); | |
510 | |
511 gtk_window_set_title(GTK_WINDOW(configure_win), | |
985 | 512 _("File Writer Configuration")); |
984 | 513 gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE); |
514 | |
515 gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10); | |
516 | |
517 configure_vbox = gtk_vbox_new(FALSE, 10); | |
518 gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox); | |
519 | |
520 | |
521 fileext_hbox = gtk_hbox_new(FALSE, 5); | |
522 gtk_box_pack_start(GTK_BOX(configure_vbox), fileext_hbox, FALSE, FALSE, 0); | |
523 | |
986 | 524 fileext_label = gtk_label_new(_("Output file format:")); |
984 | 525 gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_label, FALSE, FALSE, 0); |
526 | |
527 fileext_combo = gtk_combo_box_new_text(); | |
528 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "WAV"); | |
1000 | 529 #ifdef FILEWRITER_MP3 |
984 | 530 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "MP3"); |
1000 | 531 #endif |
532 #ifdef FILEWRITER_VORBIS | |
986 | 533 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "Vorbis"); |
1000 | 534 #endif |
535 #ifdef FILEWRITER_FLAC | |
991 | 536 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "FLAC"); |
1000 | 537 #endif |
984 | 538 gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_combo, FALSE, FALSE, 0); |
539 gtk_combo_box_set_active(GTK_COMBO_BOX(fileext_combo), fileext); | |
540 g_signal_connect(G_OBJECT(fileext_combo), "changed", G_CALLBACK(fileext_cb), NULL); | |
541 | |
542 plugin_button = gtk_button_new_with_label(_("Configure")); | |
543 gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL); | |
544 g_signal_connect(G_OBJECT(plugin_button), "clicked", G_CALLBACK(plugin_configure_cb), NULL); | |
545 gtk_box_pack_end(GTK_BOX(fileext_hbox), plugin_button, FALSE, FALSE, 0); | |
546 | |
547 | |
548 | |
549 | |
550 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
551 | |
552 | |
553 | |
554 saveplace_hbox = gtk_hbox_new(FALSE, 5); | |
555 gtk_container_add(GTK_CONTAINER(configure_vbox), saveplace_hbox); | |
556 | |
557 saveplace = gtk_radio_button_new_with_label(NULL, _("Save into original directory")); | |
558 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_original_cb), NULL); | |
559 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0); | |
560 | |
561 saveplace = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(saveplace), | |
562 _("Save into custom directory")); | |
563 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_custom_cb), NULL); | |
564 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0); | |
565 | |
566 if (!save_original) | |
567 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(saveplace), TRUE); | |
568 | |
569 | |
570 | |
571 path_hbox = gtk_hbox_new(FALSE, 5); | |
572 gtk_box_pack_start(GTK_BOX(configure_vbox), path_hbox, FALSE, FALSE, 0); | |
573 | |
574 path_label = gtk_label_new(_("Output file folder:")); | |
575 gtk_box_pack_start(GTK_BOX(path_hbox), path_label, FALSE, FALSE, 0); | |
576 | |
577 path_dirbrowser = | |
578 gtk_file_chooser_button_new ("Pick a folder", | |
579 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); | |
580 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(path_dirbrowser), | |
581 file_path); | |
582 gtk_box_pack_start(GTK_BOX(path_hbox), path_dirbrowser, TRUE, TRUE, 0); | |
583 | |
584 if (save_original) | |
585 gtk_widget_set_sensitive(path_hbox, FALSE); | |
586 | |
587 | |
588 | |
589 | |
590 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
591 | |
592 | |
593 | |
594 | |
595 filenamefrom_hbox = gtk_hbox_new(FALSE, 5); | |
596 gtk_container_add(GTK_CONTAINER(configure_vbox), filenamefrom_hbox); | |
597 | |
598 filenamefrom_label = gtk_label_new(_("Get filename from:")); | |
599 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_label, FALSE, FALSE, 0); | |
600 | |
601 filenamefrom_toggle = gtk_radio_button_new_with_label(NULL, _("original file tags")); | |
602 g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromtags_cb), NULL); | |
603 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0); | |
604 | |
605 filenamefrom_toggle = | |
606 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filenamefrom_toggle), | |
607 _("original filename")); | |
608 g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromfilename_cb), NULL); | |
609 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0); | |
610 | |
611 if (!filenamefromtags) | |
612 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filenamefrom_toggle), TRUE); | |
613 | |
614 | |
615 | |
616 | |
617 use_suffix_toggle = gtk_check_button_new_with_label(_("Don't strip file name extension")); | |
618 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), use_suffix); | |
619 gtk_box_pack_start(GTK_BOX(configure_vbox), use_suffix_toggle, FALSE, FALSE, 0); | |
620 use_suffix_tooltips = gtk_tooltips_new(); | |
621 gtk_tooltips_set_tip(use_suffix_tooltips, use_suffix_toggle, "If enabled, the extension from the original filename will not be stripped before adding the .wav extension to the end.", NULL); | |
622 gtk_tooltips_enable(use_suffix_tooltips); | |
623 | |
624 if (filenamefromtags) | |
625 gtk_widget_set_sensitive(use_suffix_toggle, FALSE); | |
626 | |
627 | |
628 | |
629 | |
630 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
631 | |
632 | |
633 | |
634 | |
635 prependnumber_toggle = gtk_check_button_new_with_label(_("Prepend track number to filename")); | |
636 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prependnumber_toggle), prependnumber); | |
637 gtk_box_pack_start(GTK_BOX(configure_vbox), prependnumber_toggle, FALSE, FALSE, 0); | |
638 | |
639 | |
640 | |
641 configure_bbox = gtk_hbutton_box_new(); | |
642 gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox), | |
643 GTK_BUTTONBOX_END); | |
644 gtk_button_box_set_spacing(GTK_BUTTON_BOX(configure_bbox), 5); | |
645 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_bbox, | |
646 FALSE, FALSE, 0); | |
647 | |
648 configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
649 gtk_signal_connect_object(GTK_OBJECT(configure_cancel), "clicked", | |
650 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
651 GTK_OBJECT(configure_win)); | |
652 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel, | |
653 TRUE, TRUE, 0); | |
654 | |
655 configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK); | |
656 gtk_signal_connect(GTK_OBJECT(configure_ok), "clicked", | |
657 GTK_SIGNAL_FUNC(configure_ok_cb), NULL); | |
658 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok, | |
659 TRUE, TRUE, 0); | |
660 | |
661 gtk_widget_show_all(configure_win); | |
662 } | |
663 } | |
664 | |
665 VFSFile *output_file = NULL; | |
666 guint64 written = 0; | |
667 guint64 offset = 0; | |
668 TitleInput *tuple = NULL; |