File: cdrtoaster

package info (click to toggle)
cdrtoaster 1.04p2-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 80 kB
  • ctags: 29
  • sloc: tcl: 1,012; makefile: 40
file content (1222 lines) | stat: -rwxr-xr-x 35,800 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
#!/usr/bin/wish
proc interface {} {

wm title . "CDR Toaster - 1.04pre2"

label .title -text {CDR Toaster} -font -*-times-bold-r-*-*-30-*-*-*-*-*-*-*

frame .b -border 3 -relief raised
button .b.burn -text {Have a Cook-Off}

set m .b.trick.m
menubutton .b.trick -text {Do Tricks} -menu $m -relief raised -border 2
menu $m -tearoff 0
$m add command -label "Read CDROM to create ISO image" -command read_iso
$m add command -label "Read audio tracks from CDROM" -command read_audio
$m add command -label "Blank a CDRW Media" -command blank_cdrw

button .b.quit -text {Never Mind}

set m .b.help.m
menubutton .b.help -text {Get Help!} -menu $m -relief raised -border 2
menu $m -tearoff 0
$m add command -label "About" -command help
$m add command -label "Clarifications" -command help_clarify

frame .audio
label .audio.la -text {Audio Track List} 
frame .audio.f -border 3 -relief sunken 
listbox .audio.f.lb -height 16 -width 30 -selectmode browse  -yscrollcommand {.audio.f.sb set}
scrollbar .audio.f.sb -orient v -command {.audio.f.lb yview}
frame .audio.m
button .audio.m.up -text {Move up} -command {
 set num [.audio.f.lb curselection]
 if {""==$num} return
 if {$num==0} return
 flip $num
 incr num -1
 .audio.f.lb selection set $num
 .audio.f.lb see $num
}
button .audio.m.dn -text {Move Down} -command {
 set num [.audio.f.lb curselection]
 if {""==$num} return
 incr num 1
 if {$num==[.audio.f.lb index end]} return
 flip $num
 .audio.f.lb selection set $num
 .audio.f.lb see $num
}
frame .audio.ar -relief flat 
button .audio.ar.add -text {Add} -command {
audio_add
}
button .audio.ar.rem -text {Remove} -command {
audio_remove
}
button .audio.remall -text {Remove All} -command audio_removeall

label .lds -text "Data Track Source"

frame .ds -border 3 -relief sunken 
radiobutton .ds.none -text {Make audio-only disk} -variable {ds} -value none
radiobutton .ds.mk -text {Make data track on the fly} -variable {ds} -value mkisofs
radiobutton .ds.pre -text {Use pre-made data track} -variable {ds} -value premade
entry .ds.tname -width 20 -font 7x14
.ds.tname insert 0 "image.iso"

# Lets make the selection button if you have tk8.0 +
if {[info tclversion] >= 8.0} {
  button .ds.select -text {Select} -command {my_image}
}


label .lm -text {Data Track Creation Options}
frame .m -border 3 -relief sunken

frame .m.scan
checkbutton .m.scan.all -text {All files (keep backups etc.)} -variable {all}
checkbutton .m.scan.links -text {Follow SymLinks} -variable {follow}

frame .m.file
checkbutton .m.file.joliet -text {Joliet support} -variable {joliet}
checkbutton .m.file.trans -text {Translation Tables (old)} -variable {trans}

frame .m.rock -border 0 -relief flat 
label .m.rock.l -text {Rock Ridge:}
radiobutton .m.rock.none -text {None} -variable {rock} -value none
radiobutton .m.rock.rational -text {Rationalized} -variable {rock} -value rat
radiobutton .m.rock.literal -text {Literal} -variable {rock} -value lit

frame .m.volid -border 0
label .m.volid.l -text {Volume ID (name)}
entry .m.volid.e -width 32 -font 7x14
frame .m.root -border 0 -relief flat
label .m.root.l -text {Root of Tree}
entry .m.root.e -width 24 -font 7x14
button .m.root.p -text "Peruse" -command {
 peruse
 .m.root.e delete 0 end
 .m.root.e insert 0 $perused
}

frame .m.custom -border 0
checkbutton .m.custom.use -text "Use Custom Layout" -variable custom(use)
button .m.custom.b -text {Set Custom Layout} -command custom_layout

frame .m.boot
checkbutton .m.boot.check -text "El Torito Bootable CD" -variable boot
button .m.boot.opts -text "Boot Setup" -command boot_setup

label .lc -text {cdrecord options} 
frame .c -border 3 -relief sunken
frame .c.flag
checkbutton .c.flag.dummy -text {Dummy Burn} -variable {dummy}
checkbutton .c.flag.eject -text {Eject when done} -variable {eject}
button .c.flag.pad -text "Padding..." -command padbox
frame .c.dev -border 0 -relief flat 
label .c.dev.l -text {Device} 
entry .c.dev.e -width 20 -font 7x14 
frame .c.speed
label .c.speed.l -text "Speed:"
radiobutton .c.speed.1 -text "1x" -variable speed -value 1
radiobutton .c.speed.2 -text "2x" -variable speed -value 2
radiobutton .c.speed.4 -text "4x" -variable speed -value 4
radiobutton .c.speed.6 -text "6x" -variable speed -value 6
radiobutton .c.speed.8 -text "8x" -variable speed -value 8

pack .title -side top
pack .b -side top -ipadx 30 -ipady 10
pack .b.burn -side left -expand 1
pack .b.trick -side left -expand 1 -ipady 1 -ipadx 1
pack .b.quit -side left -expand 1
pack .b.help -side left -expand 1
pack .audio -side right -anchor n
pack .audio.la -side top
pack .audio.f -side top
pack .audio.f.lb -side left
pack .audio.f.sb -side left -fill y
pack .audio.m -side top
pack .audio.m.up -side left
pack .audio.m.dn -side left
pack .audio.ar -side top
pack .audio.ar.add -side left
pack .audio.ar.rem -side left
pack .audio.remall -side top
pack .lds -side top
pack .ds -side top -padx 5
pack .ds.none -side bottom -anchor w
pack .ds.mk -side bottom -anchor w
pack .ds.pre -side left -anchor w
pack .ds.tname -side left -anchor w

# Lets make the selection button if you have tk8.0 +
if {[info tclversion] >= 8.0} {
  pack .ds.select -side right -anchor n
}

pack .lm -side top
pack .m -side top
pack .m.scan -side top -fill x
pack .m.scan.all -side left
pack .m.scan.links -side right
pack .m.file -side top -fill x
pack .m.file.joliet -side left
pack .m.file.trans -side right
pack .m.rock -side top -anchor w
pack .m.rock.l -side left
pack .m.rock.none -side left
pack .m.rock.rational -side left
pack .m.rock.literal -side left
pack .m.volid -side top -anchor w
pack .m.volid.l -side left
pack .m.volid.e -side left
pack .m.root -side top -anchor w -fill x
pack .m.root.l -side left
pack .m.root.e .m.root.p -side left
pack .m.custom -side top -fill x
pack .m.custom.use -side left
pack .m.custom.b -side right
pack .m.boot -side top -anchor w -fill x
pack .m.boot.check -side left
pack .m.boot.opts -side left -expand 1
pack .lc -side top
pack .c -side top
pack .c.flag -side top
pack .c.flag.dummy -side left
pack .c.flag.eject -side left
pack .c.flag.pad -side left
pack .c.dev -side top
pack .c.dev.l -side left
pack .c.dev.e -side left
pack .c.speed -side top
pack .c.speed.l .c.speed.1 .c.speed.2 .c.speed.4 .c.speed.6 .c.speed.8 -side left

frame .spacer -height 10
pack .spacer -side top

.c.dev.e insert 0 "/dev/sg0"

}
proc toast {} {
global apad dpad ds

if {$ds == "none"} {
set source ""
}

if {$ds == "premade"} {
 set source [.ds.tname get]
 if {![file isfile $source]} {
 alert "Premade data track must be a regular file."
 return
 }
}

if {$ds == "mkisofs"} {
 set source -
 set mk [make_mkisofs_cmd]
 if {$mk == ""} {
  return
 }
}

set cd [base_cdrec]

set nuke ""
set convlist ""

if {$source != ""} {
 lappend cd -data
 if $dpad {lappend cd "-pad"}
 lappend cd $source
}
set tmp [.audio.f.lb get 0 end]
if {$tmp == ""} {
 if {$ds == "none"} {
  alert "No audio tracks were specified for an audio-only disk. This makes no sense."
  return
 }
} else {
 lappend cd -audio
 if $apad {lappend cd "-pad"} else {
  if $dpad {lappend cd "-nopad"}
 }
 set warned 0
 foreach i $tmp {
  ## Have to validate audio track type
  switch [file extension $i] {
   .mp2 -
   .mpg -
   .mp3 {
    if {$warned == 0} {
     # Give use opportunity to opt out. Also collect info for conversion.
     set tempdir [get_mp3_burn_info]
     if {$tempdir==""} {
      alert "An understandable choice."
      return
     }
     set warned 1
    }
    # Queue for conversion burning, and nuking.
    # Yes, there are race conditions. No, I don't care too much. If
    # you have a fix for the race conditions which is not too complicated,
    # tell me and I'll probably add your fix. Thanks.
    set tail [file tail $i]
    set tempfile [file join $tempdir "###${tail}.raw"]
    if [file exists $tempfile] {
     alert "$tempfile already exists. I will cancel the burn and let you decide what to do."
     return
    }
    lappend convlist $i
    lappend nuke $tempfile
    lappend cd $tempfile
   }
   
   .wav -
   .raw -
   .pcm {
    # queue for burning
    lappend cd $i
   }
   
   default {
    # Note the offending file for the user.
    alert "I don't recognize the file extention on '$i'. For safety reasons, I won't burn that file as an audio track.\n\nI'd suggest removing it and others like it from the audio track list."
    return
   }
  }
 }
}

if {$ds == "mkisofs"} { set cd [concat $mk $cd] }

if {[sure "About to run command:\n\n$cd\n\nAre you sure?"]} {
 set err 0
 set err [catch {
  # Run necessary conversions
  if [llength $convlist] {
    
    toplevel .conv
    wm title .conv "Converting MP3s"
    text .conv.t -width 80 -height [llength $convlist]
    pack .conv.t
    
    foreach orig $convlist tempfile $nuke {
      .conv.t insert end "$orig --> $tempfile ..."
      update
      exec mpg123 -s $orig | sox -t raw -w -s -c 2 -r 44100 - $tempfile >&/dev/null
      .conv.t insert end " Done.\n"
    }
    
    destroy .conv
  }
 }]
 
 if $err {
  alert "Some error occured during the MPEG conversion process. You probably ran out of space or don't have the mpg123 and sox tools installed."
 } else {
  # Remove temp files when done...
  foreach tempfile $nuke {
    set cd [concat $cd ";\n rm $tempfile"]
  }
  dispatch $cd {CD Burn Progress}
 }

}

}
proc audio_add {} {
catch {destroy .add}
toplevel .add
wm title .add {Add Audio Tracks}


label .add.l -text {Track Name (Globals OK)} 
entry .add.e -width 32 -font 7x14 
button .add.ok -text {OK} -command {
set tmp [glob -nocomplain [.add.e get]]
foreach i $tmp {.audio.f.lb insert end $i}
destroy .add
}
button .add.cancel -text {Cancel} -command {
destroy .add
}

pack .add.l -side top
pack .add.e -side top
pack .add.ok -side left
pack .add.cancel -side right


}
proc audio_remove {} {
set victim [.audio.f.lb curselection]
catch {.audio.f.lb delete $victim}
}
proc audio_removeall {} {
.audio.f.lb delete 0 end
}
proc flip n {
.audio.f.lb selection clear 0 end
set above [expr $n - 1]
set tmp [.audio.f.lb get $n]
.audio.f.lb insert $above $tmp
.audio.f.lb delete [expr $n + 1]
}
proc alert msg {
tk_dialog .alert Alert $msg info 0 "So it goes."
}
proc help {} {
catch {destroy .help}
toplevel .help
wm title .help {Help!}

button .help.ok -text {This Rules!} -command {destroy .help}
text .help.t -width 60 -height 18 -yscrollcommand {.help.sb set} -wrap word
scrollbar .help.sb -orient v -command {.help.t yview}

pack .help.ok -side bottom
pack .help.t -side left
pack .help.sb -side left -fill y

.help.t insert 1.0 {About CDR-Toaster version 1.04pre2

This is a graphical front-end for the excelent programs 'mkisofs', 'cdrecord', and 'cdparanoia'.

It's good for:
 o Avoiding coasters due to command-line mistakes
 o Eliminating the tedium of consulting documentation
 o Feeling more secure in a correct set of options
 o Being lazy

As you can guess, I wrote it for what it's good for.

CDR-Toaster is copyright 1999 Ian Kjos <brooke@jump.net>

CDR-Toaster contains some code contributed by:
  Andrew Williams <woodchuk@bellatlantic.net>

CDR-Toaster is availible under the GNU General
Public License version 2.0 or later (at your option).
This license can be found at 
http://www.gnu.org/copyleft/gpl.html

}

.help.t config -state disabled

}
proc sure msg {
return [expr ![tk_dialog .alert Confirmation $msg questhead -1 yes no]]
}
proc read_iso {} {
catch {destroy .top}
toplevel .top
wm title .top "Read ISO image"

frame .top.dev -border 0 -relief flat 
frame .top.file -border 0 -relief flat 
frame .top.b -border 0 -relief flat 
label .top.dev.l -text {device to read:} 
label .top.file.l -text {file to write:} 
entry .top.dev.e -width 20 -font 7x14 
entry .top.file.e -width 20 -font 7x14 
button .top.b.ok -text {Do it} -command {
if {![file readable [.top.dev.e get]]} {
 alert "You do not have read permissions on '[.top.dev.e get]'. You should probably be running this as root."
 return
}
set tmp "echo 'This takes a good while.';dd if=[.top.dev.e get] of=[.top.file.e get] bs=1024k; eject [.top.dev.e get]"
dispatch $tmp "Reading ISO Image"
destroy .top
}
button .top.b.dis -text {Forget it} -command {
destroy .top
}

pack .top.dev -side top
pack .top.file -side top
pack .top.b -side top -fill x
pack .top.dev.l -side left
pack .top.file.l -side left
pack .top.dev.e -side left
pack .top.file.e -side left
pack .top.b.ok -side left -expand 1
pack .top.b.dis -side left -expand 1

.top.dev.e insert 0 "/dev/cdrom"
.top.file.e insert 0 "image.iso"

}
proc read_audio {} {
catch {destroy .top}
toplevel .top
wm title .top "Read audio tracks"

frame .top.path
label .top.path.l -text "Rip Destination: "
entry .top.path.dest
button .top.path.peruse -text "Peruse" -command {
peruse
.top.path.dest delete 0 end
.top.path.dest insert 0 $perused
}

frame .top.1 -border 0 -relief flat 
frame .top.2 -border 0 -relief flat 
frame .top.3 -border 0 -relief flat 
frame .top.4 -border 0 -relief flat 
radiobutton .top.1.entire -text {Rip Entire Disk} -variable {rip} -value {all}
radiobutton .top.2.track -text {Tracks:} -variable {rip} -value {track}
radiobutton .top.3.custom -text {Custom Options} -variable {rip} -value {custom}
button .top.4.ok -text {Do it} -command {
 set tmp "Ripping Audio"
 switch $rip {
  all {
   set dp "cdparanoia -s -w -B 1-"
  }
  track {
   set dp "cdparanoia -s -w -B [.top.2.from get]-[.top.2.to get]"
  }
  custom {
   set dp "cdparanoia [.top.3.opt get]"
  }
 }
 if {[.top.path.dest get] != ""} {
  set dp "cd [.top.path.dest get];$dp"
 }
 dispatch $dp $dp
 destroy .top
}
button .top.4.dis -text {Not now.} -command {
 destroy .top
}
label .top.2.lfr -text {From:} 
entry .top.2.from -width 4 -font 7x14 
label .top.2.lto -text {To:} 
entry .top.2.to -width 4 -font 7x14 
entry .top.3.opt -width 20 -font 7x14 

pack .top.path -side top -fill x
pack .top.path.l .top.path.dest .top.path.peruse -side left
pack .top.1 -side top -fill x
pack .top.2 -side top -fill x
pack .top.3 -side top -fill x
pack .top.4 -side top -fill x
pack .top.1.entire -side left -anchor w
pack .top.2.track -side left -anchor w
pack .top.3.custom -side left -anchor w
pack .top.4.ok -side left -expand 1
pack .top.4.dis -side left -expand 1
pack .top.2.lfr -side left -anchor e
pack .top.2.from -side left -anchor e
pack .top.2.lto -side left -anchor e
pack .top.2.to -side left -anchor e
pack .top.3.opt -side left -anchor e

global rip
set rip all


}
proc blank_cdrw {} {
global blank

catch {destroy .top}
toplevel .top
wm title .top "Blank CDRW Media"

frame .top.type -border 0 -relief flat 
frame .top.b -border 0 -relief flat 
label .top.type.l -text {Blank Type} 
frame .top.type.r
radiobutton .top.type.all -text {Entire Disk} -variable {blank} -value {all}
radiobutton .top.type.session -text {Session} -variable {blank} -value {session}
radiobutton .top.type.track -text {Track} -variable {blank} -value {track}
radiobutton .top.type.fast -text {Fast} -variable {blank} -value {fast}
radiobutton .top.type.r.unreserve -text {Unreserve} -variable {blank} -value {unreserve}
radiobutton .top.type.r.trtail -text {Track Tail} -variable {blank} -value {trtail}
radiobutton .top.type.r.unclose -text {Unclose} -variable {blank} -value {unclose}
button .top.b.ok -text {Do it} -command {
 set cmd [base_cdrec]
 lappend cmd "blank=${blank}"
 dispatch $cmd "Blanking CDRW: ${blank}"
 destroy .top
}
button .top.b.dis -text {Let's not.} -command {
 destroy .top
}

pack .top.type -side top
pack .top.b -side top -fill x
pack .top.type.l -side left
pack .top.type.r -side right -fill y
pack .top.type.all -side top -anchor w
pack .top.type.session -side top -anchor w
pack .top.type.track -side top -anchor w
pack .top.type.fast -side top -anchor w
pack .top.type.r.unreserve -side top -anchor w
pack .top.type.r.trtail -side top -anchor w
pack .top.type.r.unclose -side top -anchor w
pack .top.b.ok -side left -expand 1
pack .top.b.dis -side left -expand 1

set blank session

}
proc dispatch {cmd title} {
 exec /usr/X11R6/bin/xterm -geometry 80x6 -title $title -e sh -c [concat $cmd \; echo Done. Press Enter\; read] &
}
proc base_cdrec {} {
global dummy eject speed
set cd [list cdrecord -v]
if {$dummy} {lappend cd -dummy}
if {$eject} {lappend cd -eject}
set dev [.c.dev.e get]
if {![file writable $dev]} {
 alert "You don't have write permission to the device you selected. You should probably be running this as root. If that is not an option, get the system administrator to give you write priveleges for the cd-writer."
 return -code return
}
lappend cd "dev=$dev" "speed=$speed"
return $cd
}
proc help_clarify {} {
catch {destroy .help}
toplevel .help
wm title .help {Help!}

set helpstuff {
 {All Files}
{   Ordinarily files with names contataing '#' or '~'
   are backup files on Linux. CDR-Toaster will instruct
   mkisofs to skip these files in the creation of a
   CD. If you DON'T want to skip them, click this box.
}
 {Joliet support}
{   This stores long filenames on a CD so Windows 9x/NT
   machines can read them. Unlike the Joliet CDs produced
   on MS-Windows, you can still see the 8.3 filenames on
   MS-Dos and other systems that don't support Joliet.
   Linux kernels 2.2 and up can also read Joliet names.
}
 {Rock Ridge}
{   This is another way to store long filenames on a CD.
   It works with all Un*x-like systems that also support
   CDs. It allows file permissions, ownership info, and
   symbolic links to be stored and appear as such on the
   CD. If you choose "Literal", the final CD will look in
   all respects identical to the directory hierarchy it
   was created from, except for some reason you can't
   write to it. This could be good for system backups.
   If you choose "Rationalized", you get a more generally
   useful CD. It sets the user and group of all files to
   root, removes SUID and SGID bits, makes all files and
   folders readable globally, sets all execute bits for
   anything that has any execute bits, and clears all
   write bits.
}
 {Follow SymLinks}
{   Normally symbolic links are ignored, unless you use
   Rock Ridge, when they are copied literally. If you
   want the actual files and folders pointed to by the
   symbolic links to show up on the CD, check this box.
}
 {Translation Tables}
{   Puts a file called "TRANS.TBL" in every directory on
   the CD which maps 8.3 files to their long equivalents.
   Very simple, very old.
}
 {MPEG Compressed Audio}
{   CDR-Toaster will extract MPEG Compressed audio (mp3)
   if you have mpg123 and sox installed. This way you
   can burn an audio CD from mp3 files. The sound will
   not be as good quality as the original uncompressed
   audio, but that's the trade off that a lossy compression
   like MPEG makes to attain the high ratios that it does.
   For more information, point your web browser at these:
   http://www.mpeg.org/MPEG/
   http://drogo.cselt.stet.it/mpeg/
}
 {PCM vs. WAV}
{   WAV is a format composed of 44 bytes of header data,
   then raw PCM data. PCM means only pulse code modulation,
   which is to say a digitial audio format made of numbers
   to signify each sample. There is no attempt made to
   compress the signals beyond the decisions of sample rate
   and dynamic range.

   For CDR-Toaster to burn audio, you can feed it either a
   raw PCM file or a WAV file. WAV files are better because
   they contain enough information in the header to ensure
   that the audio format is correct. To get an audio track
   to burn properly, the PCM data needs to be composed of
   exactly the same structure as on a CD - that is 41.1 khz
   16 bit stereo. Anything else and you get an unusable
   audio track.

   When using WAV files ripped from a CD, (as CDPARANOIA
   does) you will get files that are already correct. If
   you want to use a WAV file you recorded yourself, it is
   wise to ensure you recorded cd-quality (16 bit stereo
   44.1khz) uncompressed audio. If you did otherwise, there
   are many format converters availible which can convert to
   this format without any signal loss. The other issue with
   audio files you record yourself is that they must be a
   precise multiple of 1/75th of a second. This is where
   audio padding comes into play. If you do not have the
   right number of samples, the Pad Audio option can round
   up using absolute silence.
}
 {Burning Bootable CDs}
{   When your computer boots from a CD, it treats part of
   the CD as a floppy drive. The emulation is at the BIOS
   level, so programs like the Linux Kernel operate
   normally but programs like LILO or SYSLINUX are fooled.
   All attempts to access the (primary) floppy drive are
   mapped to the "BOOT" extent on the CD.

   Step by step, the easiest way to make a bootable CD
   is as follows:

   1. Make a real live floppy disk that boots your computer
      ok. There are many rescue disk packages which are
      good for this purpose, or you can use your operating
      system install disk. Make sure the floppy actually
      boots properly.

   2. Copy this floppy disk to an image file. Under Linux
      you can type:
         dd if=/dev/fd0 of=bootimage.bin bs=18k

   3. Put this file in the directory you are going to make
      your CD from:
         mv bootimage.bin /tmp/my_cdrom/

   4. Bring up CDR-Toaster. Put a check in the "El Torito
      Bootable CD" box, and click the "Boot Setup" button.

   5. For "Boot Image Path" type "bootimage.bin"

   6. For "Boot Catalog Path" type "bootcat.bin"

   7. Click OK, and set the "Root of Tree" appropriately.
      From the example above, it would be "/tmp/my_cdrom"

   8. Finish burning your CD as you would normally.

   9. Set your bios to boot from CD, and things should
      be happy.

   The Boot Catalog is a place for information about the
   Boot Image. It is generated automatically. It need not
   exist beforehand. In fact, if it does exist, it will
   be overwritten.

   Both paths are interpretted relative to the root
   of the CD.

   For more information, see "man mkisofs". It should be on
   your system for CDR-Toaster to operate properly.
}
 {Using ATAPI CDR(W) Devices}
{   ATAPI CDR(W)s are special. The Linux kernel needs to be 
   compiled specially for them to work properly.

   Basically, you must TURN OFF IDE CDROM support and 
   instead use both "SCSI emulation" and "SCSI generic 
   support".

   If you have never compiled a kernel before, you are wise 
   to read the Kernel Howto.

   I tend to use "make menuconfig" to configure the kernel, 
   and these are the things I did:

   Under "Block devices", I set "Include IDE/ATAPI CDROM 
   support" to "n" and I set "SCSI emulation support" to 
   "Y".

   Under "SCSI support", I make sure there is "SCSI CD-ROM 
   support" and "SCSI generic support" turned on. Since I 
   have no true SCSI cards, I need nothing from the "SCSI 
   low-level drivers" section.

   I built and installed this kernel. As a result, my 
   CD-ROM detected as a scsi device (/dev/scd0 in my case) 
   during bootup and I have been able to burn to /dev/sg0 
   as is the default in CDR-Toaster.

   For more information on the special needs of your 
   CDR(W), see the documentation for "cdrecord" which is 
   the burn program that CDR-Toaster calls out to.
}
}

frame .help.b

set m .help.b.topic.m
menubutton .help.b.topic -menu $m -text Topic -relief raised
menu $m

button .help.b.ok -text {This Rules!} -command {destroy .help}
text .help.t -width 60 -height 18 -yscrollcommand {.help.sb set} -wrap word
scrollbar .help.sb -orient v -command {.help.t yview}

pack .help.b -side bottom -fill x
pack .help.b.topic -side left
pack .help.b.ok -side bottom
pack .help.t -side left
pack .help.sb -side left -fill y

.help.t insert 1.0 {Clarifications:

}

foreach {topic body} $helpstuff {
 set end [.help.t index end]
 set line [expr $end - 1]
 $m add command -label $topic -command ".help.t yview $line"
 .help.t insert end " o $topic\n"
 .help.t insert end "$body\n"
 .help.t tag add head $line $end
}

.help.t tag configure head -foreground white -background blue -font 8x16

.help.t tag add top 1.0 2.0
.help.t tag config top -foreground white -background blue -font 10x20

.help.t config -state disabled

}
proc padbox {} {

catch {destroy .pad}
toplevel .pad
wm title .pad {Padding Options}

frame .pad.audio
checkbutton .pad.audio.cb -text {Pad Audio Tracks} -variable {apad}
message .pad.audio.amesg -text {This option will pad audio track data to be a multiple of 2352 bytes. The padding is done with all zeroes which means complete silence. See also PCM vs. WAV in help.
}
frame .pad.data
checkbutton .pad.data.cb -text {Pad Data Track} -variable {dpad}
message .pad.data.dmesg -text {This option appends 15 sectors of zeroes to each data track. This works around a bug in very old Linux kernels.}
button .pad.ok -text Dismiss -command {destroy .pad}

pack .pad.audio -fill x
pack .pad.audio.cb -side left -anchor n
pack .pad.audio.amesg
pack .pad.data -fill x
pack .pad.data.cb -side left -anchor n
pack .pad.data.dmesg
pack .pad.ok

}
proc peruse {} {
# Just browse directories

global perused

set perused ""

catch {destroy .peruse}
toplevel .peruse
wm title .peruse {Peruse Folders}

frame .peruse.dir -border 0 -relief flat 
frame .peruse.mod -border 0 -relief flat 
frame .peruse.control -border 0 -relief flat
menubutton .peruse.dir.up -menu .peruse.dir.up.m -relief raised -border 2
button .peruse.dir.ok -text {<-- Accept} -command {
}
listbox .peruse.mod.lb -height 10 -width 20 -selectmode browse -yscrollcommand {.peruse.mod.sb set}
scrollbar .peruse.mod.sb -orient v -command {.peruse.mod.lb yview}
button .peruse.control.go -text {Delve} -command {
}
button .peruse.control.cancel -text {Cancel} -command {
}

pack .peruse.dir -side top -fill x
pack .peruse.mod -side top -fill x
pack .peruse.control -side top -fill x
pack .peruse.dir.up -side left
pack .peruse.dir.ok -side right
pack .peruse.mod.lb -side left -fill y -anchor w
pack .peruse.mod.sb -side left -fill y -anchor w
pack .peruse.control.go -side left -expand 1
pack .peruse.control.cancel -side left -expand 1

peruse_populate [pwd]
tkwait window .peruse

}
proc peruse_populate dir {

set tmp [file tail $dir]
if {$tmp == ""} {set tmp /}
.peruse.dir.up configure -text $tmp

set m .peruse.dir.up.m
catch {
destroy $m
}
menu $m -tearoff 0

set up /
foreach dcomp [file split $dir] {
 set up [file join $up $dcomp]
 $m add command -label $dcomp -command "peruse_populate \"$up\""
}

.peruse.mod.lb delete 0 end
set tmp [lsort [glob $dir/.* $dir/*]]
foreach dcan $tmp {
 if [file isdirectory $dcan] {
  set tail [file tail $dcan]
  if {$tail != "." && $tail != ".."} {
   .peruse.mod.lb insert end $tail
  }
 }
}

## Bindings

.peruse.control.cancel config -command {
 set perused ""
 destroy .peruse
}
.peruse.dir.ok config -command [subst {
 set perused "$dir"
 destroy .peruse
}]

set go [subst -nocommands {
 if {[.peruse.mod.lb get active] != ""} {
  peruse_populate [file join "$dir" [.peruse.mod.lb get active]]
 } else bell
}]

bind .peruse.mod.lb <Double-1> $go
.peruse.control.go config -command $go

}
proc boot_setup {} {
global bootimg bootcat

catch {destroy .boot}
toplevel .boot
wm title .boot {Bootable CD Setup}


frame .boot.img -border 0 -relief flat 
frame .boot.cat -border 0 -relief flat 
frame .boot.cmd -border 0 -relief flat 
label .boot.img.l -text {Boot Image Path} 
label .boot.cat.l -text {Boot Catalog Path} 
entry .boot.img.e -width 20 -font 7x14 
entry .boot.cat.e -width 20 -font 7x14 

# Got TK8? You get a pretty button.
if {[info tclversion] >= 8.0} {
  button .boot.img.b -text {Select} -command open_bootfile
  button .boot.cat.c -text {Select} -command open_catfile
}

button .boot.cmd.ok -text {OK} -command {
 set bootimg [.boot.img.e get]
 set bootcat [.boot.cat.e get]
 destroy .boot
}
button .boot.cmd.cancel -text {Cancel} -command {
 destroy .boot
}
button .boot.cmd.revert -text {Revert} -command {
 .boot.img.e delete 0 end
 .boot.cat.e delete 0 end
 .boot.img.e insert 0 $bootimg
 .boot.cat.e insert 0 $bootcat
}

# Populate Data Fields
.boot.img.e insert 0 $bootimg
.boot.cat.e insert 0 $bootcat

pack .boot.img -side top -fill x
pack .boot.cat -side top -fill x
pack .boot.cmd -side top -fill x
pack .boot.img.l -side left
pack .boot.cat.l -side left
pack .boot.img.e -side right
pack .boot.cat.e -side right
pack .boot.cmd.ok -side left -expand 1
pack .boot.cmd.cancel -side left -expand 1
pack .boot.cmd.revert -side left -expand 1

# Got TK8? You get a pretty button.
if {[info tclversion] >= 8.0} {
  pack .boot.img.b -side right
  pack .boot.cat.c -side right
}

# frame .m.img
# label .m.img.l -text "Boot Image Path"
# entry .m.img.e
# frame .m.cat
# label .m.cat.l -text "Boot Catalog Path"
# entry .m.cat.e
}
proc get_mp3_burn_info {} {
# Returns either the empty list, indicating a cancelation,
# or the temp directory.

global perused

set warn {\
You have chosen to burn an MPEG compressed file as an audio track. This will not be the same quality as the original from which it was made. However, the burn can proceed if given a space to uncompress the audio files.

Do you wish to proceed?}

set go [sure $warn]
if {!$go} {
 return {}
}

set df [exec -keepnewline df]

catch {destroy .df}
toplevel .df
wm title .df {Free Disk Space}

text .df.t -width 80 -height 10 -setgrid 1 -yscrollcommand {.df.sb set}
scrollbar .df.sb -orient v -command {.df.t yview}

.df.t insert end "Please browse to a directory with sufficient free space.\n\n"
.df.t insert end $df
.df.t config -state disabled

pack .df.sb -side right -fill y
pack .df.t -side left

peruse
destroy .df

alert "Be aware that the MP3 conversion process typically takes some time."

return $perused
}
proc custom_layout {} {

global custom

catch {destroy .custom}
toplevel .custom
wm title .custom {Custom CD Layout}


frame .custom.dirs -border 0 -relief flat 
frame .custom.table -border 0 -relief flat 
frame .custom.cmds -border 0 -relief flat 
frame .custom.help -border 0 -relief flat 
label .custom.dirs.a -text {Make contents of:} 
label .custom.dirs.b -text {Show up on CD within:} 

foreach x {0 1 2 3 4 5 6 7 8 9} {
 frame .custom.table.$x -border 0 -relief flat 
 button .custom.table.$x.peruse -text {Peruse} -command "custom_peruse $x"
 entry .custom.table.$x.from -width 25 -font 7x14 
 entry .custom.table.$x.to -width 25 -font 7x14 
 
 button .custom.table.$x.clear -text {Clear} -command [subst {
 .custom.table.$x.from delete 0 end
 .custom.table.$x.to delete 0 end
 }]
 
 pack .custom.table.$x -side top -fill x
 pack .custom.table.$x.peruse -side left -anchor w
 pack .custom.table.$x.from -side left -anchor w
 pack .custom.table.$x.clear -side right -anchor e
 pack .custom.table.$x.to -side right -anchor e
 
}

scrollbar .custom.help.sb -orient v -command {} -command {.custom.help.t yview}
text .custom.help.t -width 70 -height 10 -setgrid 1 -yscrollcommand {.custom.help.sb set}
button .custom.cmds.ok -text {OK} -command {
 set from {}
 set to {}
 foreach s [pack slaves .custom.table] {
  lappend from [$s.from get]
  lappend to [$s.to get]
 }
 set custom(from) $from
 set custom(to) $to
 set custom(use) 1
 destroy .custom
}
button .custom.cmds.revert -text {Revert} -command {
 foreach s [pack slaves .custom.table] from $custom(from) to $custom(to) {
  $s.from delete 0 end
  $s.to delete 0 end
  $s.from insert 0 $from
  $s.to insert 0 $to
 }
}
button .custom.cmds.cancel -text {Cancel} -command {
destroy .custom
}

pack .custom.dirs -side top -fill x
pack .custom.table -side top -fill x
pack .custom.cmds -side top -fill x
pack .custom.help -side top -fill both -expand 1
pack .custom.dirs.a -side left -anchor w
pack .custom.dirs.b -side right -anchor e
pack .custom.help.sb -side right -fill y -anchor e
pack .custom.help.t -side right -fill both -anchor w
pack .custom.cmds.ok -side left -expand 1
pack .custom.cmds.revert -side left -expand 1
pack .custom.cmds.cancel -side left -expand 1

.custom.cmds.revert invoke

.custom.help.t insert 1.0 {              Custom CD Layout Help

This was always the biggest pain for me. I want stuff from the hard
drive from arbitrary places to show up on the final CD in (other)
arbitrary places.

I've tried to make this fairly general. Name what you want on the
left, and where to put it on the right. The one thing to remember
is that if you put a directory on the left, you have to give it
a name on the right unless you want a whole bunch of files sprayed
all over the root of the CD.

The names you give on the right do not have to exist anywhere
except your imagination. If they don't exist within other parts of
what you burn, the directories will be automatically created to
exist on the CD. Directories created in this way will be owned by
root.root and have permissions 555 (read/exec for all).

I'm not yet sure how these custom layouts interact with bootable
CD creation. I think that you specify the boot paths relative to
the final CD image. I know it works that way in the simple case.

}

.custom.help.t tag add cool 1.0 2.0
.custom.help.t tag config cool -font 10x20
.custom.help.t tag config cool -background blue
.custom.help.t tag config cool -foreground white

.custom.help.t config -state disabled
}
proc custom_peruse x {
global perused
peruse
if {$perused != ""} {
  .custom.table.$x.from delete 0 end
  .custom.table.$x.from insert 0 $perused
}}
proc make_mkisofs_cmd {} {
 global all joliet follow trans ds rock
 global boot bootimg bootcat custom
 
 set vol [.m.volid.e get]
 set root [.m.root.e get]

 # Presumably this is not necessary if there is a custom layout.
 
 if {![file isdirectory $root]} {
 alert "For on-the-fly ISO image creation, the root of tree must be a directory."
 return
 }
 
 set mk mkisofs
 if {$all} {lappend mk -all-files}
 if {$joliet} {lappend mk -joliet}
 switch -exact $rock {
  none {}
  rat {lappend mk -r}
  lit {lappend mk -R}
 }
 if {$follow} {lappend mk -follow-links}
 if {$trans} {lappend mk -translation-table}
 if {$boot} {
  if {($bootimg == "") || ($bootcat == "")} {
   alert "You selected 'Bootable CD' but either the boot image or boot catalog entries are blank. This will not work."
   return
  }
  if {![file exists [file join $root $bootimg]]} {
   alert "[file join $root $bootimg] is not there. You can't make a bootable CD without a bootimage."
   return
  }
  if {[file exists [file join $root $bootcat]]} {
   if {![sure "[file join $root $bootcat] will be overwritten if you continue. Is this ok?"]} {return}
  }
  lappend mk -b $bootimg -c $bootcat
 } else {
  if {$bootimg != ""} {
   set ok [sure "You have stuff in the bootimage entry, but have not chosen the 'Bootable CD' option. Do you want a standard non-bootable cd?"]
   if {!$ok} {return}
  }
 }
 if {$vol != ""} {lappend mk -volid $vol}
 
 ## Here we need to (maybe) process the custom layout entries.
 lappend mk $root
 
 if {$custom(use)} {
  foreach dir $custom(from) graftpoint $custom(to) {
   if {$dir == ""} continue
   set isdir [file isdirectory $dir]
   if {$isdir} {set dir "$dir/"}
   lappend mk "$graftpoint/=$dir"
  }
 }
 
 ## Last gasp.
 lappend mk "|"
 return $mk
 }
proc open_bootfile {} {
set types {
    {{Disk Images}      {.img}        }
    {{All Files}        *             }
}
set boot_img [tk_getOpenFile -filetypes $types -initialdir ~/ -title {Choose Image}]
.boot.img.e delete 0 250
.boot.img.e insert 0 $boot_img
}
proc open_catfile {} {
set types {
    {{All Files}        *             }
}
set boot_cat [tk_getOpenFile -filetypes $types -initialdir ~/ -title {Choose File}]
.boot.cat.e delete 0 250
.boot.cat.e insert 0 $boot_cat
}

# This is CDR-Toaster

set speed 2
set joliet 1
set rock none
set dummy 1
set eject 1
set ds mkisofs
set apad 1
set dpad 0
set bootimg ""
set bootcat ""

set custom(from) {}
set custom(to) {}
set custom(use) 0

interface

.b.quit configure -command {destroy .}
.b.burn configure -command {toast}