Mostly ALSA fixing - Alex
[terminatorX.git] / terminatorX / 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.c
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 #ifndef WIN32
42 #include <X11/extensions/XInput.h>
43 #include <X11/X.h>
44 #endif
45
46 #include "license.c"
47 #include "tX_mastergui.h"
48 #include "version.h"
49 #include <dirent.h>
50
51 extern char *logo_xpm[];
52 GtkWidget *opt_dialog;
53 int opt_hidden=0;
54
55 void apply_options(GtkWidget *dialog) {
56         /* Audio */
57         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "alsa_driver")))) {
58                 globals.audiodevice_type=ALSA;
59         } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "oss_driver")))) {
60                 globals.audiodevice_type=OSS;
61         } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "jack_driver")))) {
62                 globals.audiodevice_type=JACK;
63         }
64         
65         /* Audio: OSS */
66         strcpy(globals.oss_device, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_audio_device"))->entry)));
67         globals.oss_buff_no=(int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "oss_buffers")));
68         globals.oss_buff_size=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "oss_buffersize")));
69         globals.oss_samplerate=atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_samplerate"))->entry)));
70         
71         /* Audio: ALSA */
72         strcpy(globals.alsa_device, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_audio_device"))->entry)));
73         globals.alsa_buffer_time=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "alsa_buffer_time")));
74         globals.alsa_buffer_time*=1000;
75         globals.alsa_period_time=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "alsa_period_time")));
76         globals.alsa_period_time*=1000;
77         globals.alsa_samplerate=atoi(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate"))->entry)));        
78         
79         /* TODO: JACK
80         */
81         
82         /* Input */
83         globals.xinput_enable=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "xinput_enable")))==TRUE);
84         strcpy(globals.xinput_device, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "xinput_device"))->entry)));
85         globals.mouse_speed=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "mouse_speed")));
86         globals.sense_cycles=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "stop_sense_cycles")));
87         
88         /* User Interface */ 
89         globals.show_nag=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "startup_nagbox")))==TRUE);
90         globals.tooltips=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "mainwin_tooltips")))==TRUE);
91         if (globals.tooltips) gtk_tooltips_enable(gui_tooltips);
92         else gtk_tooltips_disable(gui_tooltips);
93
94         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_only")))) {
95                 globals.button_type=BUTTON_TYPE_TEXT;
96         } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_icon_only")))) {
97                 globals.button_type=BUTTON_TYPE_ICON;
98         } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_and_icon")))) {
99                 globals.button_type=BUTTON_TYPE_BOTH;
100         }
101         
102         globals.update_delay=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "update_delay")));
103         globals.update_idle=(int) gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "update_idle")));
104         globals.flash_response=gtk_range_get_value(GTK_RANGE(lookup_widget(dialog, "vumeter_decay")));
105
106         /* Misc */
107         strcpy(globals.file_editor, gtk_entry_get_text(GTK_ENTRY(lookup_widget(dialog, "soundfile_editor"))));
108         strcpy(globals.lrdf_path, gtk_entry_get_text(GTK_ENTRY(lookup_widget(dialog, "ladspa_rdf_path"))));
109         globals.prelis=(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "prelisten_enabled")))==TRUE);
110 }
111
112
113 #define WID_DYN TRUE, TRUE, 0
114 #define WID_FIX FALSE, FALSE, 0
115
116 #define my_new_subsec(s); \
117         separator=gtk_hseparator_new(); \
118         gtk_box_pack_start(GTK_BOX(vbox), separator, WID_DYN);\
119         gtk_widget_show(separator); \
120         label=gtk_label_new(s); \
121         gtk_misc_set_alignment (GTK_MISC(label), 0 ,0.5); \
122         gtk_box_pack_start(GTK_BOX(vbox), label, WID_DYN); \
123         gtk_widget_show(label); 
124
125 #define my_new_button(btn, s); \
126         btn=gtk_button_new_with_label(s); \
127         gtk_box_pack_start(GTK_BOX(aa), btn, WID_DYN); \
128         gtk_widget_show(btn);
129         
130
131 #define begin_box(); box=gtk_hbox_new(FALSE, 5);
132
133 #define begin_hom_box(); box=gtk_hbox_new(TRUE, 5);
134
135 #define end_box(); gtk_box_pack_start(GTK_BOX(vbox), box, WID_DYN); \
136         gtk_widget_show(box);
137
138 #define add_widget_dyn(wid); gtk_box_pack_start(GTK_BOX(box), wid, WID_DYN);\
139         gtk_widget_show(wid);
140         
141 #define add_widget_fix(wid); gtk_box_pack_start(GTK_BOX(box), wid, WID_FIX);\
142         gtk_widget_show(wid);
143
144 #define add_expl(s); label=gtk_label_new(s); \
145         gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);\
146         add_widget_fix(label);
147
148 #define add_expl_dyn(s); label=gtk_label_new(s); \
149         gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);\
150         add_widget_dyn(label);
151
152 #ifdef USE_ALSA
153 static GList *alsa_devices;
154
155 GList *get_alsa_device_list() {
156         if (alsa_devices) {
157                 return alsa_devices;
158         }
159         
160         FILE *file;
161         char buffer[PATH_MAX+1];
162         
163         if ((file = fopen("/proc/asound/pcm", "r"))) {
164                 while(fgets(buffer, PATH_MAX, file)) {
165                         buffer[PATH_MAX]=0;
166                         if (strlen(buffer)) buffer[strlen(buffer)-1]=0;
167                         if(strstr(buffer, "playback")) {
168                                 alsa_devices=g_list_append (alsa_devices, strdup(buffer));
169                         }
170                 }
171                 fclose(file);
172         }
173         
174         return alsa_devices;
175 }
176 #else
177 GList *get_alsa_device_list() {
178         return NULL;
179 }
180 #endif
181
182
183 #ifdef USE_OSS
184 static GList *oss_devices=NULL;
185
186 int oss_select_dsp_only(const struct dirent *entry){
187         return (strstr(entry->d_name, "dsp")!=0);
188 }
189
190 GList *get_oss_device_list() {
191         if (oss_devices) {
192                 return oss_devices;
193         }
194         
195         
196     struct dirent **namelist;
197     int n,i;
198     n = scandir("/dev", &namelist, oss_select_dsp_only, alphasort);
199     
200     if (n>0) {
201         for (i=0; i<n; i++) {
202                         char buffer[256];
203             sprintf(buffer, "/dev/%s", namelist[i]->d_name);
204             free(namelist[i]);
205                         oss_devices=g_list_append (oss_devices, strdup(buffer));
206                 }
207         }
208         
209         return oss_devices;
210 }
211 #endif
212
213 static GList *sampling_rates=NULL;
214
215 GList *get_sampling_rates_list() {
216         if (sampling_rates) {
217                 return sampling_rates;
218         }
219         
220         char buffer[256];
221         
222         sampling_rates=g_list_append(sampling_rates, (void *) "22000");
223         sampling_rates=g_list_append(sampling_rates, (void *) "32000");
224         sampling_rates=g_list_append(sampling_rates, (void *) "44100");
225         sampling_rates=g_list_append(sampling_rates, (void *) "48000");
226
227         return sampling_rates;  
228 }
229
230 static GList *xinput_devices=NULL;
231
232 GList *get_xinput_devices_list() {
233         if (xinput_devices) {
234                 return xinput_devices;
235         }
236         
237         int devmax;
238         Display *dpy=XOpenDisplay(NULL);
239         XDeviceInfo *xdev=XListInputDevices(dpy, &devmax);
240         XCloseDisplay(dpy);
241
242         for (int i=0; i<devmax; i++) {
243                 xinput_devices=g_list_append(xinput_devices, strdup(xdev[i].name));
244         }
245         
246         XFreeDeviceList(xdev);
247         
248         return xinput_devices;
249 }
250
251 void init_tx_options(GtkWidget *dialog) {
252         /* Audio */
253         switch (globals.audiodevice_type) {             
254                 case ALSA: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "alsa_driver")), 1);
255                         break;
256                 
257                 case JACK: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "jack_driver")), 1);
258                         break;
259
260                 case OSS: 
261                 default:
262                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "oss_driver")), 1);
263                         break;
264         }
265         
266 #ifndef USE_OSS
267         gtk_widget_set_sensitive(lookup_widget(dialog, "oss_driver"), 0);
268         gtk_widget_set_sensitive(lookup_widget(dialog, "oss_audio_device"), 0);
269         gtk_widget_set_sensitive(lookup_widget(dialog, "oss_buffers"), 0);
270         gtk_widget_set_sensitive(lookup_widget(dialog, "oss_buffersize"), 0);
271 #endif
272         
273 #ifndef USE_ALSA
274         gtk_widget_set_sensitive(lookup_widget(dialog, "alsa_driver"), 0);      
275         // TODO: Rest!  
276 #endif
277         
278 #ifndef USE_JACK
279         gtk_widget_set_sensitive(lookup_widget(dialog, "jack_driver"), 0);
280 #endif  
281         
282         /* Audio: OSS */
283         gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "oss_audio_device")), get_oss_device_list());
284         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_audio_device"))->entry), globals.oss_device);
285
286         gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(dialog, "oss_buffers")), globals.oss_buff_no);
287         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "oss_buffersize")), globals.oss_buff_size);
288
289         gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "oss_samplerate")), get_sampling_rates_list());
290         char tmp[32];
291         sprintf(tmp, "%i", globals.oss_samplerate);
292         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "oss_samplerate"))->entry), tmp);
293         
294         
295         /* Audio: ALSA */
296         gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "alsa_audio_device")), get_alsa_device_list());
297         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_audio_device"))->entry), globals.alsa_device);
298
299         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "alsa_buffer_time")), globals.alsa_buffer_time/1000);
300         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "alsa_period_time")), globals.alsa_period_time/1000);
301
302         gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate")), get_sampling_rates_list());
303         sprintf(tmp, "%i", globals.alsa_samplerate);
304         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "alsa_samplerate"))->entry), tmp);
305         
306         
307         /* TODO: Samplerate!
308                 ALSA
309                 JACK
310         */
311         
312         /* Input */
313         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "xinput_enable")), globals.xinput_enable);
314         
315         gtk_combo_set_popdown_strings(GTK_COMBO(lookup_widget(dialog, "xinput_device")), get_xinput_devices_list());
316         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(lookup_widget(dialog, "xinput_device"))->entry), globals.xinput_device);
317
318         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "mouse_speed")), globals.mouse_speed);
319         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "stop_sense_cycles")), globals.sense_cycles);
320         
321         /* User Interface */ 
322         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "startup_nagbox")), globals.show_nag);
323         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "mainwin_tooltips")), globals.tooltips);
324         
325         switch (globals.button_type) {
326                 case BUTTON_TYPE_TEXT:
327                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_only")), 1);
328                         break;
329                 
330                 case BUTTON_TYPE_ICON:
331                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_icon_only")), 1);
332                         break;
333                 
334                 case BUTTON_TYPE_BOTH:
335                 default:
336                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "buttons_text_and_icon")), 1);
337         }
338         
339         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "update_delay")), globals.update_delay);
340         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "update_idle")), globals.update_idle);
341         gtk_range_set_value(GTK_RANGE(lookup_widget(dialog, "vumeter_decay")), globals.flash_response);
342
343         /* Misc */
344         gtk_entry_set_text(GTK_ENTRY(lookup_widget(dialog, "soundfile_editor")), globals.file_editor);
345         gtk_entry_set_text(GTK_ENTRY(lookup_widget(dialog, "ladspa_rdf_path")), globals.lrdf_path);
346         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog, "prelisten_enabled")), globals.prelis);
347 }
348
349 void create_options()
350 {
351         opt_dialog=create_tx_options();
352         gtk_widget_hide(lookup_widget(opt_dialog, "jack_driver"));      
353         init_tx_options(opt_dialog);
354         gtk_widget_show(opt_dialog);
355 }
356
357 /* void create_options()
358 {
359         // gtk_tooltips_set_tip(opt_tips, buff_size_slider, "Sets the size of the kernel level audio buffers. On slower systems you might have to increase this value (if you hear \"clicks\"). Lower values mean lower latency though.", NULL);
360         // gtk_tooltips_set_tip(opt_tips, mouse_speed_slider, "The speed of your mouse in scratch mode. Use negative values to invert motion.", NULL);
361         // gtk_tooltips_set_tip(opt_tips, sense_cycles_slider, "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);
362         // gtk_tooltips_set_tip(opt_tips,       update_idle_slider, "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);
363         // gtk_tooltips_set_tip(opt_tips,       update_delay_slider, "How often to update the slow widgets.", NULL);
364 } */
365
366 void display_options()
367 {
368         if (opt_dialog) {
369                 gdk_window_raise(opt_dialog->window);   
370         } else {
371                 create_options();
372         }
373 }
374
375 GtkWidget *about=NULL;
376
377 void raise_about()
378 {
379         if (about)
380         gdk_window_raise(about->window);
381 }
382
383
384 void destroy_about()
385 {
386         if (about)
387         {       
388                 gtk_widget_destroy(about);
389                 about=NULL;
390         }
391 }
392
393
394
395 #define add_about_wid(wid); gtk_box_pack_start(GTK_BOX(box), wid, WID_DYN); \
396         gtk_widget_show(wid);
397
398 #define add_about_wid_fix(wid); gtk_box_pack_start(GTK_BOX(box), wid, WID_FIX); \
399         gtk_widget_show(wid);
400
401 GdkFont *GPL_font=NULL;
402
403 void show_about(int nag)
404 {
405         GtkWidget *window, *pwid;
406         GdkBitmap *mask;
407         GtkStyle *style;
408         GtkWidget *btn;
409         GtkWidget *box;
410         GtkWidget *hbox;
411         GtkWidget *label;
412         GtkWidget *sep;
413         GtkWidget *text;
414         GtkWidget *scroll;
415         GdkPixmap *pmap=NULL;
416         
417         if (about) 
418         {
419                 gdk_window_raise(about->window);
420                 return;
421         }
422         
423         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);   
424         gtk_window_set_wmclass(GTK_WINDOW(window), "terminatorX", "tX_about");
425
426         gtk_container_set_border_width(GTK_CONTAINER(window), 5);
427
428 //      GTK_WINDOW(window)->use_uposition=TRUE;
429
430         gtk_widget_realize(window);
431         
432         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
433         gtk_window_set_title(GTK_WINDOW(window), "terminatorX - About");
434         
435         if (nag)
436         {
437                 gdk_window_set_decorations(window->window, (enum GdkWMDecoration) 0);
438         }
439
440         
441         style = gtk_widget_get_style( window );
442
443         pmap=gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **)logo_xpm);
444
445         pwid = gtk_pixmap_new( pmap, mask );
446         
447         if (nag) {
448                 GtkWidget *box=gtk_vbox_new(FALSE, 2);
449                 GtkWidget *box2=gtk_hbox_new(FALSE, 2);
450                 GtkWidget *label;
451                 
452                 gtk_container_add(GTK_CONTAINER(window), box);
453                 gtk_box_pack_start(GTK_BOX(box), pwid, WID_FIX);
454                 gtk_box_pack_start(GTK_BOX(box), box2, WID_FIX);
455                 
456                 label=gtk_label_new(PACKAGE" release "VERSION);
457                 gtk_box_pack_start(GTK_BOX(box2), label, WID_DYN);
458                 gtk_misc_set_alignment(GTK_MISC(label), 0.1, 0.5);
459                 gtk_widget_show(label);
460
461                 label=gtk_label_new("Copyright (C) 1999-2003 by Alexander K\xC3\xB6nig");
462                 gtk_box_pack_start(GTK_BOX(box2), label, WID_DYN);
463                 gtk_misc_set_alignment(GTK_MISC(label), 0.9, 0.5);
464                 gtk_widget_show(label);
465                 
466                 gtk_widget_show(box2);
467                 gtk_widget_show(box);
468                 gtk_widget_show(window);
469                 gtk_widget_show(pwid);
470                 
471                 while (gtk_events_pending()) gtk_main_iteration();      
472         }
473         else
474         {
475                 box=gtk_vbox_new(FALSE, 5);
476                 add_about_wid_fix(pwid);
477                 
478                 sep=gtk_hseparator_new();
479                 add_about_wid_fix(sep);
480                 char about_prefix_umlaut[]="\nThis is "PACKAGE" Release "VERSION" - Copyright (C) 1999-2003 by Alexander K\xC3\xB6nig";
481                 char about_rest[]="\n\nSend comments, patches and scratches to: alex@lisas.de\n"
482                 "terminatorX-homepage: http://www.terminatorX.cx\n\nThis binary has been compiled with the following flags: "
483                 "Sox support: "
484 #ifdef USE_SOX_INPUT
485                 "ON"
486 #else
487                 "OFF"
488 #endif          
489                 " - mpg123 support: "
490 #ifdef USE_MPG123_INPUT
491                 "ON"
492 #else
493                 "OFF"
494 #endif
495                 " - \nogg123 support: "
496 #ifdef USE_OGG123_INPUT
497                 "ON"
498 #else
499                 "OFF"
500 #endif
501
502                 " - 3DNow!: "
503 #ifdef USE_3DNOW
504                 "ON"
505 #else
506                 "OFF"
507 #endif
508                 
509                 " - enhanced scheduling: "
510 #ifdef USE_SCHEDULER
511                 "ON"
512 #else
513                 "OFF"
514 #endif
515                 " - for a "
516 #ifdef WORDS_BIGENDIAN
517                 "big"
518                 
519 #else
520                 "little"
521 #endif
522                 " endian machine.\n";
523                 
524                 char buffer[4096];
525                 
526                 strcpy(buffer, about_prefix_umlaut);
527                 strcat(buffer, about_rest);
528                 
529                 label=gtk_label_new(buffer);
530
531                 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
532                 add_about_wid_fix(label);
533                 
534                 sep=gtk_hseparator_new();
535                 add_about_wid_fix(sep);
536
537                 label=gtk_label_new("License (GPL V2):");
538                 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
539                 add_about_wid_fix(label);
540
541                 hbox=gtk_hbox_new(FALSE, 5);            
542
543                 GtkTextIter iter;
544                 GtkTextBuffer *tbuffer;
545
546                 text=gtk_text_view_new();
547                 tbuffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
548                 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_NONE);
549                 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), false);
550                 gtk_text_buffer_get_iter_at_offset (tbuffer, &iter, 0);
551                 
552                 scroll=gtk_scrolled_window_new (NULL, NULL);
553                 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
554                 gtk_container_add (GTK_CONTAINER (scroll), text);
555                 gtk_text_buffer_create_tag (tbuffer, "courier", "family", "courier", NULL);
556                 
557                 gtk_text_buffer_insert_with_tags_by_name(tbuffer, &iter, license, -1, "courier", NULL);
558                 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);
559                 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 5);
560                 gtk_widget_set_usize(GTK_WIDGET(text), 640, 180);
561                 gtk_widget_show(text);          
562                 
563                 gtk_box_pack_start(GTK_BOX(hbox), scroll, WID_DYN);
564                 gtk_widget_show(scroll);                
565                 
566                 add_about_wid(hbox);
567
568                 sep=gtk_hseparator_new();
569                 add_about_wid_fix(sep);
570
571                 btn=gtk_button_new_with_label("Close");
572                 add_about_wid_fix(btn);
573
574                 gtk_container_add(GTK_CONTAINER(window), box);
575                 gtk_widget_show(box);
576                 
577                 gtk_signal_connect(GTK_OBJECT(btn), "clicked", (GtkSignalFunc) destroy_about, NULL);            
578                 gtk_signal_connect(GTK_OBJECT(window), "delete-event", (GtkSignalFunc) destroy_about, NULL);            
579         }
580         gtk_widget_show(window);
581         tX_set_icon(window, "tX About");
582         
583         while (gtk_events_pending()) gtk_main_iteration();
584                 
585         about=window;
586 }
587
588 GdkBitmap *tX_icon_mask=NULL;
589 GdkPixmap *tX_icon_pmap=NULL;
590 GtkWidget *tX_icon_widget=NULL;
591
592 void tX_set_icon(GtkWidget *widget, char *name)
593 {
594         GtkStyle *style;
595
596         style = gtk_widget_get_style( widget );
597
598         if (!tX_icon_pmap)
599         {
600                 tX_icon_pmap=gdk_pixmap_create_from_xpm_d(widget->window, &tX_icon_mask, &style->bg[GTK_STATE_NORMAL], (gchar **) tX_icon_xpm );
601                 //tX_icon_widget = gtk_pixmap_new( tX_icon_pmap, tX_icon_mask );                
602                 //gtk_widget_realize(tX_icon_widget);           
603         }
604
605         gdk_window_set_icon(widget->window, NULL, tX_icon_pmap, tX_icon_mask);
606         gdk_window_set_icon_name(widget->window, name); 
607 }