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