db32c2113c8e52c7b0e9417cfb8ad42b5346a0ff
[terminatorX.git] / src / tX_dialog.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999-2003  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_dialog.cc
20  
21     Description: Contains the implementation of the Options and About
22                  Dialogs. (And some really ugly "WE WANT TO 
23                  TYPE LESS" macros)
24                  
25     Changes:
26     
27     28 Jul 1999: Now display compiletime settings in the about dialog.
28 */    
29
30 #include "config.h"
31 #include "tX_types.h"
32 #include "tX_global.h"
33 #include "tX_dialog.h"
34 #include <gtk/gtk.h>
35 #include <string.h>
36 #include <gdk/gdk.h>
37 #include "tX_icon.h"
38 #include "tX_glade_interface.h"
39 #include "tX_glade_support.h"
40
41 #include "tX_widget.h"
42 #include "tX_flash.h"
43
44 #ifndef WIN32
45 #include <X11/extensions/XInput.h>
46 #include <X11/X.h>
47 #endif
48
49 #include "license.c"
50 #include "tX_mastergui.h"
51 #include "version.h"
52 #include "tX_vtt.h"
53 #include <dirent.h>
54
55 #ifdef USE_JACK
56 extern void jack_check();
57 #endif
58
59 extern char *logo_xpm[];
60 GtkWidget *opt_dialog;
61 int opt_hidden=0;
62
63 static GtkWidget *last_alsa_device_widget=NULL;
64 static GtkWidget *alsa_device_entry=NULL;
65
66 void apply_options(GtkWidget *dialog) {
67         /* Audio */
68         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "alsa_driver")))) {
69                 globals.audiodevice_type=ALSA;
70         } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "oss_driver")))) {
71                 globals.audiodevice_type=OSS;
72         } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "jack_driver")))) {
73                 globals.audiodevice_type=JACK;
74         }
75         
76         /* Audio: OSS */
77         strcpy(globals.oss_device, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_audio_device"))->entry)));
78         globals.oss_buff_no=(int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "oss_buffers")));
79         globals.oss_buff_size=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "oss_buffersize")));
80         globals.oss_samplerate=atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_samplerate"))->entry)));
81         
82         /* Audio: ALSA */
83         strcpy(globals.alsa_device_id, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_audio_device"))->entry)));
84         globals.alsa_buffer_time=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "alsa_buffer_time")));
85         globals.alsa_buffer_time*=1000;
86         globals.alsa_period_time=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "alsa_period_time")));
87         globals.alsa_period_time*=1000;
88         globals.alsa_samplerate=atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate"))->entry)));        
89         globals.alsa_free_hwstats=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "alsa_free_hwstats")));
90         
91         /* TODO: JACK
92         */
93         
94         /* Input */
95         globals.xinput_enable=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "xinput_enable")))==TRUE);
96         strcpy(globals.xinput_device, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "xinput_device"))->entry)));
97         globals.mouse_speed=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "mouse_speed")));
98         globals.sense_cycles=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "stop_sense_cycles")));
99         globals.vtt_inertia=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "vtt_inertia")));
100         
101         /* User Interface */ 
102         globals.show_nag=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "startup_nagbox")))==TRUE);
103         globals.tooltips=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "mainwin_tooltips")))==TRUE);
104         globals.filename_length=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(dialog, "filename_length")));
105         if (globals.tooltips) gtk_tooltips_enable(gui_tooltips);
106         else gtk_tooltips_disable(gui_tooltips);
107
108         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_only")))) {
109                 globals.button_type=BUTTON_TYPE_TEXT;
110         } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_icon_only")))) {
111                 globals.button_type=BUTTON_TYPE_ICON;
112         } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_and_icon")))) {
113                 globals.button_type=BUTTON_TYPE_BOTH;
114         }
115         
116         globals.update_delay=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "update_delay")));
117         globals.update_idle=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "update_idle")));
118         globals.flash_response=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "vumeter_decay")));
119         
120         /* Audio Colors */
121         
122         strcpy(globals.wav_display_bg_focus, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "wav_display_bg_focus")), "Color"));
123         strcpy(globals.wav_display_bg_no_focus, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "wav_display_bg_no_focus")), "Color"));
124         strcpy(globals.wav_display_fg_focus, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "wav_display_fg_focus")), "Color"));
125         strcpy(globals.wav_display_fg_no_focus, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "wav_display_fg_no_focus")), "Color"));
126         strcpy(globals.wav_display_cursor, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "wav_display_cursor")), "Color"));
127         strcpy(globals.wav_display_cursor_mute, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "wav_display_cursor_mute")), "Color"));
128
129         /* VU Colors */ 
130         strcpy(globals.vu_meter_bg, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "vu_meter_bg")), "Color"));
131         strcpy(globals.vu_meter_loud, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "vu_meter_loud")), "Color"));
132         strcpy(globals.vu_meter_normal, (char *) g_object_get_data(G_OBJECT(lookup_widget(dialog, "vu_meter_normal")), "Color"));
133
134         globals.vu_meter_border_intensity=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "vu_meter_border_intensity")));
135         
136         /* Misc */
137         strcpy(globals.file_editor, gtk_entry_get_text(GTK_ENTRY(lookup_widget(dialog, "soundfile_editor"))));
138         strcpy(globals.lrdf_path, gtk_entry_get_text(GTK_ENTRY(lookup_widget(dialog, "ladspa_rdf_path"))));
139         globals.compress_set_files=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "compress_set_files")))==TRUE);        
140         globals.prelis=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "prelisten_enabled")))==TRUE);
141         globals.restore_midi_connections=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "reconnect_enabled")))==TRUE);
142         globals.quit_confirm=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "quit_confirm")))==TRUE);
143         
144         /* update colors */
145         std::list<vtt_class *>::iterator vtt;
146         
147         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++) {
148                 gtk_tx_update_colors(GTK_TX((*vtt)->gui.display));
149                 gtk_widget_queue_draw((*vtt)->gui.display);
150                 gtk_tx_flash_update_colors(GTK_TX_FLASH((*vtt)->gui.flash));
151                 gtk_widget_queue_draw((*vtt)->gui.flash);
152         }
153         
154         gtk_tx_flash_update_colors(GTK_TX_FLASH(main_flash_l));
155         gtk_widget_queue_draw(main_flash_l);
156         gtk_tx_flash_update_colors(GTK_TX_FLASH(main_flash_r));
157         gtk_widget_queue_draw(main_flash_r);
158         
159 #ifdef USE_JACK
160         jack_check();
161 #endif  
162 }
163
164
165 #define WID_DYN TRUE, TRUE, 0
166 #define WID_FIX FALSE, FALSE, 0
167
168 #define my_new_subsec(s); \
169         separator=gtk_hseparator_new(); \
170         gtk_box_pack_start(GTK_BOX(vbox), separator, WID_DYN);\
171         gtk_widget_show(separator); \
172         label=gtk_label_new(s); \
173         gtk_misc_set_alignment (GTK_MISC(label), 0 ,0.5); \
174         gtk_box_pack_start(GTK_BOX(vbox), label, WID_DYN); \
175         gtk_widget_show(label); 
176
177 #define my_new_button(btn, s); \
178         btn=gtk_button_new_with_label(s); \
179         gtk_box_pack_start(GTK_BOX(aa), btn, WID_DYN); \
180         gtk_widget_show(btn);
181         
182
183 #define begin_box(); box=gtk_hbox_new(FALSE, 5);
184
185 #define begin_hom_box(); box=gtk_hbox_new(TRUE, 5);
186
187 #define end_box(); gtk_box_pack_start(GTK_BOX(vbox), box, WID_DYN); \
188         gtk_widget_show(box);
189
190 #define add_widget_dyn(wid); gtk_box_pack_start(GTK_BOX(box), wid, WID_DYN);\
191         gtk_widget_show(wid);
192         
193 #define add_widget_fix(wid); gtk_box_pack_start(GTK_BOX(box), wid, WID_FIX);\
194         gtk_widget_show(wid);
195
196 #define add_expl(s); label=gtk_label_new(s); \
197         gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);\
198         add_widget_fix(label);
199
200 #define add_expl_dyn(s); label=gtk_label_new(s); \
201         gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);\
202         add_widget_dyn(label);
203
204 #ifdef USE_ALSA
205 static GList *alsa_devices=NULL;
206
207 GList *get_alsa_device_list() {
208         if (alsa_devices) {
209                 return alsa_devices;
210         }
211         
212         FILE *file;
213         char buffer[PATH_MAX+1];
214         alsa_devices=NULL;
215         
216         if ((file = fopen("/proc/asound/pcm", "r"))) {
217                 while(fgets(buffer, PATH_MAX, file)) {
218                         buffer[PATH_MAX]=0;
219                         if (strlen(buffer)) buffer[strlen(buffer)-1]=0;
220                         if(strstr(buffer, "playback")) {
221                                 char foo[PATH_MAX];
222                                 char tmp[PATH_MAX];
223                                 memset(foo, 0, PATH_MAX);
224                                 int card;
225                                 int device;
226  
227                                 sscanf(buffer, "%i-%i: %1024c", &card, &device, foo);
228                                 sprintf(tmp, "hw:%i,%i# %s", card, device, foo);
229                                 
230                                 alsa_devices=g_list_append (alsa_devices, strdup(tmp));
231                         }
232                 }
233                 fclose(file);
234         }
235         
236         return alsa_devices;
237 }
238 #else
239 GList *get_alsa_device_list() {
240         return NULL;
241 }
242 #endif
243
244
245 #ifdef USE_OSS
246 static GList *oss_devices=NULL;
247
248 int oss_select_dsp_only(const struct dirent *entry){
249         return (strstr(entry->d_name, "dsp")!=0);
250 }
251
252 GList *get_oss_device_list() {
253         if (oss_devices) {
254                 return oss_devices;
255         }
256                 
257     struct dirent **namelist;
258     int n,i;
259     n = scandir("/dev", &namelist, oss_select_dsp_only, alphasort);
260     
261         oss_devices=NULL;
262         
263     if (n>0) {
264         for (i=0; i<n; i++) {
265                         char buffer[256];
266             sprintf(buffer, "/dev/%s", namelist[i]->d_name);
267             free(namelist[i]);
268                         oss_devices=g_list_append (oss_devices, strdup(buffer));
269                 }
270         }
271         
272         return oss_devices;
273 }
274 #endif
275
276 static GList *sampling_rates=NULL;
277
278 GList *get_sampling_rates_list() {
279         if (sampling_rates) {
280                 return sampling_rates;
281         }
282
283         sampling_rates=g_list_append(sampling_rates, (void *) "22000");
284         sampling_rates=g_list_append(sampling_rates, (void *) "32000");
285         sampling_rates=g_list_append(sampling_rates, (void *) "44100");
286         sampling_rates=g_list_append(sampling_rates, (void *) "48000");
287
288         return sampling_rates;  
289 }
290
291 static GList *xinput_devices=NULL;
292
293 GList *get_xinput_devices_list() {
294         if (xinput_devices) {
295                 return xinput_devices;
296         }
297         
298         int devmax;
299         Display *dpy=XOpenDisplay(NULL);
300         XDeviceInfo *xdev=XListInputDevices(dpy, &devmax);
301         XCloseDisplay(dpy);
302
303         for (int i=0; i<devmax; i++) {
304                 xinput_devices=g_list_append(xinput_devices, strdup(xdev[i].name));
305         }
306         
307         XFreeDeviceList(xdev);
308         
309         return xinput_devices;
310 }
311
312 #define MAX_COLORS 10
313 char *colors[MAX_COLORS]={ NULL };
314
315 #define set_color_button(s,g); \
316         sprintf(tmp, "<span foreground=\"%s\"><b>%s</b></span>", s, s);\
317         gtk_label_set_markup(GTK_LABEL(gtk_container_get_children(GTK_CONTAINER(lookup_widget(dialog, g)))->data), tmp);\
318         strcpy(colors[ctr], s);\
319         g_object_set_data(G_OBJECT(lookup_widget(dialog, g)), "Color", colors[ctr]);\
320         ctr++;
321
322
323 void init_tx_options(GtkWidget *dialog) {
324         GtkTooltips *tooltips=GTK_TOOLTIPS(lookup_widget(dialog, "tooltips"));
325         
326         if (colors[0]==NULL) {
327                 for (int i=0; i<MAX_COLORS; i++) {
328                         colors[i]=new char[8];
329                         colors[i][0]=0;
330                 }
331         }
332         
333         /* Audio */
334         switch (globals.audiodevice_type) {             
335                 case ALSA: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "alsa_driver")), 1);
336                         break;
337                 
338                 case JACK: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "jack_driver")), 1);
339                         break;
340
341                 case OSS: 
342                 default:
343                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "oss_driver")), 1);
344                         break;
345         }
346         
347 #ifndef USE_OSS
348         gtk_widget_set_sensitive(lookup_widget(dialog, "oss_driver"), 0);
349         gtk_widget_set_sensitive(lookup_widget(dialog, "oss_audio_device"), 0);
350         gtk_widget_set_sensitive(lookup_widget(dialog, "oss_buffers"), 0);
351         gtk_widget_set_sensitive(lookup_widget(dialog, "oss_buffersize"), 0);
352 #endif
353         
354 #ifndef USE_ALSA
355         gtk_widget_set_sensitive(lookup_widget(dialog, "alsa_driver"), 0);      
356         // TODO: Rest!  
357 #endif
358         
359 #ifndef USE_JACK
360         gtk_widget_set_sensitive(lookup_widget(dialog, "jack_driver"), 0);
361 #endif  
362         
363         /* Audio: OSS */
364         GList *oss_list=get_oss_device_list();
365         if (oss_list) {
366                 gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "oss_audio_device")), oss_list);
367         }
368         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_audio_device"))->entry), globals.oss_device);
369
370         gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "oss_buffers")), globals.oss_buff_no);
371         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "oss_buffersize")), globals.oss_buff_size);
372         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "oss_buffersize"), "Set the size of the kernel level audio buffers. On slower systems you might have to increase this value (if you hear \"clicks\" or drop-outs). Lower values mean lower latency though.", NULL);        
373         gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "oss_samplerate")), get_sampling_rates_list());
374         char tmp[64];
375         sprintf(tmp, "%i", globals.oss_samplerate);
376         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_samplerate"))->entry), tmp);
377         
378         
379         /* Audio: ALSA */
380         GtkCombo *combo=GTK_COMBO(lookup_widget(dialog, "alsa_audio_device"));
381         GList *alsa_list=get_alsa_device_list();
382         last_alsa_device_widget=NULL;
383         alsa_device_entry=combo->entry;
384         
385         if (alsa_list) {
386                 gtk_combo_set_popdown_strings(combo, get_alsa_device_list());
387         }
388         gtk_entry_set_text(GTK_ENTRY(combo->entry), globals.alsa_device_id);
389
390         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "alsa_buffer_time")), globals.alsa_buffer_time/1000);
391         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "alsa_buffer_time"), "Sets the size of the ALSA ring buffer. On slower systems you might have to increase this value (if you hear \"clicks\" or drop-outs). Lower values mean lower latency though.", NULL);       
392         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "alsa_period_time")), globals.alsa_period_time/1000);
393         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "alsa_period_time"), "The ALSA period time determines how much audio data will be written to the device at once. It is recommended to set this value to a half or a third of the ALSA buffer time.", NULL);        
394
395         gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate")), get_sampling_rates_list());
396         sprintf(tmp, "%i", globals.alsa_samplerate);
397         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate"))->entry), tmp);
398         
399         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "alsa_free_hwstats")), globals.alsa_free_hwstats);
400         
401         /* Input */
402         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "xinput_enable")), globals.xinput_enable);
403         
404         gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "xinput_device")), get_xinput_devices_list());
405         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "xinput_device"))->entry), globals.xinput_device);
406
407         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "mouse_speed")), globals.mouse_speed);
408         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "mouse_speed"), "The speed of your mouse in scratch mode. Use negative values to invert motion.", NULL);
409         
410         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "stop_sense_cycles")), globals.sense_cycles);
411         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "stop_sense_cycles"),"If there is no \"motion-event\" for x cycles, where x is the number of cycles you select here, terminatorX assumes mouse motion has stopped. For smaller buffer sizes (=> shorter cycle times) you might have to increase this value", NULL);        
412
413         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "vtt_inertia")), globals.vtt_inertia);
414         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "vtt_inertia"),"This value defines how fast the turntables will adapt to the speed input - the higher this value, the longer it will take the turntable to actually reach the target speed.", NULL);       
415
416         gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "filename_length")), globals.filename_length);
417
418         /* User Interface */ 
419         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "startup_nagbox")), globals.show_nag);
420         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "mainwin_tooltips")), globals.tooltips);
421         
422         switch (globals.button_type) {
423                 case BUTTON_TYPE_TEXT:
424                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_only")), 1);
425                         break;
426                 
427                 case BUTTON_TYPE_ICON:
428                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_icon_only")), 1);
429                         break;
430                 
431                 case BUTTON_TYPE_BOTH:
432                 default:
433                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_and_icon")), 1);
434         }
435         
436         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "update_delay")), globals.update_delay);
437         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "update_delay"), "How often to update the slow widgets.", NULL);   
438         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "update_idle")), globals.update_idle);
439         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "update_idle"), "The update thread will idle for the selcted amount of milliseconds. If you want to have a more responsive display update increase this value - if you have performance problems reduce this value.", NULL);       
440         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "vumeter_decay")), globals.flash_response);
441         gtk_tooltips_set_tip(tooltips, lookup_widget(dialog, "vumeter_decay"), "Defines how fast the maximum values of the VU meters should be decayed.", NULL);        
442
443         /* Audio Colors */
444         int ctr=0;
445         
446         set_color_button(globals.wav_display_bg_focus, "wav_display_bg_focus");
447         set_color_button(globals.wav_display_bg_no_focus, "wav_display_bg_no_focus");
448         set_color_button(globals.wav_display_fg_focus, "wav_display_fg_focus");
449         set_color_button(globals.wav_display_fg_no_focus, "wav_display_fg_no_focus");
450         set_color_button(globals.wav_display_cursor, "wav_display_cursor");
451         set_color_button(globals.wav_display_cursor_mute, "wav_display_cursor_mute");
452         
453         /* VU Colors */
454         set_color_button(globals.vu_meter_bg, "vu_meter_bg");
455         set_color_button(globals.vu_meter_loud, "vu_meter_loud");
456         set_color_button(globals.vu_meter_normal, "vu_meter_normal");
457         
458         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "vu_meter_border_intensity")), globals.vu_meter_border_intensity);
459         
460         /* Misc */
461         gtk_entry_set_text(GTK_ENTRY(lookup_widget(dialog, "soundfile_editor")), globals.file_editor);
462         gtk_entry_set_text(GTK_ENTRY(lookup_widget(dialog, "ladspa_rdf_path")), globals.lrdf_path);
463         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "compress_set_files")), globals.compress_set_files);
464         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "prelisten_enabled")), globals.prelis);
465         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "reconnect_enabled")), globals.restore_midi_connections);
466         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "quit_confirm")), globals.quit_confirm);
467 }
468
469 void create_options()
470 {
471         opt_dialog=create_tx_options();
472         tX_set_icon(opt_dialog);
473         init_tx_options(opt_dialog);
474         gtk_widget_show(opt_dialog);
475 }
476
477 void display_options()
478 {
479         if (opt_dialog) {
480                 gdk_window_raise(opt_dialog->window);   
481         } else {
482                 create_options();
483         }
484 }
485
486 GtkWidget *about=NULL;
487
488 void raise_about()
489 {
490         if (about) gdk_window_raise(about->window);
491 }
492
493
494 void destroy_about()
495 {
496         if (about) {    
497                 gtk_widget_destroy(about);
498                 about=NULL;
499         }
500 }
501
502 #define add_about_wid(wid); gtk_box_pack_start(GTK_BOX(box), wid, WID_DYN); \
503         gtk_widget_show(wid);
504
505 #define add_about_wid_fix(wid); gtk_box_pack_start(GTK_BOX(box), wid, WID_FIX); \
506         gtk_widget_show(wid);
507
508 GdkFont *GPL_font=NULL;
509
510 void show_about(int nag)
511 {
512         GtkWidget *window;
513         GtkWidget *btn;
514         GtkWidget *box;
515         GtkWidget *hbox;
516         GtkWidget *label;
517         GtkWidget *sep;
518         GtkWidget *text;
519         GtkWidget *scroll;
520         GtkWidget *iwid;
521         
522         /* Only raise the window if it's already open... */
523         if (about)  {
524                 gdk_window_raise(about->window);
525                 return;
526         }
527         
528         /* Create the window... */
529         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
530         gtk_container_set_border_width(GTK_CONTAINER(window), 5);
531         gtk_window_set_title(GTK_WINDOW(window), "terminatorX - About");
532         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
533         gtk_window_set_modal(GTK_WINDOW(window), TRUE);
534         gtk_window_set_resizable(GTK_WINDOW(window), nag ? TRUE: FALSE);
535
536         GdkPixbuf *image=gdk_pixbuf_new_from_xpm_data((const char **)logo_xpm);
537         iwid = gtk_image_new_from_pixbuf(image);
538         
539         if (nag) {
540                 GtkWidget *box=gtk_vbox_new(FALSE, 2);
541                 GtkWidget *box2=gtk_hbox_new(FALSE, 2);
542                 GtkWidget *label;
543                 
544                 gtk_container_add(GTK_CONTAINER(window), box);
545                 gtk_box_pack_start(GTK_BOX(box), iwid, WID_FIX);
546                 gtk_box_pack_start(GTK_BOX(box), box2, WID_FIX);
547                 
548                 label=gtk_label_new(PACKAGE" release "VERSION);
549                 gtk_box_pack_start(GTK_BOX(box2), label, WID_DYN);
550                 gtk_misc_set_alignment(GTK_MISC(label), 0.1, 0.5);
551                 gtk_widget_show(label);
552
553                 label=gtk_label_new("Copyright (C) 1999-2003 by Alexander K\xC3\xB6nig");
554                 gtk_box_pack_start(GTK_BOX(box2), label, WID_DYN);
555                 gtk_misc_set_alignment(GTK_MISC(label), 0.9, 0.5);
556                 gtk_widget_show(label);
557                 
558                 gtk_widget_show(box2);
559                 gtk_widget_show(box);
560                 gtk_widget_show(iwid);
561
562                 gtk_window_set_decorated(GTK_WINDOW(window), FALSE);            
563                 gtk_widget_show(window);
564         } else {
565                 box=gtk_vbox_new(FALSE, 5);
566                 add_about_wid_fix(iwid);
567                 
568                 sep=gtk_hseparator_new();
569                 add_about_wid_fix(sep);
570                 char about_prefix_umlaut[]="\nThis is "PACKAGE" Release "VERSION" - Copyright (C) 1999-2003 by Alexander K\xC3\xB6nig";
571                 char about_rest[]="\n\nSend comments, patches and scratches to: alex@lisas.de\n"
572                 "terminatorX-homepage: http://www.terminatorX.cx\n\nThis binary has been compiled with the following flags: "
573                 "Sox support: "
574 #ifdef USE_SOX_INPUT
575                 "ON"
576 #else
577                 "OFF"
578 #endif          
579                 " - mpg123 support: "
580 #ifdef USE_MPG123_INPUT
581                 "ON"
582 #else
583                 "OFF"
584 #endif
585                 " - \nogg123 support: "
586 #ifdef USE_OGG123_INPUT
587                 "ON"
588 #else
589                 "OFF"
590 #endif
591
592                 " - enhanced scheduling: "
593 #ifdef USE_SCHEDULER
594                 "ON"
595 #else
596                 "OFF"
597 #endif
598                 " - for a "
599 #ifdef WORDS_BIGENDIAN
600                 "big"
601                 
602 #else
603                 "little"
604 #endif
605                 " endian machine.\n";
606                 
607                 char buffer[4096];
608                 
609                 strcpy(buffer, about_prefix_umlaut);
610                 strcat(buffer, about_rest);
611                 
612                 label=gtk_label_new(buffer);
613
614                 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
615                 add_about_wid_fix(label);
616                 
617                 sep=gtk_hseparator_new();
618                 add_about_wid_fix(sep);
619
620                 label=gtk_label_new("License (GPL V2):");
621                 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
622                 add_about_wid_fix(label);
623
624                 hbox=gtk_hbox_new(FALSE, 5);            
625
626                 GtkTextIter iter;
627                 GtkTextBuffer *tbuffer;
628
629                 text=gtk_text_view_new();
630                 tbuffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
631                 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_NONE);
632                 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), false);
633                 gtk_text_buffer_get_iter_at_offset (tbuffer, &iter, 0);
634                 
635                 scroll=gtk_scrolled_window_new (NULL, NULL);
636         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
637                 gtk_container_add (GTK_CONTAINER (scroll), text);
638                 gtk_text_buffer_create_tag (tbuffer, "courier", "family", "courier", NULL);
639                 
640                 gtk_text_buffer_insert_with_tags_by_name(tbuffer, &iter, license, -1, "courier", NULL);
641                 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);
642                 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 5);
643                 gtk_widget_set_size_request(GTK_WIDGET(text), 700, 220);
644                 gtk_widget_show(text);          
645                 
646                 gtk_box_pack_start(GTK_BOX(hbox), scroll, WID_DYN);
647                 gtk_widget_show(scroll);                
648                 
649                 add_about_wid(hbox);
650
651                 sep=gtk_hseparator_new();
652                 add_about_wid_fix(sep);
653
654                 btn=gtk_button_new_with_label("Close");
655                 add_about_wid_fix(btn);
656
657                 gtk_container_add(GTK_CONTAINER(window), box);
658                 gtk_widget_show(box);
659                 
660                 g_signal_connect(G_OBJECT(btn), "clicked", (GtkSignalFunc) destroy_about, NULL);                
661                 g_signal_connect(G_OBJECT(window), "delete-event", (GtkSignalFunc) destroy_about, NULL);                
662         }
663         gtk_widget_show(window);        
664         tX_set_icon(window);
665         
666         while (gtk_events_pending()) gtk_main_iteration();
667                 
668         about=window;
669 }
670
671 static GdkPixbuf *tX_window_icon=NULL;
672
673 void tX_set_icon(GtkWidget *widget)
674 {       
675         if (!tX_window_icon) {
676                 tX_window_icon=gdk_pixbuf_new_from_inline(-1, tX_icon, FALSE, NULL);
677         }
678
679         gtk_window_set_icon(GTK_WINDOW(widget), tX_window_icon);
680 }