Adrian's patches and experimental Stereo stuff - 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 master_setup(GtkWidget *wid, vtt_class *vtt)
374 {
375         vtt->set_sync_master(GTK_TOGGLE_BUTTON(wid)->active);
376 }
377
378 void client_setup(GtkWidget *wid, vtt_class *vtt)
379 {
380         int client;
381         
382         client=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client));   
383         vtt->sp_sync_client.receive_gui_value(client);
384 }
385
386 void client_setup_number(GtkWidget *wid, vtt_class *vtt)
387 {
388         int cycles;
389         
390         cycles=(int) GTK_ADJUSTMENT(vtt->gui.cycles)->value;    
391         
392         vtt->sp_sync_cycles.receive_gui_value(cycles);
393 }
394
395 /*
396 void control_changed(GtkWidget *wid, vtt_class *vtt)
397 {
398         int x,y;
399         vtt_gui *g=&vtt->gui;
400         
401         if (GTK_TOGGLE_BUTTON(g->x_scratch)->active) x=CONTROL_SCRATCH;
402         else if (GTK_TOGGLE_BUTTON(g->x_volume)->active) x=CONTROL_VOLUME;
403         else if (GTK_TOGGLE_BUTTON(g->x_lp_cutoff)->active) x=CONTROL_CUTOFF;
404         else if (GTK_TOGGLE_BUTTON(g->x_ec_feedback)->active) x=CONTROL_FEEDBACK;
405         else if (GTK_TOGGLE_BUTTON(g->x_nothing)->active) x=CONTROL_NOTHING;
406
407         if (GTK_TOGGLE_BUTTON(g->y_scratch)->active) y=CONTROL_SCRATCH;
408         else if (GTK_TOGGLE_BUTTON(g->y_volume)->active) y=CONTROL_VOLUME;
409         else if (GTK_TOGGLE_BUTTON(g->y_lp_cutoff)->active) y=CONTROL_CUTOFF;
410         else if (GTK_TOGGLE_BUTTON(g->y_ec_feedback)->active) y=CONTROL_FEEDBACK;
411         else if (GTK_TOGGLE_BUTTON(g->y_nothing)->active) y=CONTROL_NOTHING;
412         
413         vtt->set_controls(x,y);
414 }
415 */
416
417 void vg_display_xcontrol(vtt_class *vtt)
418 {
419         char buffer[2048];
420         
421         if (vtt->x_par)
422         {
423                 strcpy(buffer, vtt->x_par->get_name());
424                 if (strlen(buffer)>35) 
425                 {
426                         buffer[34] = '.';
427                         buffer[35] = '.';
428                         buffer[36] = '.';
429                         buffer[37] = 0;                 
430                 }
431                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.x_control)->child), buffer);                
432         }
433         else
434         {
435                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.x_control)->child), "Nothing");
436         }
437 }
438
439 void vg_display_ycontrol(vtt_class *vtt)
440 {
441         char buffer[2048];
442         
443         if (vtt->y_par)
444         {
445                 strcpy(buffer, vtt->y_par->get_name());
446                 if (strlen(buffer)>26) 
447                 {
448                         buffer[24] = '.';
449                         buffer[25] = '.';
450                         buffer[26] = '.';
451                         buffer[27] = 0;                 
452                 }
453                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.y_control)->child), buffer);                
454         }
455         else
456         {
457                 gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.y_control)->child), "Nothing");
458         }
459 }
460
461 void vg_xcontrol_dis(GtkWidget *wid, vtt_class *vtt)
462 {
463         vtt->set_x_input_parameter(NULL);
464 }
465
466 void vg_ycontrol_dis(GtkWidget *wid, vtt_class *vtt)
467 {
468         vtt->set_y_input_parameter(NULL);
469 }
470
471 void vg_xcontrol_set(GtkWidget *wid, tX_seqpar *sp)
472 {
473         vtt_class *vtt=(vtt_class *) sp->vtt;
474         vtt->set_x_input_parameter(sp);
475 }
476
477 void vg_ycontrol_set(GtkWidget *wid, tX_seqpar *sp)
478 {
479         vtt_class *vtt=(vtt_class *) sp->vtt;
480         vtt->set_y_input_parameter(sp);
481 }
482
483 void vg_control_menu_popup(vtt_class *vtt, int axis)
484 {
485         list <tX_seqpar *> :: iterator sp;
486         vtt_gui *g=&vtt->gui;
487         GtkWidget *item;
488
489         if (g->par_menu) gtk_object_destroy(GTK_OBJECT(g->par_menu));
490         g->par_menu=gtk_menu_new();
491         
492         item = gtk_menu_item_new_with_label("Nothing");
493         gtk_menu_append(GTK_MENU(g->par_menu), item);
494         gtk_widget_show(item);
495         if (axis) gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_xcontrol_dis), vtt);
496         else gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_ycontrol_dis), vtt);
497         
498         
499         for (sp=tX_seqpar::all.begin(); sp!=tX_seqpar::all.end(); sp++)
500         {
501                 if (((*sp)->is_mappable) && ((*sp)->vtt) == (void*) vtt)
502                 {
503                         item = gtk_menu_item_new_with_label((*sp)->get_name());
504                         gtk_menu_append(GTK_MENU(g->par_menu), item);
505                         gtk_widget_show(item);
506                         if (axis) gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_xcontrol_set), (void*) (*sp));
507                         else gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(vg_ycontrol_set), (void*) (*sp));
508                 }
509         }
510         gtk_menu_popup (GTK_MENU(g->par_menu), NULL, NULL, NULL, NULL, 0, 0);
511 }
512
513 void vg_xcontrol_popup(GtkWidget *wid, vtt_class *vtt) 
514 {
515         vg_control_menu_popup(vtt, 1);
516 }
517
518 void vg_ycontrol_popup(GtkWidget *wid, vtt_class *vtt)
519 {
520         vg_control_menu_popup(vtt, 0);
521 }
522
523 static vtt_class * fx_vtt;
524
525 void new_effect(GtkWidget *wid, LADSPA_Plugin *plugin)
526 {
527         fx_vtt->add_effect(plugin);
528 }
529
530 void fx_button_pressed(GtkWidget *wid, vtt_class *vtt)
531 {
532         vtt_gui *g=&vtt->gui;
533         GtkWidget *item;
534         int i;
535         LADSPA_Plugin *plugin;
536         char buffer[1024];
537         char oldfile[1024]="";
538         GtkWidget *submenu;
539
540         fx_vtt=vtt; /* AAAAARGH - Long live ugly code */
541
542         if (g->ladspa_menu) gtk_object_destroy(GTK_OBJECT(g->ladspa_menu));
543         g->ladspa_menu=gtk_menu_new();
544         
545         for (i=0; i<LADSPA_Plugin::getPluginCount(); i++)
546         {
547                 plugin=LADSPA_Plugin::getPluginByIndex(i);
548                 if (strcmp(plugin->get_file_name(), oldfile))
549                 {
550                         strcpy(oldfile, plugin->get_file_name());
551                         item = gtk_menu_item_new_with_label(oldfile);
552                         submenu=gtk_menu_new();
553                         gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
554                         gtk_menu_append(GTK_MENU(g->ladspa_menu), item);
555                         gtk_widget_show(item);
556                 }
557                 sprintf(buffer, "%s - [%i, %s]", plugin->getName(), plugin->getUniqueID(), plugin->getLabel());
558                 item=gtk_menu_item_new_with_label(buffer);
559                 gtk_menu_append(GTK_MENU(submenu), item);
560                 gtk_widget_show(item);
561                 gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(new_effect), plugin);
562         }
563         
564         gtk_menu_popup (GTK_MENU(g->ladspa_menu), NULL, NULL, NULL, NULL, 0, 0);
565 }
566
567 #define connect_entry(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "activate", (GtkSignalFunc) func, (void *) vtt);
568 #define connect_adj(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "value_changed", (GtkSignalFunc) func, (void *) vtt);
569 #define connect_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "clicked", (GtkSignalFunc) func, (void *) vtt);
570 #define connect_press_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "pressed", (GtkSignalFunc) func, (void *) vtt);
571 #define connect_rel_button(wid, func); gtk_signal_connect(GTK_OBJECT(g->wid), "released", (GtkSignalFunc) func, (void *) vtt);
572
573 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel);
574
575 void gui_connect_signals(vtt_class *vtt)
576 {
577         vtt_gui *g=&vtt->gui;
578
579         connect_entry(name, name_changed);
580         connect_adj(volume, volume_changed);
581         connect_button(edit, edit_vtt_buffer);
582         connect_button(reload, reload_vtt_buffer);
583         connect_adj(pitch, pitch_changed);
584         connect_adj(pan, pan_changed);
585         connect_button(file, load_file);
586         
587         connect_button(del, delete_vtt);
588 //      connect_button(clone, clone_vtt);
589         connect_button(trigger, trigger_vtt);
590         connect_button(stop, stop_vtt);
591         connect_button(autotrigger, autotrigger_toggled);
592         connect_button(loop, loop_toggled);
593         connect_button(sync_master, master_setup);
594         connect_button(sync_client, client_setup);
595         connect_adj(cycles, client_setup_number);
596 /*      
597         connect_button(x_scratch, control_changed);
598         connect_button(x_volume, control_changed);
599         connect_button(x_lp_cutoff, control_changed);
600         connect_button(x_ec_feedback, control_changed);
601         connect_button(x_nothing, control_changed);
602
603         connect_button(y_scratch, control_changed);
604         connect_button(y_volume, control_changed);
605         connect_button(y_lp_cutoff, control_changed);
606         connect_button(y_ec_feedback, control_changed);
607         connect_button(y_nothing, control_changed);
608 */      
609         connect_button(fx_button, fx_button_pressed);
610         
611         connect_button(lp_enable, lp_enabled);
612         connect_adj(lp_gain, lp_gain_changed);
613         connect_adj(lp_reso, lp_reso_changed);
614         connect_adj(lp_freq, lp_freq_changed);
615         
616         connect_button(ec_enable, ec_enabled);
617         connect_adj(ec_length, ec_length_changed);
618         connect_adj(ec_feedback, ec_feedback_changed);
619         connect_adj(ec_pan, ec_pan_changed);
620         connect_button(x_control, vg_xcontrol_popup);
621         connect_button(y_control, vg_ycontrol_popup);
622
623         static GtkTargetEntry drop_types [] = {
624                 { "text/uri-list", 0, 0}
625         };
626         static gint n_drop_types = sizeof (drop_types) / sizeof(drop_types[0]);
627         
628         gtk_drag_dest_set (GTK_WIDGET (g->file), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
629                         drop_types, n_drop_types,
630                         GDK_ACTION_COPY);
631                                                 
632         gtk_signal_connect (GTK_OBJECT (g->file), "drag_data_received",
633                         GTK_SIGNAL_FUNC(drop_file), (void *) vtt);
634
635         gtk_drag_dest_set (GTK_WIDGET (g->display), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
636                         drop_types, n_drop_types,
637                         GDK_ACTION_COPY);
638                                                 
639         gtk_signal_connect (GTK_OBJECT (g->display), "drag_data_received",
640                         GTK_SIGNAL_FUNC(drop_file), (void *) vtt);
641         
642 }
643         
644 void build_vtt_gui(vtt_class *vtt)
645 {
646         GtkWidget *tempbox;
647         GtkWidget *tempbox2;
648         GtkWidget *dummy;
649         char nice_name[FILENAME_BUTTON_MAX];
650         
651         vtt_gui *g;
652         
653         g=&vtt->gui;
654         vtt->have_gui=1;
655         g->par_menu=NULL;
656         g->ladspa_menu=NULL;
657
658         /* Building Audio Box */
659         g->audio_box=gtk_vbox_new(FALSE,2);
660         gtk_widget_show(g->audio_box);
661         
662         tempbox=gtk_hbox_new(FALSE,2);
663         gtk_widget_show(tempbox);
664         gtk_box_pack_start(GTK_BOX(g->audio_box), tempbox, WID_FIX);
665         
666         g->audio_label=gtk_label_new(vtt->name);
667         gtk_widget_show(g->audio_label);
668         gtk_box_pack_start(GTK_BOX(tempbox), g->audio_label, WID_DYN);
669
670         dummy=gtk_vseparator_new();
671         gtk_widget_show(dummy);
672         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
673
674         nicer_filename(nice_name, vtt->filename);
675         g->file = gtk_button_new_with_label(nice_name);
676         gtk_widget_show(g->file);
677         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.");
678         gtk_box_pack_start(GTK_BOX(tempbox), g->file, WID_DYN);
679
680         g->edit=tx_xpm_button_new(TX_ICON_EDIT, "Edit", 0);
681         gtk_widget_show(g->edit);
682         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.");
683         gtk_box_pack_start(GTK_BOX(tempbox), g->edit, WID_FIX);
684         
685         g->reload=tx_xpm_button_new(TX_ICON_RELOAD, "Reload", 0);
686         gtk_widget_show(g->reload);
687         gui_set_tooltip(g->reload, "Click here to reload the audiofile loaded into this turntable.");
688         gtk_box_pack_start(GTK_BOX(tempbox), g->reload, WID_FIX);
689         
690         dummy=gtk_vseparator_new();
691         gtk_widget_show(dummy);
692         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
693
694         dummy=gtk_label_new("X:");
695         gtk_widget_show(dummy);
696         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
697
698         g->x_control=gtk_button_new_with_label(vtt->x_par->get_name());
699         gtk_widget_show(g->x_control);
700         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).");
701         gtk_box_pack_start(GTK_BOX(tempbox), g->x_control, WID_DYN);
702
703         dummy=gtk_label_new("Y:");
704         gtk_widget_show(dummy);
705         gtk_box_pack_start(GTK_BOX(tempbox), dummy, WID_FIX);
706         
707         g->y_control=gtk_button_new_with_label(vtt->y_par->get_name());
708         gtk_widget_show(g->y_control);
709         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).");
710
711         gtk_box_pack_start(GTK_BOX(tempbox), g->y_control, WID_DYN);
712
713         g->display=gtk_tx_new(vtt->buffer, vtt->samples_in_buffer);
714         gtk_box_pack_start(GTK_BOX(g->audio_box), g->display, WID_DYN);
715         gtk_widget_show(g->display);    
716         
717         /* Building Control Box */
718         
719         g->control_box=gtk_vbox_new(FALSE,2);
720         gtk_widget_show(g->control_box);
721         
722         g->control_label=gtk_label_new(vtt->name);
723         gtk_widget_show(g->control_label);
724         gtk_box_pack_start(GTK_BOX(g->control_box), g->control_label, WID_FIX);
725         
726         g->scrolled_win=gtk_scrolled_window_new (NULL, NULL);
727         gtk_container_set_border_width (GTK_CONTAINER (g->scrolled_win), 0);
728         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (g->scrolled_win),
729                                     GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
730         gtk_widget_show(g->scrolled_win);
731         gtk_box_pack_start(GTK_BOX(g->control_box), g->scrolled_win, WID_DYN);
732                                     
733         g->control_subbox=gtk_vbox_new(FALSE,0);
734         gtk_scrolled_window_add_with_viewport (
735                    GTK_SCROLLED_WINDOW (g->scrolled_win), g->control_subbox);
736         gtk_widget_show(g->control_subbox);
737                    
738
739         /* Main panel */
740         
741         tX_panel *p=new tX_panel("Main", g->control_subbox);
742         g->main_panel=p;
743                         
744         g->name = gtk_entry_new_with_max_length(256);   
745         gtk_entry_set_text(GTK_ENTRY(g->name), vtt->name);
746         p->add_client_widget(g->name);
747         gui_set_tooltip(g->name, "Enter the turntable's name here.");
748         gtk_widget_set_usize(g->name, 40, g->name->requisition.height);
749         
750         g->del=gtk_button_new_with_label("Delete");
751         gui_set_tooltip(g->del, "Click here to annihilate this turntable. All events recorded for this turntable will be erased, too.");
752         p->add_client_widget(g->del);
753         
754 //      g->show_audio=gtk_toggle_button_new_with_label("Show Audio");
755 //      p->add_client_widget(g->show_audio);
756                 
757         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
758                                 
759         p=new tX_panel("Trigger", g->control_subbox);
760         g->trigger_panel=p;
761         
762         g->trigger=gtk_button_new_with_label("Trigger!");
763         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.");
764         p->add_client_widget(g->trigger);
765         
766         g->stop=gtk_button_new_with_label("Stop.");
767         gui_set_tooltip(g->stop, "Stop this turntable's playback.");
768         p->add_client_widget(g->stop);
769         
770         g->autotrigger=gtk_check_button_new_with_label("Auto");
771         p->add_client_widget(g->autotrigger);
772         gui_set_tooltip(g->autotrigger, "If turned on, this turntable will be automagically triggered whenever the audio engine is turned on.");
773         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->autotrigger), vtt->autotrigger);
774         
775         g->loop=gtk_check_button_new_with_label("Loop");
776         p->add_client_widget(g->loop);
777         gui_set_tooltip(g->loop, "Enable this option to make the turntable loop the audio data.");
778         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->loop), vtt->loop);
779         
780         g->sync_master=gtk_check_button_new_with_label("Master");
781         p->add_client_widget(g->sync_master);
782         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.");
783         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_master), vtt->is_sync_master);
784         
785         g->sync_client=gtk_check_button_new_with_label("Client");
786         p->add_client_widget(g->sync_client);
787         gui_set_tooltip(g->sync_client, "If enabled this turntable will be (re-)triggerd in relation to the sync-master turntable.");
788         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_client), vtt->is_sync_client);
789         
790         g->cycles=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->sync_cycles, 0, 10.0, 1,1,1));
791         dummy=gtk_spin_button_new(g->cycles, 1.0, 0);
792         p->add_client_widget(dummy);
793         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.");
794
795         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
796
797         dummy=gtk_button_new_with_label("FX");
798         gtk_widget_show(dummy);
799         g->fx_button=dummy;
800         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.");
801         gtk_box_pack_start(GTK_BOX(g->control_subbox), dummy, WID_FIX);
802         
803         /* Lowpass Panel */
804
805         p=new tX_panel("Lowpass", g->control_subbox);
806         g->lp_panel=p;
807                 
808         g->lp_enable=gtk_check_button_new_with_label("Enable");
809         gui_set_tooltip(g->lp_enable, "Click here to enable the built-in lowpass effect.");
810         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->lp_enable), vtt->lp_enable);
811         p->add_client_widget(vg_create_fx_bar(vtt, vtt->lp_fx, 0));
812
813         p->add_client_widget(g->lp_enable);
814
815         g->lp_gain=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_gain, 0, 2, 0.1, 0.01, 0.01));
816         g->lp_reso=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_reso, 0, 0.99, 0.1, 0.01, 0.01));
817         g->lp_freq=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_freq, 0, 1, 0.1, 0.01, 0.01));
818
819         g->lp_gaind=new tX_extdial("Input Gain", g->lp_gain);
820         p->add_client_widget(g->lp_gaind->get_widget());
821         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.");
822
823         g->lp_freqd=new tX_extdial("Frequency", g->lp_freq);
824         p->add_client_widget(g->lp_freqd->get_widget());
825         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.");
826
827         g->lp_resod=new tX_extdial("Resonance", g->lp_reso);
828         p->add_client_widget(g->lp_resod->get_widget());
829         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.");
830
831         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
832
833         /* Echo Panel */
834
835         p=new tX_panel("Echo", g->control_subbox);
836         g->ec_panel=p;
837
838         p->add_client_widget(vg_create_fx_bar(vtt, vtt->ec_fx, 0));
839         
840         g->ec_enable=gtk_check_button_new_with_label("Enable");
841         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->ec_enable), vtt->ec_enable);
842         p->add_client_widget(g->ec_enable);
843         gui_set_tooltip(g->ec_enable, "Enable the built-in echo effect.");
844
845         g->ec_length=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_length, 0, 1, 0.1, 0.01, 0.001));
846         g->ec_feedback=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_feedback, 0, 1, 0.1, 0.01, 0.001));
847         g->ec_pan=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_pan, -1.0, 1, 0.1, 0.01, 0.001));
848
849         g->ec_lengthd=new tX_extdial("Duration", g->ec_length);
850         p->add_client_widget(g->ec_lengthd->get_widget());
851         gui_set_tooltip(g->ec_lengthd->get_entry(), "Adjust the length of the echo buffer.");
852
853         g->ec_feedbackd=new tX_extdial("Feedback", g->ec_feedback);
854         p->add_client_widget(g->ec_feedbackd->get_widget());
855         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.");
856
857         g->ec_pand=new tX_extdial("Pan", g->ec_pan);
858         p->add_client_widget(g->ec_pand->get_widget());
859         gui_set_tooltip(g->ec_pand->get_entry(), "Adjust the panning of the echo effect.");
860
861         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
862         
863         /* Output */
864         
865         tempbox=gtk_hbox_new(FALSE,2);
866         gtk_widget_show(tempbox);
867         gtk_box_pack_end(GTK_BOX(g->control_box), tempbox, WID_FIX);
868         
869         tempbox2=gtk_vbox_new(FALSE,0);
870         gtk_widget_show(tempbox2);
871         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
872         
873         g->pitch=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->rel_pitch, -3, +3, 0.1, 0.01, 0.001));
874         g->pan=GTK_ADJUSTMENT(gtk_adjustment_new(0, -1, 1, 0.1, 0.01, 0.001));
875
876         g->pitchd=new tX_extdial("Pitch", g->pitch);
877         gui_set_tooltip(g->pitchd->get_entry(), "Adjust this turntable's pitch.");
878
879         gtk_box_pack_start(GTK_BOX(tempbox2), g->pitchd->get_widget(), WID_FIX);
880
881         g->pand=new tX_extdial("Pan", g->pan);
882         gtk_box_pack_start(GTK_BOX(tempbox2), g->pand->get_widget(), WID_FIX);
883         gui_set_tooltip(g->pand->get_entry(), "Specifies the position of this turntable within the stereo spectrum: -1 -> left, 0-> center, 1->right.");
884
885         tempbox2=gtk_hbox_new(FALSE,0);
886         gtk_widget_show(tempbox2);
887         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
888         
889         g->volume=GTK_ADJUSTMENT(gtk_adjustment_new(2.0-vtt->rel_volume, 0, 2, 0.01, 0.01, 0.01));
890         dummy=gtk_vscale_new(GTK_ADJUSTMENT(g->volume)); 
891         gtk_scale_set_draw_value(GTK_SCALE(dummy), False);
892         gui_set_tooltip(dummy, "Adjust this turntable's volume.");
893
894         gtk_box_pack_start(GTK_BOX(tempbox2), dummy, WID_FIX);
895         gtk_widget_show(dummy);
896
897         g->flash=gtk_tx_flash_new();
898         gtk_box_pack_start(GTK_BOX(tempbox2), g->flash, WID_FIX);
899         gtk_widget_show(g->flash);              
900
901         g->file_dialog=NULL;
902
903 //      gtk_notebook_set_page(GTK_NOTEBOOK(vtt->gui.notebook), g->current_gui);
904         
905         gui_connect_signals(vtt);
906 }
907
908 void fx_up(GtkWidget *wid, vtt_fx *effect)
909 {
910         vtt_class *vtt;
911         
912         vtt=(vtt_class*)effect->get_vtt();
913         vtt->effect_up(effect);
914 }
915
916 void fx_down(GtkWidget *wid, vtt_fx *effect)
917 {
918         vtt_class *vtt;
919         
920         vtt=(vtt_class*)effect->get_vtt();
921         vtt->effect_down(effect);
922 }
923
924
925 void fx_kill(GtkWidget *wid, vtt_fx_ladspa *effect)
926 {
927         vtt_class *vtt;
928         
929         vtt=(vtt_class*)effect->get_vtt();
930         vtt->effect_remove(effect);
931 }
932
933 GtkWidget *vg_create_fx_bar(vtt_class *vtt, vtt_fx *effect, int showdel)
934 {
935         GtkWidget *box;
936         GtkWidget *pixmap;
937         GtkWidget *button;
938         
939         box=gtk_hbox_new(FALSE,0);
940
941         if (showdel)
942         {
943                 button=gtk_button_new();
944                 pixmap=tx_pixmap_widget(TX_ICON_FX_CLOSE);
945                 gtk_container_add (GTK_CONTAINER (button), pixmap);     
946                 gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
947                 gtk_widget_show(pixmap);
948                 gtk_widget_show(button);
949                 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_kill, (void *) effect);
950         }
951
952         button=gtk_button_new();
953         pixmap=tx_pixmap_widget(TX_ICON_FX_DOWN);
954         gtk_container_add (GTK_CONTAINER (button), pixmap);     
955         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
956         gtk_widget_show(pixmap);
957         gtk_widget_show(button);
958         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_down, (void *) effect);
959
960         button=gtk_button_new();
961         pixmap=tx_pixmap_widget(TX_ICON_FX_UP);
962         gtk_container_add (GTK_CONTAINER (button), pixmap);     
963         gtk_box_pack_end(GTK_BOX(box), button, WID_FIX);
964         gtk_widget_show(pixmap);
965         gtk_widget_show(button);
966         gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) fx_up, (void *) effect);
967         
968         gtk_widget_show(box);
969         
970         return box;
971 }
972
973
974 int gtk_box_get_widget_pos(GtkBox *box, GtkWidget *child)
975 {
976         int i=0;
977         GList *list;
978  
979         list = box->children;
980         while (list)
981         {
982                 GtkBoxChild *child_info;
983                 child_info = (GtkBoxChild *) list->data;
984                 if (child_info->widget == child)
985                 break;
986                 list = list->next; i++;
987         }
988         return i;
989 }
990
991 void vg_move_fx_panel_up(GtkWidget *wid, vtt_class *vtt)
992 {
993         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
994         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos-1);
995 }
996
997 void vg_move_fx_panel_down(GtkWidget *wid, vtt_class *vtt)
998 {
999         int pos=gtk_box_get_widget_pos(GTK_BOX(vtt->gui.control_subbox), wid);
1000         gtk_box_reorder_child(GTK_BOX(vtt->gui.control_subbox), wid, pos+1);
1001 }
1002
1003 void vg_show_fx_info(GtkWidget *wid, vtt_fx *effect)
1004 {
1005         tx_l_note(effect->get_info_string());
1006 }
1007
1008 void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plugin)
1009 {
1010         char buffer[1024];
1011         
1012         vtt_gui *g;
1013         g=&vtt->gui;    
1014         tX_panel *p;
1015         list <tX_seqpar_vttfx *> :: iterator sp;
1016         
1017         strcpy(buffer, plugin->getLabel());
1018         if (strlen(buffer) > 8)
1019         {
1020                 buffer[7]='.';
1021                 buffer[8]='.';
1022                 buffer[9]='.';
1023                 buffer[10]=0;
1024         }
1025
1026         p=new tX_panel(buffer, g->control_subbox);
1027         
1028         p->add_client_widget(vg_create_fx_bar(vtt, effect, 1));
1029         
1030         for (sp = effect->controls.begin(); sp != effect->controls.end(); sp++)
1031         {
1032                         p->add_client_widget((*sp)->get_widget());
1033         }
1034
1035         gtk_signal_connect(GTK_OBJECT(p->get_labelbutton()), "clicked", (GtkSignalFunc) vg_show_fx_info, (void *) effect);
1036         gui_set_tooltip(p->get_labelbutton(), "Click here to learn more about this plugin.");
1037         effect->set_panel_widget(p->get_widget());
1038         effect->set_panel(p);
1039
1040         gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX);
1041 }
1042
1043 void gui_set_name(vtt_class *vtt, char *newname)
1044 {
1045         gtk_label_set_text(GTK_LABEL(vtt->gui.audio_label), newname);
1046         gtk_label_set_text(GTK_LABEL(vtt->gui.control_label), newname);
1047         gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
1048 }
1049
1050 void gui_set_filename (vtt_class *vtt, char *newname)
1051 {
1052         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), newname);
1053 }
1054
1055 void gui_update_display(vtt_class *vtt)
1056 {
1057         nicer_filename(global_filename_buffer, vtt->filename);
1058         gtk_label_set(GTK_LABEL(GTK_BUTTON(vtt->gui.file)->child), global_filename_buffer);
1059         gtk_tx_set_data(GTK_TX(vtt->gui.display), vtt->buffer, vtt->samples_in_buffer);
1060 }
1061
1062 void delete_gui(vtt_class *vtt)
1063 {
1064         delete vtt->gui.main_panel;
1065         delete vtt->gui.trigger_panel;
1066         
1067         delete vtt->gui.pitchd;
1068         delete vtt->gui.pand;
1069         
1070         delete vtt->gui.lp_gaind;
1071         delete vtt->gui.lp_resod;
1072         delete vtt->gui.lp_freqd;
1073         delete vtt->gui.lp_panel;
1074         
1075         delete vtt->gui.ec_lengthd;
1076         delete vtt->gui.ec_feedbackd;
1077         delete vtt->gui.ec_pand;
1078         delete vtt->gui.ec_panel;
1079         
1080         gtk_widget_destroy(vtt->gui.control_box);
1081         gtk_widget_destroy(vtt->gui.audio_box);
1082 }
1083
1084 /*
1085 void recreate_gui(vtt_class *vtt, GtkWidget *ctrl, GtkWidget *audio)
1086 {
1087         build_vtt_gui(vtt);
1088 //      gtk_notebook_set_page(GTK_NOTEBOOK(vtt->gui.notebook), g->current_gui);
1089         gtk_box_pack_start(GTK_BOX(daddy), vtt->gui.frame, TRUE, TRUE, 0);
1090         gtk_widget_show(vtt->gui.frame);
1091 }
1092
1093 void delete_gui(vtt_class *vtt)
1094 {
1095         gtk_widget_destroy(vtt->gui.frame);
1096 }*/
1097
1098 void update_all_vtts()
1099 {
1100         list <vtt_class *> :: iterator vtt;
1101         f_prec temp;
1102         
1103         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1104         {
1105                 if ((*vtt)->is_playing)
1106                 {
1107                         gtk_tx_update_pos_display(GTK_TX((*vtt)->gui.display), (*vtt)->pos_i, (*vtt)->mute);
1108 #ifdef USE_FLASH
1109                         temp=(*vtt)->max_value*(*vtt)->res_volume*vtt_class::vol_channel_adjust;
1110                         (*vtt)->max_value=0;
1111                         gtk_tx_flash_set_level((*vtt)->gui.flash, temp);
1112 #endif          
1113                 }
1114         }
1115 }
1116
1117 void cleanup_vtt(vtt_class *vtt)
1118 {
1119                 gtk_tx_cleanup_pos_display(GTK_TX(vtt->gui.display));   
1120 #ifdef USE_FLASH
1121                 gtk_tx_flash_set_level(vtt->gui.flash, 0.0);
1122                 gtk_tx_flash_clear(vtt->gui.flash);
1123 #endif          
1124 }
1125
1126 void cleanup_all_vtts()
1127 {
1128         list <vtt_class *> :: iterator vtt;
1129         
1130         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1131         {
1132                 if ((*vtt)->buffer) gtk_tx_cleanup_pos_display(GTK_TX((*vtt)->gui.display));
1133 #ifdef USE_FLASH
1134                 gtk_tx_flash_set_level((*vtt)->gui.flash, 0.0);
1135                 gtk_tx_flash_clear((*vtt)->gui.flash);
1136 #endif          
1137         }
1138 }
1139
1140 void gui_clear_master_button(vtt_class *vtt)
1141 {
1142         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_master), 0);
1143 }
1144
1145 void gui_show_frame(vtt_class *vtt, int show)
1146 {
1147         gtk_tx_show_frame(GTK_TX(vtt->gui.display), show);
1148 }
1149
1150 void show_all_guis(int show)
1151 {
1152         list <vtt_class *> :: iterator vtt;
1153 /*      
1154         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1155         {
1156                 if (show)
1157                 {
1158                         gtk_widget_show((*vtt)->gui.notebook);
1159                 }
1160                 else
1161                 {
1162                         gtk_widget_hide((*vtt)->gui.notebook);          
1163                 }
1164         }
1165         */
1166 }
1167 /*
1168 void vg_update_sync(void *p)
1169 {
1170         vtt_class *vtt=(vtt_class*) p;
1171         
1172         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client), vtt->is_sync_client);
1173 //      gtk_adjustment_set_value(vtt->gui.cycles
1174 }
1175 */
1176 #define vgui (*vtt)->gui
1177 #define v (*vtt)
1178
1179 void vg_enable_critical_buttons(int enable)
1180 {
1181         list <vtt_class *> :: iterator vtt;
1182         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1183         {
1184                 gtk_widget_set_sensitive(vgui.del, enable);
1185                 gtk_widget_set_sensitive(vgui.sync_master, enable);
1186         }
1187 }
1188
1189
1190 int vg_get_current_page(vtt_class *vtt)
1191 {
1192         return (0);
1193 }
1194
1195 void vg_set_current_page(vtt_class *vtt, int page)
1196 {
1197         vtt->gui.current_gui=page;
1198 }
1199
1200 void vg_init_all_non_seqpars()
1201 {
1202         list <vtt_class *> :: iterator vtt;
1203         
1204         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1205         {
1206                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.autotrigger), (*vtt)->autotrigger);
1207                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.sync_master), (*vtt)->is_sync_master);
1208         }       
1209 }