summaryrefslogtreecommitdiff
path: root/app/xlockmore/configure.tcl
blob: 013eaee8a439021ac27bc7432912493025aa4f37 (plain)
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
#!/bin/sh
#charles vidal 1998 <cvidal@ivsweb.com>
# Thu Jul 30 06:21:57 MET DST 1998
#Projet Wizard in french Assistant
#http://www.chez.com/vidalc/assist/
#Sun Jul  4 01:35:05 MET DST 1999
# Add filevents find in setup.tcl of the xap ( X Application Panel )
# thank's to rasca, berlin 1999
#
# Sat Jul 29 20:18:28 JST 2000
#   Fix font dialog and button action.
#   Add I18N system
#      By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
#

# the next line restart wish \
exec wish "$0" "$@"

# Setup I18N system
set auto_path [linsert $auto_path end .]
set_catalogue [set_language]

set titleassist [_ "Wizard configure"]
wm title . $titleassist

# Declaration des variables globales
set nbwidget 0

# number of the current screen
set nb_ecran 0

set lang " "

proc cont {w input} {
    if [eof $input] {
	close $input
    } else {
	gets $input line
	$w insert end "$line\n"
	$w see end
    }
}

proc read_pipe { command w } {
    $w delete 1.0 end
    $w insert end "$command\n"
    set fileid [open "|$command" r]
    fileevent $fileid readable "cont $w $fileid"
}

proc action { } {
    global bitmapdir pixmapdir
    global incdir libdir
    global soundprog
    global wgcc wmotif weditres wpurify wxpm wopengl wmesa wdtsaver wdpms
    global esyslog emulroot emuluser eunstable
    global nb_ecran nbtotalecran
    global lang

    if { $nb_ecran == [expr $nbtotalecran -1 ]}  {
	# Press "configure" button
	set commandline "./configure"
	append commandline $wgcc $wpurify $wmotif $weditres $wxpm $wopengl $wmesa $wdtsaver \
		$esyslog $emuluser $emulroot $eunstable
	if {$bitmapdir!=""} { append commandline " --enable-bitmapdir=$bitmapdir" }
	if {$pixmapdir!=""} { append commandline " --enable-pixmapdir=$pixmapdir" }
	if {$incdir!=""}    { append commandline " --x-includes=$incdir" }
	if {$libdir!=""}    { append commandline " --x-libraries=$libdir" }
	if {$soundprog!=""} { append commandline " --enable-def-play=$soundprog" }
	append commandline " $lang"
	if { [getyesno [_ "Do you really want to launch configure?"]] == "yes" } {
	    puts $commandline
	    pack forget .f$nb_ecran

	    frame .fconf
	    button .f.make -text [_ "Make"] -command {
		set commandline "make"
		read_pipe $commandline  .fconf.t
	    }
	    button .f.install -text [_ "Make Install"] -command {
		set commandline "make install"
		read_pipe $commandline .fconf.t
	    }
	    button .f.exit -text [_ "Exit"] -command exit
	    scrollbar .fconf.s -orient vertical -command {.fconf.t yview}

	    text .fconf.t -yscrollcommand {.fconf.s set} \
		    -wrap word -width 50 -height 10 \
		    -setgrid 1

	    pack .fconf.s -side right  -fill y
	    pack .fconf.t -expand yes -side right -fill both
	    pack .fconf -side top -expand yes -fill both
	    pack .f.make  .f.install .f.exit  -side left
	    pack forget .f.b1 .f.b2 .f.b3

	    update
	    read_pipe $commandline  .fconf.t
	}
    } else {
	# Press "abort" button
	exit
    }
}

# get a dialog yes or no
proc getyesno { text } {
    return [ tk_messageBox -parent . -title [_ "Launch Configure"] -type yesno \
	    -icon warning \
	    -message $text ]
}

set tmpfnt ""

# Declaration des variables globales
set nbwidget 0

# numero de l'ecran courant
set nb_ecran 0

