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