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