It's 2020...
[terminatorX.git] / src / tX_vttgui.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999-2020  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, see <http://www.gnu.org/licenses/>.
17  
18     File: tX_vttgui.cc
19  
20     Description: This implements the gtk+ GUI for the virtual turntable
21                  class implemented in tX_vtt.cc. This code is not in tX_vtt.cc
22                  for mainly to keep the GUI code divided from the audio-rendering
23                  code and as gtk+ callback to C++ method call wrapper.
24 */    
25
26 #include <gdk/gdk.h>
27 #include <gtk/gtk.h>
28 #include "tX_vttgui.h"
29 #include "tX_vtt.h"
30 #include "tX_widget.h"
31 #include "tX_mastergui.h"
32 #include "tX_loaddlg.h"
33 #include "tX_prelis.h"
34 #include "tX_pbutton.h"
35 #include "tX_global.h"
36 #include "tX_extdial.h"
37 #include "tX_panel.h"
38 #include "tX_ladspa.h"
39 #include "tX_ladspa_class.h"
40 #include "tX_engine.h"
41 #include "tX_ui_interface.h"
42 #include "tX_ui_support.h"
43 #include "tX_dialog.h"
44
45 #ifdef USE_DIAL
46 #include "tX_dial.h"
47 #endif
48
49 #include "tX_flash.h"
50 #include <stdio.h>
51 #include <ctype.h>
52 #include <string.h>
53
54 #define WID_DYN TRUE, TRUE, 0
55 #define WID_FIX FALSE, FALSE, 0
56
57 void nicer_filename(char *dest, char *source)
58 {
59                 char *fn;
60                 char temp[PATH_MAX];
61                 
62                 fn=strrchr(source, '/');
63                 if (fn) fn++;
64                 else fn=source;
65                 
66                 strcpy (temp, fn);
67                 
68                 fn=strrchr(temp, '.');
69                 if (fn) *fn=0;
70                 
71                 if (strlen(temp) > (unsigned int) globals.filename_length) {
72                         temp[globals.filename_length-3]='.';
73                         temp[globals.filename_length-2]='.';
74                         temp[globals.filename_length-1]='.';
75                         temp[globals.filename_length]=0;
76                 } 
77                 strcpy (dest, temp);
78 }
79
80 void name_changed(GtkWidget *wid, vtt_class *vtt)
81 {
82         vtt->set_name((char *) 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_get_value(GTK_ADJUSTMENT(wid)));
88 }
89
90 void pan_changed(GtkWidget *wid, vtt_class *vtt)
91 {
92       vtt->sp_pan.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
93 }
94
95 void pitch_changed(GtkWidget *wid, vtt_class *vtt)
96 {
97         vtt->sp_pitch.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
98 }
99
100 GCallback chooser_prelis(GtkWidget *w)
101 {
102         GtkFileChooser *fc=GTK_FILE_CHOOSER(gtk_widget_get_toplevel(w));
103         char *filename=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
104         
105         if (filename) {
106                 prelis_start(filename);
107                 g_free(filename);
108         } else {
109                 prelis_stop();
110         }
111         return NULL;
112 }
113
114 char global_filename_buffer[PATH_MAX];
115
116 void load_part(char *newfile, vtt_class *vtt)
117 {
118         tX_audio_error ret=TX_AUDIO_SUCCESS;
119
120         ld_create_loaddlg(TX_LOADDLG_MODE_SINGLE, 1);
121         ld_set_filename(newfile);
122
123         ret = vtt->load_file(newfile);
124         
125         ld_destroy();
126         if (ret) {
127                 switch(ret) {
128                         case TX_AUDIO_ERR_ALLOC:
129                         tx_note("Failed to load audiofile - there's not enough memory available.", true);
130                         break;
131                         case TX_AUDIO_ERR_PIPE_READ:
132                         tx_note("An error occured on reading from the piped process - probably the file format of the audiofile is not supported by this configuration - please check terminatorX' INSTALL file on howto configure terminatorX for files of this format.", true);
133                         break;
134                         case TX_AUDIO_ERR_SOX:
135                         tx_note("Failed to run sox - to load the given audiofile please ensure that sox is installed correctly.", true);
136                         break;
137                         case TX_AUDIO_ERR_MPG123:
138                         tx_note("Failed to run mpg123 - to load the given mp3 file please ensure that mpg123 (or mpg321) is installed correctly.", true);
139                         break;
140                         case TX_AUDIO_ERR_WAV_NOTFOUND:
141                         tx_note("Couldn't acces the audiofile - file not found.", true);
142                         break;
143                         case TX_AUDIO_ERR_NOT_16BIT:
144                         tx_note("The wav file doesn't use 16 bit wide samples - please compile terminatorX with libaudiofile support to enable loading of such files.", true);
145                         break;
146                         case TX_AUDIO_ERR_NOT_MONO:
147                         tx_note("The wav file is not mono - please compile terminatorX with libaudiofile support to enable loading of such files.", true);
148                         break;
149                         case TX_AUDIO_ERR_WAV_READ:
150                         tx_note("The wav file seems to be corrupt.", true);
151                         break;
152                         case TX_AUDIO_ERR_NOT_SUPPORTED:
153                         tx_note("The file format of the audiofile is not supported - please check terminatorX' INSTALL file on howto configure terminatorX for files of this format.", true);
154                         break;
155                         case TX_AUDIO_ERR_MAD_OPEN:
156                         tx_note("Failed to open this mp3 file - please ensure that the file exists and is readable.", true);
157                         break;  
158                         case TX_AUDIO_ERR_MAD_STAT:
159                         tx_note("Failed to 'stat' this mp3 file - please ensure that the file exists and is readable.", true);
160                         break;
161                         case TX_AUDIO_ERR_MAD_DECODE:
162                         tx_note("Failed to decode the mp3 stream - file is corrupt.", true);
163                         break;
164                         case TX_AUDIO_ERR_MAD_MMAP:
165                         tx_note("Failed to map the audiofile to memory - please ensure the file is readable.", true);
166                         break;
167                         case TX_AUDIO_ERR_MAD_MUNMAP:
168                         tx_note("Failed to unmap audiofile.", true);
169                         break;
170                         case TX_AUDIO_ERR_VORBIS_OPEN:
171                         tx_note("Failed to open ogg file - please ensure the file is an ogg stream and that it is readable.", true);
172                         break;                  
173                         case TX_AUDIO_ERR_VORBIS_NODATA:
174                         tx_note("The vorbis codec failed to decode any data - possibly this ogg stream is corrupt.", true);
175                         break;
176                         case TX_AUDIO_ERR_AF_OPEN:
177                         tx_note("Failed to open this file with libaudiofile - please check terminatorX' INSTALL file on howto configure terminatorX for files of this format.",true);
178                         break;
179                         case TX_AUDIO_ERR_AF_NODATA:
180                         tx_note("libaudiofile failed to decode any data - possilby the audiofile is corrupt.", true);
181                         break;
182                         default:                                        
183                         tx_note("An unknown error occured - if this bug is reproducible please report it, thanks.", true);      
184                 }
185         } else {
186                 nicer_filename(global_filename_buffer, newfile);
187         gtk_button_set_label(GTK_BUTTON(vtt->gui.file), global_filename_buffer);
188         }       
189 }
190
191 void drop_file(GtkWidget *widget, GdkDragContext *context,
192                 gint x, gint y, GtkSelectionData *selection_data,
193                 guint info, guint time, vtt_class *vtt)
194 {
195         char filename[PATH_MAX];
196         char *fn;
197         
198         strncpy(filename, (char *) gtk_selection_data_get_data(selection_data), (size_t) gtk_selection_data_get_length(selection_data));
199         gtk_drag_finish(context, TRUE, FALSE, time);
200         filename[gtk_selection_data_get_length(selection_data)]=0;
201
202         fn = strchr (filename, '\r');
203         *fn=0;  
204         
205         char *realfn=NULL;
206         char *host=NULL;
207         
208         realfn=g_filename_from_uri(filename, &host, NULL);
209         if (realfn) {
210                 fn=realfn;
211         } else {
212                 fn = strchr (filename, ':');
213                 if (fn) fn++; else fn=(char *) gtk_selection_data_get_data(selection_data);
214         }
215
216         load_part(fn, vtt);
217
218         if (realfn) g_free(realfn);
219         if (host) g_free(host);
220 }
221
222 GCallback load_file(GtkWidget *wid, vtt_class *vtt)
223 {
224         const char *extensions[]={ "mp3", "wav", "ogg", "flac", "iff", "aiff", "voc", "au", "spx", NULL };
225         char name_buf[512];
226         sprintf(name_buf, "Select Audio File for %s", vtt->name);
227         
228         GtkWidget * dialog = gtk_file_chooser_dialog_new (name_buf,
229                 GTK_WINDOW(main_window), GTK_FILE_CHOOSER_ACTION_OPEN, 
230                 "_Cancel", GTK_RESPONSE_CANCEL, 
231                 "_Open", GTK_RESPONSE_ACCEPT, NULL);
232
233                 
234         GtkFileFilter *filter=gtk_file_filter_new();
235         for (int i=0; extensions[i]!=NULL; i++) {
236                 char buffer[32]="*.";
237                 
238                 gtk_file_filter_add_pattern(filter, strcat(buffer, extensions[i]));
239                 for (unsigned int c=0; c<strlen(buffer); c++) {
240                         buffer[c]=toupper(buffer[c]);
241                 }
242                 gtk_file_filter_add_pattern(filter, buffer);
243         }
244         
245         gtk_file_filter_set_name(filter, "Audio Files");
246         gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); 
247
248         filter=gtk_file_filter_new();
249         gtk_file_filter_add_pattern (filter, "*");
250         gtk_file_filter_set_name(filter, "All Files");
251         gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); 
252         
253         if (vtt->audiofile) {
254                 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), vtt->filename); 
255         } else if (strlen(globals.current_path)>0 ) {
256                 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), globals.current_path);
257         }
258         
259         g_signal_connect (G_OBJECT(dialog), "selection-changed", G_CALLBACK(chooser_prelis), vtt);      
260
261         if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
262         char * filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
263                 gtk_widget_hide(dialog);
264                 tX_cursor::set_cursor(tX_cursor::WAIT_CURSOR);
265                 load_part(filename, vtt);
266                 strcpy(globals.current_path, filename);
267                 tX_cursor::reset_cursor();
268         }
269
270         prelis_stop();
271         gtk_widget_destroy(dialog);
272
273         return NULL;
274 }
275
276 void delete_vtt(GtkWidget *wid, vtt_class *vtt)
277 {
278         if (audioon) tx_note("Sorry, you'll have to stop playback first.");
279         else delete(vtt);
280
281         mg_update_status();
282 }
283
284 void edit_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
285 {
286         char command[2*PATH_MAX+32];
287
288         if (vtt->samples_in_buffer == 0) {
289                 tx_note("No audiofile loaded - so there's nothing to edit.", true);
290         } else if (strlen(globals.file_editor)>0) {
291                 snprintf(command, sizeof(command), "%s \"%s\" &", globals.file_editor, vtt->filename);
292                 if (system(command) < 0) {
293                         tx_note("Error running the soundfile editor.");
294                 }
295         } else {
296                 tx_note("No soundfile editor has been configured - to do so enter the soundfile editor of your choice in the options dialog.", true);
297         }
298 }
299
300 void reload_vtt_buffer(GtkWidget *wid, vtt_class *vtt)
301 {
302         char reload_buffer[PATH_MAX];
303
304         while (gtk_events_pending()) gtk_main_iteration();
305
306         if (vtt->samples_in_buffer > 0) {
307                 strcpy(reload_buffer, vtt->filename);
308                 load_part(reload_buffer, vtt);
309         }
310         else tx_note("No audiofile loaded - so there's nothing to reload.", true);
311 }
312
313 void clone_vtt(GtkWidget *wid, vtt_class *vtt)
314 {
315         vtt->stop();
316 }
317
318 void trigger_vtt(GtkWidget *wid, vtt_class *vtt)
319 {
320         vtt->sp_trigger.receive_gui_value((float) 1.0);
321 }
322
323 void stop_vtt(GtkWidget *wid, vtt_class *vtt)
324 {
325         vtt->sp_trigger.receive_gui_value((float) 0.0);
326 }
327
328 void autotrigger_toggled(GtkWidget *wid, vtt_class *vtt)
329 {
330         vtt->set_autotrigger(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid)));
331 }
332
333 void loop_toggled(GtkWidget *wid, vtt_class *vtt)
334 {
335         vtt->sp_loop.receive_gui_value(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid)));
336 }
337
338 void lp_enabled(GtkWidget *wid, vtt_class *vtt)
339 {
340         vtt->sp_lp_enable.receive_gui_value(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid)));
341 }
342
343 void lp_gain_changed(GtkWidget *wid, vtt_class *vtt)
344 {
345         vtt->sp_lp_gain.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
346 }
347
348 void lp_reso_changed(GtkWidget *wid, vtt_class *vtt)
349 {
350         vtt->sp_lp_reso.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
351 }
352
353 void lp_freq_changed(GtkWidget *wid, vtt_class *vtt)
354 {
355         vtt->sp_lp_freq.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
356 }
357
358 void ec_enabled(GtkWidget *wid, vtt_class *vtt)
359 {
360         vtt->sp_ec_enable.receive_gui_value(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid)));
361 }
362
363 #ifdef USE_ALSA_MIDI_IN
364 void midi_mapping_clicked(GtkWidget *wid, vtt_class *vtt)
365 {
366         tX_engine::get_instance()->get_midi()->configure_bindings(vtt);
367 }
368 #endif
369
370 void ec_length_changed(GtkWidget *wid, vtt_class *vtt)
371 {
372         vtt->sp_ec_length.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
373 }
374
375 void ec_feedback_changed(GtkWidget *wid, vtt_class *vtt)
376 {
377         vtt->sp_ec_feedback.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
378 }
379
380 void ec_pan_changed(GtkWidget *wid, vtt_class *vtt)
381 {
382         vtt->sp_ec_pan.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
383 }
384
385 void ec_volume_changed(GtkWidget *wid, vtt_class *vtt)
386 {
387         vtt->sp_ec_volume.receive_gui_value(gtk_adjustment_get_value(GTK_ADJUSTMENT(wid)));
388 }
389
390 void master_setup(GtkWidget *wid, vtt_class *vtt)
391 {
392         vtt->set_sync_master(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid)));
393 }
394
395 void client_setup(GtkWidget *wid, vtt_class *vtt)
396 {
397         int client;
398         
399         client=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_client));   
400         vtt->sp_sync_client.receive_gui_value(client);
401 }
402
403 void client_setup_number(GtkWidget *wid, vtt_class *vtt)
404 {
405         int cycles;
406         
407         cycles=(int) gtk_adjustment_get_value(GTK_ADJUSTMENT(vtt->gui.cycles));
408         
409         vtt->sp_sync_cycles.receive_gui_value(cycles);
410 }
411
412 void mute_volume(GtkWidget *widget, vtt_class *vtt)
413 {
414         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
415                 vtt->set_mix_mute(1);
416         } else {
417                 vtt->set_mix_mute(0);
418         }
419 }
420
421 void solo_vtt(GtkWidget *widget, vtt_class *vtt)
422 {
423         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
424                 vtt->set_mix_solo(1);
425         } else {
426                 vtt->set_mix_solo(0);
427         }
428 }      
429
430 void minimize_control_panel(GtkWidget *wid, vtt_class *vtt)
431 {
432         vtt->hide_control(true);
433 }
434
435 void unminimize_control_panel(GtkWidget *wid, vtt_class *vtt)
436 {
437         vtt->hide_control(false);
438 }
439
440 void minimize_audio_panel(GtkWidget *wid, vtt_class *vtt)
441 {
442         vtt->hide_audio(true);
443 }
444
445 void unminimize_audio_panel(GtkWidget *wid, vtt_class *vtt)
446 {
447         vtt->hide_audio(false);
448 }
449
450 void vg_xcontrol_dis(GtkWidget *wid, vtt_class *vtt)
451 {
452         vtt->set_x_input_parameter(NULL);
453 }
454
455 void vg_ycontrol_dis(GtkWidget *wid, vtt_class *vtt)
456 {
457         vtt->set_y_input_parameter(NULL);
458 }
459
460 void vg_xcontrol_set(GtkWidget *wid, tX_seqpar *sp)
461 {
462         vtt_class *vtt=(vtt_class *) sp->vtt;
463         vtt->set_x_input_parameter(sp);
464 }
465
466 void vg_ycontrol_set(GtkWidget *wid, tX_seqpar *sp)
467 {
468         vtt_class *vtt=(vtt_class *) sp->vtt;
469         vtt->set_y_input_parameter(sp);
470 }
471
472 gboolean vg_delete_pitch_adjust (GtkWidget *wid, vtt_class *vtt) {
473         vtt->gui.adjust_dialog=NULL;
474         return FALSE;
475 }
476
477 void vg_do_pitch_adjust (GtkWidget *wid, vtt_class *vtt) {
478         int master_cycles=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(vtt->gui.adjust_dialog, "master_cycles")));
479         int cycles=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(vtt->gui.adjust_dialog, "cycles")));
480         bool create_event=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(vtt->gui.adjust_dialog, "create_event")));
481
482         vtt->adjust_to_master_pitch(master_cycles, cycles, create_event);
483         
484         gtk_widget_destroy(vtt->gui.adjust_dialog);
485 }
486
487 void vg_cancel_pitch_adjust (GtkWidget *wid, vtt_class *vtt) {
488         gtk_widget_destroy(vtt->gui.adjust_dialog);
489 }
490
491 void vg_adjust_pitch_vtt(GtkWidget *wid, vtt_class *vtt) {
492         if (vtt->gui.adjust_dialog) {
493                 gtk_widget_destroy(vtt->gui.adjust_dialog);
494                 return;
495         }
496         
497         if (!vtt_class::sync_master) {
498                 tx_note("No master turntable to adjust pitch to selected.", true);
499                 return;
500         }
501         
502         if (vtt==vtt_class::sync_master) {
503                 tx_note("This is the master turntable - cannot adjust a turntable to itself.", true);
504                 return;
505         }
506         
507         vtt->gui.adjust_dialog=create_tx_adjust();
508         tX_set_icon(vtt->gui.adjust_dialog);
509         gtk_widget_show(vtt->gui.adjust_dialog);
510         
511         GtkWidget *ok_button=lookup_widget(vtt->gui.adjust_dialog, "ok");
512         GtkWidget *cancel_button=lookup_widget(vtt->gui.adjust_dialog, "cancel");
513         
514         g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(vg_do_pitch_adjust), vtt);
515         g_signal_connect(G_OBJECT(vtt->gui.adjust_dialog), "destroy", G_CALLBACK(vg_delete_pitch_adjust), vtt);
516         g_signal_connect(G_OBJECT(cancel_button), "clicked", G_CALLBACK(vg_cancel_pitch_adjust), vtt);
517 }
518
519 static gint vg_mouse_mapping_pressed(GtkWidget *wid, GdkEventButton *event, vtt_class *vtt) {
520         if (vtt->gui.mouse_mapping_menu) {
521                 gtk_widget_destroy(vtt->gui.mouse_mapping_menu);
522                 vtt->gui.mouse_mapping_menu=NULL;
523         }
524         /* gtk+ seems to cleanup the submenus automatically */
525         
526         vtt->gui.mouse_mapping_menu=gtk_menu_new();
527         GtkWidget *x_item;
528         GtkWidget *y_item;
529         
530         x_item=gtk_menu_item_new_with_label("X-axis (Left <-> Right)");
531         gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.mouse_mapping_menu), x_item);
532         gtk_widget_show(x_item);
533
534         y_item=gtk_menu_item_new_with_label("Y-axis (Up <-> Down)");
535         gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.mouse_mapping_menu), y_item);
536         gtk_widget_show(y_item);
537         
538         vtt->gui.mouse_mapping_menu_x=gtk_menu_new();
539         vtt->gui.mouse_mapping_menu_y=gtk_menu_new();
540         
541         GtkWidget *item;
542         GtkWidget *item_to_activate=NULL;
543         
544         /* Filling the X menu */
545         item = gtk_check_menu_item_new_with_label("Disable");
546         gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.mouse_mapping_menu_x), item);
547         gtk_widget_show(item);
548         g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(vg_xcontrol_dis), vtt);
549         if (vtt->x_par==NULL) item_to_activate=item;
550
551         list <tX_seqpar *> :: iterator sp;
552
553         for (sp=tX_seqpar::all->begin(); sp!=tX_seqpar::all->end(); sp++) {
554                 if (((*sp)->is_mappable) && ((*sp)->vtt) == (void*) vtt) {
555                         item=gtk_check_menu_item_new_with_label((*sp)->get_name());
556                         gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.mouse_mapping_menu_x), item);
557                         gtk_widget_show(item);
558                         g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(vg_xcontrol_set), (void*) (*sp));
559                         
560                         if (vtt->x_par==(*sp)) item_to_activate=item;
561                 }
562         }
563
564         if (item_to_activate) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item_to_activate), TRUE);
565         
566         /* Filling the Y menu */
567         item_to_activate=NULL;
568         
569         item = gtk_check_menu_item_new_with_label("Disable");
570         gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.mouse_mapping_menu_y), item);
571         gtk_widget_show(item);
572         g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(vg_ycontrol_dis), vtt);
573         if (vtt->y_par==NULL) item_to_activate=item;
574
575         for (sp=tX_seqpar::all->begin(); sp!=tX_seqpar::all->end(); sp++) {
576                 if (((*sp)->is_mappable) && ((*sp)->vtt) == (void*) vtt) {
577                         item=gtk_check_menu_item_new_with_label((*sp)->get_name());
578                         gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.mouse_mapping_menu_y), item);
579                         gtk_widget_show(item);
580                         g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(vg_ycontrol_set), (void*) (*sp));
581                         
582                         if (vtt->y_par==(*sp)) item_to_activate=item;
583                 }
584         }
585
586         if (item_to_activate) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item_to_activate), TRUE);
587         
588         gtk_menu_item_set_submenu(GTK_MENU_ITEM(x_item), vtt->gui.mouse_mapping_menu_x);
589         gtk_menu_item_set_submenu(GTK_MENU_ITEM(y_item), vtt->gui.mouse_mapping_menu_y);
590         gtk_menu_popup (GTK_MENU(vtt->gui.mouse_mapping_menu), NULL, NULL, NULL, NULL, 0, 0);
591         
592         g_signal_emit_by_name(G_OBJECT(wid), "released", vtt);
593         
594         return TRUE;
595 }
596
597 static gint vg_file_button_pressed(GtkWidget *wid, GdkEventButton *event, vtt_class *vtt) {
598         if (vtt->gui.file_menu==NULL) {
599                 GtkWidget *item;
600                 
601                 vtt->gui.file_menu=gtk_menu_new();
602                 item=gtk_menu_item_new_with_label("Load audio file");
603                 gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.file_menu), item);
604                 gtk_widget_show(item);
605                 
606                 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(load_file), vtt);
607                 
608                 item=gtk_menu_item_new_with_label("Edit audio file");
609                 gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.file_menu), item);
610                 gtk_widget_show(item);
611
612                 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(edit_vtt_buffer), vtt);
613
614                 item=gtk_menu_item_new_with_label("Reload current audio file");
615                 gtk_menu_shell_append(GTK_MENU_SHELL(vtt->gui.file_menu), item);
616                 gtk_widget_show(item);
617
618                 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(reload_vtt_buffer), vtt);
619         }
620         
621         gtk_menu_popup(GTK_MENU(vtt->gui.file_menu), NULL, NULL, NULL, NULL, 0,0);
622         /* gtk+ is really waiting for this.. */
623         g_signal_emit_by_name(G_OBJECT(wid), "released", vtt);
624         
625         return TRUE;
626 }
627
628 void vg_adjust_zoom(GtkWidget *wid, vtt_class *vtt) {   
629         GtkAdjustment *adj=gtk_range_get_adjustment(GTK_RANGE(vtt->gui.zoom));
630         gtk_tx_set_zoom(GTK_TX(vtt->gui.display), gtk_adjustment_get_value(adj)/100.0, vtt->is_playing);
631 }
632
633 static gint fx_button_pressed(GtkWidget *wid, GdkEventButton *event, vtt_class *vtt)
634 {
635         vtt_gui *g=&vtt->gui;
636
637         LADSPA_Class::set_current_vtt(vtt);
638
639         if (g->ladspa_menu) gtk_widget_destroy(GTK_WIDGET(g->ladspa_menu));
640         g->ladspa_menu=LADSPA_Class::get_ladspa_menu();
641         gtk_menu_popup (GTK_MENU(g->ladspa_menu), NULL, NULL, NULL, NULL, 0, 0);
642
643         /* gtk+ is really waiting for this.. */
644         g_signal_emit_by_name(G_OBJECT(wid), "released", vtt);
645         
646         return TRUE;
647 }
648
649 static gint stereo_fx_button_pressed(GtkWidget *wid, GdkEventButton *event, vtt_class *vtt)
650 {
651         vtt_gui *g=&vtt->gui;
652
653         LADSPA_Class::set_current_vtt(vtt);
654
655         if (g->ladspa_menu) gtk_widget_destroy(GTK_WIDGET(g->ladspa_menu));
656         g->ladspa_menu=LADSPA_Class::get_stereo_ladspa_menu();
657         gtk_menu_popup (GTK_MENU(g->ladspa_menu), NULL, NULL, NULL, NULL, 0, 0);
658
659         /* gtk+ is really waiting for this.. */
660         g_signal_emit_by_name(G_OBJECT(wid), "released", vtt);
661         
662         return TRUE;
663 }
664
665 #define TOOLTIP_LENGTH 2048
666
667 void gui_set_name(vtt_class *vtt, char *newname)
668 {
669         char bold_name[128];
670         strcpy(bold_name, "<b>");
671         strcat(bold_name, newname);
672         strcat(bold_name, "</b>");
673         
674         gtk_label_set_markup(GTK_LABEL(vtt->gui.audio_label), bold_name);
675         gtk_label_set_markup(GTK_LABEL(vtt->gui.control_label), bold_name);
676         gtk_entry_set_text(GTK_ENTRY(vtt->gui.name), newname);
677         char tooltip[2048];
678         
679         if (vtt->gui.audio_minimized_panel_bar_button!=NULL) {
680                 gtk_label_set_text(GTK_LABEL(vtt->gui.audio_minimized_panel_bar_label), newname);
681                 snprintf(tooltip, TOOLTIP_LENGTH, "Show \"%s\" audio panel.", newname);
682                 gui_set_tooltip(vtt->gui.audio_minimized_panel_bar_button, tooltip);
683         }
684
685         if (vtt->gui.control_minimized_panel_bar_button!=NULL) {
686                 gtk_label_set_text(GTK_LABEL(vtt->gui.control_minimized_panel_bar_label), newname);
687                 snprintf(tooltip, TOOLTIP_LENGTH, "Show \"%s\" control panel.", newname);
688                 gui_set_tooltip(vtt->gui.control_minimized_panel_bar_button, tooltip);
689         }
690 }
691
692 f_prec gui_get_audio_x_zoom(vtt_class *vtt) {
693         return gtk_tx_get_zoom(GTK_TX(vtt->gui.display));
694 }
695
696 int vttgui_zoom_depth=0;
697
698 void gui_set_audio_x_zoom(vtt_class *vtt, f_prec value) {
699         if (vttgui_zoom_depth==0) {
700                 vttgui_zoom_depth=1;
701                 gtk_range_set_value(GTK_RANGE(vtt->gui.zoom), value*100.0);
702                 vttgui_zoom_depth=0;
703         } else {
704                 gtk_tx_set_zoom(GTK_TX(vtt->gui.display), value, vtt->is_playing);
705         }
706 }
707
708 void gui_scroll_callback(GtkWidget *tx, GdkEventScroll *eventScroll, gpointer userdata) {
709         vtt_class *vtt = (vtt_class *) userdata;
710         f_prec zoom = gui_get_audio_x_zoom(vtt);
711
712         if ((eventScroll->direction == GDK_SCROLL_UP) || (eventScroll->direction == GDK_SCROLL_RIGHT)) {
713                 zoom += 0.1;
714         } else if ((eventScroll->direction == GDK_SCROLL_DOWN) || (eventScroll->direction == GDK_SCROLL_LEFT)) {
715                 zoom -= 0.1;
716         }
717         gui_set_audio_x_zoom(vtt, zoom);
718 }
719
720
721 #define connect_entry(wid, func); g_signal_connect(G_OBJECT(g->wid), "activate", G_CALLBACK(func), (void *) vtt);
722 #define connect_adj(wid, func); g_signal_connect(G_OBJECT(g->wid), "value_changed", G_CALLBACK(func), (void *) vtt);
723 #define connect_button(wid, func); g_signal_connect(G_OBJECT(g->wid), "clicked", G_CALLBACK(func), (void *) vtt);
724 #define connect_range(wid, func); g_signal_connect(G_OBJECT(gtk_range_get_adjustment(GTK_RANGE(g->wid))), "value_changed", G_CALLBACK(func), (void *) vtt);
725 #define connect_scale_format(wid, func); g_signal_connect(G_OBJECT(g->wid), "format-value", G_CALLBACK(func), (void *) vtt);
726 #define connect_press_button(wid, func); g_signal_connect(G_OBJECT(g->wid), "button_press_event", G_CALLBACK(func), (void *) vtt);
727 #define connect_rel_button(wid, func); g_signal_connect(G_OBJECT(g->wid), "released", G_CALLBACK(func), (void *) vtt);
728
729 gchar dnd_uri[128];
730
731 void gui_connect_signals(vtt_class *vtt)
732 {
733         vtt_gui *g=&vtt->gui;
734         strncpy(dnd_uri, "text/uri-list", 128);
735
736         connect_entry(name, name_changed);
737         connect_adj(volume, volume_changed);
738         connect_adj(pitch, pitch_changed);
739         connect_adj(pan, pan_changed);
740         connect_press_button(file, vg_file_button_pressed);
741         
742         connect_button(del, delete_vtt);
743         connect_button(trigger, trigger_vtt);
744         connect_button(stop, stop_vtt);
745         connect_button(autotrigger, autotrigger_toggled);
746         connect_button(loop, loop_toggled);
747         connect_button(sync_master, master_setup);
748         connect_button(sync_client, client_setup);
749         connect_button(adjust_button, vg_adjust_pitch_vtt);
750         connect_adj(cycles, client_setup_number);
751         connect_press_button(fx_button, fx_button_pressed);
752         connect_press_button(stereo_fx_button, stereo_fx_button_pressed);
753         
754         connect_button(lp_enable, lp_enabled);
755         connect_adj(lp_gain, lp_gain_changed);
756         connect_adj(lp_reso, lp_reso_changed);
757         connect_adj(lp_freq, lp_freq_changed);
758         
759         connect_button(ec_enable, ec_enabled);
760 #ifdef USE_ALSA_MIDI_IN 
761         connect_button(midi_mapping, midi_mapping_clicked);
762 #endif  
763         connect_adj(ec_length, ec_length_changed);
764         connect_adj(ec_feedback, ec_feedback_changed);
765         connect_adj(ec_pan, ec_pan_changed);
766         connect_adj(ec_volume, ec_volume_changed);      
767         connect_range(zoom, vg_adjust_zoom);
768         //connect_scale_format(zoom, vg_format_zoom);
769         connect_press_button(mouse_mapping, vg_mouse_mapping_pressed);
770         connect_button(control_minimize, minimize_control_panel);
771         connect_button(audio_minimize, minimize_audio_panel);
772
773         gtk_widget_add_events(GTK_WIDGET(g->display), GDK_SCROLL_MASK);
774   g_signal_connect(G_OBJECT(g->display), "scroll-event", G_CALLBACK(gui_scroll_callback), vtt);
775
776         static GtkTargetEntry drop_types [] = {
777                 { dnd_uri, 0, 0}
778         };
779         static gint n_drop_types = sizeof (drop_types) / sizeof(drop_types[0]);
780         
781         gtk_drag_dest_set (GTK_WIDGET (g->file), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
782                         drop_types, n_drop_types,
783                         GDK_ACTION_COPY);
784                                                 
785         g_signal_connect (G_OBJECT (g->file), "drag_data_received",
786                         G_CALLBACK(drop_file), (void *) vtt);
787
788         gtk_drag_dest_set (GTK_WIDGET (g->display), (GtkDestDefaults) (GTK_DEST_DEFAULT_MOTION |GTK_DEST_DEFAULT_HIGHLIGHT |GTK_DEST_DEFAULT_DROP),
789                         drop_types, n_drop_types,
790                         GDK_ACTION_COPY);
791                                                 
792         g_signal_connect (G_OBJECT (g->display), "drag_data_received",
793                         G_CALLBACK(drop_file), (void *) vtt);
794         
795 }
796
797 void build_vtt_gui(vtt_class *vtt)
798 {
799         GtkWidget *tempbox;
800         GtkWidget *tempbox2;
801         GtkWidget *tempbox3;
802         GtkWidget *dummy;
803         char nice_name[256];
804         
805         vtt_gui *g;
806         
807         g=&vtt->gui;
808         vtt->have_gui=1;
809         g->par_menu=NULL;
810         g->ladspa_menu=NULL;
811
812         /* Building Audio Box */
813         g->audio_box=gtk_box_new(GTK_ORIENTATION_VERTICAL,2);
814         gtk_widget_show(g->audio_box);
815         
816         tempbox2=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2);
817         gtk_widget_show(tempbox2);
818         gtk_box_pack_start(GTK_BOX(g->audio_box), tempbox2, WID_FIX);
819         
820         tempbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2);
821         gtk_box_set_homogeneous(GTK_BOX(tempbox), TRUE);
822         gtk_widget_show(tempbox);
823         gtk_box_pack_start(GTK_BOX(tempbox2), tempbox, WID_DYN);
824
825         GtkWidget *pixmap;
826         g->audio_minimize=create_top_button(MINIMIZE);
827         gtk_box_pack_end(GTK_BOX(tempbox2), g->audio_minimize, WID_FIX);
828         gtk_widget_show(g->audio_minimize);
829
830         g->audio_label=gtk_label_new(vtt->name);
831         gtk_widget_set_halign(g->audio_label, GTK_ALIGN_START);
832         gtk_widget_set_margin_start(g->audio_label, 10);
833         gtk_widget_show(g->audio_label);
834         gtk_box_pack_start(GTK_BOX(tempbox), g->audio_label, WID_DYN);
835
836         nicer_filename(nice_name, vtt->filename);
837         g->file = gtk_button_new_with_label(nice_name);
838         gtk_widget_show(g->file);
839         gui_set_tooltip(g->file, "Click to Load/Edit/Reload a sample for this turntable. To load you can also drag a file and drop it over this button or the sound data display below.");
840         gtk_box_pack_start(GTK_BOX(tempbox), g->file, WID_DYN);
841
842         g->mouse_mapping=gtk_button_new_with_label("Mouse");
843         gtk_widget_show(g->mouse_mapping);
844         gui_set_tooltip(g->mouse_mapping, "Determines what parameters should be affected on mouse motion in mouse grab mode.");
845         gtk_box_pack_start(GTK_BOX(tempbox2), g->mouse_mapping, WID_FIX);
846
847 #ifdef USE_ALSA_MIDI_IN
848         g->midi_mapping=gtk_button_new_with_label("MIDI");
849         gtk_widget_show(g->midi_mapping);
850         gui_set_tooltip(g->midi_mapping, "Determines what parameters should be bound to what MIDI events.");
851         gtk_box_pack_start(GTK_BOX(tempbox2), g->midi_mapping, WID_FIX);
852         
853         if (!tX_engine::get_instance()->get_midi()->get_is_open()) {
854                 gtk_widget_set_sensitive(g->midi_mapping, FALSE);
855         }
856 #endif
857
858         tempbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
859
860         g->display=gtk_tx_new(vtt->buffer, vtt->samples_in_buffer);
861         gtk_box_pack_start(GTK_BOX(tempbox), g->display, WID_DYN);
862         gtk_widget_show(g->display);    
863         
864         g->zoom=gtk_scale_new_with_range(GTK_ORIENTATION_VERTICAL, 0,99.0,1.0);
865         gtk_range_set_inverted(GTK_RANGE(g->zoom), TRUE);
866         gtk_scale_set_draw_value(GTK_SCALE(g->zoom), TRUE);
867         gtk_scale_set_digits(GTK_SCALE(g->zoom), 0);
868         gtk_scale_set_value_pos(GTK_SCALE(g->zoom), GTK_POS_BOTTOM);
869         gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(g->zoom)), 0);
870         
871         gui_set_tooltip(g->zoom, "Set the zoom-level for the audio data display.");
872         gtk_box_pack_start(GTK_BOX(tempbox), g->zoom, WID_FIX);
873         gtk_widget_show(g->zoom);
874         
875         gtk_box_pack_start(GTK_BOX(g->audio_box), tempbox, WID_DYN);
876         gtk_widget_show(tempbox);
877         
878         /* Building Control Box */
879         
880         g->control_box=gtk_box_new(GTK_ORIENTATION_VERTICAL,2);
881         gtk_widget_show(g->control_box);
882
883         tempbox2=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
884         gtk_widget_show(tempbox2);
885         gtk_box_pack_start(GTK_BOX(g->control_box), tempbox2, WID_FIX);
886
887         g->control_label=gtk_label_new(vtt->name);
888         gtk_widget_show(g->control_label);
889         gtk_box_pack_start(GTK_BOX(tempbox2), g->control_label, WID_DYN);
890
891         g->control_minimize=create_top_button(MINIMIZE);
892         gtk_box_pack_end(GTK_BOX(tempbox2), g->control_minimize, WID_FIX);
893         gtk_widget_show(g->control_minimize);
894
895         g->scrolled_win=gtk_scrolled_window_new (NULL, NULL);
896         gtk_container_set_border_width (GTK_CONTAINER (g->scrolled_win), 0);
897         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (g->scrolled_win),
898                                     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
899         gtk_widget_show(g->scrolled_win);
900         gtk_box_pack_start(GTK_BOX(g->control_box), g->scrolled_win, WID_DYN);
901                                     
902         g->control_subbox=gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
903 #if GTK_CHECK_VERSION(3,8,0)
904         gtk_container_add(GTK_CONTAINER(g->scrolled_win), g->control_subbox);
905 #else
906         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(g->scrolled_win), g->control_subbox);
907 #endif
908         gtk_widget_show(g->control_subbox);
909
910         g->static_box = gtk_list_box_new();
911         gtk_list_box_set_selection_mode (GTK_LIST_BOX (g->static_box), GTK_SELECTION_NONE);
912         gtk_widget_show(g->static_box);
913         gtk_container_add(GTK_CONTAINER(g->control_subbox), g->static_box);
914
915         /* Main panel */
916         
917         tX_panel *p=new tX_panel("Main", g->control_subbox);
918         g->main_panel=p;
919                         
920         g->name = gtk_entry_new();
921         gtk_entry_set_max_length(GTK_ENTRY(g->name), 256);
922         gtk_entry_set_text(GTK_ENTRY(g->name), vtt->name);
923         gtk_entry_set_width_chars(GTK_ENTRY(g->name), 10);
924         gtk_entry_set_max_width_chars(GTK_ENTRY(g->name), 10);
925         p->add_client_widget(g->name);
926         gui_set_tooltip(g->name, "Enter the turntable's name here.");
927         //gtk_widget_set_size_request(g->name, 40, -1);
928
929         g->del=gtk_button_new_with_label("Delete");
930         gui_set_tooltip(g->del, "Click here to annihilate this turntable. All events recorded for this turntable will be erased, too.");
931         p->add_client_widget(g->del);
932         
933         g->adjust_button=gtk_button_new_with_label("Pitch Adj.");
934         gui_set_tooltip(g->adjust_button, "Activate this button to adjust this turntable's speed to the master turntable's speed.");
935         p->add_client_widget(g->adjust_button);
936
937         gtk_list_box_insert(GTK_LIST_BOX(g->static_box), p->get_list_box_row(), -1);
938                                 
939         p=new tX_panel("Playback", g->control_subbox);
940         g->trigger_panel=p;
941         
942         g->trigger=gtk_button_new_with_label("Trigger");
943         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.");
944         p->add_client_widget(g->trigger);
945         
946         g->stop=gtk_button_new_with_label("Stop");
947         gui_set_tooltip(g->stop, "Stop this turntable's playback.");
948         p->add_client_widget(g->stop);
949         g_signal_connect(G_OBJECT(g->trigger), "button_press_event", (GCallback) tX_seqpar::tX_seqpar_press, &vtt->sp_trigger);         
950         g_signal_connect(G_OBJECT(g->stop), "button_press_event", (GCallback) tX_seqpar::tX_seqpar_press, &vtt->sp_trigger);            
951         
952         g->autotrigger=gtk_check_button_new_with_label("Auto");
953         p->add_client_widget(g->autotrigger);
954         gui_set_tooltip(g->autotrigger, "If turned on, this turntable will be automagically triggered whenever the audio engine is turned on.");
955         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->autotrigger), vtt->autotrigger);
956
957         g->loop=gtk_check_button_new_with_label("Loop");
958         p->add_client_widget(g->loop);
959         gui_set_tooltip(g->loop, "Enable this option to make the turntable loop the audio data.");
960         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->loop), vtt->loop);
961         g_signal_connect(G_OBJECT(g->loop), "button_press_event", (GCallback) tX_seqpar::tX_seqpar_press, &vtt->sp_loop);               
962         
963         g->sync_master=gtk_check_button_new_with_label("Master");
964         p->add_client_widget(g->sync_master);
965         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.");
966         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_master), vtt->is_sync_master);
967         
968         g->sync_client=gtk_check_button_new_with_label("Client");
969         p->add_client_widget(g->sync_client);
970         gui_set_tooltip(g->sync_client, "If enabled this turntable will be (re-)triggerd in relation to the sync-master turntable.");
971         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->sync_client), vtt->is_sync_client);
972         g_signal_connect(G_OBJECT(g->sync_client), "button_press_event", (GCallback) tX_seqpar::tX_seqpar_press, &vtt->sp_sync_client); 
973         
974         g->cycles=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->sync_cycles, 0, 10.0, 1,1,0));
975         dummy=gtk_spin_button_new(g->cycles, 1.0, 0);
976         p->add_client_widget(dummy);
977         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.");
978         g_signal_connect(G_OBJECT(dummy), "button_press_event", (GCallback) tX_seqpar::tX_seqpar_press, &vtt->sp_sync_cycles);  
979
980         gtk_list_box_insert(GTK_LIST_BOX(g->static_box), p->get_list_box_row(), -1);
981         
982         dummy=gtk_header_bar_new();
983         gtk_header_bar_set_title(GTK_HEADER_BAR(dummy), "FX");
984         gtk_header_bar_set_has_subtitle(GTK_HEADER_BAR(dummy), FALSE);
985         gtk_widget_show(dummy);
986         g->fx_button=create_top_button(ADD_ITEM);
987         gtk_header_bar_pack_end(GTK_HEADER_BAR(dummy), g->fx_button);
988         gtk_widget_show(g->fx_button);
989         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.");
990         gtk_box_pack_start(GTK_BOX(g->control_subbox), dummy, WID_FIX);
991         
992         g->fx_box = gtk_list_box_new();
993         gtk_list_box_set_selection_mode (GTK_LIST_BOX (g->fx_box), GTK_SELECTION_NONE);
994         gtk_box_pack_start(GTK_BOX(g->control_subbox), g->fx_box, WID_FIX);
995         gtk_widget_show(g->fx_box);
996
997         /* Lowpass Panel */
998
999         p=new tX_panel("Lowpass", g->control_subbox, NULL, vtt->get_lp_effect());
1000         g->lp_panel=p;
1001                 
1002         g->lp_enable=gtk_check_button_new_with_label("Enable");
1003         gui_set_tooltip(g->lp_enable, "Click here to enable the built-in lowpass effect.");
1004         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->lp_enable), vtt->lp_enable);
1005         g_signal_connect(G_OBJECT(g->lp_enable), "button_press_event", (GCallback) tX_seqpar::tX_seqpar_press, &vtt->sp_lp_enable);     
1006
1007         p->add_client_widget(g->lp_enable);
1008
1009         g->lp_gain=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_gain, 0, 2, 0.1, 0.01, 0.01));
1010         g->lp_reso=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_reso, 0, 0.99, 0.1, 0.01, 0.01));
1011         g->lp_freq=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->lp_freq, 0, 1, 0.1, 0.01, 0.01));
1012
1013         g->lp_gaind=new tX_extdial("Input Gain", g->lp_gain, &vtt->sp_lp_gain);
1014         p->add_client_widget(g->lp_gaind->get_widget());
1015         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.");
1016
1017         g->lp_freqd=new tX_extdial("Frequency", g->lp_freq, &vtt->sp_lp_freq);
1018         p->add_client_widget(g->lp_freqd->get_widget());
1019         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.");
1020
1021         g->lp_resod=new tX_extdial("Resonance", g->lp_reso, &vtt->sp_lp_reso);
1022         p->add_client_widget(g->lp_resod->get_widget());
1023         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.");
1024
1025         gtk_list_box_insert(GTK_LIST_BOX(g->fx_box), p->get_list_box_row(), -1);
1026
1027         /* Echo Panel */
1028
1029         p=new tX_panel("Echo", g->control_subbox, NULL, vtt->get_ec_effect());
1030         g->ec_panel=p;
1031
1032         g->ec_enable=gtk_check_button_new_with_label("Enable");
1033         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->ec_enable), vtt->ec_enable);
1034         p->add_client_widget(g->ec_enable);
1035         gui_set_tooltip(g->ec_enable, "Enable the built-in echo effect.");
1036         g_signal_connect(G_OBJECT(g->ec_enable), "button_press_event", (GCallback) tX_seqpar::tX_seqpar_press, &vtt->sp_ec_enable);     
1037
1038         g->ec_length=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_length, 0, 1, 0.1, 0.01, 0.001));
1039         g->ec_feedback=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_feedback, 0, 1, 0.1, 0.01, 0.001));
1040         g->ec_pan=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_pan, -1.0, 1, 0.1, 0.01, 0.001));
1041         g->ec_volume=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->ec_volume, 0.0, 3.0, 0.1, 0.01, 0.001));
1042
1043         g->ec_lengthd=new tX_extdial("Duration", g->ec_length, &vtt->sp_ec_length);
1044         p->add_client_widget(g->ec_lengthd->get_widget());
1045         gui_set_tooltip(g->ec_lengthd->get_entry(), "Adjust the length of the echo buffer.");
1046
1047         g->ec_feedbackd=new tX_extdial("Feedback", g->ec_feedback, &vtt->sp_ec_feedback);
1048         p->add_client_widget(g->ec_feedbackd->get_widget());
1049         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.");
1050
1051         g->ec_volumed=new tX_extdial("Volume", g->ec_volume, &vtt->sp_ec_volume);
1052         p->add_client_widget(g->ec_volumed->get_widget());
1053         gui_set_tooltip(g->ec_volumed->get_entry(), "Adjust the volume of the echo effect.");
1054
1055         g->ec_pand=new tX_extdial("Pan", g->ec_pan, &vtt->sp_ec_pan);
1056         p->add_client_widget(g->ec_pand->get_widget());
1057         gui_set_tooltip(g->ec_pand->get_entry(), "Adjust the panning of the echo effect.");
1058
1059         gtk_list_box_insert(GTK_LIST_BOX(g->fx_box), p->get_list_box_row(), -1);
1060
1061         dummy=gtk_header_bar_new();
1062         gtk_header_bar_set_title(GTK_HEADER_BAR(dummy), "Stereo FX");
1063         gtk_header_bar_set_has_subtitle(GTK_HEADER_BAR(dummy), FALSE);
1064         gtk_widget_show(dummy);
1065         g->stereo_fx_button=create_top_button(ADD_ITEM);
1066         gtk_header_bar_pack_end(GTK_HEADER_BAR(dummy), g->stereo_fx_button);
1067         gtk_widget_show(g->stereo_fx_button);
1068         gtk_box_pack_start(GTK_BOX(g->control_subbox), dummy, WID_FIX);
1069
1070         g->stereo_fx_box = gtk_list_box_new();
1071         gtk_list_box_set_selection_mode (GTK_LIST_BOX (g->stereo_fx_box), GTK_SELECTION_NONE);
1072         gtk_box_pack_start(GTK_BOX(g->control_subbox), g->stereo_fx_box, WID_FIX);
1073         gtk_widget_show(g->stereo_fx_box);
1074
1075         /* Output */
1076         
1077         tempbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2);
1078         gtk_widget_show(tempbox);
1079         gtk_box_pack_end(GTK_BOX(g->control_box), tempbox, WID_FIX);
1080         
1081         tempbox2=gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
1082         gtk_widget_show(tempbox2);
1083         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
1084         
1085         g->pitch=GTK_ADJUSTMENT(gtk_adjustment_new(vtt->rel_pitch, -3, +3, 0.1, 0.01, 0.001));
1086         g->pan=GTK_ADJUSTMENT(gtk_adjustment_new(0, -1, 1, 0.1, 0.01, 0.001));
1087
1088         g->pitchd=new tX_extdial("Pitch", g->pitch, &vtt->sp_pitch);
1089         gui_set_tooltip(g->pitchd->get_entry(), "Adjust this turntable's pitch.");
1090
1091         gtk_box_pack_start(GTK_BOX(tempbox2), g->pitchd->get_widget(), WID_FIX);
1092
1093         g->pand=new tX_extdial("Pan", g->pan, &vtt->sp_pan);
1094         gtk_box_pack_start(GTK_BOX(tempbox2), g->pand->get_widget(), WID_FIX);
1095         gui_set_tooltip(g->pand->get_entry(), "Specifies the position of this turntable within the stereo spectrum: -1 -> left, 0-> center, 1->right.");
1096
1097         tempbox3=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2);
1098         gtk_widget_show(tempbox3);
1099
1100         g->mute=gtk_check_button_new_with_label("M");
1101         gtk_box_pack_start(GTK_BOX(tempbox3), g->mute, WID_FIX);
1102         g_signal_connect(G_OBJECT(g->mute),"clicked", (GCallback) mute_volume, vtt);
1103         gtk_widget_show(g->mute);
1104         gui_set_tooltip(g->mute, "Mute this turntable's mixer output.");
1105
1106         g->solo=gtk_check_button_new_with_label("S");
1107         gtk_box_pack_start(GTK_BOX(tempbox3), g->solo, WID_FIX);
1108         g_signal_connect(G_OBJECT(g->solo),"clicked", (GCallback) solo_vtt, vtt);
1109         gtk_widget_show(g->solo);
1110         gui_set_tooltip(g->solo, "Allow only this and other solo-switched turntabels' signal to be routed to the mixer.");
1111
1112         gtk_box_pack_start(GTK_BOX(tempbox2), tempbox3, WID_FIX);
1113
1114         tempbox2=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
1115         gtk_widget_show(tempbox2);
1116         gtk_box_pack_start(GTK_BOX(tempbox), tempbox2, WID_FIX);
1117         
1118         g->volume=GTK_ADJUSTMENT(gtk_adjustment_new(2.0-vtt->rel_volume, 0, 2, 0.01, 0.01, 0.01));
1119         dummy=gtk_scale_new(GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT(g->volume)); 
1120         gtk_scale_set_draw_value(GTK_SCALE(dummy), FALSE);
1121         gui_set_tooltip(dummy, "Adjust this turntable's volume.");
1122         g_signal_connect(G_OBJECT(dummy), "button_press_event", (GCallback) tX_seqpar::tX_seqpar_press, &vtt->sp_volume);       
1123
1124         gtk_box_pack_start(GTK_BOX(tempbox2), dummy, WID_FIX);
1125         gtk_widget_show(dummy);
1126
1127         g->flash=gtk_tx_flash_new();
1128         gtk_box_pack_start(GTK_BOX(tempbox2), g->flash, WID_FIX);
1129         gtk_widget_show(g->flash);
1130
1131         gui_connect_signals(vtt);
1132         
1133         g->audio_minimized_panel_bar_button=NULL;
1134         g->control_minimized_panel_bar_button=NULL;
1135         g->file_menu=NULL;
1136         g->mouse_mapping_menu=NULL;
1137         g->mouse_mapping_menu_x=NULL;
1138         g->mouse_mapping_menu_y=NULL;
1139         
1140         g->adjust_dialog=NULL;
1141         
1142         gui_set_name(vtt, vtt->name);   
1143 }
1144
1145 void fx_up(GtkWidget *wid, vtt_fx *effect)
1146 {
1147         vtt_class *vtt;
1148         
1149         vtt=(vtt_class*)effect->get_vtt();
1150         vtt->effect_up(effect);
1151 }
1152
1153 void fx_down(GtkWidget *wid, vtt_fx *effect)
1154 {
1155         vtt_class *vtt;
1156         
1157         vtt=(vtt_class*)effect->get_vtt();
1158         vtt->effect_down(effect);
1159 }
1160
1161 void fx_kill(GtkWidget *wid, vtt_fx_ladspa *effect)
1162 {
1163         vtt_class *vtt;
1164         
1165         vtt=(vtt_class*)effect->get_vtt();
1166         vtt->effect_remove(effect);
1167 }
1168
1169 int gtk_box_get_widget_pos(GtkBox *box, GtkWidget *child)
1170 {
1171         int i=0;
1172         GList *list;
1173  
1174         list = gtk_container_get_children(GTK_CONTAINER(box));
1175         while (list)
1176         {
1177                 GtkWidget *child_widget = (GtkWidget *) list->data;
1178                 if (child_widget == child)
1179                 break;
1180                 list = list->next; i++;
1181         }
1182         return i;
1183 }
1184
1185 void vg_move_fx_panel_up(tX_panel *panel, vtt_class *vtt, bool stereo)
1186 {
1187         GtkWidget *list_box=(stereo ? vtt->gui.stereo_fx_box : vtt->gui.fx_box);
1188         GtkWidget *row=panel->get_list_box_row();
1189
1190         int pos=gtk_list_box_row_get_index(GTK_LIST_BOX_ROW(row));
1191         g_object_ref(row);
1192         gtk_container_remove(GTK_CONTAINER(list_box), row);
1193         gtk_list_box_insert(GTK_LIST_BOX(list_box), row, pos-1);
1194         g_object_unref(row);
1195 }
1196
1197 void vg_move_fx_panel_down(tX_panel *panel, vtt_class *vtt, bool stereo)
1198 {
1199         GtkWidget *list_box=(stereo ? vtt->gui.stereo_fx_box : vtt->gui.fx_box);
1200         GtkWidget *row=panel->get_list_box_row();
1201
1202         int pos=gtk_list_box_row_get_index(GTK_LIST_BOX_ROW(row));
1203         g_object_ref(row);
1204         gtk_container_remove(GTK_CONTAINER(list_box), row);
1205         gtk_list_box_insert(GTK_LIST_BOX(list_box), row, pos+1);
1206         g_object_unref(row);
1207 }
1208
1209 void vg_toggle_drywet(GtkWidget *wid, vtt_fx *effect)
1210 {
1211         tX_panel *panel = effect->get_panel();
1212         effect->toggle_drywet();
1213
1214         if (effect->has_drywet_feature() == DRYWET_ACTIVE) {
1215                 gtk_widget_hide(panel->get_add_drywet_button());
1216                 gtk_widget_show(panel->get_remove_drywet_button());
1217         } else {
1218                 gtk_widget_show(panel->get_add_drywet_button());
1219                 gtk_widget_hide(panel->get_remove_drywet_button());
1220         }
1221 }
1222
1223 void vg_create_fx_gui(vtt_class *vtt, vtt_fx_ladspa *effect, LADSPA_Plugin *plugin)
1224 {
1225         char buffer[1024];
1226         
1227         vtt_gui *g;
1228         g=&vtt->gui;    
1229         tX_panel *p;
1230         list <tX_seqpar_vttfx *> :: iterator sp;
1231         
1232         strcpy(buffer, plugin->getName());
1233         if (strlen(buffer) > 8) {
1234                 buffer[7]='.';
1235                 buffer[8]='.';
1236                 buffer[9]='.';
1237                 buffer[10]=0;
1238         }
1239
1240         p=new tX_panel(buffer, g->control_subbox, G_CALLBACK(fx_kill), effect);
1241         
1242         for (sp = effect->controls.begin(); sp != effect->controls.end(); sp++) {
1243                 if ((strcmp((*sp)->get_label_name(), "Enable") == 0) && ((effect->has_drywet_feature() != NOT_DRYWET_CAPABLE))) {
1244                         GtkWidget *box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
1245                         gtk_container_add_with_properties(GTK_CONTAINER(box), (*sp)->get_widget(), "expand", TRUE, NULL);
1246                         gtk_widget_show((*sp)->get_widget());
1247                         
1248                         g_signal_connect(G_OBJECT(p->get_add_drywet_button()), "clicked", G_CALLBACK(vg_toggle_drywet), effect);
1249                         gtk_widget_set_tooltip_text(p->get_add_drywet_button(), "Click to add Dry/Wet controls for this effect.");      
1250                         gtk_container_add(GTK_CONTAINER(box), p->get_add_drywet_button());
1251                         if (effect->has_drywet_feature() == DRYWET_AVAILABLE) {
1252                                 gtk_widget_show(p->get_add_drywet_button());
1253                         }
1254                         
1255                         g_signal_connect(G_OBJECT(p->get_remove_drywet_button()), "clicked", G_CALLBACK(vg_toggle_drywet), effect);     
1256                         gtk_widget_set_tooltip_text(p->get_remove_drywet_button(), "Click to remove Dry/Wet controls for this effect.");        
1257                         gtk_container_add(GTK_CONTAINER(box), p->get_remove_drywet_button());
1258                         if (effect->has_drywet_feature() == DRYWET_ACTIVE) {
1259                                 gtk_widget_show(p->get_remove_drywet_button());
1260                         }
1261
1262                         p->add_client_widget(box);
1263                 } else {
1264                         p->add_client_widget((*sp)->get_widget());
1265                 }
1266         }
1267
1268         effect->set_panel_widget(p->get_widget());
1269         effect->set_panel(p);
1270
1271         gtk_list_box_insert(GTK_LIST_BOX(effect->is_stereo() ? g->stereo_fx_box : g->fx_box), p->get_list_box_row(), -1);
1272 }
1273
1274 void gui_set_filename (vtt_class *vtt, char *newname)
1275 {
1276         gtk_button_set_label(GTK_BUTTON(vtt->gui.file), newname);
1277 }
1278
1279 void gui_update_display(vtt_class *vtt)
1280 {
1281         nicer_filename(global_filename_buffer, vtt->filename);
1282         gtk_button_set_label(GTK_BUTTON(vtt->gui.file), global_filename_buffer);
1283         gtk_tx_set_data(GTK_TX(vtt->gui.display), vtt->buffer, vtt->samples_in_buffer);
1284 }
1285
1286 void gui_hide_control_panel(vtt_class *vtt, bool hide) {
1287         char tooltip[2048];
1288
1289         if (hide) {
1290                 gtk_widget_hide(vtt->gui.control_box);
1291                 vtt->gui.control_minimized_panel_bar_button=tx_xpm_button_new(MIN_CONTROL, vtt->name, 0, &vtt->gui.control_minimized_panel_bar_label);
1292                 g_signal_connect(G_OBJECT(vtt->gui.control_minimized_panel_bar_button), "clicked", (GCallback) unminimize_control_panel, vtt);
1293                 gtk_widget_show(vtt->gui.control_minimized_panel_bar_button);
1294                 snprintf(tooltip, TOOLTIP_LENGTH, "Show \"%s\" control panel.", vtt->name);
1295                 gui_set_tooltip(vtt->gui.control_minimized_panel_bar_button, tooltip);
1296                 add_to_panel_bar(vtt->gui.control_minimized_panel_bar_button);
1297         } else {
1298                 gtk_widget_show(vtt->gui.control_box);
1299                 remove_from_panel_bar(vtt->gui.control_minimized_panel_bar_button);
1300                 if (!tX_shutdown) gtk_widget_destroy(vtt->gui.control_minimized_panel_bar_button);
1301                 vtt->gui.control_minimized_panel_bar_button=NULL;
1302         }
1303 }
1304
1305 void gui_hide_audio_panel(vtt_class *vtt, bool hide) {
1306         char tooltip[2048];
1307
1308         if (hide) {
1309                 gtk_widget_hide(vtt->gui.audio_box);
1310                 vtt->gui.audio_minimized_panel_bar_button=tx_xpm_button_new(MIN_AUDIO, vtt->name, 0, &vtt->gui.audio_minimized_panel_bar_label);
1311                 g_signal_connect(G_OBJECT(vtt->gui.audio_minimized_panel_bar_button), "clicked", (GCallback) unminimize_audio_panel, vtt);              
1312                 gtk_widget_show(vtt->gui.audio_minimized_panel_bar_button);
1313                 snprintf(tooltip, TOOLTIP_LENGTH, "Show \"%s\" audio panel.", vtt->name);
1314                 gui_set_tooltip(vtt->gui.audio_minimized_panel_bar_button, tooltip);
1315                 add_to_panel_bar(vtt->gui.audio_minimized_panel_bar_button);
1316         } else {
1317                 gtk_widget_show(vtt->gui.audio_box);
1318                 remove_from_panel_bar(vtt->gui.audio_minimized_panel_bar_button);
1319                 if (!tX_shutdown) gtk_widget_destroy(vtt->gui.audio_minimized_panel_bar_button);
1320                 vtt->gui.audio_minimized_panel_bar_button=NULL;
1321         }
1322 }
1323
1324 void delete_gui(vtt_class *vtt)
1325 {
1326         if (vtt->gui.control_minimized_panel_bar_button!=NULL) gui_hide_control_panel(vtt, false);
1327         if (vtt->gui.audio_minimized_panel_bar_button!=NULL) gui_hide_audio_panel(vtt, false);
1328
1329         delete vtt->gui.main_panel;
1330         delete vtt->gui.trigger_panel;
1331         
1332         delete vtt->gui.pitchd;
1333         delete vtt->gui.pand;
1334         
1335         delete vtt->gui.lp_gaind;
1336         delete vtt->gui.lp_resod;
1337         delete vtt->gui.lp_freqd;
1338         delete vtt->gui.lp_panel;
1339         
1340         delete vtt->gui.ec_lengthd;
1341         delete vtt->gui.ec_feedbackd;
1342         delete vtt->gui.ec_volumed;
1343         delete vtt->gui.ec_pand;
1344         delete vtt->gui.ec_panel;
1345
1346         gtk_widget_destroy(vtt->gui.control_box);
1347         gtk_widget_destroy(vtt->gui.audio_box);
1348         if (vtt->gui.file_menu) gtk_widget_destroy(vtt->gui.file_menu);
1349         if (vtt->gui.mouse_mapping_menu) gtk_widget_destroy(vtt->gui.mouse_mapping_menu);
1350         if (vtt->gui.ladspa_menu) gtk_widget_destroy(vtt->gui.ladspa_menu);
1351 }
1352
1353 void cleanup_vtt(vtt_class *vtt)
1354 {
1355         gtk_tx_cleanup_pos_display(GTK_TX(vtt->gui.display));   
1356         gtk_tx_flash_set_level(vtt->gui.flash, 0.0, 0.0);
1357         gtk_tx_flash_clear(vtt->gui.flash);
1358         vtt->cleanup_required=false;
1359 }
1360
1361 void update_all_vtts()
1362 {
1363         list <vtt_class *> :: iterator vtt;
1364         f_prec temp,temp2;
1365         
1366         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1367         {
1368                 if ((*vtt)->is_playing) {
1369                         gtk_tx_update_pos_display(GTK_TX((*vtt)->gui.display), (*vtt)->pos_i, (*vtt)->mute);
1370                         temp=(*vtt)->max_value*(*vtt)->res_volume*vtt_class::vol_channel_adjust;
1371                         temp2=(*vtt)->max_value2*(*vtt)->res_volume*vtt_class::vol_channel_adjust;
1372 //                      tX_msg("Setting value: %f, %f -> %f; %f, %f -> %f (%f)\n",
1373 //                              (*vtt)->max_value, (*vtt)->res_volume, temp,
1374 //                              (*vtt)->max_value2, (*vtt)->res_volume, temp2,
1375 //                              vtt_class::vol_channel_adjust
1376 //                      );
1377                         gtk_tx_flash_set_level((*vtt)->gui.flash, temp, temp2);
1378                         
1379                         (*vtt)->max_value=0;
1380                         (*vtt)->max_value2=0;
1381                 }
1382                 
1383                 if ((*vtt)->needs_cleaning_up()) {
1384                         cleanup_vtt((*vtt));
1385                 }
1386         }
1387 }
1388
1389 void cleanup_all_vtts()
1390 {
1391         list <vtt_class *> :: iterator vtt;
1392         
1393         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1394         {
1395                 if ((*vtt)->buffer) gtk_tx_cleanup_pos_display(GTK_TX((*vtt)->gui.display));
1396                 gtk_tx_flash_set_level((*vtt)->gui.flash, 0.0, 0.0);
1397                 gtk_tx_flash_clear((*vtt)->gui.flash);
1398         }
1399 }
1400
1401 void gui_clear_master_button(vtt_class *vtt)
1402 {
1403         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vtt->gui.sync_master), 0);
1404 }
1405
1406 void gui_show_focus(vtt_class *vtt, int show)
1407 {
1408         gtk_tx_show_focus(GTK_TX(vtt->gui.display), show);
1409 }
1410
1411 #define vgui (*vtt)->gui
1412 #define v (*vtt)
1413
1414 void vg_enable_critical_buttons(int enable)
1415 {
1416         list <vtt_class *> :: iterator vtt;
1417         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1418         {
1419                 gtk_widget_set_sensitive(vgui.del, enable);
1420                 gtk_widget_set_sensitive(vgui.sync_master, enable);
1421         }
1422 }
1423
1424 void vg_init_all_non_seqpars()
1425 {
1426         list <vtt_class *> :: iterator vtt;
1427         
1428         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
1429         {
1430                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.autotrigger), (*vtt)->autotrigger);
1431                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((*vtt)->gui.sync_master), (*vtt)->is_sync_master);
1432         }       
1433 }
1434