Copyright fixes and mpg321 support - Alex
[terminatorX.git] / src / tX_vttgui.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999-2002  Alexander K├Ânig
4  
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9  
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14  
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  
19     File: tX_vttgui.cc
20  
21     Description: This implements the gtk+ GUI for the virtual turntable
22                  class implemented in tX_vtt.cc. This code is not in tX_vtt.cc
23                  for mainly to keep the GUI code divided from the audio-rendering
24                  code and as gtk+ callback to C++ method call wrapper.
25                  
26     Changes:
27     
28     before 11-26-2001: too many changes.
29     
30     11-26-2001: applied Adrian's solo/mute patch - Alex
31     
32     11-27-2001: modified solo/mute to use the set_mix_mute/solo function
33                 of the vtts. The previous approach messed up the sequencer
34                 and more. Removed some old unnecessary code, too.
35 */    
36
37 #include <gdk/gdk.h>
38 #include <gtk/gtk.h>
39 #include "tX_vttgui.h"
40 #include "tX_vtt.h"
41 #include "tX_widget.h"
42 #include "tX_mastergui.h"
43 #include "tX_loaddlg.h"
44 #include "tX_prelis.h"
45 #include "tX_pbutton.h"
46 #include "tX_global.h"
47 #include "tX_extdial.h"
48 #include "tX_panel.h"
49 #include "tX_ladspa.h"
50
51 #ifdef USE_DIAL
52 #include "tX_dial.h"
53 #endif
54
55 #ifdef USE_FLASH
56 #include "tX_flash.h"
57 #endif
58 #include <stdio.h>
59
60 #define WID_DYN TRUE, TRUE, 0
61 #define WID_FIX FALSE, FALSE, 0
62
63 #define FILENAME_BUTTON_MAX 20
64
65 void nicer_filename(char *dest, char *source)
66 {
67                 char *fn;
68                 char temp[PATH_MAX];
69                 int i;
70                 
71                 fn=strrchr(source, '/');
72                 if (fn) fn++;
73                 else fn=source;
74                 
75                 strcpy (temp, fn);
76                 
77                 fn=strrchr(temp, '.');
78                 if (fn) *fn=0;
79                 
80                 if (strlen(temp) > FILENAME_BUTTON_MAX)
81                 {
82                         temp[FILENAME_BUTTON_MAX-3]='.';
83                         temp[FILENAME_BUTTON_MAX-2]='.';
84                         temp[FILENAME_BUTTON_MAX-1]='.';
85                         temp[FILENAME_BUTTON_MAX]=0;
86                 } 
87                 strcpy (dest, temp);
88 }
89
90 void name_changed(GtkWidget *wid, vtt_class *vtt)
91 {
92         vtt->set_name(gtk_entry_get_text(GTK_ENTRY(wid)));
93 }
94
95 void volume_changed(GtkWidget *wid, vtt_class *vtt)
96 {
97         vtt->sp_volume.receive_gui_value(2.0-GTK_ADJUSTMENT(wid)->value);
98 }
99
100 void pan_changed(GtkWidget *wid, vtt_class *vtt)
101 {
102       vtt->sp_pan.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
103 }
104
105 void pitch_changed(GtkWidget *wid, vtt_class *vtt)
106 {
107         vtt->sp_pitch.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
108 }
109
110 GtkSignalFunc trigger_prelis(GtkWidget *w)
111 {
112         GtkFileSelection *fs;
113         
114         fs=GTK_FILE_SELECTION(gtk_widget_get_toplevel(w));
115         
116         prelis_start(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)));
117         return(0);
118 }
119
120 void cancel_load_file(GtkWidget *wid, vtt_class *vtt)
121 {
122         prelis_stop();
123         
124         vtt->gui.file_dialog=NULL;
125         if (vtt->gui.fs) gtk_widget_destroy(GTK_WIDGET(vtt->gui.fs));
126 }
127
128 int quit_load_file(GtkWidget *wid, vtt_class *vtt)
129 {
130         //vtt->gui.file_dialog=NULL;
131         //prelis_stop();
132         return 1;
133 }
134
135 char global_filename_buffer[PATH_MAX];
136
137 void load_part(char *newfile, vtt_class *vtt)
138 {
139         int ret=0;
140         char *fn;
141
142         ld_create_loaddlg(TX_LOADDLG_MODE_SINGLE, 1);
143         ld_set_filename(newfile);
144
145         ret = vtt->load_file(newfile);
146         
147         ld_destroy();
148         if (ret)
149         {
150                 switch(ret)
151                 {
152                         case TX_AUDIO_ERR_ALLOC:
153                         tx_note("Error loading file: failed to allocate memory");
154                         break;
155                         case TX_AUDIO_ERR_PIPE_READ:
156                         tx_note("Error loading file: broken pipe (File not supported/corrupt?)");
157                         break;
158                         case TX_AUDIO_ERR_SOX:
159                         tx_note("Error loading file: couldn't execute sox");
160                         break;
161                         case TX_AUDIO_ERR_MPG123:
162                         tx_note("Error loading file: couldn't execute mpg123");
163                         break;
164                         case TX_AUDIO_ERR_WAV_NOTFOUND:
165                         tx_note("Error loading file: file not found");
166                         break;
167                         case TX_AUDIO_ERR_NOT_16BIT:
168                         tx_note("Error loading file: RIFF/WAV is not 16 Bit.");
169                         break;
170                         case TX_AUDIO_ERR_NOT_MONO:
171                         tx_note("Error loading file: RIFF/WAV is not mono");
172                         break;
173                         case TX_AUDIO_ERR_WAV_READ:
174                         tx_note("Error loading file: RIFF/WAV corrupt?");
175                         break;
176                         case TX_AUDIO_ERR_NOT_SUPPORTED:
177                         tx_note("Error loading file: filetype not supported.");
178                         break;
179                         default:                                        
180                         tx_note("OOPS: An unknown error occured - This shouldn't happen :(");   
181                 }
182         }
183         else
184         {
185                 nicer_filename(global_filename_buffer, newfile);
186                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), global_filename_buffer);
187         }       
188 }
189
190 void do_load_file(GtkWidget *wid, vtt_class *vtt)
191 {
192         int ret;
193         char newfile[PATH_MAX];
194         char buffer[1024]="Couldn't open loop file: ";
195         char fn[FILENAME_BUTTON_MAX];
196         
197         int16_t *newbuffer;
198         unsigned int newsize;
199         
200         prelis_stop();
201
202         strcpy(newfile, gtk_file_selection_get_filename(GTK_FILE_SELECTION(vtt->gui.fs)));
203         gtk_widget_destroy(GTK_WIDGET(vtt->gui.fs));
204         
205         load_part(newfile, vtt);
206         
207         if (!globals.current_path)
208         {
209                 free(globals.current_path);
210                 globals.current_path = NULL;
211         }
212
213         globals.current_path = strdup(newfile);
214
215         vtt->gui.file_dialog=NULL;
216 }
217
218 void drop_file(GtkWidget *widget, GdkDragContext *context,
219                 gint x, gint y, GtkSelectionData *selection_data,
220                 guint info, guint time, vtt_class *vtt)
221 {
222         char filename[PATH_MAX];
223         char *fn;
224         int s;
225         void *prr;
226         
227         strncpy(filename, (char *) selection_data->data, (size_t) selection_data->length);
228         filename[selection_data->length]=0;
229
230         fn = strchr (filename, '\r');
231         *fn=0;  
232         
233         fn = strchr (filename, ':');
234         if (fn) fn++; else fn=(char *) selection_data->data;
235         
236         load_part(fn, vtt);
237 }
238
239
240 GtkSignalFunc load_file(GtkWidget *wid, vtt_class *vtt)
241 {       
242         char buffer[512];
243         
244         if (vtt->gui.file_dialog)
245         {
246                 gdk_window_raise(vtt->gui.file_dialog);
247                 return(0);
248         }
249         
250         sprintf(buffer, "Select Audio File for %s", vtt->name);
251         vtt->gui.fs=gtk_file_selection_new(buffer);
252         
253         if (strlen(vtt->filename) > 0)
254         {
255                 gtk_file_selection_set_filename(GTK_FILE_SELECTION(vtt->gui.fs), vtt->filename);        
256         }
257         
258         gtk_widget_show(GTK_WIDGET(vtt->gui.fs));
259         
260         vtt->gui.file_dialog=vtt->gui.fs->window;
261         
262         if (globals.current_path)
263                 {
264                         gtk_file_selection_set_filename(GTK_FILE_SELECTION(vtt->gui.fs),globals.current_path);
265                 }
266         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_load_file), vtt);
267         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->cancel_button), "clicked", GTK_SIGNAL_FUNC (cancel_load_file), vtt);    
268         gtk_signal_connect (GTK_OBJECT(vtt->gui.fs), "delete-event", GTK_SIGNAL_FUNC(quit_load_file), vtt);     
269         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->file_list), "select_row", GTK_SIGNAL_FUNC(trigger_prelis), vtt->gui.fs);
270 }
271
272 void delete_vtt(GtkWidget *wid, vtt_class *vtt)
273 {
274         if (audioon) tx_note("Sorry, you'll have to stop playback first.");
275         else
276         delete(vtt);
277 }
278
279 void edit_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
280 {
281         char command[2*PATH_MAX];
282
283         if (vtt->samples_in_buffer == 0)
284         {
285                 tx_note("Nothing to edit.");
286         }
287         else
288         if (strlen(globals.file_editor)>0)
289         {
290                 sprintf(command, "%s \"%s\" &", globals.file_editor, vtt->filename);
291                 system(command); /*) tx_note("Failed to run the soundfile editor."); */
292         }
293         else
294         {
295                 tx_note("No soundfile editor configured.");
296         }
297 }
298
299 void reload_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
300 {
301         char reload_buffer[PATH_MAX];
302         
303         while (gtk_events_pending()) gtk_main_iteration();
304         
305         if (vtt->samples_in_buffer > 0)
306         {
307                 strcpy(reload_buffer, vtt->filename);
308                 load_part(reload_buffer, vtt);
309         }
310         else tx_note("Nothing to reload.");
311 }
312
313 void clone_vtt(GtkWidget *wid, vtt_class *vtt)
314 {
315         vtt->stop();
316 }
317
318 void trigger_vtt(GtkWidget *wid, vtt_class *vtt)
319 {
320         vtt->sp_trigger.receive_gui_value((float) 1.0);
321 }
322
323 void stop_vtt(GtkWidget *wid, vtt_class *vtt)
324 {
325         vtt->sp_trigger.receive_gui_value((float) 0.0);
326 }
327
328 void autotrigger_toggled(GtkWidget *wid, vtt_class *vtt)
329 {
330         vtt->set_autotrigger(GTK_TOGGLE_BUTTON(wid)->active);
331 }
332
333 void loop_toggled(GtkWidget *wid, vtt_class *vtt)
334 {
335         vtt->sp_loop.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
336 }
337
338 void lp_enabled(GtkWidget *wid, vtt_class *vtt)
339 {
340         vtt->sp_lp_enable.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
341 }
342
343 void lp_gain_changed(GtkWidget *wid, vtt_class *vtt)
344 {
345         vtt->sp_lp_gain.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
346 }
347
348 void lp_reso_changed(GtkWidget *wid, vtt_class *vtt)
349 {
350         vtt->sp_lp_reso.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
351 }
352
353 void lp_freq_changed(GtkWidget *wid, vtt_class *vtt)
354 {
355         vtt->sp_lp_freq.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
356 }
357
358 void ec_enabled(GtkWidget *wid, vtt_class *vtt)
359 {
360         vtt->sp_ec_enable.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
361 }
362
363 void ec_length_changed(GtkWidget *wid, vtt_class *vtt)
364 {
365         vtt->sp_ec_length.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
366 }
367
368 void ec_feedback_changed(GtkWidget *wid, vtt_class *vtt)
369 {
370         vtt->sp_ec_feedback.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
371 }
372
373 void ec_pan_changed(GtkWidget *wid, vtt_class *vtt)
374 {
375         vtt->sp_ec_pan.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
376 }
377
378 void ec_volume_changed(GtkWidget *wid, vtt_class *vtt)
379 {
380         vtt->sp_ec_volume.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
381 }
382
383 void master_setup(GtkWidget *wid, vtt_class *vtt)
384 {
385         vtt->set_sync_master(GTK_TOGGLE_BUTTON(wid)->active);
386 }
387
388 void client_setup(GtkWidget *wid, vtt_class *vtt)
389 {
390         int client;
391         
392         client=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client));   
393         vtt->sp_sync_client.receive_gui_value(client);
394 }
395
396 void client_setup_number(GtkWidget *wid, vtt_class *vtt)
397 {
398         int cycles;
399         
400         cycles=(int) GTK_ADJUSTMENT(vtt->gui.cycles)->value;    
401         
402         vtt->sp_sync_cycles.receive_gui_value(cycles);
403 }
404
405 void mute_volume(GtkWidget *widget, vtt_class *vtt)
406 {
407         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
408         {
409                 vtt->set_mix_mute(1);
410         }
411         else
412         {
413                 vtt->set_mix_mute(0);
414         }
415 }
416
417 void solo_vtt(GtkWidget *widget, vtt_class *vtt)
418 {
419         list <vtt_class *> :: iterator it_vtt;
420
421         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) 
422         {
423                 vtt->set_mix_solo(1);
424         }
425         else
426         {
427                 vtt->set_mix_solo(0);
428         }
429 }      
430
431 void vg_display_xcontrol(vtt_class *vtt)
432 {
433         char buffer[2048];
434         
435         if (vtt->x_par)
436         {
437                 strcpy(buffer, vtt->x_par->get_name());
438                 if (strlen(buffer)>35) 
439                 {
440                         buffer[34] = '.';
441                         buffer[35] = '.';
442                         buffer[36] = '.';
443                         buffer[37] = 0;                 
444                 }
445                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.x_control)->child), buffer);                
446         }
447         else
448         {
449                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.x_control)->child), "Nothing");
450         }
451 }
452
453 void vg_display_ycontrol(vtt_class *vtt)
454 {
455         char buffer[2048];
456         
457         if (vtt->y_par)
458         {
459                 strcpy(buffer, vtt->y_par->get_name());
460                 if (strlen(buffer)>26) 
461                 {
462                         buffer[24] = '.';
463                         buffer[25] = '.';
464                         buffer[26] = '.';
465                         buffer[27] = 0;                 
466                 }
467                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.y_control)->child), buffer);                
468         }
469         else
470         {
471                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.y_control)->child), "Nothing");
472         }
473 }
474
475 void vg_xcontrol_dis(GtkWidget *wid, vtt_class *vtt)
476 {
477         vtt->set_x_input_parameter(NULL);
478 }
479
480 void vg_ycontrol_dis(GtkWidget *wid, vtt_class *vtt)
481 {
482         vtt->set_y_input_parameter(NULL);
483 }
484
485 void vg_xcontrol_set(GtkWidget *wid, tX_seqpar *sp)
486 {
487         vtt_class *vtt=(vtt_class *) sp->vtt;
488         vtt->set_x_input_parameter(sp);
489 }
490
491 void vg_ycontrol_set(GtkWidget *wid, tX_seqpar *sp)
492 {
493         vtt_class *vtt=(vtt_class *) sp->vtt;
494         vtt->set_y_input_parameter(sp);
495 }
496
497 void vg_control_menu_popup(vtt_class *vtt, int axis)
498 {
499         list <tX_seqpar *> :: iterator sp;
500         vtt_gui *g=&vtt->gui;
501         GtkWidget *item;
502
503         if (g->par_menu) gtk_object_destroy(GTK_OBJECT(g->par_menu));
504         g->par_menu=gtk_menu_new();
505         
506         item = gtk_menu_item_new_with_label("Nothing");
507         gtk_menu_append(GTK_MENU(g->par_menu), item);
508         gtk_widget_show(item);
509         if (axis) gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_xcontrol_dis), vtt);
510         else gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_ycontrol_dis), vtt);
511         
512         
513         for (sp=tX_seqpar::all.begin(); sp!=tX_seqpar::all.end(); sp++)
514         {
515                 if (((*sp)->is_mappable) && ((*sp)->vtt) == (void*) vtt)
516                 {
517                         item = gtk_menu_item_new_with_label((*sp)->get_name());
518                         gtk_menu_append(GTK_MENU(g->par_menu), item);
519                         gtk_widget_show(item);
520                         if (axis) gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_xcontrol_set), (void*) (*sp));
521                         else gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_ycontrol_set), (void*) (*sp));
522                 }
523         }
524         gtk_menu_popup (GTK_MENU(g->par_menu), NULL, NULL, NULL, NULL, 0, 0);
525 }
526
527 void vg_xcontrol_popup(GtkWidget *wid, vtt_class *vtt) 
528 {
529         vg_control_menu_popup(vtt, 1);
530 }
531
532 void vg_ycontrol_popup(GtkWidget *wid, vtt_class *vtt)
533 {
534         vg_control_menu_popup(vtt, 0);
535 }
536
537 static vtt_class * fx_vtt;
538
539 void new_effect(GtkWidget *wid, LADSPA_Plugin *plugin)
540 {
541         fx_vtt->add_effect(plugin);
542 }
543
544 void fx_button_pressed(GtkWidget *wid, vtt_class *vtt)
545 {
546         vtt_gui *g=&vtt->gui;
547         GtkWidget *item;
548         int i;
549         LADSPA_Plugin *plugin;
550         char buffer[1024];
551         char oldfile[1024]="";
552         GtkWidget *submenu;
553
554         fx_vtt=vtt; /* AAAAARGH - Long live ugly code */
555
556         if (g->ladspa_menu) gtk_object_destroy(GTK_OBJECT(g->ladspa_menu));
557         g->ladspa_menu=gtk_menu_new();
558         
559         for (i=0; i<LADSPA_Plugin::getPluginCount(); i++)
560         {
561                 plugin=LADSPA_Plugin::getPluginByIndex(i);
562                 if (strcmp(plugin->get_file_name(), oldfile))
563                 {
564                         strcpy(oldfile, plugin->get_file_name());
565                         item = gtk_menu_item_new_with_label(oldfile);
566                         submenu=gtk_menu_new();
567                         gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
568                         gtk_menu_append(GTK_MENU(g->ladspa_menu), item);
569                         gtk_widget_show(item);
570                 }
571                 sprintf(buffer, "%s - [%i, %s]", plugin->getName(), plugin->getUniqueID(), plugin->getLabel());
572                 item=gtk_menu_item_new_with_label(buffer);
573                 gtk_menu_append(GTK_MENU(submenu), item);
574                 gtk_widget_show(item);
575                 gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(new_effect), plugin);
576         }
577         
578         gtk_menu_popup (GTK_MENU(g->ladspa_menu), NULL, NULL, NULL, NULL, 0, 0);
579 }
580
581 #define connect_entry(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "activate", (GtkSignalFunc) func, (void *) vtt);
582 #define connect_adj(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "value_changed", (GtkSignalFunc) func, (void *) vtt);
583 #define connect_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "clicked", (GtkSignalFunc) func, (void *) vtt);
584 #define connect_press_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "pressed", (GtkSignalFunc) func, (void *) vtt);
585 #define connect_rel_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "released", (GtkSignalFunc) func, (void *) vtt);
586
587 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel);
588
589 void gui_connect_signals(vtt_class *vtt)
590 {
591         vtt_gui *g=&vtt->gui;
592
593         connect_entry(name, name_changed);
594         connect_adj(volume, volume_changed);
595         connect_button(edit, edit_vtt_buffer);
596         connect_button(reload, reload_vtt_buffer);
597         connect_adj(pitch, pitch_changed);
598         connect_adj(pan, pan_changed);
599         connect_button(file, load_file);
600         
601         connect_button(del, delete_vtt);
602         connect_button(trigger, trigger_vtt);
603         connect_button(stop, stop_vtt);
604         connect_button(autotrigger, autotrigger_toggled);
605         connect_button(loop, loop_toggled);
606         connect_button(sync_master, master_setup);
607         connect_button(sync_client, client_setup);
608         connect_adj(cycles, client_setup_number);
609         connect_button(fx_button, fx_button_pressed);
610         
611         connect_button(lp_enable, lp_enabled);
612         connect_adj(lp_gain, lp_gain_changed);
613         connect_adj(lp_reso, lp_reso_changed);
614         connect_adj(lp_freq, lp_freq_changed);
615         
616         connect_button(ec_enable, ec_enabled);
617         connect_adj(ec_length, ec_length_changed);
618         connect_adj(ec_feedback, ec_feedback_changed);
619         connect_adj(ec_pan, ec_pan_changed);
620         connect_adj(ec_volume, ec_volume_changed);      
621         connect_button(x_control, vg_xcontrol_popup);
622         connect_button(y_control, vg_ycontrol_popup);
623
624         static GtkTargetEntry drop_types [] = {
625                 { "text/uri-list", 0, 0}
626         };
627         static gint n_drop_types = sizeof (drop_types) / sizeof(drop_types[0]);
628         
629         gtk_drag_dest_set (GTK_WIDGET (g->file), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
630                         drop_types, n_drop_types,
631                         GDK_ACTION_COPY);
632                                                 
633         gtk_signal_connect (GTK_OBJECT (g->file), "drag_data_received",
634                         GTK_SIGNAL_FUNC(drop_file), (void *) vtt);
635
636         gtk_drag_dest_set (GTK_WIDGET (g->display), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
637                         drop_types, n_drop_types,
638                         GDK_ACTION_COPY);
639                                                 
640         gtk_signal_connect (GTK_OBJECT (g->display), "drag_data_received",
641                         GTK_SIGNAL_FUNC(drop_file), (void *) vtt);
642         
643 }
644         
645 void build_vtt_gui(vtt_class *vtt)
646 {
647         GtkWidget *tempbox;
648         GtkWidget *tempbox2;
649         GtkWidget *tempbox3;
650         GtkWidget *dummy;
651         char nice_name[FILENAME_BUTTON_MAX];
652         
653         vtt_gui *g;
654         
655         g=&vtt->gui;
656         vtt->have_gui=1;
657         g->par_menu=NULL;
658         g->ladspa_menu=NULL;
659
660         /* Building Audio Box */
661         g->audio_box=gtk_vbox_new(FALSE,2);
662         gtk_widget_show(g->audio_box);
663         
664         tempbox=gtk_hbox_new(FALSE,2);
665         gtk_widget_show(tempbox);
666         gtk_box_pack_start(GTK_BOX(g->audio_box), tempbox, WID_FIX);
667         
668         g->audio_label=gtk_label_new(vtt->name);
669         gtk_widget_show(g->audio_label);
670         gtk_box_pack_start(GTK_BOX(tempbox), g->audio_label, WID_DYN);
671
672         dummy=gtk_vseparator_new();
673         gtk_widget_show(dummy);
674         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
675
676         nicer_filename(nice_name, vtt->filename);
677         g->file = gtk_button_new_with_label(nice_name);
678         gtk_widget_show(g->file);
679         gui_set_tooltip(g->file, "Click here to load an audiofile into this turntable. As an alternative you may drop an audiofile over this button or the audio-data display.");
680         gtk_box_pack_start(GTK_BOX(tempbox), g->file, WID_DYN);
681
682         g->edit=tx_xpm_button_new(TX_ICON_EDIT, "Edit", 0);
683         gtk_widget_show(g->edit);
684         gui_set_tooltip(g->edit, "Click this button to run the soundfile editor for the audiofile loaded into this turntable. You can configure which soundfile editor to use in the Options dialog.");
685         gtk_box_pack_start(GTK_BOX(tempbox), g->edit, WID_FIX);
686         
687         g->reload=tx_xpm_button_new(TX_ICON_RELOAD, "Reload", 0);
688         gtk_widget_show(g->reload);
689         gui_set_tooltip(g->reload, "Click here to reload the audiofile loaded into this turntable.");
690         gtk_box_pack_start(GTK_BOX(tempbox), g->reload, WID_FIX);
691         
692         dummy=gtk_vseparator_new();
693         gtk_widget_show(dummy);
694         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
695
696         dummy=gtk_label_new("X:");
697         gtk_widget_show(dummy);
698         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
699
700         g->x_control=gtk_button_new_with_label(vtt->x_par->get_name());
701         gtk_widget_show(g->x_control);
702         gui_set_tooltip(g->x_control, "Select which parameter should be controlled for this turntable (in grab mode) by mouse motion (x-axis: left <-> right).");
703         gtk_box_pack_start(GTK_BOX(tempbox), g->x_control, WID_DYN);
704
705         dummy=gtk_label_new("Y:");
706         gtk_widget_show(dummy);
707         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
708         
709         g->y_control=gtk_button_new_with_label(vtt->y_par->get_name());
710         gtk_widget_show(g->y_control);
711         gui_set_tooltip(g->y_control, "Select which parameter should be controlled for this turntable (in grab mode) by mouse motion (x-axis: up <-> down).");
712
713         gtk_box_pack_start(GTK_BOX(tempbox), g->y_control, WID_DYN);
714
715         g->display=gtk_tx_new(vtt->buffer, vtt->samples_in_buffer);
716         gtk_box_pack_start(GTK_BOX(g->audio_box), g->display, WID_DYN);
717         gtk_widget_show(g->display);    
718         
719         /* Building Control Box */
720         
721         g->control_box=gtk_vbox_new(FALSE,2);
722         gtk_widget_show(g->control_box);
723         
724         g->control_label=gtk_label_new(vtt->name);
725         gtk_widget_show(g->control_label);
726         gtk_box_pack_start(GTK_BOX(g->control_box), g->control_label, WID_FIX);
727         
728         g->scrolled_win=gtk_scrolled_window_new (NULL, NULL);
729         gtk_container_set_border_width (GTK_CONTAINER (g->scrolled_win), 0);
730         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (g->scrolled_win),
731                                     GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
732         gtk_widget_show(g->scrolled_win);
733         gtk_box_pack_start(GTK_BOX(g->control_box), g->scrolled_win, WID_DYN);
734                                     
735         g->control_subbox=gtk_vbox_new(FALSE,0);
736         gtk_scrolled_window_add_with_viewport (
737                    GTK_SCROLLED_WINDOW (g->scrolled_win), g->control_subbox);
738         gtk_widget_show(g->control_subbox);
739                    
740
741         /* Main panel */
742         
743         tX_panel *p=new tX_panel("Main", g->control_subbox);
744         g->main_panel=p;
745                         
746         g->name = gtk_entry_new_with_max_length(256);   
747         gtk_entry_set_text(GTK_ENTRY(g->name), vtt->name);
748         p->add_client_widget(g->name);
749         gui_set_tooltip(g->name, "Enter the turntable's name here.");
750         gtk_widget_set_usize(g->name, 40, g->name->requisition.height);
751         
752         g->del=gtk_button_new_with_label("Delete");
753         gui_set_tooltip(g->del, "Click here to annihilate this turntable. All events recorded for this turntable will be erased, too.");
754         p->add_client_widget(g->del);
755         
756 //      g->show_audio=gtk_toggle_button_new_with_label("Show Audio");
757 //      p->add_client_widget(g->show_audio);
758                 
759         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
760                                 
761         p=new tX_panel("Trigger", g->control_subbox);
762         g->trigger_panel=p;
763         
764         g->trigger=gtk_button_new_with_label("Trigger!");
765         gui_set_tooltip(g->trigger, "Click here to trigger this turntable right now. If the audio engine is disabled this turntable will be triggerd as soon as the engine is turned on.");
766         p->add_client_widget(g->trigger);
767         
768         g->stop=gtk_button_new_with_label("Stop.");
769         gui_set_tooltip(g->stop, "Stop this turntable's playback.");
770         p->add_client_widget(g->stop);
771         
772         g->autotrigger=gtk_check_button_new_with_label("Auto");
773         p->add_client_widget(g->autotrigger);
774         gui_set_tooltip(g->autotrigger, "If turned on, this turntable will be automagically triggered whenever the audio engine is turned on.");
775         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->autotrigger), vtt->autotrigger);
776         
777         g->loop=gtk_check_button_new_with_label("Loop");
778         p->add_client_widget(g->loop);
779         gui_set_tooltip(g->loop, "Enable this option to make the turntable loop the audio data.");
780         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->loop), vtt->loop);
781         
782         g->sync_master=gtk_check_button_new_with_label("Master");
783         p->add_client_widget(g->sync_master);
784         gui_set_tooltip(g->sync_master, "Click here to make this turntable the sync-master. All turntables marked as sync-clients will be (re-)triggered in relation to the sync-master. Note that only *one* turntable can be the sync-master.");
785         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_master), vtt->is_sync_master);
786         
787         g->sync_client=gtk_check_button_new_with_label("Client");
788         p->add_client_widget(g->sync_client);
789         gui_set_tooltip(g->sync_client, "If enabled this turntable will be (re-)triggerd in relation to the sync-master turntable.");
790         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_client), vtt->is_sync_client);
791         
792         g->cycles=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->sync_cycles, 0, 10.0, 1,1,1));
793         dummy=gtk_spin_button_new(g->cycles, 1.0, 0);
794         p->add_client_widget(dummy);
795         gui_set_tooltip(dummy, "Determines how often a sync-client turntable gets triggered. 0 -> this turntable will be triggered with every trigger of the sync-master table, 1 -> the table will be triggered every 2nd master trigger and so on.");
796
797         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
798
799         dummy=gtk_button_new_with_label("FX");
800         gtk_widget_show(dummy);
801         g->fx_button=dummy;
802         gui_set_tooltip(g->fx_button, "Click here to load a LADSPA plugin. You will get a menu from which you can choose which plugin to load.");
803         gtk_box_pack_start(GTK_BOX(g->control_subbox), dummy, WID_FIX);
804         
805         /* Lowpass Panel */
806
807         p=new tX_panel("Lowpass", g->control_subbox);
808         g->lp_panel=p;
809                 
810         g->lp_enable=gtk_check_button_new_with_label("Enable");
811         gui_set_tooltip(g->lp_enable, "Click here to enable the built-in lowpass effect.");
812         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->lp_enable), vtt->lp_enable);
813         p->add_client_widget(vg_create_fx_bar(vtt, vtt->lp_fx, 0));
814
815         p->add_client_widget(g->lp_enable);
816
817         g->lp_gain=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_gain, 0, 2, 0.1, 0.01, 0.01));
818         g->lp_reso=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_reso, 0, 0.99, 0.1, 0.01, 0.01));
819         g->lp_freq=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_freq, 0, 1, 0.1, 0.01, 0.01));
820
821         g->lp_gaind=new tX_extdial("Input Gain", g->lp_gain);
822         p->add_client_widget(g->lp_gaind->get_widget());
823         gui_set_tooltip(g->lp_gaind->get_entry(), "Adjust the input gain. with this parameter you can either amplify or damp the input-signal for the lowpass effect.");
824
825         g->lp_freqd=new tX_extdial("Frequency", g->lp_freq);
826         p->add_client_widget(g->lp_freqd->get_widget());
827         gui_set_tooltip(g->lp_freqd->get_entry(), "Adjust the cutoff frequency of the lowpass filter. 0 is 0 Hz, 1 is 22.1 kHz.");
828
829         g->lp_resod=new tX_extdial("Resonance", g->lp_reso);
830         p->add_client_widget(g->lp_resod->get_widget());
831         gui_set_tooltip(g->lp_resod->get_entry(), "Adjust the resonance of the lowpass filter. This value determines how much the signal at the cutoff frequency will be amplified.");
832
833         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
834
835         /* Echo Panel */
836
837         p=new tX_panel("Echo", g->control_subbox);
838         g->ec_panel=p;
839
840         p->add_client_widget(vg_create_fx_bar(vtt, vtt->ec_fx, 0));
841         
842         g->ec_enable=gtk_check_button_new_with_label("Enable");
843         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->ec_enable), vtt->ec_enable);
844         p->add_client_widget(g->ec_enable);
845         gui_set_tooltip(g->ec_enable, "Enable the built-in echo effect.");
846
847         g->ec_length=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_length, 0, 1, 0.1, 0.01, 0.001));
848         g->ec_feedback=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_feedback, 0, 1, 0.1, 0.01, 0.001));
849         g->ec_pan=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_pan, -1.0, 1, 0.1, 0.01, 0.001));
850         g->ec_volume=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_volume, 0.0, 3.0, 0.1, 0.01, 0.001));
851
852         g->ec_lengthd=new tX_extdial("Duration", g->ec_length);
853         p->add_client_widget(g->ec_lengthd->get_widget());
854         gui_set_tooltip(g->ec_lengthd->get_entry(), "Adjust the length of the echo buffer.");
855
856         g->ec_feedbackd=new tX_extdial("Feedback", g->ec_feedback);
857         p->add_client_widget(g->ec_feedbackd->get_widget());
858         gui_set_tooltip(g->ec_feedbackd->get_entry(), "Adjust the feedback of the echo effect. Note that a value of 1 will result in a constant signal.");
859
860         g->ec_volumed=new tX_extdial("Volume", g->ec_volume);
861         p->add_client_widget(g->ec_volumed->get_widget());
862         gui_set_tooltip(g->ec_volumed->get_entry(), "Adjust the volume of the echo effect.");
863
864         g->ec_pand=new tX_extdial("Pan", g->ec_pan);
865         p->add_client_widget(g->ec_pand->get_widget());
866         gui_set_tooltip(g->ec_pand->get_entry(), "Adjust the panning of the echo effect.");
867
868         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
869         
870         /* Output */
871         
872         tempbox=gtk_hbox_new(FALSE,2);
873         gtk_widget_show(tempbox);
874         gtk_box_pack_end(GTK_BOX(g->control_box), tempbox, WID_FIX);
875         
876         tempbox2=gtk_vbox_new(FALSE,0);
877         gtk_widget_show(tempbox2);
878         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
879         
880         g->pitch=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->rel_pitch, -3, +3, 0.1, 0.01, 0.001));
881         g->pan=GTK_ADJUSTMENT(gtk_adjustment_new(0, -1, 1, 0.1, 0.01, 0.001));
882
883         g->pitchd=new tX_extdial("Pitch", g->pitch);
884         gui_set_tooltip(g->pitchd->get_entry(), "Adjust this turntable's pitch.");
885
886         gtk_box_pack_start(GTK_BOX(tempbox2), g->pitchd->get_widget(), WID_FIX);
887
888         g->pand=new tX_extdial("Pan", g->pan);
889         gtk_box_pack_start(GTK_BOX(tempbox2), g->pand->get_widget(), WID_FIX);
890         gui_set_tooltip(g->pand->get_entry(), "Specifies the position of this turntable within the stereo spectrum: -1 -> left, 0-> center, 1->right.");
891
892         tempbox3=gtk_hbox_new(FALSE,2);
893         gtk_widget_show(tempbox3);
894
895         g->mute=gtk_check_button_new_with_label("M");
896         gtk_box_pack_start(GTK_BOX(tempbox3), g->mute, WID_FIX);
897         gtk_signal_connect(GTK_OBJECT(g->mute),"clicked", (GtkSignalFunc) mute_volume, vtt);
898         gtk_widget_show(g->mute);
899         gui_set_tooltip(g->mute, "Mute this turntable's mixer output.");
900
901         g->solo=gtk_check_button_new_with_label("S");
902         gtk_box_pack_start(GTK_BOX(tempbox3), g->solo, WID_FIX);
903         gtk_signal_connect(GTK_OBJECT(g->solo),"clicked", (GtkSignalFunc) solo_vtt, vtt);
904         gtk_widget_show(g->solo);
905         gui_set_tooltip(g->mute, "Allow only this and other solo-switched turntabels' signal to be routed to the mixer.");
906
907         gtk_box_pack_start(GTK_BOX(tempbox2), tempbox3, WID_FIX);
908
909         tempbox2=gtk_hbox_new(FALSE,0);
910         gtk_widget_show(tempbox2);
911         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
912         
913         g->volume=GTK_ADJUSTMENT(gtk_adjustment_new(2.0-vtt->rel_volume, 0, 2, 0.01, 0.01, 0.01));
914         dummy=gtk_vscale_new(GTK_ADJUSTMENT(g->volume)); 
915         gtk_scale_set_draw_value(GTK_SCALE(dummy), False);
916         gui_set_tooltip(dummy, "Adjust this turntable's volume.");
917
918         gtk_box_pack_start(GTK_BOX(tempbox2), dummy, WID_FIX);
919         gtk_widget_show(dummy);
920
921         g->flash=gtk_tx_flash_new();
922         gtk_box_pack_start(GTK_BOX(tempbox2), g->flash, WID_FIX);
923         gtk_widget_show(g->flash);              
924
925         g->file_dialog=NULL;
926
927         gui_connect_signals(vtt);
928 }
929
930 void fx_up(GtkWidget *wid, vtt_fx *effect)
931 {
932         vtt_class *vtt;
933         
934         vtt=(vtt_class*)effect->get_vtt();
935         vtt->effect_up(effect);
936 }
937
938 void fx_down(GtkWidget *wid, vtt_fx *effect)
939 {
940         vtt_class *vtt;
941         
942         vtt=(vtt_class*)effect->get_vtt();
943         vtt->effect_down(effect);
944 }
945
946 void fx_kill(GtkWidget *wid, vtt_fx_ladspa *effect)
947 {
948         vtt_class *vtt;
949         
950         vtt=(vtt_class*)effect->get_vtt();
951         vtt->effect_remove(effect);
952 }
953
954 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel)
955 {
956         GtkWidget *box;
957         GtkWidget *pixmap;
958         GtkWidget *button;
959         
960         box=gtk_hbox_new(FALSE,0);
961
962         if (showdel)
963         {
964                 button=gtk_button_new();
965                 pixmap=tx_pixmap_widget(TX_ICON_FX_CLOSE);
966                 gtk_container_add (GTK_CONTAINER (button), pixmap);     
967                 gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
968                 gtk_widget_show(pixmap);
969                 gtk_widget_show(button);
970                 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_kill, (void *) effect);
971         }
972
973         button=gtk_button_new();
974         pixmap=tx_pixmap_widget(TX_ICON_FX_DOWN);
975         gtk_container_add (GTK_CONTAINER (button), pixmap);     
976         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
977         gtk_widget_show(pixmap);
978         gtk_widget_show(button);
979         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_down, (void *) effect);
980
981         button=gtk_button_new();
982         pixmap=tx_pixmap_widget(TX_ICON_FX_UP);
983         gtk_container_add (GTK_CONTAINER (button), pixmap);     
984         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
985         gtk_widget_show(pixmap);
986         gtk_widget_show(button);
987         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_up, (void *) effect);
988         
989         gtk_widget_show(box);
990         
991         return box;
992 }
993
994
995 int gtk_box_get_widget_pos(GtkBox *box, GtkWidget *child)
996 {
997         int i=0;
998         GList *list;
999  
1000         list = box->children;
1001         while (list)
1002         {
1003                 GtkBoxChild *child_info;
1004                 child_info = (GtkBoxChild *) list->data;
1005                 if (child_info->widget == child)
1006                 break;
1007                 list = list->next; i++;
1008         }
1009         return i;
1010 }
1011
1012 void vg_move_fx_panel_up(GtkWidget *wid, vtt_class *vtt)
1013 {
1014         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1015         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos-1);
1016 }
1017
1018 void vg_move_fx_panel_down(GtkWidget *wid, vtt_class *vtt)
1019 {
1020         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1021         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos+1);
1022 }
1023
1024 void vg_show_fx_info(GtkWidget *wid, vtt_fx *effect)
1025 {
1026         tx_l_note(effect->get_info_string());
1027 }
1028
1029 void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plugin)
1030 {
1031         char buffer[1024];
1032         
1033         vtt_gui *g;
1034         g=&vtt->gui;    
1035         tX_panel *p;
1036         list <tX_seqpar_vttfx *> :: iterator sp;
1037         
1038         strcpy(buffer, plugin->getLabel());
1039         if (strlen(buffer) > 6)
1040         {
1041                 buffer[5]='.';
1042                 buffer[6]='.';
1043                 buffer[7]='.';
1044                 buffer[8]=0;
1045         }
1046
1047         p=new tX_panel(buffer, g->control_subbox);
1048         
1049         p->add_client_widget(vg_create_fx_bar(vtt, effect, 1));
1050         
1051         for (sp = effect->controls.begin(); sp != effect->controls.end(); sp++)
1052         {
1053                         p->add_client_widget((*sp)->get_widget());
1054         }
1055
1056         gtk_signal_connect(GTK_OBJECT(p->get_labelbutton()), "clicked", (GtkSignalFunc) vg_show_fx_info, (void *) effect);
1057         gui_set_tooltip(p->get_labelbutton(), "Click here to learn more about this plugin.");
1058         effect->set_panel_widget(p->get_widget());
1059         effect->set_panel(p);
1060
1061         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
1062 }
1063
1064 void gui_set_name(vtt_class *vtt, char *newname)
1065 {
1066         gtk_label_set_text(GTK_LABEL(vtt->gui.audio_label), newname);
1067         gtk_label_set_text(GTK_LABEL(vtt->gui.control_label), newname);
1068         gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
1069 }
1070
1071 void gui_set_filename (vtt_class *vtt, char *newname)
1072 {
1073         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), newname);
1074 }
1075
1076 void gui_update_display(vtt_class *vtt)
1077 {
1078         nicer_filename(global_filename_buffer, vtt->filename);
1079         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), global_filename_buffer);
1080         gtk_tx_set_data(GTK_TX(vtt->gui.display), vtt->buffer, vtt->samples_in_buffer);
1081 }
1082
1083 void delete_gui(vtt_class *vtt)
1084 {
1085         delete vtt->gui.main_panel;
1086         delete vtt->gui.trigger_panel;
1087         
1088         delete vtt->gui.pitchd;
1089         delete vtt->gui.pand;
1090         
1091         delete vtt->gui.lp_gaind;
1092         delete vtt->gui.lp_resod;
1093         delete vtt->gui.lp_freqd;
1094         delete vtt->gui.lp_panel;
1095         
1096         delete vtt->gui.ec_lengthd;
1097         delete vtt->gui.ec_feedbackd;
1098         delete vtt->gui.ec_volumed;
1099         delete vtt->gui.ec_pand;
1100         delete vtt->gui.ec_panel;
1101         
1102         gtk_widget_destroy(vtt->gui.control_box);
1103         gtk_widget_destroy(vtt->gui.audio_box);
1104 }
1105
1106 void update_all_vtts()
1107 {
1108         list <vtt_class *> :: iterator vtt;
1109         f_prec temp;
1110         
1111         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1112         {
1113                 if ((*vtt)->is_playing)
1114                 {
1115                         gtk_tx_update_pos_display(GTK_TX((*vtt)->gui.display), (*vtt)->pos_i, (*vtt)->mute);
1116 #ifdef USE_FLASH
1117                         temp=(*vtt)->max_value*(*vtt)->res_volume*vtt_class::vol_channel_adjust;
1118                         (*vtt)->max_value=0;
1119                         gtk_tx_flash_set_level((*vtt)->gui.flash, temp);
1120 #endif          
1121                 }
1122         }
1123 }
1124
1125 void cleanup_vtt(vtt_class *vtt)
1126 {
1127                 gtk_tx_cleanup_pos_display(GTK_TX(vtt->gui.display));   
1128 #ifdef USE_FLASH
1129                 gtk_tx_flash_set_level(vtt->gui.flash, 0.0);
1130                 gtk_tx_flash_clear(vtt->gui.flash);
1131 #endif          
1132 }
1133
1134 void cleanup_all_vtts()
1135 {
1136         list <vtt_class *> :: iterator vtt;
1137         
1138         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1139         {
1140                 if ((*vtt)->buffer) gtk_tx_cleanup_pos_display(GTK_TX((*vtt)->gui.display));
1141 #ifdef USE_FLASH
1142                 gtk_tx_flash_set_level((*vtt)->gui.flash, 0.0);
1143                 gtk_tx_flash_clear((*vtt)->gui.flash);
1144 #endif          
1145         }
1146 }
1147
1148 void gui_clear_master_button(vtt_class *vtt)
1149 {
1150         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_master), 0);
1151 }
1152
1153 void gui_show_frame(vtt_class *vtt, int show)
1154 {
1155         gtk_tx_show_frame(GTK_TX(vtt->gui.display), show);
1156 }
1157
1158 #define vgui (*vtt)->gui
1159 #define v (*vtt)
1160
1161 void vg_enable_critical_buttons(int enable)
1162 {
1163         list <vtt_class *> :: iterator vtt;
1164         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1165         {
1166                 gtk_widget_set_sensitive(vgui.del, enable);
1167                 gtk_widget_set_sensitive(vgui.sync_master, enable);
1168         }
1169 }
1170
1171
1172 void vg_init_all_non_seqpars()
1173 {
1174         list <vtt_class *> :: iterator vtt;
1175         
1176         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1177         {
1178                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.autotrigger), (*vtt)->autotrigger);
1179                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.sync_master), (*vtt)->is_sync_master);
1180         }       
1181 }