annotate src/filewriter/filewriter.c @ 1101:661777673349 trunk

[svn] - pulse: convert to plugin API v2
author nenolod
date Thu, 24 May 2007 23:37:12 -0700
parents 91f6c4647bae
children 0eddd8516e32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
1 /* FileWriter-Plugin
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
2 * (C) copyright 2007 merging of Disk Writer and Out-Lame by Michael Färber
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
3 *
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
4 * Original Out-Lame-Plugin:
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
5 * (C) copyright 2002 Lars Siebold <khandha5@gmx.net>
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
6 * (C) copyright 2006-2007 porting to audacious by Yoshiki Yazawa <yaz@cc.rim.or.jp>
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
7 *
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
11 * (at your option) any later version.
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
12 *
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
16 * GNU General Public License for more details.
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
17 *
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
21 */
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
22
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
23 #include "filewriter.h"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
24 #include "plugins.h"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
25
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
26 static GtkWidget *configure_win = NULL, *configure_vbox;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
27 static GtkWidget *path_hbox, *path_label, *path_dirbrowser;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
28 static GtkWidget *configure_bbox, *configure_ok, *configure_cancel;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
29
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
30 static GtkWidget *fileext_hbox, *fileext_label, *fileext_combo, *plugin_button;
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
31
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
32 enum fileext_t
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
33 {
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
34 WAV = 0,
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
35 #ifdef FILEWRITER_MP3
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
36 MP3,
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
37 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
38 #ifdef FILEWRITER_VORBIS
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
39 VORBIS,
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
40 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
41 #ifdef FILEWRITER_FLAC
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
42 FLAC,
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
43 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
44 FILEEXT_MAX
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
45 };
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
46
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
47 static gint fileext = WAV;
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
48 static gchar *fileext_str[] =
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
49 {
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
50 "wav",
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
51 #ifdef FILEWRITER_MP3
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
52 "mp3",
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
53 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
54 #ifdef FILEWRITER_VORBIS
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
55 "ogg",
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
56 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
57 #ifdef FILEWRITER_FLAC
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
58 "flac"
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
59 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
60 };
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
61
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
62 static FileWriter plugin;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
63
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
64 static GtkWidget *saveplace_hbox, *saveplace;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
65 static gboolean save_original = TRUE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
66
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
67 static GtkWidget *filenamefrom_hbox, *filenamefrom_label, *filenamefrom_toggle;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
68 static gboolean filenamefromtags = TRUE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
69
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
70 static GtkWidget *use_suffix_toggle = NULL;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
71 static gboolean use_suffix = FALSE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
72
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
73 static GtkWidget *prependnumber_toggle;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
74 static gboolean prependnumber = FALSE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
75
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
76 static gchar *file_path = NULL;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
77
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
78 static void file_init(void);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
79 static void file_about(void);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
80 static gint file_open(AFormat fmt, gint rate, gint nch);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
81 static void file_write(void *ptr, gint length);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
82 static void file_close(void);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
83 static void file_flush(gint time);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
84 static void file_pause(short p);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
85 static gint file_free(void);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
86 static gint file_playing(void);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
87 static gint file_get_written_time(void);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
88 static gint file_get_output_time(void);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
89 static void file_configure(void);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
90
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
91 OutputPlugin file_op =
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
92 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
93 NULL,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
94 NULL,
1076
91f6c4647bae [svn] - filewriter: transition to plugin API v2
nenolod
parents: 1011
diff changeset
95 "FileWriter Plugin",
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
96 file_init,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
97 NULL,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
98 file_about,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
99 file_configure,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
100 NULL,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
101 NULL,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
102 file_open,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
103 file_write,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
104 file_close,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
105 file_flush,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
106 file_pause,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
107 file_free,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
108 file_playing,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
109 file_get_output_time,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
110 file_get_written_time,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
111 NULL
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
112 };
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
113
1076
91f6c4647bae [svn] - filewriter: transition to plugin API v2
nenolod
parents: 1011
diff changeset
114 OutputPlugin *file_oplist[] = { &file_op, NULL };
91f6c4647bae [svn] - filewriter: transition to plugin API v2
nenolod
parents: 1011
diff changeset
115
91f6c4647bae [svn] - filewriter: transition to plugin API v2
nenolod
parents: 1011
diff changeset
116 DECLARE_PLUGIN(filewriter, NULL, NULL, file_oplist, NULL, NULL, NULL, NULL);
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
117
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
118 static void set_plugin(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
119 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
120 if (fileext < 0 || fileext >= FILEEXT_MAX)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
121 fileext = 0;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
122
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
123 if (fileext == WAV)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
124 plugin = wav_plugin;
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
125 #ifdef FILEWRITER_MP3
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
126 if (fileext == MP3)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
127 plugin = mp3_plugin;
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
128 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
129 #ifdef FILEWRITER_VORBIS
986
5523559a1eac [svn] - add Vorbis output mode
nenolod
parents: 985
diff changeset
130 if (fileext == VORBIS)
5523559a1eac [svn] - add Vorbis output mode
nenolod
parents: 985
diff changeset
131 plugin = vorbis_plugin;
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
132 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
133 #ifdef FILEWRITER_FLAC
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents: 986
diff changeset
134 if (fileext == FLAC)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents: 986
diff changeset
135 plugin = flac_plugin;
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
136 #endif
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
137 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
138
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
139 static void file_init(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
140 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
141 ConfigDb *db;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
142
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
143 db = bmp_cfg_db_open();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
144 bmp_cfg_db_get_int(db, "filewriter", "fileext", &fileext);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
145 bmp_cfg_db_get_string(db, "filewriter", "file_path", &file_path);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
146 bmp_cfg_db_get_bool(db, "filewriter", "save_original", &save_original);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
147 bmp_cfg_db_get_bool(db, "filewriter", "use_suffix", &use_suffix);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
148 bmp_cfg_db_get_bool(db, "filewriter", "filenamefromtags", &filenamefromtags);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
149 bmp_cfg_db_get_bool(db, "filewriter", "prependnumber", &prependnumber);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
150 bmp_cfg_db_close(db);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
151
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
152 if (!file_path)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
153 file_path = g_strdup(g_get_home_dir());
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
154
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
155 set_plugin();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
156 if (plugin.init)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
157 plugin.init();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
158 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
159
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
160 void file_about(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
161 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
162 static GtkWidget *dialog;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
163
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
164 if (dialog != NULL)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
165 return;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
166
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
167 dialog = xmms_show_message("About FileWriter-Plugin",
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
168 "FileWriter-Plugin\n\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
169 "This program is free software; you can redistribute it and/or modify\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
170 "it under the terms of the GNU General Public License as published by\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
171 "the Free Software Foundation; either version 2 of the License, or\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
172 "(at your option) any later version.\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
173 "\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
174 "This program is distributed in the hope that it will be useful,\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
175 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
176 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
177 "GNU General Public License for more details.\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
178 "\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
179 "You should have received a copy of the GNU General Public License\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
180 "along with this program; if not, write to the Free Software\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
181 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
182 "USA.", "Ok", FALSE, NULL, NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
183 gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
184 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
185 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
186
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
187 static gint file_open(AFormat fmt, gint rate, gint nch)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
188 {
1011
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
189 gchar *filename = NULL, *temp = NULL;
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
190 gint pos;
1004
be2d04b2bd28 [svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents: 1000
diff changeset
191 gint rv;
1011
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
192 Playlist *playlist;
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
193
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
194 if (xmms_check_realtime_priority())
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
195 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
196 xmms_show_message(_("Error"),
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
197 _("You cannot use the FileWriter plugin\n"
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
198 "when you're running in realtime mode."),
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
199 _("OK"), FALSE, NULL, NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
200 return 0;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
201 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
202
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
203 input.format = fmt;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
204 input.frequency = rate;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
205 input.channels = nch;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
206
1011
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
207 playlist = playlist_get_active();
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
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
210
1011
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
211 pos = playlist_get_position(playlist);
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
212 tuple = playlist_get_tuple(playlist, pos);
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
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
215
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
216 if (filenamefromtags)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
217 {
1011
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
218 gchar *utf8 = xmms_get_titlestring(xmms_get_gentitle_format(), tuple);
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
219
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
220 g_strchomp(utf8); //chop trailing ^J --yaz
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
221
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
222 filename = g_locale_from_utf8(utf8, -1, NULL, NULL, NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
223 g_free(utf8);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
224 while (filename != NULL && (temp = strchr(filename, '/')) != NULL)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
225 *temp = '-';
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
226 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
227 if (filename == NULL)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
228 {
1011
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
229 filename = g_strdup(tuple->file_name);
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
230 if (!use_suffix)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
231 if ((temp = strrchr(filename, '.')) != NULL)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
232 *temp = '\0';
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
233 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
234 if (filename == NULL)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
235 filename = g_strdup_printf("aud-%d", pos);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
236
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
237
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
238 if (prependnumber)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
239 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
240 gint number;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
241 if (tuple && tuple->track_number)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
242 number = tuple->track_number;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
243 else
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
244 number = pos + 1;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
245
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
246 temp = g_strdup_printf("%.02d %s", number, filename);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
247 g_free(filename);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
248 filename = temp;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
249 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
250
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
251 gchar *directory;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
252 if (save_original)
1011
4a693f5b7054 [svn] - replace xmms_remote_*() with playlist functions.
yaz
parents: 1004
diff changeset
253 directory = g_strdup(tuple->file_path);
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
254 else
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
255 directory = g_strdup(file_path);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
256
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
257 temp = g_strdup_printf("%s/%s.%s",
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
258 directory, filename, fileext_str[fileext]);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
259 g_free(directory);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
260 g_free(filename);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
261 filename = temp;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
262
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
263 output_file = vfs_fopen(filename, "w");
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
264 g_free(filename);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
265
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
266 if (!output_file)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
267 return 0;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
268
1004
be2d04b2bd28 [svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents: 1000
diff changeset
269 rv = plugin.open();
be2d04b2bd28 [svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents: 1000
diff changeset
270
be2d04b2bd28 [svn] - move bmp_title_input_free() into file_open() to avoid memory leak.
yaz
parents: 1000
diff changeset
271 return rv;
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
272 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
273
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
274 static void convert_buffer(gpointer buffer, gint length)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
275 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
276 gint i;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
277
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
278 if (input.format == FMT_S8)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
279 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
280 guint8 *ptr1 = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
281 gint8 *ptr2 = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
282
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
283 for (i = 0; i < length; i++)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
284 *(ptr1++) = *(ptr2++) ^ 128;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
285 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
286 if (input.format == FMT_S16_BE)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
287 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
288 gint16 *ptr = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
289
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
290 for (i = 0; i < length >> 1; i++, ptr++)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
291 *ptr = GUINT16_SWAP_LE_BE(*ptr);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
292 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
293 if (input.format == FMT_S16_NE)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
294 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
295 gint16 *ptr = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
296
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
297 for (i = 0; i < length >> 1; i++, ptr++)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
298 *ptr = GINT16_TO_LE(*ptr);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
299 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
300 if (input.format == FMT_U16_BE)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
301 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
302 gint16 *ptr1 = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
303 guint16 *ptr2 = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
304
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
305 for (i = 0; i < length >> 1; i++, ptr2++)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
306 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
307 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
308 if (input.format == FMT_U16_LE)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
309 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
310 gint16 *ptr1 = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
311 guint16 *ptr2 = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
312
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
313 for (i = 0; i < length >> 1; i++, ptr2++)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
314 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
315 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
316 if (input.format == FMT_U16_NE)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
317 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
318 gint16 *ptr1 = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
319 guint16 *ptr2 = buffer;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
320
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
321 for (i = 0; i < length >> 1; i++, ptr2++)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
322 *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
323 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
324 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
325
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
326 static void file_write(void *ptr, gint length)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
327 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
328 AFormat new_format;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
329 int new_frequency, new_channels;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
330 EffectPlugin *ep;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
331
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
332 new_format = input.format;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
333 new_frequency = input.frequency;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
334 new_channels = input.channels;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
335
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
336 ep = get_current_effect_plugin();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
337 if ( effects_enabled() && ep && ep->query_format ) {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
338 ep->query_format(&new_format,&new_frequency,&new_channels);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
339 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
340
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
341 if ( effects_enabled() && ep && ep->mod_samples ) {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
342 length = ep->mod_samples(&ptr,length,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
343 input.format,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
344 input.frequency,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
345 input.channels );
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
346 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
347
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
348 if (input.format == FMT_S8 || input.format == FMT_S16_BE ||
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
349 input.format == FMT_U16_LE || input.format == FMT_U16_BE ||
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
350 input.format == FMT_U16_NE)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
351 convert_buffer(ptr, length);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
352 #ifdef WORDS_BIGENDIAN
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
353 if (input.format == FMT_S16_NE)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
354 convert_buffer(ptr, length);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
355 #endif
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
356
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
357 plugin.write(ptr, length);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
358 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
359
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
360 static void file_close(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
361 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
362 plugin.close();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
363
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
364 if (output_file)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
365 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
366 written = 0;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
367 vfs_fclose(output_file);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
368 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
369 output_file = NULL;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
370 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
371
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
372 static void file_flush(gint time)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
373 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
374 if (time < 0)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
375 return;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
376
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
377 file_close();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
378 file_open(input.format, input.frequency, input.channels);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
379
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
380 offset = time;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
381 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
382
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
383 static void file_pause(short p)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
384 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
385 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
386
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
387 static gint file_free(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
388 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
389 return plugin.free();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
390 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
391
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
392 static gint file_playing(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
393 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
394 return plugin.playing();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
395 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
396
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
397 static gint file_get_written_time(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
398 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
399 return plugin.get_written_time();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
400 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
401
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
402 static gint file_get_output_time(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
403 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
404 return file_get_written_time();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
405 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
406
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
407 static void configure_ok_cb(gpointer data)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
408 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
409 ConfigDb *db;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
410
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
411 fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
412
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
413 g_free(file_path);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
414 file_path = g_strdup(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(path_dirbrowser)));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
415
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
416 use_suffix =
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
417 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_suffix_toggle));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
418
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
419 prependnumber =
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
420 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prependnumber_toggle));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
421
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
422 db = bmp_cfg_db_open();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
423 bmp_cfg_db_set_int(db, "filewriter", "fileext", fileext);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
424 bmp_cfg_db_set_string(db, "filewriter", "file_path", file_path);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
425 bmp_cfg_db_set_bool(db, "filewriter", "save_original", save_original);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
426 bmp_cfg_db_set_bool(db, "filewriter", "filenamefromtags", filenamefromtags);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
427 bmp_cfg_db_set_bool(db, "filewriter", "use_suffix", use_suffix);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
428 bmp_cfg_db_set_bool(db, "filewriter", "prependnumber", prependnumber);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
429
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
430 bmp_cfg_db_close(db);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
431
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
432 gtk_widget_destroy(configure_win);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
433 if (path_dirbrowser)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
434 gtk_widget_destroy(path_dirbrowser);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
435 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
436
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
437 static void fileext_cb(GtkWidget *combo, gpointer data)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
438 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
439 fileext = gtk_combo_box_get_active(GTK_COMBO_BOX(fileext_combo));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
440 set_plugin();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
441
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
442 gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
443 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
444
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
445 static void plugin_configure_cb(GtkWidget *button, gpointer data)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
446 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
447 if (plugin.configure)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
448 plugin.configure();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
449 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
450
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
451
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
452 static void saveplace_original_cb(GtkWidget *button, gpointer data)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
453 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
454 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
455 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
456 gtk_widget_set_sensitive(path_hbox, FALSE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
457 save_original = TRUE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
458 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
459 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
460
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
461 static void saveplace_custom_cb(GtkWidget *button, gpointer data)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
462 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
463 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
464 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
465 gtk_widget_set_sensitive(path_hbox, TRUE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
466 save_original = FALSE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
467 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
468 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
469
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
470 static void filenamefromtags_cb(GtkWidget *button, gpointer data)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
471 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
472 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
473 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
474 gtk_widget_set_sensitive(use_suffix_toggle, FALSE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
475 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), FALSE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
476 use_suffix = FALSE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
477 filenamefromtags = TRUE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
478 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
479 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
480
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
481 static void filenamefromfilename_cb(GtkWidget *button, gpointer data)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
482 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
483 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
484 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
485 gtk_widget_set_sensitive(use_suffix_toggle, TRUE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
486 filenamefromtags = FALSE;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
487 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
488 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
489
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
490
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
491 static void configure_destroy(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
492 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
493 if (path_dirbrowser)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
494 gtk_widget_destroy(path_dirbrowser);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
495 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
496
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
497 static void file_configure(void)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
498 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
499 GtkTooltips *use_suffix_tooltips;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
500
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
501 if (!configure_win)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
502 {
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
503 configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
504
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
505 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy",
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
506 GTK_SIGNAL_FUNC(configure_destroy), NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
507 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy",
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
508 GTK_SIGNAL_FUNC(gtk_widget_destroyed),
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
509 &configure_win);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
510
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
511 gtk_window_set_title(GTK_WINDOW(configure_win),
985
029056fb9f9d [svn] - rename titles of configure windows.
yaz
parents: 984
diff changeset
512 _("File Writer Configuration"));
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
513 gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
514
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
515 gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
516
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
517 configure_vbox = gtk_vbox_new(FALSE, 10);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
518 gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
519
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
520
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
521 fileext_hbox = gtk_hbox_new(FALSE, 5);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
522 gtk_box_pack_start(GTK_BOX(configure_vbox), fileext_hbox, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
523
986
5523559a1eac [svn] - add Vorbis output mode
nenolod
parents: 985
diff changeset
524 fileext_label = gtk_label_new(_("Output file format:"));
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
525 gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_label, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
526
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
527 fileext_combo = gtk_combo_box_new_text();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
528 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "WAV");
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
529 #ifdef FILEWRITER_MP3
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
530 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "MP3");
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
531 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
532 #ifdef FILEWRITER_VORBIS
986
5523559a1eac [svn] - add Vorbis output mode
nenolod
parents: 985
diff changeset
533 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "Vorbis");
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
534 #endif
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
535 #ifdef FILEWRITER_FLAC
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents: 986
diff changeset
536 gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "FLAC");
1000
d980b7e5bf1d [svn] - Prepared FileWriter for partial compilation
mf0102
parents: 991
diff changeset
537 #endif
984
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
538 gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_combo, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
539 gtk_combo_box_set_active(GTK_COMBO_BOX(fileext_combo), fileext);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
540 g_signal_connect(G_OBJECT(fileext_combo), "changed", G_CALLBACK(fileext_cb), NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
541
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
542 plugin_button = gtk_button_new_with_label(_("Configure"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
543 gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
544 g_signal_connect(G_OBJECT(plugin_button), "clicked", G_CALLBACK(plugin_configure_cb), NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
545 gtk_box_pack_end(GTK_BOX(fileext_hbox), plugin_button, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
546
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
547
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
548
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
549
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
550 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
551
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
552
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
553
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
554 saveplace_hbox = gtk_hbox_new(FALSE, 5);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
555 gtk_container_add(GTK_CONTAINER(configure_vbox), saveplace_hbox);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
556
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
557 saveplace = gtk_radio_button_new_with_label(NULL, _("Save into original directory"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
558 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_original_cb), NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
559 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
560
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
561 saveplace = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(saveplace),
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
562 _("Save into custom directory"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
563 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_custom_cb), NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
564 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
565
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
566 if (!save_original)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
567 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(saveplace), TRUE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
568
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
569
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
570
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
571 path_hbox = gtk_hbox_new(FALSE, 5);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
572 gtk_box_pack_start(GTK_BOX(configure_vbox), path_hbox, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
573
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
574 path_label = gtk_label_new(_("Output file folder:"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
575 gtk_box_pack_start(GTK_BOX(path_hbox), path_label, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
576
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
577 path_dirbrowser =
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
578 gtk_file_chooser_button_new ("Pick a folder",
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
579 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
580 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(path_dirbrowser),
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
581 file_path);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
582 gtk_box_pack_start(GTK_BOX(path_hbox), path_dirbrowser, TRUE, TRUE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
583
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
584 if (save_original)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
585 gtk_widget_set_sensitive(path_hbox, FALSE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
586
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
587
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
588
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
589
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
590 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
591
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
592
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
593
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
594
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
595 filenamefrom_hbox = gtk_hbox_new(FALSE, 5);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
596 gtk_container_add(GTK_CONTAINER(configure_vbox), filenamefrom_hbox);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
597
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
598 filenamefrom_label = gtk_label_new(_("Get filename from:"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
599 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_label, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
600
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
601 filenamefrom_toggle = gtk_radio_button_new_with_label(NULL, _("original file tags"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
602 g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromtags_cb), NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
603 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
604
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
605 filenamefrom_toggle =
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
606 gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filenamefrom_toggle),
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
607 _("original filename"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
608 g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromfilename_cb), NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
609 gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
610
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
611 if (!filenamefromtags)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
612 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filenamefrom_toggle), TRUE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
613
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
614
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
615
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
616
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
617 use_suffix_toggle = gtk_check_button_new_with_label(_("Don't strip file name extension"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
618 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), use_suffix);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
619 gtk_box_pack_start(GTK_BOX(configure_vbox), use_suffix_toggle, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
620 use_suffix_tooltips = gtk_tooltips_new();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
621 gtk_tooltips_set_tip(use_suffix_tooltips, use_suffix_toggle, "If enabled, the extension from the original filename will not be stripped before adding the .wav extension to the end.", NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
622 gtk_tooltips_enable(use_suffix_tooltips);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
623
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
624 if (filenamefromtags)
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
625 gtk_widget_set_sensitive(use_suffix_toggle, FALSE);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
626
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
627
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
628
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
629
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
630 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
631
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
632
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
633
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
634
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
635 prependnumber_toggle = gtk_check_button_new_with_label(_("Prepend track number to filename"));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
636 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prependnumber_toggle), prependnumber);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
637 gtk_box_pack_start(GTK_BOX(configure_vbox), prependnumber_toggle, FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
638
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
639
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
640
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
641 configure_bbox = gtk_hbutton_box_new();
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
642 gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox),
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
643 GTK_BUTTONBOX_END);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
644 gtk_button_box_set_spacing(GTK_BUTTON_BOX(configure_bbox), 5);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
645 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_bbox,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
646 FALSE, FALSE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
647
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
648 configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
649 gtk_signal_connect_object(GTK_OBJECT(configure_cancel), "clicked",
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
650 GTK_SIGNAL_FUNC(gtk_widget_destroy),
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
651 GTK_OBJECT(configure_win));
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
652 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
653 TRUE, TRUE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
654
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
655 configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
656 gtk_signal_connect(GTK_OBJECT(configure_ok), "clicked",
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
657 GTK_SIGNAL_FUNC(configure_ok_cb), NULL);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
658 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok,
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
659 TRUE, TRUE, 0);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
660
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
661 gtk_widget_show_all(configure_win);
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
662 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
663 }
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
664
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
665 VFSFile *output_file = NULL;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
666 guint64 written = 0;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
667 guint64 offset = 0;
df7b09989aee [svn] - We got a new plugin, captain!
mf0102
parents:
diff changeset
668 TitleInput *tuple = NULL;