Alex: Added the new sources for terminatorX 3.5
[terminatorX.git] / src / tX_mastergui.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999  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_mastergui.cc
20  
21     Description: This implements the main (aka master) gtk+ GUI of terminatorX
22                  It serves as a container for the vtt-guis.
23 */    
24
25 #include <gtk/gtk.h>
26 #include <gdk/gdkx.h>
27 #include <X11/Xlib.h>
28 #include <math.h>
29 #include <string.h>
30 #include "version.h"
31 #include "tX_global.h"
32 #include "tX_engine.h"
33 #include "tX_vttgui.h"
34 #include "tX_vtt.h"
35 #include "tX_flash.h"
36 #include "tX_smlog.c"
37 #include "tX_dialog.h"
38 #define MAX_ROWS 5
39
40 GtkWidget *tt_box[MAX_ROWS];
41 GtkWidget *tt_parent;
42 GtkWidget *main_window;
43 GtkWidget *wav_progress;
44 GtkWidget *grab_button;
45 GtkWidget *main_flash;
46 GtkWidget *rec_btn;
47 GtkAdjustment *volume_adj;
48 GtkAdjustment *pitch_adj;
49 int rec_dont_care=0;
50
51 #define connect_entry(wid, func, ptr); gtk_signal_connect(GTK_OBJECT(wid), "activate", (GtkSignalFunc) func, (void *) ptr);
52 #define connect_adj(wid, func, ptr); gtk_signal_connect(GTK_OBJECT(wid), "value_changed", (GtkSignalFunc) func, (void *) ptr);
53 #define connect_button(wid, func, ptr); gtk_signal_connect(GTK_OBJECT(wid), "clicked", (GtkSignalFunc) func, (void *) ptr);
54
55 Window xwindow;
56 #define WID_DYN TRUE, TRUE, 0
57 #define WID_FIX FALSE, FALSE, 0
58 extern int add_vtt(GtkWidget *);
59 extern void recreate_gui(vtt_class *vtt, GtkWidget *daddy);
60 extern void destroy_gui(vtt_class *vtt);
61 extern void gui_show_frame(vtt_class *vtt, int show);
62
63 GdkWindow *save_dialog_win=NULL;
64 GdkWindow *load_dialog_win=NULL;
65 GtkWidget *save_dialog=NULL;
66 GtkWidget *load_dialog=NULL;
67
68 GdkWindow *rec_dialog_win=NULL;
69 GtkWidget *rec_dialog=NULL;
70
71 int stop_update=0;
72
73 vtt_class *old_focus=NULL;
74
75 int grab_status=0;
76 int last_grab_status=0;
77
78 void tx_note(char *message);
79
80 gint pos_update(gpointer data)
81 {
82         f_prec temp;
83
84         if (stop_update) 
85         {               
86                 cleanup_all_vtts();
87                 if (old_focus) gui_show_frame(old_focus, 0);
88                 old_focus=NULL;
89                 gtk_tx_flash_clear(main_flash);
90                 gdk_flush();    
91                 return(FALSE);
92         }
93         else
94         {
95                 update_all_vtts();
96                 temp=vtt_class::mix_max;
97                 vtt_class::mix_max=0;
98                 gtk_tx_flash_set_level(main_flash, temp);
99                 if (vtt_class::focused_vtt!=old_focus)
100                 {
101                         if (old_focus) gui_show_frame(old_focus, 0);
102                         old_focus=vtt_class::focused_vtt;
103                         if (old_focus) gui_show_frame(old_focus, 1);                    
104                 }
105                 if (grab_status!=last_grab_status)
106                 {
107                         last_grab_status=grab_status;
108                         if (!grab_status) 
109                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(grab_button), 0);
110                         //      gtk_widget_draw_default(grab_button);
111                 }
112                 gdk_flush();    
113                 return(TRUE);
114         }
115 }
116
117 void rebuild_vtts(int need_delete)
118 {
119         int i,box;
120         list <vtt_class *> :: iterator vtt;
121         
122         int vtts, vtt_per_box, boxes, maxboxes;
123         
124         if (need_delete)
125         for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++)
126         {
127                 destroy_gui((*vtt));
128         }
129         
130         
131         for (i=0; i<MAX_ROWS; i++)
132         {
133                 if (tt_box[i])
134                 {
135                         //gtk_container_remove(GTK_CONTAINER(tt_parent), tt_box[i]);
136                         gtk_widget_destroy(tt_box[i]);
137                         tt_box[i]=NULL;
138                 }
139         }
140
141         vtt_per_box=globals.gui_wrap;
142         vtts=vtt_class::main_list.size();
143         if (vtts>1)
144         {
145         maxboxes=vtts/globals.gui_wrap; 
146         if (vtts%globals.gui_wrap) maxboxes++;
147         boxes=maxboxes;
148                 
149         while (boxes<=maxboxes)
150         {
151                 vtt_per_box--;
152                 boxes=vtts/vtt_per_box;
153                 if (vtts%vtt_per_box) boxes++;
154         }
155         
156         vtt_per_box++;
157         }
158         
159         for (i=0, vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); i++, vtt++)
160         {
161                 box=i/vtt_per_box;
162
163                 if (!tt_box[box])
164                 {       
165                         tt_box[box]=gtk_vbox_new(FALSE, 0);     
166                         gtk_box_pack_start(GTK_BOX(tt_parent), tt_box[box], WID_DYN);
167                         gtk_widget_show(tt_box[box]); 
168                 }
169                 recreate_gui((*vtt), tt_box[box]);
170         }
171 }
172
173 GtkSignalFunc new_table()
174 {
175         int i;
176         
177         i=vtt_class::main_list.size()/globals.gui_wrap;
178         
179         if (i<MAX_ROWS)
180         {
181                 if (!tt_box[i])
182                 {
183                         tt_box[i]=gtk_vbox_new(FALSE, 0);       
184                         gtk_box_pack_start(GTK_BOX(tt_parent), tt_box[i], WID_DYN);
185                         gtk_widget_show(tt_box[i]); 
186                 }
187                 add_vtt(tt_box[i]);                             
188         }
189         rebuild_vtts(1);
190 }
191
192 /* Loading saved setups */
193
194 GtkSignalFunc cancel_load_tables(GtkWidget *wid)
195 {
196         gtk_widget_destroy(load_dialog);
197         load_dialog=NULL;
198         load_dialog_win=NULL;
199         return(0);
200 }
201
202 void do_load_tables(GtkWidget *wid)
203 {
204         FILE *in;
205         char buffer[PATH_MAX];
206         
207         strcpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(load_dialog)));
208         strcpy(globals.tables_filename, buffer);
209         
210         gtk_widget_destroy(load_dialog);
211         
212         load_dialog=NULL;
213         load_dialog_win=NULL;
214         
215         in=fopen(buffer, "r");
216         
217         if (in)
218         {
219                 if (vtt_class::load_all(in)) tx_note("Error while reading file.");
220                 fclose(in);
221                 gtk_adjustment_set_value(volume_adj, globals.volume);
222                 gtk_adjustment_set_value(pitch_adj, globals.pitch);
223         }
224         else
225         {
226                 tx_note("Failed to access file.");
227         }
228         rebuild_vtts(0);
229 }
230
231 GtkSignalFunc load_tables()
232 {
233         if (load_dialog_win) 
234         {
235                 gdk_window_raise(load_dialog_win);
236                 return 0;
237         }
238         
239         load_dialog=gtk_file_selection_new("Load Turntables");  
240         
241         if (strlen(globals.tables_filename))
242         {
243                 gtk_file_selection_set_filename(GTK_FILE_SELECTION(load_dialog), globals.tables_filename);
244         }
245         
246         gtk_widget_show(load_dialog);
247         
248         load_dialog_win=load_dialog->window;
249         
250         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(load_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_load_tables), NULL);
251         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(load_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC (cancel_load_tables), NULL); 
252         gtk_signal_connect (GTK_OBJECT(load_dialog), "delete-event", GTK_SIGNAL_FUNC(cancel_load_tables), NULL);        
253 }
254
255 /* save tables */
256
257 GtkSignalFunc cancel_save_tables(GtkWidget *wid)
258 {
259         gtk_widget_destroy(save_dialog);
260         save_dialog=NULL;
261         save_dialog_win=NULL;
262         return(0);
263 }
264
265 void do_save_tables(GtkWidget *wid)
266 {
267         FILE *out;
268         char buffer[PATH_MAX];
269         char *ext;
270         
271         strcpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(save_dialog)));
272         strcpy(globals.tables_filename, buffer);
273         
274         gtk_widget_destroy(save_dialog);
275         
276         save_dialog=NULL;
277         save_dialog_win=NULL;
278         
279         ext=strrchr(buffer, '.');
280         
281         if (ext)
282         {
283                 if (strcmp(ext, ".tX")) strcat(buffer, ".tX");
284         }
285         else
286         {
287                 strcat(buffer, ".tX");
288         }
289         
290         out=fopen(buffer, "w");
291         
292         if (out)
293         {
294                 if (vtt_class::save_all(out)) tx_note("Error while writing file.");
295                 fclose(out);
296         }
297         else
298         {
299                 tx_note("Failed to access file.");
300         }
301         rebuild_vtts(0);
302 }
303
304 GtkSignalFunc save_tables()
305 {
306         if (save_dialog_win) 
307         {
308                 gdk_window_raise(save_dialog_win);
309                 return 0;
310         }
311         
312         save_dialog=gtk_file_selection_new("Save Turntables");  
313         
314         if (strlen(globals.tables_filename))
315         {
316                 gtk_file_selection_set_filename(GTK_FILE_SELECTION(save_dialog), globals.tables_filename);
317         }
318         
319         gtk_widget_show(save_dialog);
320         
321         save_dialog_win=save_dialog->window;
322         
323         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(save_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_save_tables), NULL);
324         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(save_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC (cancel_save_tables), NULL); 
325         gtk_signal_connect (GTK_OBJECT(save_dialog), "delete-event", GTK_SIGNAL_FUNC(cancel_save_tables), NULL);        
326 }
327
328 GtkSignalFunc master_volume_changed (GtkWidget *wid, void *d)
329 {
330         vtt_class::set_master_volume(GTK_ADJUSTMENT(wid)->value);
331 }
332
333 GtkSignalFunc master_pitch_changed(GtkWidget *wid, void *d)
334 {
335         vtt_class::set_master_pitch (GTK_ADJUSTMENT(wid)->value);
336 }
337
338 GtkSignalFunc saturate_changed(GtkWidget *w, void *d)
339 {
340         vtt_class::enable_saturate (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)));
341 }
342
343 GtkSignalFunc audio_on(GtkWidget *w, void *d)
344 {
345         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
346         {
347                 stop_update=0;
348                 run_engine();
349                 gtk_timeout_add(globals.update_idle, (GtkFunction) pos_update, NULL);
350         }
351         else
352         {
353                 stop_engine();
354                 stop_update=1;
355                 
356                 if ((want_recording) && (!globals.autoname))
357                 {
358                         want_recording=0;
359                         rec_dont_care=1;
360                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rec_btn), 0);
361                         rec_dont_care=0;
362                 }
363         }
364 }
365
366 GtkSignalFunc cancel_rec(GtkWidget *wid)
367 {
368         gtk_widget_destroy(rec_dialog);
369         rec_dialog=NULL;
370         rec_dialog_win=NULL;
371         rec_dont_care=0;
372         return(0);
373 }
374
375 void do_rec(GtkWidget *wid)
376 {
377         char buffer[PATH_MAX];
378         
379         strcpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(rec_dialog)));
380
381         if (strlen(buffer))
382         {
383                 strcpy(globals.record_filename, buffer);                
384                 want_recording=1;
385                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rec_btn), 1);
386         }
387         
388         rec_dont_care=0;
389         
390         gtk_widget_destroy(rec_dialog);
391         
392         rec_dialog=NULL;
393         rec_dialog_win=NULL;
394 }
395
396 GtkSignalFunc select_rec_file()
397 {
398         if (rec_dialog_win) 
399         {
400                 gdk_window_raise(rec_dialog_win);
401                 return 0;
402         }
403         
404         rec_dialog=gtk_file_selection_new("Record To Disk");    
405         
406         if (strlen(globals.record_filename))
407         {
408                 gtk_file_selection_set_filename(GTK_FILE_SELECTION(rec_dialog), globals.record_filename);
409         }
410         
411         gtk_widget_show(rec_dialog);
412         
413         rec_dialog_win=rec_dialog->window;
414         
415         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(rec_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_rec), NULL);
416         gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(rec_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC (cancel_rec), NULL);  
417         gtk_signal_connect (GTK_OBJECT(rec_dialog), "delete-event", GTK_SIGNAL_FUNC(cancel_rec), NULL); 
418 }
419
420 GtkSignalFunc tape_on(GtkWidget *w, void *d)
421 {
422         if (rec_dont_care) return 0;
423
424         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
425         {       
426                 if (globals.autoname)
427                 {               
428                         globals.filectr++;
429                         sprintf(globals.record_filename, "%s%04i.wav", globals.prefix, globals.filectr);
430                         want_recording=1;
431                 }
432                 else
433                 {
434                         rec_dont_care=1;
435                         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), 0);
436                         select_rec_file();
437                 }
438         }
439         else
440         {
441                         want_recording=0;
442         }
443 }
444
445 GtkSignalFunc grab_on(GtkWidget *w, void *d)
446 {
447         grab_mouse(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)));
448         grab_status=1;
449 }
450
451 void grab_off()
452 {
453         grab_status=0;
454 }
455
456 GtkSignalFunc hide_clicked(GtkWidget *w, void *d)
457 {
458         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
459         {
460                 show_all_guis(0);
461         }
462         else
463         {
464                 show_all_guis(1);
465         }
466 }
467
468 void quit()
469 {
470         globals.width=main_window->allocation.width;
471         globals.height=main_window->allocation.height;
472
473         gtk_main_quit();
474 }
475
476 void mplcfitx()
477 /* Most Proabably Least Called Function In Terminator X :) */
478 {
479         show_about(0);
480 }
481
482
483
484 #define add_sep();      dummy=gtk_hseparator_new ();\
485         gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);\
486         gtk_widget_show(dummy);\
487
488 #define add_sep2();     dummy=gtk_hseparator_new ();\
489         gtk_box_pack_end(GTK_BOX(smaller_box), dummy, WID_FIX);\
490         gtk_widget_show(dummy);\
491
492
493 int create_mastergui(int x, int y)
494 {
495         GtkWidget *main_vbox;
496         GtkWidget *right_hbox;
497         GtkWidget *left_hbox;
498         GtkWidget *control_box;
499         GtkAdjustment *dumadj;
500         GtkWidget *dummy;
501         GtkWidget *small_box;
502         GtkWidget *smaller_box;
503         int i;
504
505         main_window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
506         gtk_window_set_title(GTK_WINDOW(main_window), VERSIONSTRING);
507         
508         gtk_container_set_border_width(GTK_CONTAINER(main_window), 5);
509         
510         main_vbox=gtk_hbox_new(FALSE, 5);
511         
512         gtk_container_add(GTK_CONTAINER(main_window), main_vbox);
513         gtk_widget_show(main_vbox);
514         
515         left_hbox=gtk_vbox_new(FALSE, 5);
516         gtk_box_pack_start(GTK_BOX(main_vbox), left_hbox, WID_DYN);
517         gtk_widget_show(left_hbox);
518         
519         control_box=gtk_hbox_new(FALSE, 5);
520         gtk_box_pack_start(GTK_BOX(left_hbox), control_box, WID_FIX);
521         gtk_widget_show(control_box);
522         
523         dummy=gtk_hseparator_new();
524         gtk_box_pack_start(GTK_BOX(left_hbox), dummy, WID_FIX);
525         gtk_widget_show(dummy);
526         
527         dummy=gtk_toggle_button_new_with_label(" Audio Engine ");
528         connect_button(dummy,audio_on, NULL);
529         gtk_box_pack_start(GTK_BOX(control_box), dummy, WID_FIX);
530         gtk_widget_show(dummy);
531         
532         grab_button=gtk_toggle_button_new_with_label(" Mouse Grab ");
533         gtk_box_pack_start(GTK_BOX(control_box), grab_button, WID_FIX);
534         connect_button(grab_button, grab_on, NULL);
535         gtk_widget_show(grab_button);
536
537         dummy=gtk_check_button_new_with_label("Record");
538         rec_btn=dummy;
539         connect_button(dummy,tape_on, NULL);
540         gtk_box_pack_start(GTK_BOX(control_box), dummy, WID_FIX);
541         gtk_widget_show(dummy);
542
543         
544         dummy=gtk_label_new("Master Volume:");
545         gtk_box_pack_start(GTK_BOX(control_box), dummy, WID_FIX);
546         gtk_widget_show(dummy);
547         
548         dumadj=(GtkAdjustment*) gtk_adjustment_new(globals.volume, 0, 1.5, 0.001, 0.001, 0.01);
549         volume_adj=dumadj;
550         connect_adj(dumadj, master_volume_changed, NULL);       
551         dummy=gtk_hscale_new(dumadj);
552         gtk_scale_set_digits(GTK_SCALE(dummy), 2);
553         gtk_scale_set_value_pos(GTK_SCALE(dummy), GTK_POS_LEFT);
554         gtk_box_pack_start(GTK_BOX(control_box), dummy, WID_DYN);
555         gtk_widget_show(dummy);
556
557         dummy=gtk_label_new("Master Pitch:");
558         gtk_box_pack_start(GTK_BOX(control_box), dummy, WID_FIX);
559         gtk_widget_show(dummy);
560
561         dumadj=(GtkAdjustment*) gtk_adjustment_new(globals.pitch, -3, 3, 0.001, 0.001, 0.01);
562         pitch_adj=dumadj;
563         connect_adj(dumadj, master_pitch_changed, NULL);        
564         dummy=gtk_hscale_new(dumadj);
565         gtk_scale_set_digits(GTK_SCALE(dummy), 2);
566         gtk_scale_set_value_pos(GTK_SCALE(dummy), GTK_POS_LEFT);
567         gtk_box_pack_start(GTK_BOX(control_box), dummy, WID_DYN);
568         gtk_widget_show(dummy);
569         
570         dummy=gtk_hbox_new(FALSE,0);
571         gtk_box_pack_start(GTK_BOX(left_hbox), dummy, WID_DYN);
572         gtk_widget_show(dummy);
573         
574         tt_parent=dummy;
575         
576         tt_box[0]=gtk_vbox_new(FALSE, 0);       
577         gtk_box_pack_start(GTK_BOX(dummy), tt_box[0], WID_DYN);
578         gtk_widget_show(tt_box[0]); 
579                 
580         tt_box[1]=NULL;
581         tt_box[2]=NULL;
582         
583         dummy=gtk_hseparator_new();
584         gtk_box_pack_start(GTK_BOX(left_hbox), dummy, WID_FIX);
585         gtk_widget_show(dummy);
586         
587         wav_progress = gtk_progress_bar_new();
588         gtk_box_pack_start (GTK_BOX(left_hbox), wav_progress, WID_FIX);
589         gtk_widget_show(wav_progress);
590
591         dummy=gtk_vseparator_new();
592         gtk_box_pack_start(GTK_BOX(main_vbox), dummy, WID_FIX);
593         gtk_widget_show(dummy);
594                 
595         right_hbox=gtk_vbox_new(FALSE, 5);
596         gtk_box_pack_start(GTK_BOX(main_vbox), right_hbox, WID_FIX);
597         gtk_widget_show(right_hbox);
598         
599         dummy=gtk_button_new_with_label("Add Turntable");
600         gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);
601         gtk_widget_show(dummy);
602         
603         gtk_signal_connect(GTK_OBJECT(dummy), "clicked", GtkSignalFunc(new_table), NULL);       
604
605         dummy=gtk_button_new_with_label("Load Turntables");
606         gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);
607         gtk_widget_show(dummy);
608         gtk_signal_connect(GTK_OBJECT(dummy), "clicked", GtkSignalFunc(load_tables), NULL);     
609         
610         dummy=gtk_button_new_with_label("Save Turntables");
611         gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);
612         gtk_widget_show(dummy);
613         gtk_signal_connect(GTK_OBJECT(dummy), "clicked", GtkSignalFunc(save_tables), NULL);     
614
615         add_sep();
616
617         dummy=gtk_check_button_new_with_label("Saturate");
618         gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);
619         gtk_widget_show(dummy);
620         connect_button(dummy, saturate_changed, NULL);
621         
622         dummy=gtk_check_button_new_with_label("Hide Gui");
623         gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);
624         gtk_widget_show(dummy);
625         connect_button(dummy, hide_clicked, NULL);
626         
627         add_sep();
628         
629         dummy=gtk_button_new_with_label("Options");
630         gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);
631         gtk_widget_show(dummy);
632         gtk_signal_connect (GTK_OBJECT(dummy), "clicked", (GtkSignalFunc) display_options, NULL);
633
634         dummy=gtk_button_new_with_label("About");
635         gtk_box_pack_start(GTK_BOX(right_hbox), dummy, WID_FIX);
636         gtk_widget_show(dummy);
637         gtk_signal_connect (GTK_OBJECT(dummy), "clicked", (GtkSignalFunc) mplcfitx, NULL);      
638         
639         add_sep();              
640
641         small_box=gtk_hbox_new(FALSE, 5);
642         gtk_box_pack_start(GTK_BOX(right_hbox), small_box, WID_DYN);
643         gtk_widget_show(small_box);
644         
645         smaller_box=gtk_vbox_new(FALSE, 0);
646         gtk_box_pack_start(GTK_BOX(small_box), smaller_box, WID_FIX);
647         gtk_widget_show(smaller_box);
648
649         GdkBitmap *mask;
650         GtkStyle *style;
651         GdkPixmap *pmap=NULL;
652         GtkWidget *pwid;
653         
654         gtk_widget_realize(main_window);
655         style = gtk_widget_get_style( main_window );
656         pmap=gdk_pixmap_create_from_xpm_d(main_window->window, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **) tx_smlog_xpm );
657         pwid = gtk_pixmap_new( pmap, mask );
658         gtk_box_pack_start(GTK_BOX(smaller_box), pwid, WID_FIX);
659         gtk_widget_show( pwid );
660         
661
662         dummy=gtk_label_new("14628");
663         gtk_misc_set_alignment(GTK_MISC(dummy), 1, 0.5);
664         gtk_box_pack_end(GTK_BOX(smaller_box), dummy, WID_FIX);
665         gtk_widget_show(dummy);
666
667         dummy=gtk_label_new("Memory/kB:");
668         gtk_misc_set_alignment(GTK_MISC(dummy), 0, 0.5);
669         gtk_box_pack_end(GTK_BOX(smaller_box), dummy, WID_FIX);
670         gtk_widget_show(dummy);
671         
672         add_sep2();
673
674         dummy=gtk_label_new("4");
675         gtk_misc_set_alignment(GTK_MISC(dummy), 1, 0.5);
676         gtk_box_pack_end(GTK_BOX(smaller_box), dummy, WID_FIX);
677         gtk_widget_show(dummy);
678
679         dummy=gtk_label_new("Vtts:");
680         gtk_misc_set_alignment(GTK_MISC(dummy), 0, 0.5);
681         gtk_box_pack_end(GTK_BOX(smaller_box), dummy, WID_FIX);
682         gtk_widget_show(dummy);
683
684         add_sep2();
685
686         dummy=gtk_label_new("3.5");
687         gtk_misc_set_alignment(GTK_MISC(dummy), 1, 0.5);
688         gtk_box_pack_end(GTK_BOX(smaller_box), dummy, WID_FIX);
689         gtk_widget_show(dummy);
690
691         dummy=gtk_label_new("Release:");
692         gtk_misc_set_alignment(GTK_MISC(dummy), 0, 0.5);
693         gtk_box_pack_end(GTK_BOX(smaller_box), dummy, WID_FIX);
694         gtk_widget_show(dummy);
695         
696         add_sep2();
697
698         dummy=gtk_label_new("Status:");
699         gtk_misc_set_alignment(GTK_MISC(dummy), 0.5, 0.5);
700         gtk_box_pack_end(GTK_BOX(smaller_box), dummy, WID_FIX);
701         gtk_widget_show(dummy);
702         
703         main_flash=gtk_tx_flash_new();
704         gtk_box_pack_end(GTK_BOX(small_box), main_flash, WID_DYN);
705         gtk_widget_show(main_flash);
706
707         gtk_window_set_default_size(GTK_WINDOW(main_window), x, y);     
708
709         gtk_signal_connect (GTK_OBJECT(main_window), "destroy", (GtkSignalFunc) quit, NULL);    
710 }
711
712 gfloat old_percent=-1;
713
714 void wav_progress_update(gfloat percent)
715 {
716         percent=floor(percent*10.0)/10.0; //Updateing statusbars with gtk-themes eats up hell of a lot CPU-time
717                                           // which is why we update every 10% only.
718         
719         if (wav_progress)
720         {
721                 if (old_percent != percent)
722                 {
723                         old_percent = percent;
724                         gtk_progress_bar_update(GTK_PROGRESS_BAR(wav_progress), percent);
725                         while (gtk_events_pending()) gtk_main_iteration();      
726                 }
727         }
728
729 }
730
731 void note_destroy(GtkWidget *widget, GtkWidget *mbox)
732 {
733         gtk_widget_destroy(GTK_WIDGET(mbox));
734 }
735
736 void tx_note(char *message)
737 {
738         char buffer[4096]="\n     [ terminatorX Message: ]     \n\n";
739         
740         GtkWidget *mbox;
741         GtkWidget *label;
742         GtkWidget *btn;
743         
744         mbox=gtk_dialog_new();
745
746         strcat(buffer, "   ");  
747         strcat(buffer, message);
748         strcat(buffer, "   ");
749         label=gtk_label_new(buffer);
750         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mbox)->vbox), label, TRUE, TRUE, 0);
751         gtk_widget_show(label);
752         
753         btn = gtk_button_new_with_label("Ok");
754         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mbox)->action_area), btn, TRUE, TRUE, 0);
755         gtk_widget_show(btn);
756         
757         gtk_signal_connect(GTK_OBJECT(btn), "clicked", GtkSignalFunc(note_destroy), mbox);
758         
759         gtk_widget_show(mbox);
760 }
761
762 void display_mastergui()
763 {
764         GtkWidget *top;
765         
766         gtk_widget_show(main_window);
767         top=gtk_widget_get_toplevel(main_window);
768         xwindow=GDK_WINDOW_XWINDOW(top->window);
769 }