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