comparison src/disk_writer/disk_writer.c @ 904:4a2e5c1e7c3b trunk

[svn] - Added option to save output files to original file directory
author mf0102
date Fri, 30 Mar 2007 06:37:26 -0700
parents a9199ee8e5c0
children
comparison
equal deleted inserted replaced
903:1820b4026fe2 904:4a2e5c1e7c3b
34 #include "audacious/util.h" 34 #include "audacious/util.h"
35 #include "audacious/vfs.h" 35 #include "audacious/vfs.h"
36 36
37 37
38 struct format_info { 38 struct format_info {
39 AFormat format; 39 AFormat format;
40 int frequency; 40 int frequency;
41 int channels; 41 int channels;
42 }; 42 };
43 struct format_info input; 43 struct format_info input;
44 44
45 struct wavhead 45 struct wavhead
46 { 46 {
47 guint32 main_chunk; 47 guint32 main_chunk;
48 guint32 length; 48 guint32 length;
49 guint32 chunk_type; 49 guint32 chunk_type;
50 guint32 sub_chunk; 50 guint32 sub_chunk;
51 guint32 sc_len; 51 guint32 sc_len;
52 guint16 format; 52 guint16 format;
53 guint16 modus; 53 guint16 modus;
54 guint32 sample_fq; 54 guint32 sample_fq;
55 guint32 byte_p_sec; 55 guint32 byte_p_sec;
56 guint16 byte_p_spl; 56 guint16 byte_p_spl;
57 guint16 bit_p_spl; 57 guint16 bit_p_spl;
58 guint32 data_chunk; 58 guint32 data_chunk;
59 guint32 data_length; 59 guint32 data_length;
60 }; 60 };
61 61
62 static GtkWidget *configure_win = NULL, *configure_vbox; 62 static GtkWidget *configure_win = NULL, *configure_vbox;
63 static GtkWidget *path_hbox, *path_label, *path_dirbrowser = NULL; 63 static GtkWidget *path_hbox, *path_label, *path_dirbrowser;
64 static GtkWidget *configure_separator; 64 static GtkWidget *configure_separator;
65 static GtkWidget *configure_bbox, *configure_ok, *configure_cancel; 65 static GtkWidget *configure_bbox, *configure_ok, *configure_cancel;
66
67 static GtkWidget *saveplace_hbox, *saveplace;
68 static gboolean save_original = TRUE;
66 69
67 static GtkWidget *use_suffix_toggle = NULL; 70 static GtkWidget *use_suffix_toggle = NULL;
68 static gboolean use_suffix = FALSE; 71 static gboolean use_suffix = FALSE;
69 72
70 static gchar *file_path = NULL; 73 static gchar *file_path = NULL;
71 static VFSFile *output_file = NULL; 74 static VFSFile *output_file = NULL;
72 static struct wavhead header; 75 static struct wavhead header;
73 static guint64 written = 0; 76 static guint64 written = 0;
74 static AFormat afmt; 77 static AFormat afmt;
75 static gint arate, ach; 78 static gint arate, ach;
76 gint ctrlsocket_get_session_id(void); /* FIXME */ 79 gint ctrlsocket_get_session_id(void); /* FIXME */
77 80
78 static void disk_init(void); 81 static void disk_init(void);
79 static gint disk_open(AFormat fmt, gint rate, gint nch); 82 static gint disk_open(AFormat fmt, gint rate, gint nch);
80 static void disk_write(void *ptr, gint length); 83 static void disk_write(void *ptr, gint length);
81 static void disk_close(void); 84 static void disk_close(void);
91 94
92 static int lvol = 0, rvol = 0; 95 static int lvol = 0, rvol = 0;
93 96
94 OutputPlugin disk_op = 97 OutputPlugin disk_op =
95 { 98 {
96 NULL, 99 NULL,
97 NULL, 100 NULL,
98 NULL, /* Description */ 101 NULL,
99 disk_init, 102 disk_init,
100 NULL, 103 NULL,
101 NULL, /* about */ 104 NULL,
102 disk_configure, /* configure */ 105 disk_configure,
103 disk_getvol, /* get_volume */ 106 disk_getvol,
104 disk_setvol, /* set_volume */ 107 disk_setvol,
105 disk_open, 108 disk_open,
106 disk_write, 109 disk_write,
107 disk_close, 110 disk_close,
108 disk_flush, 111 disk_flush,
109 disk_pause, 112 disk_pause,
110 disk_free, 113 disk_free,
111 disk_playing, 114 disk_playing,
112 disk_get_output_time, 115 disk_get_output_time,
113 disk_get_written_time, 116 disk_get_written_time,
114 NULL 117 NULL
115 }; 118 };
116 119
117 OutputPlugin *get_oplugin_info(void) 120 OutputPlugin *get_oplugin_info(void)
118 { 121 {
119 disk_op.description = g_strdup_printf(_("Disk Writer Plugin %s"), VERSION); 122 disk_op.description = g_strdup_printf(_("Disk Writer Plugin %s"), VERSION);
120 return &disk_op; 123 return &disk_op;
121 } 124 }
122 125
123 static void disk_init(void) 126 static void disk_init(void)
124 { 127 {
125 ConfigDb *db; 128 ConfigDb *db;
126 129
127 db = bmp_cfg_db_open(); 130 db = bmp_cfg_db_open();
128 bmp_cfg_db_get_string(db, "disk_writer", "file_path", &file_path); 131 bmp_cfg_db_get_string(db, "disk_writer", "file_path", &file_path);
129 bmp_cfg_db_get_bool(db, "disk_writer", "use_suffix", &use_suffix); 132 bmp_cfg_db_get_bool(db, "disk_writer", "save_original", &save_original);
130 bmp_cfg_db_close(db); 133 bmp_cfg_db_get_bool(db, "disk_writer", "use_suffix", &use_suffix);
131 134 bmp_cfg_db_close(db);
132 if (!file_path) 135
133 file_path = g_strdup(g_get_home_dir()); 136 if (!file_path)
137 file_path = g_strdup(g_get_home_dir());
134 } 138 }
135 139
136 static gint disk_open(AFormat fmt, gint rate, gint nch) 140 static gint disk_open(AFormat fmt, gint rate, gint nch)
137 { 141 {
138 gchar *filename, *title, *temp; 142 gchar *filename, *title, *temp;
139 gint pos; 143 gint pos;
140 144
141 written = 0; 145 written = 0;
142 afmt = fmt; 146 afmt = fmt;
143 arate = rate; 147 arate = rate;
144 ach = nch; 148 ach = nch;
145 149
146 if (xmms_check_realtime_priority()) 150 if (xmms_check_realtime_priority())
147 { 151 {
148 xmms_show_message(_("Error"), 152 xmms_show_message(_("Error"),
149 _("You cannot use the Disk Writer plugin\n" 153 _("You cannot use the Disk Writer plugin\n"
150 "when you're running in realtime mode."), 154 "when you're running in realtime mode."),
151 _("OK"), FALSE, NULL, NULL); 155 _("OK"), FALSE, NULL, NULL);
152 return 0; 156 return 0;
153 } 157 }
154 158
155 pos = xmms_remote_get_playlist_pos(ctrlsocket_get_session_id()); 159 pos = xmms_remote_get_playlist_pos(ctrlsocket_get_session_id());
156 title = xmms_remote_get_playlist_file(ctrlsocket_get_session_id(), pos); 160 title = xmms_remote_get_playlist_file(ctrlsocket_get_session_id(), pos);
157 if (!use_suffix) { 161 if (!use_suffix) {
158 if (title != NULL && (temp = strrchr(title, '.')) != NULL) { 162 if (title != NULL && (temp = strrchr(title, '.')) != NULL) {
159 *temp = '\0'; 163 *temp = '\0';
160 } 164 }
161 } 165 }
162 if (title == NULL || strlen(g_basename(title)) == 0) 166 if (title == NULL || strlen(g_basename(title)) == 0)
163 { 167 {
164 g_free(title); 168 g_free(title);
165 /* No filename, lets try title instead */ 169 /* No filename, lets try title instead */
166 title = xmms_remote_get_playlist_title(ctrlsocket_get_session_id(), pos); 170 title = xmms_remote_get_playlist_title(ctrlsocket_get_session_id(), pos);
167 while (title != NULL && (temp = strchr(title, '/')) != NULL) 171 while (title != NULL && (temp = strchr(title, '/')) != NULL)
168 *temp = '-'; 172 *temp = '-';
169 173
170 if (title == NULL || strlen(g_basename(title)) == 0) 174 if (title == NULL || strlen(g_basename(title)) == 0)
171 { 175 {
172 g_free(title); 176 g_free(title);
173 /* No title either. Just set it to something. */ 177 /* No title either. Just set it to something. */
174 title = g_strdup_printf("xmms-%d", pos); 178 title = g_strdup_printf("xmms-%d", pos);
175 } 179 }
176 } 180 }
177 filename = g_strdup_printf("%s/%s.wav", file_path, g_basename(title)); 181
178 g_free(title); 182 if (save_original)
179 183 filename = g_strdup_printf("%s.wav", title);
180 output_file = vfs_fopen(filename, "wb"); 184 else
181 g_free(filename); 185 filename = g_strdup_printf("%s/%s.wav", file_path, g_basename(title));
182 186 // FIXME: check if filename equals title
183 if (!output_file) 187 g_free(title);
184 return 0; 188
185 189 output_file = vfs_fopen(filename, "wb");
186 memcpy(&header.main_chunk, "RIFF", 4); 190 g_free(filename);
187 header.length = GUINT32_TO_LE(0); 191
188 memcpy(&header.chunk_type, "WAVE", 4); 192 if (!output_file)
189 memcpy(&header.sub_chunk, "fmt ", 4); 193 return 0;
190 header.sc_len = GUINT32_TO_LE(16); 194
191 header.format = GUINT16_TO_LE(1); 195 memcpy(&header.main_chunk, "RIFF", 4);
192 header.modus = GUINT16_TO_LE(nch); 196 header.length = GUINT32_TO_LE(0);
193 header.sample_fq = GUINT32_TO_LE(rate); 197 memcpy(&header.chunk_type, "WAVE", 4);
194 if (fmt == FMT_U8 || fmt == FMT_S8) 198 memcpy(&header.sub_chunk, "fmt ", 4);
195 header.bit_p_spl = GUINT16_TO_LE(8); 199 header.sc_len = GUINT32_TO_LE(16);
196 else 200 header.format = GUINT16_TO_LE(1);
197 header.bit_p_spl = GUINT16_TO_LE(16); 201 header.modus = GUINT16_TO_LE(nch);
198 header.byte_p_sec = GUINT32_TO_LE(rate * header.modus * (GUINT16_FROM_LE(header.bit_p_spl) / 8)); 202 header.sample_fq = GUINT32_TO_LE(rate);
199 header.byte_p_spl = GUINT16_TO_LE((GUINT16_FROM_LE(header.bit_p_spl) / (8 / nch))); 203 if (fmt == FMT_U8 || fmt == FMT_S8)
200 memcpy(&header.data_chunk, "data", 4); 204 header.bit_p_spl = GUINT16_TO_LE(8);
201 header.data_length = GUINT32_TO_LE(0); 205 else
202 vfs_fwrite(&header, sizeof (struct wavhead), 1, output_file); 206 header.bit_p_spl = GUINT16_TO_LE(16);
203 207 header.byte_p_sec = GUINT32_TO_LE(rate * header.modus * (GUINT16_FROM_LE(header.bit_p_spl) / 8));
204 input.format = fmt; 208 header.byte_p_spl = GUINT16_TO_LE((GUINT16_FROM_LE(header.bit_p_spl) / (8 / nch)));
205 input.frequency = rate; 209 memcpy(&header.data_chunk, "data", 4);
206 input.channels = nch; 210 header.data_length = GUINT32_TO_LE(0);
207 211 vfs_fwrite(&header, sizeof (struct wavhead), 1, output_file);
208 return 1; 212
213 input.format = fmt;
214 input.frequency = rate;
215 input.channels = nch;
216
217 return 1;
209 } 218 }
210 219
211 static void convert_buffer(gpointer buffer, gint length) 220 static void convert_buffer(gpointer buffer, gint length)
212 { 221 {
213 gint i; 222 gint i;
214 223
215 if (afmt == FMT_S8) 224 if (afmt == FMT_S8)
216 { 225 {
217 guint8 *ptr1 = buffer; 226 guint8 *ptr1 = buffer;
218 gint8 *ptr2 = buffer; 227 gint8 *ptr2 = buffer;
219 228
220 for (i = 0; i < length; i++) 229 for (i = 0; i < length; i++)
221 *(ptr1++) = *(ptr2++) ^ 128; 230 *(ptr1++) = *(ptr2++) ^ 128;
222 } 231 }
223 if (afmt == FMT_S16_BE) 232 if (afmt == FMT_S16_BE)
224 { 233 {
225 gint16 *ptr = buffer; 234 gint16 *ptr = buffer;
226 235
227 for (i = 0; i < length >> 1; i++, ptr++) 236 for (i = 0; i < length >> 1; i++, ptr++)
228 *ptr = GUINT16_SWAP_LE_BE(*ptr); 237 *ptr = GUINT16_SWAP_LE_BE(*ptr);
229 } 238 }
230 if (afmt == FMT_S16_NE) 239 if (afmt == FMT_S16_NE)
231 { 240 {
232 gint16 *ptr = buffer; 241 gint16 *ptr = buffer;
233 242
234 for (i = 0; i < length >> 1; i++, ptr++) 243 for (i = 0; i < length >> 1; i++, ptr++)
235 *ptr = GINT16_TO_LE(*ptr); 244 *ptr = GINT16_TO_LE(*ptr);
236 } 245 }
237 if (afmt == FMT_U16_BE) 246 if (afmt == FMT_U16_BE)
238 { 247 {
239 gint16 *ptr1 = buffer; 248 gint16 *ptr1 = buffer;
240 guint16 *ptr2 = buffer; 249 guint16 *ptr2 = buffer;
241 250
242 for (i = 0; i < length >> 1; i++, ptr2++) 251 for (i = 0; i < length >> 1; i++, ptr2++)
243 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768); 252 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768);
244 } 253 }
245 if (afmt == FMT_U16_LE) 254 if (afmt == FMT_U16_LE)
246 { 255 {
247 gint16 *ptr1 = buffer; 256 gint16 *ptr1 = buffer;
248 guint16 *ptr2 = buffer; 257 guint16 *ptr2 = buffer;
249 258
250 for (i = 0; i < length >> 1; i++, ptr2++) 259 for (i = 0; i < length >> 1; i++, ptr2++)
251 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768); 260 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768);
252 } 261 }
253 if (afmt == FMT_U16_NE) 262 if (afmt == FMT_U16_NE)
254 { 263 {
255 gint16 *ptr1 = buffer; 264 gint16 *ptr1 = buffer;
256 guint16 *ptr2 = buffer; 265 guint16 *ptr2 = buffer;
257 266
258 for (i = 0; i < length >> 1; i++, ptr2++) 267 for (i = 0; i < length >> 1; i++, ptr2++)
259 *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768); 268 *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768);
260 } 269 }
261 } 270 }
262 271
263 static void disk_write(void *ptr, gint length) 272 static void disk_write(void *ptr, gint length)
264 { 273 {
265 AFormat new_format; 274 AFormat new_format;
266 int new_frequency, new_channels; 275 int new_frequency, new_channels;
267 EffectPlugin *ep; 276 EffectPlugin *ep;
268 277
269 new_format = input.format; 278 new_format = input.format;
270 new_frequency = input.frequency; 279 new_frequency = input.frequency;
271 new_channels = input.channels; 280 new_channels = input.channels;
272 281
273 ep = get_current_effect_plugin(); 282 ep = get_current_effect_plugin();
274 if ( effects_enabled() && ep && ep->query_format ) { 283 if ( effects_enabled() && ep && ep->query_format ) {
275 ep->query_format(&new_format,&new_frequency,&new_channels); 284 ep->query_format(&new_format,&new_frequency,&new_channels);
276 } 285 }
277 286
278 if ( effects_enabled() && ep && ep->mod_samples ) { 287 if ( effects_enabled() && ep && ep->mod_samples ) {
279 length = ep->mod_samples(&ptr,length, 288 length = ep->mod_samples(&ptr,length,
280 input.format, 289 input.format,
281 input.frequency, 290 input.frequency,
282 input.channels ); 291 input.channels );
283 } 292 }
284 293
285 if (afmt == FMT_S8 || afmt == FMT_S16_BE || 294 if (afmt == FMT_S8 || afmt == FMT_S16_BE ||
286 afmt == FMT_U16_LE || afmt == FMT_U16_BE || afmt == FMT_U16_NE) 295 afmt == FMT_U16_LE || afmt == FMT_U16_BE || afmt == FMT_U16_NE)
287 convert_buffer(ptr, length); 296 convert_buffer(ptr, length);
288 #ifdef WORDS_BIGENDIAN 297 #ifdef WORDS_BIGENDIAN
289 if (afmt == FMT_S16_NE) 298 if (afmt == FMT_S16_NE)
290 convert_buffer(ptr, length); 299 convert_buffer(ptr, length);
291 #endif 300 #endif
292 written += vfs_fwrite(ptr, 1, length, output_file); 301 written += vfs_fwrite(ptr, 1, length, output_file);
293 } 302 }
294 303
295 static void disk_close(void) 304 static void disk_close(void)
296 { 305 {
297 if (output_file) 306 if (output_file)
298 { 307 {
299 header.length = GUINT32_TO_LE(written + sizeof (struct wavhead) - 8); 308 header.length = GUINT32_TO_LE(written + sizeof (struct wavhead) - 8);
300 309
301 header.data_length = GUINT32_TO_LE(written); 310 header.data_length = GUINT32_TO_LE(written);
302 vfs_fseek(output_file, 0, SEEK_SET); 311 vfs_fseek(output_file, 0, SEEK_SET);
303 vfs_fwrite(&header, sizeof (struct wavhead), 1, output_file); 312 vfs_fwrite(&header, sizeof (struct wavhead), 1, output_file);
304 313
305 vfs_fclose(output_file); 314 vfs_fclose(output_file);
306 written = 0; 315 written = 0;
307 } 316 }
308 output_file = NULL; 317 output_file = NULL;
309 } 318 }
310 319
311 static void disk_flush(gint time) 320 static void disk_flush(gint time)
312 { 321 {
313 if (time == 0) 322 if (time == 0)
314 { 323 {
315 disk_close(); 324 disk_close();
316 disk_open(afmt, arate, ach); 325 disk_open(afmt, arate, ach);
317 } 326 }
318 } 327 }
319 328
320 static void disk_pause(short p) 329 static void disk_pause(short p)
321 { 330 {
322 } 331 }
323 332
324 static gint disk_free(void) 333 static gint disk_free(void)
325 { 334 {
326 return 1000000; 335 return 1000000;
327 } 336 }
328 337
329 static gint disk_playing(void) 338 static gint disk_playing(void)
330 { 339 {
331 return 0; 340 return 0;
332 } 341 }
333 342
334 static gint disk_get_written_time(void) 343 static gint disk_get_written_time(void)
335 { 344 {
336 if(header.byte_p_sec != 0) 345 if(header.byte_p_sec != 0)
337 return (gint) ((written * 1000) / header.byte_p_sec); 346 return (gint) ((written * 1000) / header.byte_p_sec);
338 return 0; 347 return 0;
339 } 348 }
340 349
341 static gint disk_get_output_time(void) 350 static gint disk_get_output_time(void)
342 { 351 {
343 return disk_get_written_time(); 352 return disk_get_written_time();
344 } 353 }
345 354
346 static void configure_ok_cb(gpointer data) 355 static void configure_ok_cb(gpointer data)
347 { 356 {
348 ConfigDb *db; 357 ConfigDb *db;
349 358
350 if (file_path) 359 if (file_path)
351 g_free(file_path); 360 g_free(file_path);
352 file_path = g_strdup(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(path_dirbrowser))); 361 file_path = g_strdup(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(path_dirbrowser)));
353 362
354 use_suffix = 363 use_suffix =
355 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_suffix_toggle)); 364 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_suffix_toggle));
356 365
357 db = bmp_cfg_db_open(); 366 db = bmp_cfg_db_open();
358 bmp_cfg_db_set_string(db, "disk_writer", "file_path", file_path); 367 bmp_cfg_db_set_string(db, "disk_writer", "file_path", file_path);
359 bmp_cfg_db_set_bool(db, "disk_writer", "use_suffix", use_suffix); 368 bmp_cfg_db_set_bool(db, "disk_writer", "save_original", save_original);
360 bmp_cfg_db_close(db); 369 bmp_cfg_db_set_bool(db, "disk_writer", "use_suffix", use_suffix);
361 370 bmp_cfg_db_close(db);
362 gtk_widget_destroy(configure_win); 371
363 if (path_dirbrowser) 372 gtk_widget_destroy(configure_win);
364 gtk_widget_destroy(path_dirbrowser); 373 if (path_dirbrowser)
374 gtk_widget_destroy(path_dirbrowser);
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 }
365 } 393 }
366 394
367 static void configure_destroy(void) 395 static void configure_destroy(void)
368 { 396 {
369 if (path_dirbrowser) 397 if (path_dirbrowser)
370 gtk_widget_destroy(path_dirbrowser); 398 gtk_widget_destroy(path_dirbrowser);
371 } 399 }
372 400
373 static void disk_configure(void) 401 static void disk_configure(void)
374 { 402 {
375 GtkTooltips *use_suffix_tooltips; 403 GtkTooltips *use_suffix_tooltips;
376 404
377 if (!configure_win) 405 if (!configure_win)
378 { 406 {
379 configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); 407 configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
380 408
381 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", 409 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy",
382 GTK_SIGNAL_FUNC(configure_destroy), NULL); 410 GTK_SIGNAL_FUNC(configure_destroy), NULL);
383 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", 411 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy",
384 GTK_SIGNAL_FUNC(gtk_widget_destroyed), 412 GTK_SIGNAL_FUNC(gtk_widget_destroyed),
385 &configure_win); 413 &configure_win);
386 414
387 gtk_window_set_title(GTK_WINDOW(configure_win), 415 gtk_window_set_title(GTK_WINDOW(configure_win),
388 _("Disk Writer Configuration")); 416 _("Disk Writer Configuration"));
389 gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE); 417 gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE);
390 418
391 gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10); 419 gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10);
392 420
393 configure_vbox = gtk_vbox_new(FALSE, 10); 421 configure_vbox = gtk_vbox_new(FALSE, 10);
394 gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox); 422 gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox);
395 423
396 path_hbox = gtk_hbox_new(FALSE, 5); 424 saveplace_hbox = gtk_hbox_new(FALSE, 5);
397 gtk_box_pack_start(GTK_BOX(configure_vbox), path_hbox, FALSE, FALSE, 0); 425 gtk_container_add(GTK_CONTAINER(configure_vbox), saveplace_hbox);
398 426
399 path_label = gtk_label_new(_("Output file folder:")); 427 saveplace = gtk_radio_button_new_with_label(NULL, _("Save into original directory"));
400 gtk_box_pack_start(GTK_BOX(path_hbox), path_label, FALSE, FALSE, 0); 428 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_original_cb), NULL);
401 429 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0);
402 path_dirbrowser = 430
403 gtk_file_chooser_button_new ("Pick a folder", 431 saveplace = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(saveplace),
404 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); 432 _("Save into custom directory"));
405 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(path_dirbrowser), 433 g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_custom_cb), NULL);
406 file_path); 434 gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0);
407 gtk_box_pack_start(GTK_BOX(path_hbox), path_dirbrowser, TRUE, TRUE, 0); 435
408 436 if (!save_original)
409 use_suffix_toggle = gtk_check_button_new_with_label(_("Don't strip file name extension")); 437 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(saveplace), TRUE);
410 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), use_suffix); 438
411 gtk_box_pack_start(GTK_BOX(configure_vbox), use_suffix_toggle, FALSE, FALSE, 0); 439
412 use_suffix_tooltips = gtk_tooltips_new(); 440
413 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); 441 path_hbox = gtk_hbox_new(FALSE, 5);
414 gtk_tooltips_enable(use_suffix_tooltips); 442 gtk_box_pack_start(GTK_BOX(configure_vbox), path_hbox, FALSE, FALSE, 0);
415 443
416 configure_separator = gtk_hseparator_new(); 444 path_label = gtk_label_new(_("Output file folder:"));
417 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_separator, 445 gtk_box_pack_start(GTK_BOX(path_hbox), path_label, FALSE, FALSE, 0);
418 FALSE, FALSE, 0); 446
419 447 path_dirbrowser =
420 configure_bbox = gtk_hbutton_box_new(); 448 gtk_file_chooser_button_new ("Pick a folder",
421 gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox), 449 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
422 GTK_BUTTONBOX_END); 450 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(path_dirbrowser),
423 gtk_button_box_set_spacing(GTK_BUTTON_BOX(configure_bbox), 5); 451 file_path);
424 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_bbox, 452 gtk_box_pack_start(GTK_BOX(path_hbox), path_dirbrowser, TRUE, TRUE, 0);
425 FALSE, FALSE, 0); 453
426 454 if (save_original)
427 configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK); 455 gtk_widget_set_sensitive(path_hbox, FALSE);
428 gtk_signal_connect(GTK_OBJECT(configure_ok), "clicked", 456
429 GTK_SIGNAL_FUNC(configure_ok_cb), NULL); 457
430 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok, 458
431 TRUE, TRUE, 0); 459 use_suffix_toggle = gtk_check_button_new_with_label(_("Don't strip file name extension"));
432 460 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), use_suffix);
433 configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); 461 gtk_box_pack_start(GTK_BOX(configure_vbox), use_suffix_toggle, FALSE, FALSE, 0);
434 gtk_signal_connect_object(GTK_OBJECT(configure_cancel), "clicked", 462 use_suffix_tooltips = gtk_tooltips_new();
435 GTK_SIGNAL_FUNC(gtk_widget_destroy), 463 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);
436 GTK_OBJECT(configure_win)); 464 gtk_tooltips_enable(use_suffix_tooltips);
437 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel, 465
438 TRUE, TRUE, 0); 466 configure_separator = gtk_hseparator_new();
439 467 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_separator,
440 gtk_widget_show_all(configure_win); 468 FALSE, FALSE, 0);
441 } 469
470 configure_bbox = gtk_hbutton_box_new();
471 gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox),
472 GTK_BUTTONBOX_END);
473 gtk_button_box_set_spacing(GTK_BUTTON_BOX(configure_bbox), 5);
474 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_bbox,
475 FALSE, FALSE, 0);
476
477 configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK);
478 gtk_signal_connect(GTK_OBJECT(configure_ok), "clicked",
479 GTK_SIGNAL_FUNC(configure_ok_cb), NULL);
480 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok,
481 TRUE, TRUE, 0);
482
483 configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
484 gtk_signal_connect_object(GTK_OBJECT(configure_cancel), "clicked",
485 GTK_SIGNAL_FUNC(gtk_widget_destroy),
486 GTK_OBJECT(configure_win));
487 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel,
488 TRUE, TRUE, 0);
489
490 gtk_widget_show_all(configure_win);
491 }
442 } 492 }
443 493
444 static void disk_getvol(gint *l, gint *r) 494 static void disk_getvol(gint *l, gint *r)
445 { 495 {
446 (*l) = lvol; 496 (*l) = lvol;
447 (*r) = rvol; 497 (*r) = rvol;
448 } 498 }
449 499
450 static void disk_setvol(gint l, gint r) 500 static void disk_setvol(gint l, gint r)
451 { 501 {
452 lvol = l; 502 lvol = l;
453 rvol = r; 503 rvol = r;
454 } 504 }