# open font dialog
proc openfont { var } {
    upvar $var toto
    global tmpfnt

    set w .font

    toplevel $w
    wm title $w [_ "Font Options"]

    frame $w.f
    label $w.f.msg0 -text [_ "Font Options"]

    listbox $w.f.names -yscrollcommand "$w.f.scroll set" \
	-xscrollcommand "$w.f.scroll2 set"  -setgrid 1 \
         -exportselection false
    bind $w.f.names <Double-1> "fontselect_action $w"
    scrollbar $w.f.scroll -orient vertical -command "$w.f.names yview" \
            -relief sunken -borderwidth 2
    scrollbar $w.f.scroll2 -orient horizontal -command "$w.f.names xview" \
            -relief sunken -borderwidth 2

    label $w.f.test -text [_ "ABCDEFGHIJKabedfghijkmnopq12345"]

    set fd [open "|xlsfonts" r]
    while {[gets $fd line]>=0} {
	$w.f.names insert end $line
    }
    close $fd

    grid rowconfigure $w 0 -weight 100
    grid columnconfigure $w 0 -weight 100

    grid $w.f -column 0 -row 0 -sticky nsew
    grid $w.f.msg0 -column 0 -row 0 -sticky ew
    grid $w.f.names -column 0 -row 1 -sticky nsew
    grid $w.f.scroll -column 1 -row 1 -sticky ns
    grid $w.f.scroll2 -column 0 -row 2 -sticky ew
    grid $w.f.test -column 0 -row 3 -sticky ew
    grid rowconfigure $w.f 1 -weight 100
    grid columnconfigure $w.f 0 -weight 100

    frame $w.f2
    button $w.f2.cancel -text [_ "Cancel"] -command "destroy $w"
    button $w.f2.ok -text [_ "OK"] -command "set $var \$tmpfnt; destroy $w"

    grid $w.f2 -column 0 -row 1
    pack $w.f2.ok $w.f2.cancel -side left
}

proc fontselect_action {w} {
    global tmpfnt

    set fname [$w.f.names get [$w.f.names curselection]]
    $w.f.test configure -font $fname
    set tmpfnt $fname
}

# open color dialog
proc opencolorsel {titre var wf} {
    upvar $var toto
    set toto [tk_chooseColor -title $titre]
    $wf.label configure -foreground $toto
}

# open file dialog
proc openfilesel { var } {
    upvar $var toto
    set toto [ tk_getOpenFile -parent .]
}

# Configure button state for "previous" button and "next" button
proc state_configure {} {
    global nbtotalecran nb_ecran

    if {$nb_ecran != 0} {
	.f.b1 configure -state active
    } else {
	.f.b1 configure -state disabled
    }

    if {$nb_ecran != [expr $nbtotalecran - 1]} {
	.f.b2 configure -state active
    } else {
	.f.b2 configure -state disabled
    }
}


# Callback pour revenir a l'ecran precedent
proc prec_ecran { } {
    global nbtotalecran nb_ecran
    set tmp [expr $nb_ecran - 1]
    if { $tmp >= 0} {
	pack forget .f$nb_ecran
	set nb_ecran [expr $nb_ecran - 1]
	pack .f$nb_ecran
    }

    state_configure

    if { $nb_ecran != [expr $nbtotalecran - 1 ]}  {
	.f.b3 configure -text [_ "Abort"]
    }
}

# Callback pour aller a l'ecran suivant
proc next_ecran { } {
    global nb_ecran nbtotalecran
    set tmp [expr $nb_ecran + 1]
    if { $tmp < $nbtotalecran} {
	pack forget .f$nb_ecran
	set nb_ecran [expr $nb_ecran + 1]
	pack .f$nb_ecran
    }

    state_configure

    if { $nb_ecran == [expr $nbtotalecran - 1 ]}  {
	.f.b3 configure -text [_ "Configure"]
    }

    if { $nb_ecran != [expr $nbtotalecran - 1 ]}  {
	.f.b3 configure -text [_ "Abort"]
    }
}

