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