Mercurial > audlegacy-plugins
annotate src/filewriter/filewriter.c @ 2595:cde42a37ccf6
More indentation cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 21 May 2008 02:27:01 +0300 |
parents | 769e17da93dd |
children | 5df83337516f |
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 | |
1569
25ea2127eefa
filewriter: fix symbol collisions
William Pitcock <nenolod@atheme.org>
parents:
1525
diff
changeset
|
26 struct format_info input; |
25ea2127eefa
filewriter: fix symbol collisions
William Pitcock <nenolod@atheme.org>
parents:
1525
diff
changeset
|
27 |
984 | 28 static GtkWidget *configure_win = NULL, *configure_vbox; |
29 static GtkWidget *path_hbox, *path_label, *path_dirbrowser; | |
30 static GtkWidget *configure_bbox, *configure_ok, *configure_cancel; | |
31 | |
32 static GtkWidget *fileext_hbox, *fileext_label, *fileext_combo, *plugin_button; | |
1000 | 33 |
34 enum fileext_t | |
35 { | |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
36 WAV = 0, |
1000 | 37 #ifdef FILEWRITER_MP3 |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
38 MP3, |
1000 | 39 #endif |
40 #ifdef FILEWRITER_VORBIS | |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
41 VORBIS, |
1000 | 42 #endif |
43 #ifdef FILEWRITER_FLAC | |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
44 FLAC, |
1000 | 45 #endif |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
46 FILEEXT_MAX |
1000 | 47 }; |
48 | |
984 | 49 static gint fileext = WAV; |
1000 | 50 static gchar *fileext_str[] = |
51 { | |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
52 "wav", |
1000 | 53 #ifdef FILEWRITER_MP3 |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
54 "mp3", |
1000 | 55 #endif |
56 #ifdef FILEWRITER_VORBIS | |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
57 "ogg", |
1000 | 58 #endif |
59 #ifdef FILEWRITER_FLAC | |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
60 "flac" |
1000 | 61 #endif |
62 }; | |
63 | |
984 | 64 static FileWriter plugin; |
65 | |
66 static GtkWidget *saveplace_hbox, *saveplace; | |
67 static gboolean save_original = TRUE; | |
68 | |
69 static GtkWidget *filenamefrom_hbox, *filenamefrom_label, *filenamefrom_toggle; | |
70 static gboolean filenamefromtags = TRUE; | |
71 | |
72 static GtkWidget *use_suffix_toggle = NULL; | |
73 static gboolean use_suffix = FALSE; | |
74 | |
75 static GtkWidget *prependnumber_toggle; | |
76 static gboolean prependnumber = FALSE; | |
77 | |
78 static gchar *file_path = NULL; | |
79 | |
80 static void file_init(void); | |
81 static void file_about(void); | |
82 static gint file_open(AFormat fmt, gint rate, gint nch); | |
83 static void file_write(void *ptr, gint length); | |
84 static void file_close(void); | |
85 static void file_flush(gint time); | |
86 static void file_pause(short p); | |
87 static gint file_free(void); | |
88 static gint file_playing(void); | |
89 static gint file_get_written_time(void); | |
90 static gint file_get_output_time(void); | |
91 static void file_configure(void); | |
92 | |
93 OutputPlugin file_op = | |
94 { | |
1651 | 95 .description = "FileWriter Plugin", |
96 .init = file_init, | |
97 .about = file_about, | |
98 .configure = file_configure, | |
99 .open_audio = file_open, | |
100 .write_audio = file_write, | |
101 .close_audio = file_close, | |
102 .flush = file_flush, | |
103 .pause = file_pause, | |
104 .buffer_free = file_free, | |
105 .buffer_playing = file_playing, | |
106 .output_time = file_get_output_time, | |
107 .written_time = file_get_written_time | |
984 | 108 }; |
109 | |
1076 | 110 OutputPlugin *file_oplist[] = { &file_op, NULL }; |
111 | |
1651 | 112 SIMPLE_OUTPUT_PLUGIN(filewriter, file_oplist); |
984 | 113 |
114 static void set_plugin(void) | |
115 { | |
116 if (fileext < 0 || fileext >= FILEEXT_MAX) | |
117 fileext = 0; | |
118 | |
119 if (fileext == WAV) | |
120 plugin = wav_plugin; | |
1000 | 121 #ifdef FILEWRITER_MP3 |
984 | 122 if (fileext == MP3) |
123 plugin = mp3_plugin; | |
1000 | 124 #endif |
125 #ifdef FILEWRITER_VORBIS | |
986 | 126 if (fileext == VORBIS) |
127 plugin = vorbis_plugin; | |
1000 | 128 #endif |
129 #ifdef FILEWRITER_FLAC | |
991 | 130 if (fileext == FLAC) |
131 plugin = flac_plugin; | |
1000 | 132 #endif |
984 | 133 } |
134 | |
135 static void file_init(void) | |
136 { | |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2227
diff
changeset
|
137 mcs_handle_t *db; |
2227 | 138 /*GtkWidget *menu_root; |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
139 |
2227 | 140 menu_root = gtk_menu_item_new_with_label(_("FileWriter")); |
2181
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
141 gtk_widget_show(menu_root); |
bbb631ab78e9
started initial (very humble) efforts on making FileWriter a general
mf0102 <0102@gmx.at>
parents:
2124
diff
changeset
|
142 audacious_menu_plugin_item_add(AUDACIOUS_MENU_PLAYLIST_RCLICK, menu_root);*/ |
984 | 143 |
2124 | 144 db = aud_cfg_db_open(); |
145 aud_cfg_db_get_int(db, "filewriter", "fileext", &fileext); | |
146 aud_cfg_db_get_string(db, "filewriter", "file_path", &file_path); | |
147 aud_cfg_db_get_bool(db, "filewriter", "save_original", &save_original); | |
148 aud_cfg_db_get_bool(db, "filewriter", "use_suffix", &use_suffix); | |
149 aud_cfg_db_get_bool(db, "filewriter", "filenamefromtags", &filenamefromtags); | |
150 aud_cfg_db_get_bool(db, "filewriter", "prependnumber", &prependnumber); | |
151 aud_cfg_db_close(db); | |
984 | 152 |
153 if (!file_path) | |
154 file_path = g_strdup(g_get_home_dir()); | |
155 | |
156 set_plugin(); | |
157 if (plugin.init) | |
158 plugin.init(); | |
159 } | |
160 | |
161 void file_about(void) | |
162 { | |
163 static GtkWidget *dialog; | |
164 | |
165 if (dialog != NULL) | |
166 return; | |
167 | |
1677
f6f5603a0954
xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents:
1651
diff
changeset
|
168 dialog = audacious_info_dialog(_("About FileWriter-Plugin"), |
1298
94eee8a16189
The "i18n" saga is still going on...
Stany HENRY <StrassBoy@gmail.com>
parents:
1269
diff
changeset
|
169 _("FileWriter-Plugin\n\n" |
984 | 170 "This program is free software; you can redistribute it and/or modify\n" |
171 "it under the terms of the GNU General Public License as published by\n" | |
172 "the Free Software Foundation; either version 2 of the License, or\n" | |
173 "(at your option) any later version.\n" | |
174 "\n" | |
175 "This program is distributed in the hope that it will be useful,\n" | |
176 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" | |
177 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" | |
178 "GNU General Public License for more details.\n" | |
179 "\n" | |
180 "You should have received a copy of the GNU General Public License\n" | |
181 "along with this program; if not, write to the Free Software\n" | |
182 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\n" | |
1298
94eee8a16189
The "i18n" saga is still going on...
Stany HENRY <StrassBoy@gmail.com>
parents:
1269
diff
changeset
|
183 "USA."), _("Ok"), FALSE, NULL, NULL); |
984 | 184 gtk_signal_connect(GTK_OBJECT(dialog), "destroy", |
185 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog); | |
186 } | |
187 | |
188 static gint file_open(AFormat fmt, gint rate, gint nch) | |
189 { | |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
190 gchar *filename = NULL, *temp = NULL; |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1569
diff
changeset
|
191 const gchar *directory; |
984 | 192 gint pos; |
1004
be2d04b2bd28
[svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents:
1000
diff
changeset
|
193 gint rv; |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
194 Playlist *playlist; |
984 | 195 |
196 input.format = fmt; | |
197 input.frequency = rate; | |
198 input.channels = nch; | |
199 | |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2055
diff
changeset
|
200 playlist = aud_playlist_get_active(); |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
201 if(!playlist) |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
202 return 0; |
984 | 203 |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2055
diff
changeset
|
204 pos = aud_playlist_get_position(playlist); |
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2055
diff
changeset
|
205 tuple = aud_playlist_get_tuple(playlist, pos); |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
206 if(!tuple) |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
207 return 0; |
984 | 208 |
209 if (filenamefromtags) | |
210 { | |
2055 | 211 gchar *utf8 = aud_tuple_formatter_make_title_string(tuple, aud_get_gentitle_format()); |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
212 |
984 | 213 g_strchomp(utf8); //chop trailing ^J --yaz |
214 | |
215 filename = g_locale_from_utf8(utf8, -1, NULL, NULL, NULL); | |
216 g_free(utf8); | |
217 while (filename != NULL && (temp = strchr(filename, '/')) != NULL) | |
218 *temp = '-'; | |
219 } | |
220 if (filename == NULL) | |
221 { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1712
diff
changeset
|
222 filename = g_strdup(aud_tuple_get_string(tuple, FIELD_FILE_NAME, NULL)); |
984 | 223 if (!use_suffix) |
224 if ((temp = strrchr(filename, '.')) != NULL) | |
225 *temp = '\0'; | |
226 } | |
227 if (filename == NULL) | |
228 filename = g_strdup_printf("aud-%d", pos); | |
229 | |
230 | |
231 if (prependnumber) | |
232 { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1712
diff
changeset
|
233 gint number = aud_tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL); |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1569
diff
changeset
|
234 if (!tuple || !number) |
984 | 235 number = pos + 1; |
236 | |
237 temp = g_strdup_printf("%.02d %s", number, filename); | |
238 g_free(filename); | |
239 filename = temp; | |
240 } | |
241 | |
242 if (save_original) | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1712
diff
changeset
|
243 directory = aud_tuple_get_string(tuple, FIELD_FILE_PATH, NULL); |
984 | 244 else |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1569
diff
changeset
|
245 directory = file_path; |
984 | 246 |
1269
0e160bafce1c
- adapt filewriter for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1113
diff
changeset
|
247 temp = g_strdup_printf("file://%s/%s.%s", |
984 | 248 directory, filename, fileext_str[fileext]); |
249 g_free(filename); | |
250 filename = temp; | |
251 | |
1978 | 252 output_file = aud_vfs_fopen(filename, "w"); |
984 | 253 g_free(filename); |
254 | |
255 if (!output_file) | |
256 return 0; | |
257 | |
1712
bf2ec8f4289b
- Fix open-is-a-macro for newer glibcs
Ralf Ertzinger <ralf@skytale.net>
parents:
1703
diff
changeset
|
258 rv = (plugin.open)(); |
1004
be2d04b2bd28
[svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents:
1000
diff
changeset
|
259 |
be2d04b2bd28
[svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents:
1000
diff
changeset
|
260 return rv; |
984 | 261 } |
262 | |
263 static void convert_buffer(gpointer buffer, gint length) | |
264 { | |
265 gint i; | |
266 | |
267 if (input.format == FMT_S8) | |
268 { | |
269 guint8 *ptr1 = buffer; | |
270 gint8 *ptr2 = buffer; | |
271 | |
272 for (i = 0; i < length; i++) | |
273 *(ptr1++) = *(ptr2++) ^ 128; | |
274 } | |
275 if (input.format == FMT_S16_BE) | |
276 { | |
277 gint16 *ptr = buffer; | |
278 | |
279 for (i = 0; i < length >> 1; i++, ptr++) | |
280 *ptr = GUINT16_SWAP_LE_BE(*ptr); | |
281 } | |
282 if (input.format == FMT_S16_NE) | |
283 { | |
284 gint16 *ptr = buffer; | |
285 | |
286 for (i = 0; i < length >> 1; i++, ptr++) | |
287 *ptr = GINT16_TO_LE(*ptr); | |
288 } | |
289 if (input.format == FMT_U16_BE) | |
290 { | |
291 gint16 *ptr1 = buffer; | |
292 guint16 *ptr2 = buffer; | |
293 | |
294 for (i = 0; i < length >> 1; i++, ptr2++) | |
295 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768); | |
296 } | |
297 if (input.format == FMT_U16_LE) | |
298 { | |
299 gint16 *ptr1 = buffer; | |
300 guint16 *ptr2 = buffer; | |
301 | |
302 for (i = 0; i < length >> 1; i++, ptr2++) | |
303 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768); | |
304 } | |
305 if (input.format == FMT_U16_NE) | |
306 { | |
307 gint16 *ptr1 = buffer; | |
308 guint16 *ptr2 = buffer; | |
309 | |
310 for (i = 0; i < length >> 1; i++, ptr2++) | |
311 *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768); | |
312 } | |
313 } | |
314 | |
315 static void file_write(void *ptr, gint length) | |
316 { | |
317 if (input.format == FMT_S8 || input.format == FMT_S16_BE || | |
318 input.format == FMT_U16_LE || input.format == FMT_U16_BE || | |
319 input.format == FMT_U16_NE) | |
320 convert_buffer(ptr, length); | |
321 #ifdef WORDS_BIGENDIAN | |
322 if (input.format == FMT_S16_NE) | |
323 convert_buffer(ptr, length); | |
324 #endif | |
325 | |
326 plugin.write(ptr, length); | |
327 } | |
328 | |
329 static void file_close(void) | |
330 { | |
331 plugin.close(); | |
332 | |
333 if (output_file) | |
334 { | |
335 written = 0; | |
1978 | 336 aud_vfs_fclose(output_file); |
984 | 337 } |
338 output_file = NULL; | |
339 } | |
340 | |
341 static void file_flush(gint time) | |
342 { | |
343 if (time < 0) | |
344 return; | |
345 | |
346 file_close(); | |
347 file_open(input.format, input.frequency, input.channels); | |
348 | |
349 offset = time; | |
350 } | |
351 | |
352 static void file_pause(short p) | |
353 { | |
354 } | |
355 | |
356 static gint file_free(void) | |
357 { | |
358 return plugin.free(); | |
359 } | |
360 | |
361 static gint file_playing(void) | |
362 { | |
363 return plugin.playing(); | |
364 } | |
365 | |
366 static gint file_get_written_time(void) | |
367 { | |
368 return plugin.get_written_time(); | |
369 } | |
370 | |
371 static gint file_get_output_time(void) | |
372 { | |
373 return file_get_written_time(); | |
374 } | |
375 | |
376 static void configure_ok_cb(gpointer data) | |
377 { | |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2227
diff
changeset
|
378 mcs_handle_t *db; |
984 | 379 |
380 fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo)); | |
381 | |
382 g_free(file_path); | |
383 file_path = g_strdup(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(path_dirbrowser))); | |
384 | |
385 use_suffix = | |
386 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_suffix_toggle)); | |
387 | |
388 prependnumber = | |
389 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prependnumber_toggle)); | |
390 | |
2124 | 391 db = aud_cfg_db_open(); |
392 aud_cfg_db_set_int(db, "filewriter", "fileext", fileext); | |
393 aud_cfg_db_set_string(db, "filewriter", "file_path", file_path); | |
394 aud_cfg_db_set_bool(db, "filewriter", "save_original", save_original); | |
395 aud_cfg_db_set_bool(db, "filewriter", "filenamefromtags", filenamefromtags); | |
396 aud_cfg_db_set_bool(db, "filewriter", "use_suffix", use_suffix); | |
397 aud_cfg_db_set_bool(db, "filewriter", "prependnumber", prependnumber); | |
984 | 398 |
2124 | 399 aud_cfg_db_close(db); |
984 | 400 |
401 gtk_widget_destroy(configure_win); | |
402 if (path_dirbrowser) | |
403 gtk_widget_destroy(path_dirbrowser); | |
404 } | |
405 | |
406 static void fileext_cb(GtkWidget *combo, gpointer data) | |
407 { | |
408 fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo)); | |
409 set_plugin(); | |
410 | |
411 gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL); | |
412 } | |
413 | |
414 static void plugin_configure_cb(GtkWidget *button, gpointer data) | |
415 { | |
416 if (plugin.configure) | |
417 plugin.configure(); | |
418 } | |
419 | |
420 | |
421 static void saveplace_original_cb(GtkWidget *button, gpointer data) | |
422 { | |
423 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
424 { | |
425 gtk_widget_set_sensitive(path_hbox, FALSE); | |
426 save_original = TRUE; | |
427 } | |
428 } | |
429 | |
430 static void saveplace_custom_cb(GtkWidget *button, gpointer data) | |
431 { | |
432 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
433 { | |
434 gtk_widget_set_sensitive(path_hbox, TRUE); | |
435 save_original = FALSE; | |
436 } | |
437 } | |
438 | |
439 static void filenamefromtags_cb(GtkWidget *button, gpointer data) | |
440 { | |
441 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
442 { | |
443 gtk_widget_set_sensitive(use_suffix_toggle, FALSE); | |
444 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), FALSE); | |
445 use_suffix = FALSE; | |
446 filenamefromtags = TRUE; | |
447 } | |
448 } | |
449 | |
450 static void filenamefromfilename_cb(GtkWidget *button, gpointer data) | |
451 { | |
452 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
453 { | |
454 gtk_widget_set_sensitive(use_suffix_toggle, TRUE); | |
455 filenamefromtags = FALSE; | |
456 } | |
457 } | |
458 | |
459 | |
460 static void configure_destroy(void) | |
461 { | |
462 if (path_dirbrowser) | |
463 gtk_widget_destroy(path_dirbrowser); | |
464 } | |
465 | |
466 static void file_configure(void) | |
467 { | |
468 GtkTooltips *use_suffix_tooltips; | |
469 | |
470 if (!configure_win) | |
471 { | |
472 configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
473 | |
474 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", | |
475 GTK_SIGNAL_FUNC(configure_destroy), NULL); | |
476 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", | |
477 GTK_SIGNAL_FUNC(gtk_widget_destroyed), | |
478 &configure_win); | |
479 | |
480 gtk_window_set_title(GTK_WINDOW(configure_win), | |
985 | 481 _("File Writer Configuration")); |
984 | 482 gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE); |
483 | |
484 gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10); | |
485 | |
486 configure_vbox = gtk_vbox_new(FALSE, 10); | |
487 gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox); | |
488 | |
489 | |
490 fileext_hbox = gtk_hbox_new(FALSE, 5); | |
491 gtk_box_pack_start(GTK_BOX(configure_vbox), fileext_hbox, FALSE, FALSE, 0); | |
492 | |
986 | 493 fileext_label = gtk_label_new(_("Output file format:")); |
984 | 494 gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_label, FALSE, FALSE, 0); |
495 | |
496 fileext_combo = gtk_combo_box_new_text(); | |
497 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "WAV"); | |
1000 | 498 #ifdef FILEWRITER_MP3 |
984 | 499 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "MP3"); |
1000 | 500 #endif |
501 #ifdef FILEWRITER_VORBIS | |
986 | 502 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "Vorbis"); |
1000 | 503 #endif |
504 #ifdef FILEWRITER_FLAC | |
991 | 505 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "FLAC"); |
1000 | 506 #endif |
984 | 507 gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_combo, FALSE, FALSE, 0); |
508 gtk_combo_box_set_active(GTK_COMBO_BOX(fileext_combo), fileext); | |
509 g_signal_connect(G_OBJECT(fileext_combo), "changed", G_CALLBACK(fileext_cb), NULL); | |
510 | |
511 plugin_button = gtk_button_new_with_label(_("Configure")); | |
512 gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL); | |
513 g_signal_connect(G_OBJECT(plugin_button), "clicked", G_CALLBACK(plugin_configure_cb), NULL); | |
514 gtk_box_pack_end(GTK_BOX(fileext_hbox), plugin_button, FALSE, FALSE, 0); | |
515 | |
516 | |
517 | |
518 | |
519 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
520 | |
521 | |
522 | |
523 saveplace_hbox = gtk_hbox_new(FALSE, 5); | |
524 gtk_container_add(GTK_CONTAINER(configure_vbox), saveplace_hbox); | |
525 | |
526 saveplace = gtk_radio_button_new_with_label(NULL, _("Save into original directory")); | |
527 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_original_cb), NULL); | |
528 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0); | |
529 | |
530 saveplace = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(saveplace), | |
531 _("Save into custom directory")); | |
532 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_custom_cb), NULL); | |
533 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0); | |
534 | |
535 if (!save_original) | |
536 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(saveplace), TRUE); | |
537 | |
538 | |
539 | |
540 path_hbox = gtk_hbox_new(FALSE, 5); | |
541 gtk_box_pack_start(GTK_BOX(configure_vbox), path_hbox, FALSE, FALSE, 0); | |
542 | |
543 path_label = gtk_label_new(_("Output file folder:")); | |
544 gtk_box_pack_start(GTK_BOX(path_hbox), path_label, FALSE, FALSE, 0); | |
545 | |
546 path_dirbrowser = | |
1298
94eee8a16189
The "i18n" saga is still going on...
Stany HENRY <StrassBoy@gmail.com>
parents:
1269
diff
changeset
|
547 gtk_file_chooser_button_new (_("Pick a folder"), |
984 | 548 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); |
549 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(path_dirbrowser), | |
550 file_path); | |
551 gtk_box_pack_start(GTK_BOX(path_hbox), path_dirbrowser, TRUE, TRUE, 0); | |
552 | |
553 if (save_original) | |
554 gtk_widget_set_sensitive(path_hbox, FALSE); | |
555 | |
556 | |
557 | |
558 | |
559 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
560 | |
561 | |
562 | |
563 | |
564 filenamefrom_hbox = gtk_hbox_new(FALSE, 5); | |
565 gtk_container_add(GTK_CONTAINER(configure_vbox), filenamefrom_hbox); | |
566 | |
567 filenamefrom_label = gtk_label_new(_("Get filename from:")); | |
568 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_label, FALSE, FALSE, 0); | |
569 | |
570 filenamefrom_toggle = gtk_radio_button_new_with_label(NULL, _("original file tags")); | |
571 g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromtags_cb), NULL); | |
572 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0); | |
573 | |
574 filenamefrom_toggle = | |
575 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filenamefrom_toggle), | |
576 _("original filename")); | |
577 g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromfilename_cb), NULL); | |
578 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0); | |
579 | |
580 if (!filenamefromtags) | |
581 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filenamefrom_toggle), TRUE); | |
582 | |
583 | |
584 | |
585 | |
586 use_suffix_toggle = gtk_check_button_new_with_label(_("Don't strip file name extension")); | |
587 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), use_suffix); | |
588 gtk_box_pack_start(GTK_BOX(configure_vbox), use_suffix_toggle, FALSE, FALSE, 0); | |
589 use_suffix_tooltips = gtk_tooltips_new(); | |
1525
bee9eaedefa5
- made the MP3 FileWriter output plugin less braindead
mf0102 <0102@gmx.at>
parents:
1510
diff
changeset
|
590 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 new file extension to the end."), NULL); |
984 | 591 gtk_tooltips_enable(use_suffix_tooltips); |
592 | |
593 if (filenamefromtags) | |
594 gtk_widget_set_sensitive(use_suffix_toggle, FALSE); | |
595 | |
596 | |
597 | |
598 | |
599 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
600 | |
601 | |
602 | |
603 | |
604 prependnumber_toggle = gtk_check_button_new_with_label(_("Prepend track number to filename")); | |
605 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prependnumber_toggle), prependnumber); | |
606 gtk_box_pack_start(GTK_BOX(configure_vbox), prependnumber_toggle, FALSE, FALSE, 0); | |
607 | |
608 | |
609 | |
610 configure_bbox = gtk_hbutton_box_new(); | |
611 gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox), | |
612 GTK_BUTTONBOX_END); | |
613 gtk_button_box_set_spacing(GTK_BUTTON_BOX(configure_bbox), 5); | |
614 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_bbox, | |
615 FALSE, FALSE, 0); | |
616 | |
617 configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
618 gtk_signal_connect_object(GTK_OBJECT(configure_cancel), "clicked", | |
619 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
620 GTK_OBJECT(configure_win)); | |
621 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel, | |
622 TRUE, TRUE, 0); | |
623 | |
624 configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK); | |
625 gtk_signal_connect(GTK_OBJECT(configure_ok), "clicked", | |
626 GTK_SIGNAL_FUNC(configure_ok_cb), NULL); | |
627 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok, | |
628 TRUE, TRUE, 0); | |
629 | |
630 gtk_widget_show_all(configure_win); | |
631 } | |
632 } | |
633 | |
634 VFSFile *output_file = NULL; | |
635 guint64 written = 0; | |
636 guint64 offset = 0; | |
1441
1b52e7eacd4c
filewriter: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
637 Tuple *tuple = NULL; |