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