# Creation du label titre et du texte explicatif
# Argument n:numero de l'ecran title:titre desc description

proc creationscreennb { n title desc icon} {
    set currentarg 0
    frame .f$n -height 10 -width 10
    image create bitmap  image$n -file bitmaps/$icon
    label .f$n.lt$n -text [_ $title] -font [_ -Adobe-Courier-Bold-R-Normal-*-140-*]
    label .f$n.li$n -image image$n
    pack .f$n.lt$n  .f$n.li$n
    frame .f$n.fdesc
    message  .f$n.mesg -text [_ $desc] -width 25c
    pack .f$n.mesg -fill x
    pack .f$n.fdesc
}

# Creation de deux label + entry avec variable texte
# Argument n:numero de l'ecran label1:label devant texte vtext1:variable text
# De meme pour les xxxx2

proc creationentry { n nbf  text variable value} {
    frame .f$n.fr$nbf
    label .f$n.fr$nbf.lab1 -text [_ $text]
    entry .f$n.fr$nbf.e1 -textvariable  $variable
    .f$n.fr$nbf.e1 insert 0 $value
    pack .f$n.fr$nbf
    pack .f$n.fr$nbf.e1  -side right
    pack .f$n.fr$nbf.lab1  -side left
}

proc mkecran { n args } {
    global nbwidget
    set nbf 0
    set w .f$n
    foreach i $args {
	switch -regexp  [lindex $i 0] {
	    LIST {
		listbox  $w.list$nbwidget
		pack  $w.list$nbwidget
	    }
	    ENTRY {
		creationentry  $n $nbwidget [lindex $i 1] [lindex $i 2] [lindex $i 3]
	    }
	    LABEL {
		label  $w.label$nbwidget -text [_ [lindex $i 1]]
		pack  $w.label$nbwidget
	    }
	    CHECK {
		checkbutton  $w.check$nbwidget \
			-text [_ [lindex $i 1]] \
			-variable  [lindex $i 2] \
			-onvalue  [lindex $i 3] \
			-offvalue [lindex $i 4]
		pack  $w.check$nbwidget
	    }
	    RADIO {
		frame $w.fr$nbwidget
		image create photo   [lindex $i 4] -file [lindex $i 5]
		label  $w.fr$nbwidget.labrad  -image [lindex $i 4]
		radiobutton  $w.fr$nbwidget.radio$nbwidget \
			-text [_ [lindex $i 1]] \
			-variable  [lindex $i 2] \
			-value [lindex $i 3]
		pack   $w.fr$nbwidget.labrad  $w.fr$nbwidget.radio$nbwidget -side left
		pack   $w.fr$nbwidget
	    }
	    BUTTON {
		button  $w.button$nbwidget -text [_ [lindex $i 1]]
		pack  $w.button$nbwidget
	    }
	    SCALE {
		scale  $w.scale$nbwidget -from [lindex $i 1] -to [lindex $i 2] -orient horizontal
		pack  $w.scale$nbwidget
	    }
	    FILE {
		frame   $w.frame$nbwidget
		set  wf $w.frame$nbwidget
		label   $wf.label  -text [_ [lindex $i 1]]
		entry   $wf.entry  -textvariable [lindex $i 2]
		$wf.entry insert 0 [lindex $i 3]
		button $wf.button -text [_ "File"] -command "openfilesel [lindex $i 2]"
		pack $wf
		pack  $wf.label $wf.entry $wf.button -side left
	    }
	    COLOR {
		frame   $w.frame$nbwidget
		set  wf $w.frame$nbwidget
		if { [lindex $i 4] !="" } {
		    label $wf.label  -text [_ [lindex $i 1]] -foreground [lindex $i 4]
		} else {
		    label $wf.label  -text [_ [lindex $i 1]]
		}
		entry   $wf.entry  -textvariable [lindex $i 2]
		$wf.entry insert 0 [lindex $i 4]
		button $wf.button -text [_ "Color"] -command "opencolorsel [lindex $i 3] [lindex $i 2] $wf"
		pack $wf
		pack  $wf.label $wf.entry $wf.button  -side left
	    }
	    FONT {
		frame   $w.frame$nbwidget
		set  wf $w.frame$nbwidget
		label   $wf.label  -text [_ [lindex $i 1]]
		entry   $wf.entry  -textvariable [lindex $i 2]
		$wf.entry insert 0 [lindex $i 3]
		button $wf.button -text [_ "Font"] -command "openfont [lindex $i 2]"
		pack $wf
		pack  $wf.label $wf.entry $wf.button -side left
	    }
	}
	set nbwidget [expr $nbwidget + 1]
    }
}

