Changes for the upcomming 3.73 release - 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((char *) 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((char *) 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 #ifdef  USE_GTK2
187         gtk_button_set_label(GTK_BUTTON(vtt->gui.file), global_filename_buffer);
188 #else           
189                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), global_filename_buffer);
190 #endif
191         }       
192 }
193
194 void do_load_file(GtkWidget *wid, vtt_class *vtt)
195 {
196         int ret;
197         char newfile[PATH_MAX];
198         char buffer[1024]="Couldn't open loop file: ";
199         char fn[FILENAME_BUTTON_MAX];
200         
201         int16_t *newbuffer;
202         unsigned int newsize;
203         
204         prelis_stop();
205
206         strcpy(newfile, gtk_file_selection_get_filename(GTK_FILE_SELECTION(vtt->gui.fs)));
207         gtk_widget_destroy(GTK_WIDGET(vtt->gui.fs));
208         
209         load_part(newfile, vtt);
210         
211         if (!globals.current_path)
212         {
213                 free(globals.current_path);
214                 globals.current_path = NULL;
215         }
216
217         globals.current_path = strdup(newfile);
218
219         vtt->gui.file_dialog=NULL;
220 }
221
222 void drop_file(GtkWidget *widget, GdkDragContext *context,
223                 gint x, gint y, GtkSelectionData *selection_data,
224                 guint info, guint time, vtt_class *vtt)
225 {
226         char filename[PATH_MAX];
227         char *fn;
228         int s;
229         void *prr;
230         
231         strncpy(filename, (char *) selection_data->data, (size_t) selection_data->length);
232         filename[selection_data->length]=0;
233
234         fn = strchr (filename, '\r');
235         *fn=0;  
236         
237         fn = strchr (filename, ':');
238         if (fn) fn++; else fn=(char *) selection_data->data;
239         
240         load_part(fn, vtt);
241 }
242
243
244 GtkSignalFunc load_file(GtkWidget *wid, vtt_class *vtt)
245 {       
246         char buffer[512];
247         
248         if (vtt->gui.file_dialog)
249         {
250                 gdk_window_raise(vtt->gui.file_dialog);
251                 return(0);
252         }
253         
254         sprintf(buffer, "Select Audio File for %s", vtt->name);
255         vtt->gui.fs=gtk_file_selection_new(buffer);
256         
257         if (strlen(vtt->filename) > 0)
258         {
259                 gtk_file_selection_set_filename(GTK_FILE_SELECTION(vtt->gui.fs), vtt->filename);        
260         }
261         
262         gtk_widget_show(GTK_WIDGET(vtt->gui.fs));
263         
264         vtt->gui.file_dialog=vtt->gui.fs->window;
265         
266         if (globals.current_path)
267                 {
268                         gtk_file_selection_set_filename(GTK_FILE_SELECTION(vtt->gui.fs),globals.current_path);
269                 }
270         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_load_file), vtt);
271         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->cancel_button), "clicked", GTK_SIGNAL_FUNC (cancel_load_file), vtt);    
272         gtk_signal_connect (GTK_OBJECT(vtt->gui.fs), "delete-event", GTK_SIGNAL_FUNC(quit_load_file), vtt);     
273         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(vtt->gui.fs)->file_list), "select_row", GTK_SIGNAL_FUNC(trigger_prelis), vtt->gui.fs);
274 }
275
276 void delete_vtt(GtkWidget *wid, vtt_class *vtt)
277 {
278         if (audioon) tx_note("Sorry, you'll have to stop playback first.");
279         else
280         delete(vtt);
281 }
282
283 void edit_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
284 {
285         char command[2*PATH_MAX];
286
287         if (vtt->samples_in_buffer == 0)
288         {
289                 tx_note("Nothing to edit.");
290         }
291         else
292         if (strlen(globals.file_editor)>0)
293         {
294                 sprintf(command, "%s \"%s\" &", globals.file_editor, vtt->filename);
295                 system(command); /*) tx_note("Failed to run the soundfile editor."); */
296         }
297         else
298         {
299                 tx_note("No soundfile editor configured.");
300         }
301 }
302
303 void reload_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
304 {
305         char reload_buffer[PATH_MAX];
306         
307         while (gtk_events_pending()) gtk_main_iteration();
308         
309         if (vtt->samples_in_buffer > 0)
310         {
311                 strcpy(reload_buffer, vtt->filename);
312                 load_part(reload_buffer, vtt);
313         }
314         else tx_note("Nothing to reload.");
315 }
316
317 void clone_vtt(GtkWidget *wid, vtt_class *vtt)
318 {
319         vtt->stop();
320 }
321
322 void trigger_vtt(GtkWidget *wid, vtt_class *vtt)
323 {
324         vtt->sp_trigger.receive_gui_value((float) 1.0);
325 }
326
327 void stop_vtt(GtkWidget *wid, vtt_class *vtt)
328 {
329         vtt->sp_trigger.receive_gui_value((float) 0.0);
330 }
331
332 void autotrigger_toggled(GtkWidget *wid, vtt_class *vtt)
333 {
334         vtt->set_autotrigger(GTK_TOGGLE_BUTTON(wid)->active);
335 }
336
337 void loop_toggled(GtkWidget *wid, vtt_class *vtt)
338 {
339         vtt->sp_loop.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
340 }
341
342 void lp_enabled(GtkWidget *wid, vtt_class *vtt)
343 {
344         vtt->sp_lp_enable.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
345 }
346
347 void lp_gain_changed(GtkWidget *wid, vtt_class *vtt)
348 {
349         vtt->sp_lp_gain.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
350 }
351
352 void lp_reso_changed(GtkWidget *wid, vtt_class *vtt)
353 {
354         vtt->sp_lp_reso.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
355 }
356
357 void lp_freq_changed(GtkWidget *wid, vtt_class *vtt)
358 {
359         vtt->sp_lp_freq.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
360 }
361
362 void ec_enabled(GtkWidget *wid, vtt_class *vtt)
363 {
364         vtt->sp_ec_enable.receive_gui_value(GTK_TOGGLE_BUTTON(wid)->active);
365 }
366
367 void ec_length_changed(GtkWidget *wid, vtt_class *vtt)
368 {
369         vtt->sp_ec_length.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
370 }
371
372 void ec_feedback_changed(GtkWidget *wid, vtt_class *vtt)
373 {
374         vtt->sp_ec_feedback.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
375 }
376
377 void ec_pan_changed(GtkWidget *wid, vtt_class *vtt)
378 {
379         vtt->sp_ec_pan.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
380 }
381
382 void ec_volume_changed(GtkWidget *wid, vtt_class *vtt)
383 {
384         vtt->sp_ec_volume.receive_gui_value(GTK_ADJUSTMENT(wid)->value);
385 }
386
387 void master_setup(GtkWidget *wid, vtt_class *vtt)
388 {
389         vtt->set_sync_master(GTK_TOGGLE_BUTTON(wid)->active);
390 }
391
392 void client_setup(GtkWidget *wid, vtt_class *vtt)
393 {
394         int client;
395         
396         client=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client));   
397         vtt->sp_sync_client.receive_gui_value(client);
398 }
399
400 void client_setup_number(GtkWidget *wid, vtt_class *vtt)
401 {
402         int cycles;
403         
404         cycles=(int) GTK_ADJUSTMENT(vtt->gui.cycles)->value;    
405         
406         vtt->sp_sync_cycles.receive_gui_value(cycles);
407 }
408
409 void mute_volume(GtkWidget *widget, vtt_class *vtt)
410 {
411         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
412         {
413                 vtt->set_mix_mute(1);
414         }
415         else
416         {
417                 vtt->set_mix_mute(0);
418         }
419 }
420
421 void solo_vtt(GtkWidget *widget, vtt_class *vtt)
422 {
423         list <vtt_class *> :: iterator it_vtt;
424
425         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) 
426         {
427                 vtt->set_mix_solo(1);
428         }
429         else
430         {
431                 vtt->set_mix_solo(0);
432         }
433 }      
434
435 void vg_display_xcontrol(vtt_class *vtt)
436 {
437         char buffer[2048];
438         
439         if (vtt->x_par)
440         {
441                 strcpy(buffer, vtt->x_par->get_name());
442                 if (strlen(buffer)>35) 
443                 {
444                         buffer[34] = '.';
445                         buffer[35] = '.';
446                         buffer[36] = '.';
447                         buffer[37] = 0;                 
448                 }
449 #ifdef  USE_GTK2
450         gtk_button_set_label(GTK_BUTTON(vtt->gui.x_control), buffer);
451 #else           
452                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.x_control)->child), buffer);                
453 #endif  
454         }
455         else
456         {
457 #ifdef  USE_GTK2
458         gtk_button_set_label(GTK_BUTTON(vtt->gui.x_control), "Nothing");
459 #else           
460                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.x_control)->child), "Nothing");
461 #endif          
462         }
463 }
464
465 void vg_display_ycontrol(vtt_class *vtt)
466 {
467         char buffer[2048];
468         
469         if (vtt->y_par)
470         {
471                 strcpy(buffer, vtt->y_par->get_name());
472                 if (strlen(buffer)>26) 
473                 {
474                         buffer[24] = '.';
475                         buffer[25] = '.';
476                         buffer[26] = '.';
477                         buffer[27] = 0;                 
478                 }
479 #ifdef  USE_GTK2
480         gtk_button_set_label(GTK_BUTTON(vtt->gui.y_control), buffer);
481 #else           
482                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.y_control)->child), buffer);                
483 #endif  
484         }
485         else
486         {
487 #ifdef  USE_GTK2
488         gtk_button_set_label(GTK_BUTTON(vtt->gui.y_control), "Nothing");
489 #else           
490                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.y_control)->child), "Nothing");
491 #endif          
492         }
493 }
494
495 void vg_xcontrol_dis(GtkWidget *wid, vtt_class *vtt)
496 {
497         vtt->set_x_input_parameter(NULL);
498 }
499
500 void vg_ycontrol_dis(GtkWidget *wid, vtt_class *vtt)
501 {
502         vtt->set_y_input_parameter(NULL);
503 }
504
505 void vg_xcontrol_set(GtkWidget *wid, tX_seqpar *sp)
506 {
507         vtt_class *vtt=(vtt_class *) sp->vtt;
508         vtt->set_x_input_parameter(sp);
509 }
510
511 void vg_ycontrol_set(GtkWidget *wid, tX_seqpar *sp)
512 {
513         vtt_class *vtt=(vtt_class *) sp->vtt;
514         vtt->set_y_input_parameter(sp);
515 }
516
517 void vg_control_menu_popup(vtt_class *vtt, int axis)
518 {
519         list <tX_seqpar *> :: iterator sp;
520         vtt_gui *g=&vtt->gui;
521         GtkWidget *item;
522
523         if (g->par_menu) gtk_object_destroy(GTK_OBJECT(g->par_menu));
524         g->par_menu=gtk_menu_new();
525         
526         item = gtk_menu_item_new_with_label("Nothing");
527         gtk_menu_append(GTK_MENU(g->par_menu), item);
528         gtk_widget_show(item);
529         if (axis) gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_xcontrol_dis), vtt);
530         else gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_ycontrol_dis), vtt);
531         
532         
533         for (sp=tX_seqpar::all.begin(); sp!=tX_seqpar::all.end(); sp++)
534         {
535                 if (((*sp)->is_mappable) && ((*sp)->vtt) == (void*) vtt)
536                 {
537                         item = gtk_menu_item_new_with_label((*sp)->get_name());
538                         gtk_menu_append(GTK_MENU(g->par_menu), item);
539                         gtk_widget_show(item);
540                         if (axis) gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_xcontrol_set), (void*) (*sp));
541                         else gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_ycontrol_set), (void*) (*sp));
542                 }
543         }
544         gtk_menu_popup (GTK_MENU(g->par_menu), NULL, NULL, NULL, NULL, 0, 0);
545 }
546
547 void vg_xcontrol_popup(GtkWidget *wid, vtt_class *vtt) 
548 {
549         vg_control_menu_popup(vtt, 1);
550 }
551
552 void vg_ycontrol_popup(GtkWidget *wid, vtt_class *vtt)
553 {
554         vg_control_menu_popup(vtt, 0);
555 }
556
557 static vtt_class * fx_vtt;
558
559 void new_effect(GtkWidget *wid, LADSPA_Plugin *plugin)
560 {
561         fx_vtt->add_effect(plugin);
562 }
563
564 void fx_button_pressed(GtkWidget *wid, vtt_class *vtt)
565 {
566         vtt_gui *g=&vtt->gui;
567         GtkWidget *item;
568         int i;
569         LADSPA_Plugin *plugin;
570         char buffer[1024];
571         char oldfile[1024]="";
572         GtkWidget *submenu;
573
574         fx_vtt=vtt; /* AAAAARGH - Long live ugly code */
575
576         if (g->ladspa_menu) gtk_object_destroy(GTK_OBJECT(g->ladspa_menu));
577         g->ladspa_menu=gtk_menu_new();
578         
579         for (i=0; i<LADSPA_Plugin::getPluginCount(); i++)
580         {
581                 plugin=LADSPA_Plugin::getPluginByIndex(i);
582                 if (strcmp(plugin->get_file_name(), oldfile))
583                 {
584                         strcpy(oldfile, plugin->get_file_name());
585                         item = gtk_menu_item_new_with_label(oldfile);
586                         submenu=gtk_menu_new();
587                         gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
588                         gtk_menu_append(GTK_MENU(g->ladspa_menu), item);
589                         gtk_widget_show(item);
590                 }
591                 sprintf(buffer, "%s - [%i, %s]", plugin->getName(), plugin->getUniqueID(), plugin->getLabel());
592                 item=gtk_menu_item_new_with_label(buffer);
593                 gtk_menu_append(GTK_MENU(submenu), item);
594                 gtk_widget_show(item);
595                 gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(new_effect), plugin);
596         }
597         
598         gtk_menu_popup (GTK_MENU(g->ladspa_menu), NULL, NULL, NULL, NULL, 0, 0);
599 }
600
601 #define connect_entry(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "activate", (GtkSignalFunc) func, (void *) vtt);
602 #define connect_adj(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "value_changed", (GtkSignalFunc) func, (void *) vtt);
603 #define connect_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "clicked", (GtkSignalFunc) func, (void *) vtt);
604 #define connect_press_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "pressed", (GtkSignalFunc) func, (void *) vtt);
605 #define connect_rel_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "released", (GtkSignalFunc) func, (void *) vtt);
606
607 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel);
608
609 void gui_connect_signals(vtt_class *vtt)
610 {
611         vtt_gui *g=&vtt->gui;
612
613         connect_entry(name, name_changed);
614         connect_adj(volume, volume_changed);
615         connect_button(edit, edit_vtt_buffer);
616         connect_button(reload, reload_vtt_buffer);
617         connect_adj(pitch, pitch_changed);
618         connect_adj(pan, pan_changed);
619         connect_button(file, load_file);
620         
621         connect_button(del, delete_vtt);
622         connect_button(trigger, trigger_vtt);
623         connect_button(stop, stop_vtt);
624         connect_button(autotrigger, autotrigger_toggled);
625         connect_button(loop, loop_toggled);
626         connect_button(sync_master, master_setup);
627         connect_button(sync_client, client_setup);
628         connect_adj(cycles, client_setup_number);
629         connect_button(fx_button, fx_button_pressed);
630         
631         connect_button(lp_enable, lp_enabled);
632         connect_adj(lp_gain, lp_gain_changed);
633         connect_adj(lp_reso, lp_reso_changed);
634         connect_adj(lp_freq, lp_freq_changed);
635         
636         connect_button(ec_enable, ec_enabled);
637         connect_adj(ec_length, ec_length_changed);
638         connect_adj(ec_feedback, ec_feedback_changed);
639         connect_adj(ec_pan, ec_pan_changed);
640         connect_adj(ec_volume, ec_volume_changed);      
641         connect_button(x_control, vg_xcontrol_popup);
642         connect_button(y_control, vg_ycontrol_popup);
643
644         static GtkTargetEntry drop_types [] = {
645                 { "text/uri-list", 0, 0}
646         };
647         static gint n_drop_types = sizeof (drop_types) / sizeof(drop_types[0]);
648         
649         gtk_drag_dest_set (GTK_WIDGET (g->file), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
650                         drop_types, n_drop_types,
651                         GDK_ACTION_COPY);
652                                                 
653         gtk_signal_connect (GTK_OBJECT (g->file), "drag_data_received",
654                         GTK_SIGNAL_FUNC(drop_file), (void *) vtt);
655
656         gtk_drag_dest_set (GTK_WIDGET (g->display), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
657                         drop_types, n_drop_types,
658                         GDK_ACTION_COPY);
659                                                 
660         gtk_signal_connect (GTK_OBJECT (g->display), "drag_data_received",
661                         GTK_SIGNAL_FUNC(drop_file), (void *) vtt);
662         
663 }
664         
665 void build_vtt_gui(vtt_class *vtt)
666 {
667         GtkWidget *tempbox;
668         GtkWidget *tempbox2;
669         GtkWidget *tempbox3;
670         GtkWidget *dummy;
671         char nice_name[FILENAME_BUTTON_MAX];
672         
673         vtt_gui *g;
674         
675         g=&vtt->gui;
676         vtt->have_gui=1;
677         g->par_menu=NULL;
678         g->ladspa_menu=NULL;
679
680         /* Building Audio Box */
681         g->audio_box=gtk_vbox_new(FALSE,2);
682         gtk_widget_show(g->audio_box);
683         
684         tempbox=gtk_hbox_new(FALSE,2);
685         gtk_widget_show(tempbox);
686         gtk_box_pack_start(GTK_BOX(g->audio_box), tempbox, WID_FIX);
687         
688         g->audio_label=gtk_label_new(vtt->name);
689         gtk_widget_show(g->audio_label);
690         gtk_box_pack_start(GTK_BOX(tempbox), g->audio_label, WID_DYN);
691
692         dummy=gtk_vseparator_new();
693         gtk_widget_show(dummy);
694         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
695
696         nicer_filename(nice_name, vtt->filename);
697         g->file = gtk_button_new_with_label(nice_name);
698         gtk_widget_show(g->file);
699         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.");
700         gtk_box_pack_start(GTK_BOX(tempbox), g->file, WID_DYN);
701
702         g->edit=tx_xpm_button_new(TX_ICON_EDIT, "Edit", 0);
703         gtk_widget_show(g->edit);
704         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.");
705         gtk_box_pack_start(GTK_BOX(tempbox), g->edit, WID_FIX);
706         
707         g->reload=tx_xpm_button_new(TX_ICON_RELOAD, "Reload", 0);
708         gtk_widget_show(g->reload);
709         gui_set_tooltip(g->reload, "Click here to reload the audiofile loaded into this turntable.");
710         gtk_box_pack_start(GTK_BOX(tempbox), g->reload, WID_FIX);
711         
712         dummy=gtk_vseparator_new();
713         gtk_widget_show(dummy);
714         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
715
716         dummy=gtk_label_new("X:");
717         gtk_widget_show(dummy);
718         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
719
720         g->x_control=gtk_button_new_with_label(vtt->x_par->get_name());
721         gtk_widget_show(g->x_control);
722         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).");
723         gtk_box_pack_start(GTK_BOX(tempbox), g->x_control, WID_DYN);
724
725         dummy=gtk_label_new("Y:");
726         gtk_widget_show(dummy);
727         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
728         
729         g->y_control=gtk_button_new_with_label(vtt->y_par->get_name());
730         gtk_widget_show(g->y_control);
731         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).");
732
733         gtk_box_pack_start(GTK_BOX(tempbox), g->y_control, WID_DYN);
734
735         g->display=gtk_tx_new(vtt->buffer, vtt->samples_in_buffer);
736         gtk_box_pack_start(GTK_BOX(g->audio_box), g->display, WID_DYN);
737         gtk_widget_show(g->display);    
738         
739         /* Building Control Box */
740         
741         g->control_box=gtk_vbox_new(FALSE,2);
742         gtk_widget_show(g->control_box);
743         
744         g->control_label=gtk_label_new(vtt->name);
745         gtk_widget_show(g->control_label);
746         gtk_box_pack_start(GTK_BOX(g->control_box), g->control_label, WID_FIX);
747         
748         g->scrolled_win=gtk_scrolled_window_new (NULL, NULL);
749         gtk_container_set_border_width (GTK_CONTAINER (g->scrolled_win), 0);
750         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (g->scrolled_win),
751                                     GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
752         gtk_widget_show(g->scrolled_win);
753         gtk_box_pack_start(GTK_BOX(g->control_box), g->scrolled_win, WID_DYN);
754                                     
755         g->control_subbox=gtk_vbox_new(FALSE,0);
756         gtk_scrolled_window_add_with_viewport (
757                    GTK_SCROLLED_WINDOW (g->scrolled_win), g->control_subbox);
758         gtk_widget_show(g->control_subbox);
759                    
760
761         /* Main panel */
762         
763         tX_panel *p=new tX_panel("Main", g->control_subbox);
764         g->main_panel=p;
765                         
766         g->name = gtk_entry_new_with_max_length(256);   
767         gtk_entry_set_text(GTK_ENTRY(g->name), vtt->name);
768         p->add_client_widget(g->name);
769         gui_set_tooltip(g->name, "Enter the turntable's name here.");
770         gtk_widget_set_usize(g->name, 40, g->name->requisition.height);
771         
772         g->del=gtk_button_new_with_label("Delete");
773         gui_set_tooltip(g->del, "Click here to annihilate this turntable. All events recorded for this turntable will be erased, too.");
774         p->add_client_widget(g->del);
775         
776 //      g->show_audio=gtk_toggle_button_new_with_label("Show Audio");
777 //      p->add_client_widget(g->show_audio);
778                 
779         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
780                                 
781         p=new tX_panel("Trigger", g->control_subbox);
782         g->trigger_panel=p;
783         
784         g->trigger=gtk_button_new_with_label("Trigger!");
785         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.");
786         p->add_client_widget(g->trigger);
787         
788         g->stop=gtk_button_new_with_label("Stop.");
789         gui_set_tooltip(g->stop, "Stop this turntable's playback.");
790         p->add_client_widget(g->stop);
791         
792         g->autotrigger=gtk_check_button_new_with_label("Auto");
793         p->add_client_widget(g->autotrigger);
794         gui_set_tooltip(g->autotrigger, "If turned on, this turntable will be automagically triggered whenever the audio engine is turned on.");
795         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->autotrigger), vtt->autotrigger);
796         
797         g->loop=gtk_check_button_new_with_label("Loop");
798         p->add_client_widget(g->loop);
799         gui_set_tooltip(g->loop, "Enable this option to make the turntable loop the audio data.");
800         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->loop), vtt->loop);
801         
802         g->sync_master=gtk_check_button_new_with_label("Master");
803         p->add_client_widget(g->sync_master);
804         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.");
805         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_master), vtt->is_sync_master);
806         
807         g->sync_client=gtk_check_button_new_with_label("Client");
808         p->add_client_widget(g->sync_client);
809         gui_set_tooltip(g->sync_client, "If enabled this turntable will be (re-)triggerd in relation to the sync-master turntable.");
810         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_client), vtt->is_sync_client);
811         
812         g->cycles=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->sync_cycles, 0, 10.0, 1,1,1));
813         dummy=gtk_spin_button_new(g->cycles, 1.0, 0);
814         p->add_client_widget(dummy);
815         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.");
816
817         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
818
819         dummy=gtk_button_new_with_label("FX");
820         gtk_widget_show(dummy);
821         g->fx_button=dummy;
822         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.");
823         gtk_box_pack_start(GTK_BOX(g->control_subbox), dummy, WID_FIX);
824         
825         /* Lowpass Panel */
826
827         p=new tX_panel("Lowpass", g->control_subbox);
828         g->lp_panel=p;
829                 
830         g->lp_enable=gtk_check_button_new_with_label("Enable");
831         gui_set_tooltip(g->lp_enable, "Click here to enable the built-in lowpass effect.");
832         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->lp_enable), vtt->lp_enable);
833         p->add_client_widget(vg_create_fx_bar(vtt, vtt->lp_fx, 0));
834
835         p->add_client_widget(g->lp_enable);
836
837         g->lp_gain=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_gain, 0, 2, 0.1, 0.01, 0.01));
838         g->lp_reso=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_reso, 0, 0.99, 0.1, 0.01, 0.01));
839         g->lp_freq=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_freq, 0, 1, 0.1, 0.01, 0.01));
840
841         g->lp_gaind=new tX_extdial("Input Gain", g->lp_gain);
842         p->add_client_widget(g->lp_gaind->get_widget());
843         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.");
844
845         g->lp_freqd=new tX_extdial("Frequency", g->lp_freq);
846         p->add_client_widget(g->lp_freqd->get_widget());
847         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.");
848
849         g->lp_resod=new tX_extdial("Resonance", g->lp_reso);
850         p->add_client_widget(g->lp_resod->get_widget());
851         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.");
852
853         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
854
855         /* Echo Panel */
856
857         p=new tX_panel("Echo", g->control_subbox);
858         g->ec_panel=p;
859
860         p->add_client_widget(vg_create_fx_bar(vtt, vtt->ec_fx, 0));
861         
862         g->ec_enable=gtk_check_button_new_with_label("Enable");
863         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->ec_enable), vtt->ec_enable);
864         p->add_client_widget(g->ec_enable);
865         gui_set_tooltip(g->ec_enable, "Enable the built-in echo effect.");
866
867         g->ec_length=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_length, 0, 1, 0.1, 0.01, 0.001));
868         g->ec_feedback=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_feedback, 0, 1, 0.1, 0.01, 0.001));
869         g->ec_pan=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_pan, -1.0, 1, 0.1, 0.01, 0.001));
870         g->ec_volume=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_volume, 0.0, 3.0, 0.1, 0.01, 0.001));
871
872         g->ec_lengthd=new tX_extdial("Duration", g->ec_length);
873         p->add_client_widget(g->ec_lengthd->get_widget());
874         gui_set_tooltip(g->ec_lengthd->get_entry(), "Adjust the length of the echo buffer.");
875
876         g->ec_feedbackd=new tX_extdial("Feedback", g->ec_feedback);
877         p->add_client_widget(g->ec_feedbackd->get_widget());
878         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.");
879
880         g->ec_volumed=new tX_extdial("Volume", g->ec_volume);
881         p->add_client_widget(g->ec_volumed->get_widget());
882         gui_set_tooltip(g->ec_volumed->get_entry(), "Adjust the volume of the echo effect.");
883
884         g->ec_pand=new tX_extdial("Pan", g->ec_pan);
885         p->add_client_widget(g->ec_pand->get_widget());
886         gui_set_tooltip(g->ec_pand->get_entry(), "Adjust the panning of the echo effect.");
887
888         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
889         
890         /* Output */
891         
892         tempbox=gtk_hbox_new(FALSE,2);
893         gtk_widget_show(tempbox);
894         gtk_box_pack_end(GTK_BOX(g->control_box), tempbox, WID_FIX);
895         
896         tempbox2=gtk_vbox_new(FALSE,0);
897         gtk_widget_show(tempbox2);
898         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
899         
900         g->pitch=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->rel_pitch, -3, +3, 0.1, 0.01, 0.001));
901         g->pan=GTK_ADJUSTMENT(gtk_adjustment_new(0, -1, 1, 0.1, 0.01, 0.001));
902
903         g->pitchd=new tX_extdial("Pitch", g->pitch);
904         gui_set_tooltip(g->pitchd->get_entry(), "Adjust this turntable's pitch.");
905
906         gtk_box_pack_start(GTK_BOX(tempbox2), g->pitchd->get_widget(), WID_FIX);
907
908         g->pand=new tX_extdial("Pan", g->pan);
909         gtk_box_pack_start(GTK_BOX(tempbox2), g->pand->get_widget(), WID_FIX);
910         gui_set_tooltip(g->pand->get_entry(), "Specifies the position of this turntable within the stereo spectrum: -1 -> left, 0-> center, 1->right.");
911
912         tempbox3=gtk_hbox_new(FALSE,2);
913         gtk_widget_show(tempbox3);
914
915         g->mute=gtk_check_button_new_with_label("M");
916         gtk_box_pack_start(GTK_BOX(tempbox3), g->mute, WID_FIX);
917         gtk_signal_connect(GTK_OBJECT(g->mute),"clicked", (GtkSignalFunc) mute_volume, vtt);
918         gtk_widget_show(g->mute);
919         gui_set_tooltip(g->mute, "Mute this turntable's mixer output.");
920
921         g->solo=gtk_check_button_new_with_label("S");
922         gtk_box_pack_start(GTK_BOX(tempbox3), g->solo, WID_FIX);
923         gtk_signal_connect(GTK_OBJECT(g->solo),"clicked", (GtkSignalFunc) solo_vtt, vtt);
924         gtk_widget_show(g->solo);
925         gui_set_tooltip(g->mute, "Allow only this and other solo-switched turntabels' signal to be routed to the mixer.");
926
927         gtk_box_pack_start(GTK_BOX(tempbox2), tempbox3, WID_FIX);
928
929         tempbox2=gtk_hbox_new(FALSE,0);
930         gtk_widget_show(tempbox2);
931         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
932         
933         g->volume=GTK_ADJUSTMENT(gtk_adjustment_new(2.0-vtt->rel_volume, 0, 2, 0.01, 0.01, 0.01));
934         dummy=gtk_vscale_new(GTK_ADJUSTMENT(g->volume)); 
935         gtk_scale_set_draw_value(GTK_SCALE(dummy), False);
936         gui_set_tooltip(dummy, "Adjust this turntable's volume.");
937
938         gtk_box_pack_start(GTK_BOX(tempbox2), dummy, WID_FIX);
939         gtk_widget_show(dummy);
940
941         g->flash=gtk_tx_flash_new();
942         gtk_box_pack_start(GTK_BOX(tempbox2), g->flash, WID_FIX);
943         gtk_widget_show(g->flash);              
944
945         g->file_dialog=NULL;
946
947         gui_connect_signals(vtt);
948 }
949
950 void fx_up(GtkWidget *wid, vtt_fx *effect)
951 {
952         vtt_class *vtt;
953         
954         vtt=(vtt_class*)effect->get_vtt();
955         vtt->effect_up(effect);
956 }
957
958 void fx_down(GtkWidget *wid, vtt_fx *effect)
959 {
960         vtt_class *vtt;
961         
962         vtt=(vtt_class*)effect->get_vtt();
963         vtt->effect_down(effect);
964 }
965
966 void fx_kill(GtkWidget *wid, vtt_fx_ladspa *effect)
967 {
968         vtt_class *vtt;
969         
970         vtt=(vtt_class*)effect->get_vtt();
971         vtt->effect_remove(effect);
972 }
973
974 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel)
975 {
976         GtkWidget *box;
977         GtkWidget *pixmap;
978         GtkWidget *button;
979         
980         box=gtk_hbox_new(FALSE,0);
981
982         if (showdel)
983         {
984                 button=gtk_button_new();
985                 pixmap=tx_pixmap_widget(TX_ICON_FX_CLOSE);
986                 gtk_container_add (GTK_CONTAINER (button), pixmap);     
987                 gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
988                 gtk_widget_show(pixmap);
989                 gtk_widget_show(button);
990                 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_kill, (void *) effect);
991         }
992
993         button=gtk_button_new();
994         pixmap=tx_pixmap_widget(TX_ICON_FX_DOWN);
995         gtk_container_add (GTK_CONTAINER (button), pixmap);     
996         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
997         gtk_widget_show(pixmap);
998         gtk_widget_show(button);
999         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_down, (void *) effect);
1000
1001         button=gtk_button_new();
1002         pixmap=tx_pixmap_widget(TX_ICON_FX_UP);
1003         gtk_container_add (GTK_CONTAINER (button), pixmap);     
1004         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
1005         gtk_widget_show(pixmap);
1006         gtk_widget_show(button);
1007         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_up, (void *) effect);
1008         
1009         gtk_widget_show(box);
1010         
1011         return box;
1012 }
1013
1014
1015 int gtk_box_get_widget_pos(GtkBox *box, GtkWidget *child)
1016 {
1017         int i=0;
1018         GList *list;
1019  
1020         list = box->children;
1021         while (list)
1022         {
1023                 GtkBoxChild *child_info;
1024                 child_info = (GtkBoxChild *) list->data;
1025                 if (child_info->widget == child)
1026                 break;
1027                 list = list->next; i++;
1028         }
1029         return i;
1030 }
1031
1032 void vg_move_fx_panel_up(GtkWidget *wid, vtt_class *vtt)
1033 {
1034         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1035         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos-1);
1036 }
1037
1038 void vg_move_fx_panel_down(GtkWidget *wid, vtt_class *vtt)
1039 {
1040         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1041         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos+1);
1042 }
1043
1044 void vg_show_fx_info(GtkWidget *wid, vtt_fx *effect)
1045 {
1046         tx_l_note(effect->get_info_string());
1047 }
1048
1049 void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plugin)
1050 {
1051         char buffer[1024];
1052         
1053         vtt_gui *g;
1054         g=&vtt->gui;    
1055         tX_panel *p;
1056         list <tX_seqpar_vttfx *> :: iterator sp;
1057         
1058         strcpy(buffer, plugin->getLabel());
1059         if (strlen(buffer) > 6)
1060         {
1061                 buffer[5]='.';
1062                 buffer[6]='.';
1063                 buffer[7]='.';
1064                 buffer[8]=0;
1065         }
1066
1067         p=new tX_panel(buffer, g->control_subbox);
1068         
1069         p->add_client_widget(vg_create_fx_bar(vtt, effect, 1));
1070         
1071         for (sp = effect->controls.begin(); sp != effect->controls.end(); sp++)
1072         {
1073                         p->add_client_widget((*sp)->get_widget());
1074         }
1075
1076         gtk_signal_connect(GTK_OBJECT(p->get_labelbutton()), "clicked", (GtkSignalFunc) vg_show_fx_info, (void *) effect);
1077         gui_set_tooltip(p->get_labelbutton(), "Click here to learn more about this plugin.");
1078         effect->set_panel_widget(p->get_widget());
1079         effect->set_panel(p);
1080
1081         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
1082 }
1083
1084 void gui_set_name(vtt_class *vtt, char *newname)
1085 {
1086         gtk_label_set_text(GTK_LABEL(vtt->gui.audio_label), newname);
1087         gtk_label_set_text(GTK_LABEL(vtt->gui.control_label), newname);
1088         gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
1089 }
1090
1091 void gui_set_filename (vtt_class *vtt, char *newname)
1092 {
1093 #ifdef  USE_GTK2
1094         gtk_button_set_label(GTK_BUTTON(vtt->gui.file), newname);
1095 #else           
1096         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), newname);
1097 #endif  
1098 }
1099
1100 void gui_update_display(vtt_class *vtt)
1101 {
1102         nicer_filename(global_filename_buffer, vtt->filename);
1103 #ifdef  USE_GTK2
1104         gtk_button_set_label(GTK_BUTTON(vtt->gui.file), global_filename_buffer);
1105 #else           
1106         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), global_filename_buffer);
1107 #endif  
1108         gtk_tx_set_data(GTK_TX(vtt->gui.display), vtt->buffer, vtt->samples_in_buffer);
1109 }
1110
1111 void delete_gui(vtt_class *vtt)
1112 {
1113         delete vtt->gui.main_panel;
1114         delete vtt->gui.trigger_panel;
1115         
1116         delete vtt->gui.pitchd;
1117         delete vtt->gui.pand;
1118         
1119         delete vtt->gui.lp_gaind;
1120         delete vtt->gui.lp_resod;
1121         delete vtt->gui.lp_freqd;
1122         delete vtt->gui.lp_panel;
1123         
1124         delete vtt->gui.ec_lengthd;
1125         delete vtt->gui.ec_feedbackd;
1126         delete vtt->gui.ec_volumed;
1127         delete vtt->gui.ec_pand;
1128         delete vtt->gui.ec_panel;
1129         
1130         gtk_widget_destroy(vtt->gui.control_box);
1131         gtk_widget_destroy(vtt->gui.audio_box);
1132 }
1133
1134 void update_all_vtts()
1135 {
1136         list <vtt_class *> :: iterator vtt;
1137         f_prec temp;
1138         
1139         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1140         {
1141                 if ((*vtt)->is_playing)
1142                 {
1143                         gtk_tx_update_pos_display(GTK_TX((*vtt)->gui.display), (*vtt)->pos_i, (*vtt)->mute);
1144 #ifdef USE_FLASH
1145                         temp=(*vtt)->max_value*(*vtt)->res_volume*vtt_class::vol_channel_adjust;
1146                         (*vtt)->max_value=0;
1147                         gtk_tx_flash_set_level((*vtt)->gui.flash, temp);
1148 #endif          
1149                 }
1150         }
1151 }
1152
1153 void cleanup_vtt(vtt_class *vtt)
1154 {
1155                 gtk_tx_cleanup_pos_display(GTK_TX(vtt->gui.display));   
1156 #ifdef USE_FLASH
1157                 gtk_tx_flash_set_level(vtt->gui.flash, 0.0);
1158                 gtk_tx_flash_clear(vtt->gui.flash);
1159 #endif          
1160 }
1161
1162 void cleanup_all_vtts()
1163 {
1164         list <vtt_class *> :: iterator vtt;
1165         
1166         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1167         {
1168                 if ((*vtt)->buffer) gtk_tx_cleanup_pos_display(GTK_TX((*vtt)->gui.display));
1169 #ifdef USE_FLASH
1170                 gtk_tx_flash_set_level((*vtt)->gui.flash, 0.0);
1171                 gtk_tx_flash_clear((*vtt)->gui.flash);
1172 #endif          
1173         }
1174 }
1175
1176 void gui_clear_master_button(vtt_class *vtt)
1177 {
1178         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_master), 0);
1179 }
1180
1181 void gui_show_frame(vtt_class *vtt, int show)
1182 {
1183         gtk_tx_show_frame(GTK_TX(vtt->gui.display), show);
1184 }
1185
1186 #define vgui (*vtt)->gui
1187 #define v (*vtt)
1188
1189 void vg_enable_critical_buttons(int enable)
1190 {
1191         list <vtt_class *> :: iterator vtt;
1192         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1193         {
1194                 gtk_widget_set_sensitive(vgui.del, enable);
1195                 gtk_widget_set_sensitive(vgui.sync_master, enable);
1196         }
1197 }
1198
1199
1200 void vg_init_all_non_seqpars()
1201 {
1202         list <vtt_class *> :: iterator vtt;
1203         
1204         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1205         {
1206                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.autotrigger), (*vtt)->autotrigger);
1207                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.sync_master), (*vtt)->is_sync_master);
1208         }       
1209 }