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