179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
}
}
proc preparePlugin {top} {
disallowEdit $top
set allow [dict get $::eskil($top,pluginpinfo) allow]
# Pass ::argv to plugin
$::eskil($top,plugin) eval [list set ::argv $::eskil(argv)]
# Pass ::Pref to plugin
$::eskil($top,plugin) eval [list array set ::Pref [array get ::Pref]]
# Pass File info to plugin
$::eskil($top,plugin) eval [list set ::File(left) $::eskil($top,leftFile)]
$::eskil($top,plugin) eval [list set ::File(right) $::eskil($top,rightFile)]
set out1 [tmpFile]
|
>
>
>
>
|
|
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
}
}
proc preparePlugin {top} {
disallowEdit $top
set allow [dict get $::eskil($top,pluginpinfo) allow]
# Pass ::argv to plugin
set pArgv $::eskil(argv)
if {[info exists ::eskil($top,pluginargv)]} {
lappend pArgv {*}$::eskil($top,pluginargv)
}
$::eskil($top,plugin) eval [list set ::argv $pArgv]
# Pass ::Pref to plugin
$::eskil($top,plugin) eval [list array set ::Pref [array get ::Pref]]
# Pass File info to plugin
$::eskil($top,plugin) eval [list set ::File(left) $::eskil($top,leftFile)]
$::eskil($top,plugin) eval [list set ::File(right) $::eskil($top,rightFile)]
set out1 [tmpFile]
|
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
|
-value $plugin -text $plugin
ttk::label $wt.l$t -text $descr -anchor w
grid $wt.rb$t $wt.l$t -in $wt.lfs -sticky we -padx 3 -pady 3
incr t
}
ttk::radiobutton $wt.rb$t -variable ::eskil($top,edit,pluginname) \
-value "" -text "No Plugin"
grid $wt.rb$t -in $wt.lfs -sticky we -padx 3 -pady 3
ttk::labelframe $wt.lfgc -text "Generic Configuration"
grid columnconfigure $wt.lfgc 1 -weight 1
ttk::label $wt.li -text "Info" -anchor w
addBalloon $wt.li "Info passed to plugin. Plugin specific."
ttk::entry $wt.ei -textvariable ::eskil($top,edit,plugininfo)
grid $wt.li $wt.ei -in $wt.lfgc -sticky we -padx 3 -pady 3
ttk::checkbutton $wt.cb -text "Privilege" \
-variable ::eskil($top,edit,pluginallow)
addBalloon $wt.cb "Run plugin with raised privileges"
grid $wt.cb - -in $wt.lfgc -sticky w -padx 3 -pady 3
ttk::labelframe $wt.lfsc -text "Specific Configuration"
grid columnconfigure $wt.lfgc 1 -weight 1
ttk::label $wt.lfsc.l -text "Not implemented yet" -anchor w
addBalloon $wt.lfsc.l "The plan is to make selected plugin's specific\
options available here"
grid $wt.lfsc.l -sticky w -padx 3 -pady 3
ttk::frame $wt.fb -padding 3
ttk::button $wt.fb.b1 -text "Ok" \
-command [list EditPrefPluginsOk $top $wt]
ttk::button $wt.fb.b2 -text "Show" \
-command "ShowPlugin $wt \$::eskil($top,edit,pluginname)"
addBalloon $wt.fb.b2 "Show plugin source code."
ttk::button $wt.fb.b3 -text "Cancel" -command [list destroy $wt]
set ::widgets($top,prefPluginsOk) $wt.fb.b1
grid $wt.fb.b1 x $wt.fb.b2 x $wt.fb.b3 -sticky we
grid columnconfigure $wt.fb {0 2 4} -uniform a
grid columnconfigure $wt.fb {1 3} -weight 1
grid $wt.lfs -sticky we -padx 3 -pady 3
grid $wt.lfgc -sticky we -padx 3 -pady 3
grid $wt.lfsc -sticky we -padx 3 -pady 3
grid $wt.fb -sticky we -padx 3 -pady 3
grid columnconfigure $wt 0 -weight 1
}
proc EditPrefPluginsOk {top wt} {
destroy $wt
set ::eskil($top,pluginname) $::eskil($top,edit,pluginname)
set ::eskil($top,plugininfo) $::eskil($top,edit,plugininfo)
set ::eskil($top,pluginallow) $::eskil($top,edit,pluginallow)
if {$::eskil($top,pluginname) ne ""} {
set pinterp [createPluginInterp $::eskil($top,pluginname) \
$::eskil($top,plugininfo) \
$::eskil($top,pluginallow) pinfo]
} else {
set pinterp ""
set pinfo ""
}
set ::eskil($top,plugin) $pinterp
set ::eskil($top,pluginpinfo) $pinfo
}
# Put Tcl code in a text widget, with some syntax highlighting
proc TextViewTcl {t data} {
$t tag configure comment -foreground "#b22222"
foreach line [split $data \n] {
if {[regexp {^\s*#} $line]} {
$t insert end $line\n comment
} elseif {[regexp {^(.*;\s*)(#.*)$} $line -> pre post]} {
$t insert end $pre
$t insert end $post\n comment
} else {
$t insert end $line\n
}
}
}
# Show plugin source
proc ShowPlugin {parent plugin} {
set src [LocatePlugin $plugin]
if {$src eq ""} return
set ch [open $src]
set data [read $ch]
close $ch
set wt $parent.plugin
if {[winfo exists $wt]} {
wm deiconify $wt
|
>
>
>
|
>
|
|
|
|
<
<
|
|
|
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
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
|
-value $plugin -text $plugin
ttk::label $wt.l$t -text $descr -anchor w
grid $wt.rb$t $wt.l$t -in $wt.lfs -sticky we -padx 3 -pady 3
incr t
}
ttk::radiobutton $wt.rb$t -variable ::eskil($top,edit,pluginname) \
-value "" -text "No Plugin"
ttk::button $wt.bs -text "Show" \
-command "ShowPlugin $wt \$::eskil($top,edit,pluginname)"
addBalloon $wt.bs "Show plugin source code."
grid $wt.rb$t $wt.bs -in $wt.lfs -sticky we -padx 3 -pady 3
grid $wt.bs -sticky e
ttk::labelframe $wt.lfgc -text "Generic Configuration"
grid columnconfigure $wt.lfgc 1 -weight 1
ttk::label $wt.li -text "Info" -anchor w
addBalloon $wt.li "Info passed to plugin. Plugin specific."
ttk::entry $wt.ei -textvariable ::eskil($top,edit,plugininfo)
grid $wt.li $wt.ei -in $wt.lfgc -sticky we -padx 3 -pady 3
ttk::checkbutton $wt.cb -text "Privilege" \
-variable ::eskil($top,edit,pluginallow)
addBalloon $wt.cb "Run plugin with raised privileges"
grid $wt.cb - -in $wt.lfgc -sticky w -padx 3 -pady 3
ttk::labelframe $wt.lfsc -text "Specific Configuration"
set ::widgets($top,prefPluginsSpec) $wt.lfsc
trace add variable ::eskil($top,edit,pluginname) write \
[list UpdateSpecificPluginConf $top]
UpdateSpecificPluginConf $top
ttk::frame $wt.fb -padding 3
ttk::button $wt.fb.b1 -text "Ok" \
-command [list EditPrefPluginsOk $top $wt 0]
ttk::button $wt.fb.b2 -text "Apply" \
-command [list EditPrefPluginsOk $top $wt 1]
ttk::button $wt.fb.b3 -text "Cancel" -command [list destroy $wt]
set ::widgets($top,prefPluginsOk) $wt.fb.b1
grid $wt.fb.b1 x $wt.fb.b2 x $wt.fb.b3 -sticky we
grid columnconfigure $wt.fb {0 2 4} -uniform a
grid columnconfigure $wt.fb {1 3} -weight 1
grid $wt.lfs -sticky we -padx 3 -pady 3
grid $wt.lfgc -sticky we -padx 3 -pady 3
grid $wt.lfsc -sticky we -padx 3 -pady 3
grid $wt.fb -sticky we -padx 3 -pady 3
grid columnconfigure $wt 0 -weight 1
}
proc UpdateSpecificPluginConf {top args} {
set w $::widgets($top,prefPluginsSpec)
# If the dialog is closed w might not exist
if {![winfo exists $w]} return
eval destroy [winfo children $w]
set arg $::eskil($top,edit,pluginname)
set pOpts {}
if {$arg ne ""} {
set res [LocatePlugin $arg]
set pOpts [dict get $res opts]
}
# Look for declarations of command line options
set n 0
set ::eskil($top,edit,opts) $pOpts
foreach {name flag doc} $pOpts {
ttk::label $w.l$n -text $name
addBalloon $w.l$n $doc
grid $w.l$n -sticky "w" -padx 3 -pady 3
if {$flag} {
ttk::checkbutton $w.s$n -text "On" \
-variable ::eskil($top,edit,$name)
grid $w.s$n -row $n -column 1 -sticky "w" -padx 3 -pady 3
} else {
ttk::entry $w.s$n \
-textvariable ::eskil($top,edit,$name)
grid $w.s$n -row $n -column 1 -sticky we -padx 3 -pady 3
}
incr n
}
grid columnconfigure $w 1 -weight 1
if {$n == 0} {
ttk::label $w.l -text "No specific configuration"
grid $w.l -sticky "w" -padx 3 -pady 3
return
}
}
proc EditPrefPluginsOk {top wt apply} {
if {!$apply} {
destroy $wt
}
set ::eskil($top,pluginname) $::eskil($top,edit,pluginname)
set ::eskil($top,plugininfo) $::eskil($top,edit,plugininfo)
set ::eskil($top,pluginallow) $::eskil($top,edit,pluginallow)
if {$::eskil($top,pluginname) ne ""} {
set pinterp [createPluginInterp $::eskil($top,pluginname) \
$::eskil($top,plugininfo) \
$::eskil($top,pluginallow) pinfo]
} else {
set pinterp ""
set pinfo ""
}
set ::eskil($top,plugin) $pinterp
set ::eskil($top,pluginpinfo) $pinfo
set ::eskil($top,pluginargv) {}
foreach {name flag doc} $::eskil($top,edit,opts) {
if {$flag} {
if {[info exists ::eskil($top,edit,$name)] && \
$::eskil($top,edit,$name)} {
lappend ::eskil($top,pluginargv) $name
}
} else {
if {[info exists ::eskil($top,edit,$name)] && \
$::eskil($top,edit,$name) ne ""} {
lappend ::eskil($top,pluginargv) $name $::eskil($top,edit,$name)
}
}
}
}
# Put Tcl code in a text widget, with some syntax highlighting
proc TextViewTcl {t data} {
$t tag configure comment -foreground "#b22222"
foreach line [split $data \n] {
if {[regexp {^\s*#} $line]} {
$t insert end $line\n comment
} elseif {[regexp {^(.*;\s*)(#.*)$} $line -> pre post]} {
$t insert end $pre
$t insert end $post\n comment
} else {
$t insert end $line\n
}
}
}
# Show plugin source
proc ShowPlugin {parent plugin} {
set res [LocatePlugin $plugin]
set src [dict get $res src]
if {$src eq ""} return
set ch [open $src]
set data [read $ch]
close $ch
set wt $parent.plugin
if {[winfo exists $wt]} {
wm deiconify $wt
|