#-----------------------------------------------------------------------------

# number total of screens
set nbtotalecran 0

creationscreennb  0 "wizard configure xlockmore" "This should help you to build xlockmore" m-xlock.xbm
mkecran 0 \
	{CHECK "without gcc    " wgcc     " --without-gcc" "" }\
	{CHECK "with-purify    " wpurify  " --with-purify" "" }\
	{CHECK "without motif  " wmotif   " --without-motif" ""}\
	{CHECK "without editres" weditres " --without-editres" ""}\
	{CHECK "without xpm    " wxpm     " --without-xpm" ""}\
	{CHECK "without opengl " wopengl  " --without-opengl" "" }\
	{CHECK "without mesa   " wmesa    " --without-mesa" "" }\
	{CHECK "without dtsaver" wdtsaver " --without-dtsaver" "" }\
	{CHECK "without dpms   " wdpms    " --without-dpms" "" }\
	{ }
incr nbtotalecran

creationscreennb  1 "Wizard configure image path" "please enter the image path"  m-xlock.xbm
mkecran 1 \
	{ENTRY  "Bitmap dir" bitmapdir }\
	{ENTRY "Pixmaps dir" pixmapdir }\
	{ENTRY "sound player program" soundprog    }\
	{CHECK "enable syslog logging      " esyslog   " --enable-syslog" "" }\
	{CHECK "enable multiple users      " emuluser  " --enable-multiple-user" "" }\
	{CHECK "enable multiple root users " emulroot  " --enable-multiple-root" "" }\
	{CHECK "enable unstable            " eunstable " --enable-unstable" "" }\
	{ }
incr nbtotalecran

creationscreennb  2 "Wizard configure include and library path" "Please enter the path"  m-x11.xbm
mkecran 2 \
	{ENTRY "path of X include          " incdir   }\
	{ENTRY "path of X library          " libdir }\
	{ENTRY "user executables in        " bindir }\
	{ENTRY "system admin executables in" sbindir }\
	{ENTRY "program executables in     " libexecdir }\
	{ENTRY "info documentation in      " infodir }\
	{ENTRY "man documentation in       " mandir }\
	{ENTRY "find the sources in        " srcdir }\
	{ }
incr nbtotalecran

creationscreennb  3 "Wizard configure language" "Please choice your language "  m-xlock.xbm
mkecran 3 \
	{RADIO "Dutch   " lang  " --with-lang=nl" fdutch etc/gif/nlflag.gif}\
	{RADIO "English " lang " " fenglish etc/gif/ukflag.gif}\
	{RADIO "French  " lang  " --with-lang=fr" ffrench etc/gif/frflag.gif}\
	{RADIO "German  " lang  " --with-lang=de" fgerman etc/gif/deflag.gif}\
	{RADIO "Japanese" lang  " --with-lang=jp" fjapanese etc/gif/jpflag.gif}\
	{}
incr nbtotalecran

#-----------------------------

frame .f

button .f.b1 -text [_ "< Previous"] -command {prec_ecran} -state disabled
button .f.b2 -text [_ "Next >"] -command {next_ecran}
button .f.b3 -text [_ "Abort"] -command {action}

pack .f.b1 .f.b2  .f.b3  -padx 2m -pady 2m -side left
pack .f -side bottom
pack .f0

# end