Mercurial > audlegacy-plugins
annotate src/filewriter/filewriter.c @ 3148:d443c917dab9
Remove stale library variable from Makefile, as pointed out by RafaŠČ MuŤ÷yŠČo on #audacious.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Mon, 11 May 2009 17:32:04 +0100 |
parents | 0d47d41b39ec |
children |
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 | |
2970
57d499fc5056
revert default format to wav
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2969
diff
changeset
|
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 | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
65 static FileWriter *plugin; |
984 | 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; | |
2969
20ad1c7ff026
changed default values for filewriter:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2950
diff
changeset
|
77 static gboolean prependnumber = TRUE; |
984 | 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 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 |
3020
fdcf79446ddf
Port to new API, lowest prio and NO_DEVICES to avoid autoselect.
Tony Vroon <chainsaw@gentoo.org>
parents:
2970
diff
changeset
|
85 static OutputPluginInitStatus file_init(void); |
984 | 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", |
3020
fdcf79446ddf
Port to new API, lowest prio and NO_DEVICES to avoid autoselect.
Tony Vroon <chainsaw@gentoo.org>
parents:
2970
diff
changeset
|
102 .probe_priority = 0, |
1651 | 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 |
3042 | 121 FileWriter *plugins[FILEEXT_MAX] = { |
122 &wav_plugin, | |
123 #ifdef FILEWRITER_MP3 | |
124 &mp3_plugin, | |
125 #endif | |
126 #ifdef FILEWRITER_VORBIS | |
127 &vorbis_plugin, | |
128 #endif | |
129 #ifdef FILEWRITER_FLAC | |
130 &flac_plugin, | |
131 #endif | |
132 }; | |
133 | |
984 | 134 static void set_plugin(void) |
135 { | |
136 if (fileext < 0 || fileext >= FILEEXT_MAX) | |
137 fileext = 0; | |
138 | |
3042 | 139 plugin = plugins[fileext]; |
984 | 140 } |
141 | |
3020
fdcf79446ddf
Port to new API, lowest prio and NO_DEVICES to avoid autoselect.
Tony Vroon <chainsaw@gentoo.org>
parents:
2970
diff
changeset
|
142 static OutputPluginInitStatus file_init(void) |
984 | 143 { |
144 ConfigDb *db; | |
145 | |
2124 | 146 db = aud_cfg_db_open(); |
2807
f06ec6936b7e
migrated some plugins to auto_CFGID
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2775
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 aud_cfg_db_get_bool(db, FILEWRITER_CFGID, "prependnumber", &prependnumber); |
2124 | 153 aud_cfg_db_close(db); |
984 | 154 |
155 if (!file_path) | |
156 file_path = g_strdup(g_get_home_dir()); | |
157 | |
158 set_plugin(); | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
159 if (plugin->init) |
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
160 plugin->init(&file_write_output); |
3020
fdcf79446ddf
Port to new API, lowest prio and NO_DEVICES to avoid autoselect.
Tony Vroon <chainsaw@gentoo.org>
parents:
2970
diff
changeset
|
161 |
fdcf79446ddf
Port to new API, lowest prio and NO_DEVICES to avoid autoselect.
Tony Vroon <chainsaw@gentoo.org>
parents:
2970
diff
changeset
|
162 return OUTPUT_PLUGIN_INIT_NO_DEVICES; |
984 | 163 } |
164 | |
165 void file_about(void) | |
166 { | |
167 static GtkWidget *dialog; | |
168 | |
169 if (dialog != NULL) | |
170 return; | |
171 | |
1677
f6f5603a0954
xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents:
1651
diff
changeset
|
172 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
|
173 _("FileWriter-Plugin\n\n" |
984 | 174 "This program is free software; you can redistribute it and/or modify\n" |
175 "it under the terms of the GNU General Public License as published by\n" | |
176 "the Free Software Foundation; either version 2 of the License, or\n" | |
177 "(at your option) any later version.\n" | |
178 "\n" | |
179 "This program is distributed in the hope that it will be useful,\n" | |
180 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" | |
181 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" | |
182 "GNU General Public License for more details.\n" | |
183 "\n" | |
184 "You should have received a copy of the GNU General Public License\n" | |
185 "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
|
186 "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
|
187 "USA."), _("Ok"), FALSE, NULL, NULL); |
984 | 188 gtk_signal_connect(GTK_OBJECT(dialog), "destroy", |
189 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog); | |
190 } | |
191 | |
192 static gint file_open(AFormat fmt, gint rate, gint nch) | |
193 { | |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
194 gchar *filename = NULL, *temp = NULL; |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1569
diff
changeset
|
195 const gchar *directory; |
984 | 196 gint pos; |
1004
be2d04b2bd28
[svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents:
1000
diff
changeset
|
197 gint rv; |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
198 Playlist *playlist; |
984 | 199 |
200 input.format = fmt; | |
201 input.frequency = rate; | |
202 input.channels = nch; | |
203 | |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2055
diff
changeset
|
204 playlist = aud_playlist_get_active(); |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
205 if(!playlist) |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
206 return 0; |
984 | 207 |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2055
diff
changeset
|
208 pos = aud_playlist_get_position(playlist); |
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2055
diff
changeset
|
209 tuple = aud_playlist_get_tuple(playlist, pos); |
1011
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
210 if(!tuple) |
4a693f5b7054
[svn] - replace xmms_remote_*() with playlist functions.
yaz
parents:
1004
diff
changeset
|
211 return 0; |
984 | 212 |
213 if (filenamefromtags) | |
214 { | |
2055 | 215 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
|
216 |
2950
dcd8d93ba781
- mp3: adapted to lame-3.98. now filewriter writes valid TLEN.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2874
diff
changeset
|
217 g_strchomp(utf8); /* chop trailing ^J --yaz */ |
984 | 218 |
219 filename = g_locale_from_utf8(utf8, -1, NULL, NULL, NULL); | |
220 g_free(utf8); | |
221 while (filename != NULL && (temp = strchr(filename, '/')) != NULL) | |
222 *temp = '-'; | |
223 } | |
224 if (filename == NULL) | |
225 { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1712
diff
changeset
|
226 filename = g_strdup(aud_tuple_get_string(tuple, FIELD_FILE_NAME, NULL)); |
984 | 227 if (!use_suffix) |
228 if ((temp = strrchr(filename, '.')) != NULL) | |
229 *temp = '\0'; | |
230 } | |
231 if (filename == NULL) | |
232 filename = g_strdup_printf("aud-%d", pos); | |
233 | |
234 | |
235 if (prependnumber) | |
236 { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1712
diff
changeset
|
237 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
|
238 if (!tuple || !number) |
984 | 239 number = pos + 1; |
240 | |
241 temp = g_strdup_printf("%.02d %s", number, filename); | |
242 g_free(filename); | |
243 filename = temp; | |
244 } | |
245 | |
246 if (save_original) | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1712
diff
changeset
|
247 directory = aud_tuple_get_string(tuple, FIELD_FILE_PATH, NULL); |
984 | 248 else |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1569
diff
changeset
|
249 directory = file_path; |
984 | 250 |
1269
0e160bafce1c
- adapt filewriter for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1113
diff
changeset
|
251 temp = g_strdup_printf("file://%s/%s.%s", |
984 | 252 directory, filename, fileext_str[fileext]); |
253 g_free(filename); | |
254 filename = temp; | |
255 | |
1978 | 256 output_file = aud_vfs_fopen(filename, "w"); |
984 | 257 g_free(filename); |
258 | |
259 if (!output_file) | |
260 return 0; | |
261 | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
262 convert_init(fmt, plugin->format_required, nch); |
2874
11ef2164d90b
re-written format conversion using libSAD;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2873
diff
changeset
|
263 |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
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 file_write(void *ptr, gint length) | |
270 { | |
2874
11ef2164d90b
re-written format conversion using libSAD;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2873
diff
changeset
|
271 int len; |
984 | 272 |
2874
11ef2164d90b
re-written format conversion using libSAD;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2873
diff
changeset
|
273 len = convert_process(ptr, length); |
11ef2164d90b
re-written format conversion using libSAD;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2873
diff
changeset
|
274 |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
275 plugin->write(convert_output, len); |
984 | 276 } |
277 | |
2766
6d08e3120615
make some file filewriter backends use callbacks instead of calling VFS directly
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2227
diff
changeset
|
278 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
|
279 { |
6d08e3120615
make some file filewriter backends use callbacks instead of calling VFS directly
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2227
diff
changeset
|
280 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
|
281 } |
6d08e3120615
make some file filewriter backends use callbacks instead of calling VFS directly
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2227
diff
changeset
|
282 |
984 | 283 static void file_close(void) |
284 { | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
285 plugin->close(); |
2874
11ef2164d90b
re-written format conversion using libSAD;
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2873
diff
changeset
|
286 convert_free(); |
984 | 287 |
288 if (output_file) | |
289 { | |
1978 | 290 aud_vfs_fclose(output_file); |
984 | 291 } |
292 output_file = NULL; | |
293 } | |
294 | |
295 static void file_flush(gint time) | |
296 { | |
297 if (time < 0) | |
298 return; | |
299 | |
300 file_close(); | |
301 file_open(input.format, input.frequency, input.channels); | |
302 | |
303 offset = time; | |
304 } | |
305 | |
306 static void file_pause(short p) | |
307 { | |
308 } | |
309 | |
310 static gint file_free(void) | |
311 { | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
312 return plugin->free(); |
984 | 313 } |
314 | |
315 static gint file_playing(void) | |
316 { | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
317 return plugin->playing(); |
984 | 318 } |
319 | |
320 static gint file_get_written_time(void) | |
321 { | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
322 return plugin->get_written_time(); |
984 | 323 } |
324 | |
325 static gint file_get_output_time(void) | |
326 { | |
327 return file_get_written_time(); | |
328 } | |
329 | |
330 static void configure_ok_cb(gpointer data) | |
331 { | |
332 ConfigDb *db; | |
333 | |
334 fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo)); | |
335 | |
336 g_free(file_path); | |
337 file_path = g_strdup(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(path_dirbrowser))); | |
338 | |
339 use_suffix = | |
340 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_suffix_toggle)); | |
341 | |
342 prependnumber = | |
343 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prependnumber_toggle)); | |
344 | |
2124 | 345 db = aud_cfg_db_open(); |
2807
f06ec6936b7e
migrated some plugins to auto_CFGID
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2775
diff
changeset
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 aud_cfg_db_set_bool(db, FILEWRITER_CFGID, "prependnumber", prependnumber); |
984 | 352 |
2124 | 353 aud_cfg_db_close(db); |
984 | 354 |
355 gtk_widget_destroy(configure_win); | |
356 if (path_dirbrowser) | |
357 gtk_widget_destroy(path_dirbrowser); | |
358 } | |
359 | |
360 static void fileext_cb(GtkWidget *combo, gpointer data) | |
361 { | |
362 fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo)); | |
363 set_plugin(); | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
364 if (plugin->init) |
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
365 plugin->init(&file_write_output); |
984 | 366 |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
367 gtk_widget_set_sensitive(plugin_button, plugin->configure != NULL); |
984 | 368 } |
369 | |
370 static void plugin_configure_cb(GtkWidget *button, gpointer data) | |
371 { | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
372 if (plugin->configure) |
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
373 plugin->configure(); |
984 | 374 } |
375 | |
376 | |
377 static void saveplace_original_cb(GtkWidget *button, gpointer data) | |
378 { | |
379 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
380 { | |
381 gtk_widget_set_sensitive(path_hbox, FALSE); | |
382 save_original = TRUE; | |
383 } | |
384 } | |
385 | |
386 static void saveplace_custom_cb(GtkWidget *button, gpointer data) | |
387 { | |
388 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
389 { | |
390 gtk_widget_set_sensitive(path_hbox, TRUE); | |
391 save_original = FALSE; | |
392 } | |
393 } | |
394 | |
395 static void filenamefromtags_cb(GtkWidget *button, gpointer data) | |
396 { | |
397 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
398 { | |
399 gtk_widget_set_sensitive(use_suffix_toggle, FALSE); | |
400 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), FALSE); | |
401 use_suffix = FALSE; | |
402 filenamefromtags = TRUE; | |
403 } | |
404 } | |
405 | |
406 static void filenamefromfilename_cb(GtkWidget *button, gpointer data) | |
407 { | |
408 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) | |
409 { | |
410 gtk_widget_set_sensitive(use_suffix_toggle, TRUE); | |
411 filenamefromtags = FALSE; | |
412 } | |
413 } | |
414 | |
415 | |
416 static void configure_destroy(void) | |
417 { | |
418 if (path_dirbrowser) | |
419 gtk_widget_destroy(path_dirbrowser); | |
420 } | |
421 | |
422 static void file_configure(void) | |
423 { | |
424 GtkTooltips *use_suffix_tooltips; | |
425 | |
426 if (!configure_win) | |
427 { | |
428 configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
429 | |
430 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", | |
431 GTK_SIGNAL_FUNC(configure_destroy), NULL); | |
432 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", | |
433 GTK_SIGNAL_FUNC(gtk_widget_destroyed), | |
434 &configure_win); | |
435 | |
436 gtk_window_set_title(GTK_WINDOW(configure_win), | |
985 | 437 _("File Writer Configuration")); |
984 | 438 gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE); |
439 | |
440 gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10); | |
441 | |
442 configure_vbox = gtk_vbox_new(FALSE, 10); | |
443 gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox); | |
444 | |
445 | |
446 fileext_hbox = gtk_hbox_new(FALSE, 5); | |
447 gtk_box_pack_start(GTK_BOX(configure_vbox), fileext_hbox, FALSE, FALSE, 0); | |
448 | |
986 | 449 fileext_label = gtk_label_new(_("Output file format:")); |
984 | 450 gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_label, FALSE, FALSE, 0); |
451 | |
452 fileext_combo = gtk_combo_box_new_text(); | |
453 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "WAV"); | |
1000 | 454 #ifdef FILEWRITER_MP3 |
984 | 455 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "MP3"); |
1000 | 456 #endif |
457 #ifdef FILEWRITER_VORBIS | |
986 | 458 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "Vorbis"); |
1000 | 459 #endif |
460 #ifdef FILEWRITER_FLAC | |
991 | 461 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "FLAC"); |
1000 | 462 #endif |
984 | 463 gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_combo, FALSE, FALSE, 0); |
464 gtk_combo_box_set_active(GTK_COMBO_BOX(fileext_combo), fileext); | |
465 g_signal_connect(G_OBJECT(fileext_combo), "changed", G_CALLBACK(fileext_cb), NULL); | |
466 | |
467 plugin_button = gtk_button_new_with_label(_("Configure")); | |
3041
d6fa54737096
Copying structs is not a good idea. Lets use a pointer here.
William Pitcock <nenolod@atheme.org>
parents:
3020
diff
changeset
|
468 gtk_widget_set_sensitive(plugin_button, plugin->configure != NULL); |
984 | 469 g_signal_connect(G_OBJECT(plugin_button), "clicked", G_CALLBACK(plugin_configure_cb), NULL); |
470 gtk_box_pack_end(GTK_BOX(fileext_hbox), plugin_button, FALSE, FALSE, 0); | |
471 | |
472 | |
473 | |
474 | |
475 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
476 | |
477 | |
478 | |
479 saveplace_hbox = gtk_hbox_new(FALSE, 5); | |
480 gtk_container_add(GTK_CONTAINER(configure_vbox), saveplace_hbox); | |
481 | |
482 saveplace = gtk_radio_button_new_with_label(NULL, _("Save into original directory")); | |
483 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_original_cb), NULL); | |
484 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0); | |
485 | |
486 saveplace = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(saveplace), | |
487 _("Save into custom directory")); | |
488 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_custom_cb), NULL); | |
489 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0); | |
490 | |
491 if (!save_original) | |
492 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(saveplace), TRUE); | |
493 | |
494 | |
495 | |
496 path_hbox = gtk_hbox_new(FALSE, 5); | |
497 gtk_box_pack_start(GTK_BOX(configure_vbox), path_hbox, FALSE, FALSE, 0); | |
498 | |
499 path_label = gtk_label_new(_("Output file folder:")); | |
500 gtk_box_pack_start(GTK_BOX(path_hbox), path_label, FALSE, FALSE, 0); | |
501 | |
502 path_dirbrowser = | |
1298
94eee8a16189
The "i18n" saga is still going on...
Stany HENRY <StrassBoy@gmail.com>
parents:
1269
diff
changeset
|
503 gtk_file_chooser_button_new (_("Pick a folder"), |
984 | 504 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); |
505 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(path_dirbrowser), | |
506 file_path); | |
507 gtk_box_pack_start(GTK_BOX(path_hbox), path_dirbrowser, TRUE, TRUE, 0); | |
508 | |
509 if (save_original) | |
510 gtk_widget_set_sensitive(path_hbox, FALSE); | |
511 | |
512 | |
513 | |
514 | |
515 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
516 | |
517 | |
518 | |
519 | |
520 filenamefrom_hbox = gtk_hbox_new(FALSE, 5); | |
521 gtk_container_add(GTK_CONTAINER(configure_vbox), filenamefrom_hbox); | |
522 | |
523 filenamefrom_label = gtk_label_new(_("Get filename from:")); | |
524 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_label, FALSE, FALSE, 0); | |
525 | |
526 filenamefrom_toggle = gtk_radio_button_new_with_label(NULL, _("original file tags")); | |
527 g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromtags_cb), NULL); | |
528 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0); | |
529 | |
530 filenamefrom_toggle = | |
531 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filenamefrom_toggle), | |
532 _("original filename")); | |
533 g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromfilename_cb), NULL); | |
534 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0); | |
535 | |
536 if (!filenamefromtags) | |
537 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filenamefrom_toggle), TRUE); | |
538 | |
539 | |
540 | |
541 | |
542 use_suffix_toggle = gtk_check_button_new_with_label(_("Don't strip file name extension")); | |
543 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), use_suffix); | |
544 gtk_box_pack_start(GTK_BOX(configure_vbox), use_suffix_toggle, FALSE, FALSE, 0); | |
545 use_suffix_tooltips = gtk_tooltips_new(); | |
1525
bee9eaedefa5
- made the MP3 FileWriter output plugin less braindead
mf0102 <0102@gmx.at>
parents:
1510
diff
changeset
|
546 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 | 547 gtk_tooltips_enable(use_suffix_tooltips); |
548 | |
549 if (filenamefromtags) | |
550 gtk_widget_set_sensitive(use_suffix_toggle, FALSE); | |
551 | |
552 | |
553 | |
554 | |
555 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); | |
556 | |
557 | |
558 | |
559 | |
560 prependnumber_toggle = gtk_check_button_new_with_label(_("Prepend track number to filename")); | |
561 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prependnumber_toggle), prependnumber); | |
562 gtk_box_pack_start(GTK_BOX(configure_vbox), prependnumber_toggle, FALSE, FALSE, 0); | |
563 | |
564 | |
565 | |
566 configure_bbox = gtk_hbutton_box_new(); | |
567 gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox), | |
568 GTK_BUTTONBOX_END); | |
569 gtk_button_box_set_spacing(GTK_BUTTON_BOX(configure_bbox), 5); | |
570 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_bbox, | |
571 FALSE, FALSE, 0); | |
572 | |
573 configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
574 gtk_signal_connect_object(GTK_OBJECT(configure_cancel), "clicked", | |
575 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
576 GTK_OBJECT(configure_win)); | |
577 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel, | |
578 TRUE, TRUE, 0); | |
579 | |
580 configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK); | |
581 gtk_signal_connect(GTK_OBJECT(configure_ok), "clicked", | |
582 GTK_SIGNAL_FUNC(configure_ok_cb), NULL); | |
583 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok, | |
584 TRUE, TRUE, 0); | |
585 | |
586 gtk_widget_show_all(configure_win); | |
587 } | |
588 } |