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