Repository URL to install this package:
|
Version:
1.1.1-1 ▾
|
#
# Copyright (c) 2005-2013, Fuji Xerox Co., Ltd.
# All rights reserved.
#
#Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#1.Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#2.Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#3.Neither the name of the <Fuji Xerox Co., Ltd.> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# set font
option add *font -Adobe-Gothic-Medium-R-Normal-*-*-120-*-*-*-*-*-*
# current dir
set cwd [file dirname [info script]]
source [file join $cwd fxcombobox.tcl]
package require combobox 2.3
catch {namespace import combobox::*}
lappend auto_path $cwd
if {[lsearch $auto_path /usr/lib] == -1} {
lappend auto_path /usr/lib
}
if {[lsearch $auto_path /usr/lib64] == -1} {
lappend auto_path /usr/lib64
}
package require fxlputil
set ComboKeyWord {Color OutputSize PrintMode Duplex Layout PaperType \
PaperTray Staple Punch}
set OptKeyWordlist {FXCollate FXColorMode PageSize FXOutputMode \
Duplex FXLayout FXMediaType InputSlot FXStaple FXPunch FXJobType \
FXUserName FXHoldKey}
# Option Info
set OptCollate [lindex $OptKeyWordlist 0]
set OptColor [lindex $OptKeyWordlist 1]
set OptColorlist {Auto Black}
set OptColorDefault 0
set OptOutputSize [lindex $OptKeyWordlist 2]
set OptOutputSizelist {A4 A3 A5 B4 B5 Letter Legal Ledger}
set OptOutputSizeDefault 0
set OptPrintMode [lindex $OptKeyWordlist 3]
set OptPrintModelist {Standard Quality2 Speed}
set OptPrintModeDefault 0
set OptDuplex [lindex $OptKeyWordlist 4]
set OptDuplexlist {None DuplexTumble DuplexNoTumble}
set OptDuplexDefault 0
set OptLayout [lindex $OptKeyWordlist 5]
set OptLayoutlist {Auto TopLeft Center Booklet 2up 4up}
set OptLayoutDefault 1
set OptPaperType [lindex $OptKeyWordlist 6]
set OptPaperTypelist {Plain Printer}
set OptPaperTypeDefault 0
set OptPaperTray [lindex $OptKeyWordlist 7]
set OptPaperTraylist {Auto Tray1 Tray2 Tray3 Tray4 Tray5}
set OptPaperTrayDefault 0
set OptStaple [lindex $OptKeyWordlist 8]
set OptStaplelist {None UpperLeftSingle LeftDouble TopDouble}
set OptStapleDefault 0
set OptPunch [lindex $OptKeyWordlist 9]
set OptPunchlist {Off On}
set OptPunchDefault 0
set OptJobType [lindex $OptKeyWordlist 10]
set OptJobTypelist {Normal Secure Sample}
set OptJobTypeDefault 0
set OptUserId [lindex $OptKeyWordlist 11]
set OptUserIdDefault [eval exec whoami]
if {[string length $OptUserIdDefault] > 8} {
set OptUserIdDefault [string range $OptUserIdDefault 0 7]
}
# Set empty as default because input validation does not work
# if unacceptable characters are set in entry UI.
if {[string is alnum $OptUserIdDefault] != 1 || \
[string is ascii $OptUserIdDefault] != 1} {
set OptUserIdDefault ""
}
set OptPasswd [lindex $OptKeyWordlist 12]
set OptPasswdDefault ""
set UserIdNormalColor black
set UserIdSaveColor $UserIdNormalColor
set PasswdNormalColor black
set PasswdSaveColor $PasswdNormalColor
# Set length of text-wrapping for message window.
set TextWrapLength 600
# デフォルト値設定
proc SetDefault {key} {
switch $key {
FXCollate {
.chCollate deselect
}
FXColorMode {
.cbColor select $::OptColorDefault
}
PageSize {
.cbOutputSize select $::OptOutputSizeDefault
}
FXOutputMode {
.cbPrintMode select $::OptPrintModeDefault
}
Duplex {
.cbDuplex select $::OptDuplexDefault
}
FXLayout {
.cbLayout select $::OptLayoutDefault
}
FXMediaType {
.cbPaperType select $::OptPaperTypeDefault
}
InputSlot {
.cbPaperTray select $::OptPaperTrayDefault
}
FXStaple {
.cbStaple select $::OptStapleDefault
}
FXPunch {
.cbPunch select $::OptPunchDefault
}
FXJobType {
.cbJobType select $::OptJobTypeDefault
ChangeJobType
}
FXUserName {
set ::bufUserId $::OptUserIdDefault
}
FXHoldKey {
set ::bufPasswd $::OptPasswdDefault
}
}
}
# プリンタリスト取得
if {[lindex $argv 0] == "--allprinters"} {
set Plist [printnamelist]
} else {
set Plist [printnamelist "FX" "FX Printer Driver for Linux"]
}
# debug
# lappend Plist kutani
# i18N
source [file join $cwd fxlocalechk.tcl]
if { $locale == "ja" } {
source [file join $cwd fxwordlistjp.tcl]
} elseif { $locale == "en" } {
source [file join $cwd fxwordlisten.tcl]
} else {
source [file join $cwd fxwordlisten.tcl]
}
wm title . "Fuji Xerox printer utility"
# プリンタリスト
label .lPri -text $printerlabel -state disable
combobox::combobox .cbPri -editable false -listvar Plist -command SelectPrint \
-selectbackground cyan -background white -textvariable bufPrinter \
-state disabled
if {[llength $Plist] > 0} {
.cbPri configure -state normal
.lPri configure -state normal
}
# .lpoptionsの設定値異常メッセージ
proc IllegalSetting {IllegalList} {
if {[llength $IllegalList] == 0} { return }
if {![winfo exists .t0]} {
toplevel .t0
wm title .t0 $::Warninglabel
# Prohibit to resize, minimize and maxmize.
wm resizable .t0 false false
wm transient .t0 .
label .t0.l -text $::IllegalValue -wraplength $::TextWrapLength -justify left
pack .t0.l
set displist [join $IllegalList ", "]
label .t0.li -text $displist -wraplength $::TextWrapLength -justify center
pack .t0.li
button .t0.b -text OK -command {destroy .t0}
pack .t0.b
}
}
# プリンタリストからプリンタを選んだとき
proc SelectPrint {args} {
# Check the printer name.
if {[string length [lindex $args 1]] == 0} {
return
}
set IllegalSettingList ""
set lpoption [exec lpoptions -p [lindex $args 1]]
.chCollate configure -state normal
foreach cmb $::ComboKeyWord {
.l$cmb configure -state normal
.cb$cmb configure -state normal
}
.lJobType configure -state normal
.cbJobType configure -state normal
.bDefault configure -state normal
.bExec configure -state normal
foreach keyword $::OptKeyWordlist {
set opt [lindex $lpoption [lsearch $lpoption $keyword*]]
if {[string length $opt] > 0} {
#set setting [split $opt =]
#set now [lindex $setting 1]
# 文字列中に"="が含まれると正しい設定値がとれないので
set now [string range $opt [expr [string first = $opt 0] + 1] end]
switch $keyword {
FXCollate {
if {[string compare $now True] == 0} {
.chCollate select
} elseif {[string compare $now False] == 0} {
.chCollate deselect
} else {
.chCollate deselect
lappend IllegalSettingList $::collatelabel
}
}
FXColorMode {
set index [lsearch $::OptColorlist $now]
if {$index == -1} {
SetDefault $keyword
.cbColor configure -fg red
lappend IllegalSettingList $::Colorlabel
} else {
.cbColor select [lsearch $::OptColorlist $now]
.cbColor configure -fg black
}
}
PageSize {
set index [lsearch $::OptOutputSizelist $now]
if {$index == -1} {
SetDefault $keyword
.cbOutputSize configure -fg red
lappend IllegalSettingList $::OutputSizelabel
} else {
.cbOutputSize select $index
.cbOutputSize configure -fg black
}
}
FXOutputMode {
set index [lsearch $::OptPrintModelist $now]
if {$index == -1} {
SetDefault $keyword
.cbPrintMode configure -fg red
lappend IllegalSettingList $::PrintModelabel
} else {
.cbPrintMode select $index
.cbPrintMode configure -fg black
}
}
Duplex {
set index [lsearch $::OptDuplexlist $now]
if {$index == -1} {
SetDefault $keyword
.cbDuplex configure -fg red
lappend IllegalSettingList $::Duplexlabel
} else {
.cbDuplex select $index
.cbDuplex configure -fg black
}
}
FXLayout {
set index [lsearch $::OptLayoutlist $now]
if {$index == -1} {
SetDefault $keyword
.cbLayout configure -fg red
lappend IllegalSettingList $::Layoutlabel
} else {
.cbLayout select $index
.cbLayout configure -fg black
}
}
FXMediaType {
set index [lsearch $::OptPaperTypelist $now]
if {$index == -1} {
SetDefault $keyword
.cbPaperType configure -fg red
lappend IllegalSettingList $::PaperTypelabel
} else {
.cbPaperType select $index
.cbPaperType configure -fg black
}
}
InputSlot {
set index [lsearch $::OptPaperTraylist $now]
if {$index == -1} {
SetDefault $keyword
.cbPaperTray configure -fg red
lappend IllegalSettingList $::PaperTraylabel
} else {
.cbPaperTray select $index
.cbPaperTray configure -fg black
}
}
FXStaple {
set index [lsearch $::OptStaplelist $now]
if {$index == -1} {
SetDefault $keyword
.cbStaple configure -fg red
lappend IllegalSettingList $::Staplelabel
} else {
.cbStaple select $index
.cbStaple configure -fg black
}
}
FXPunch {
set index [lsearch $::OptPunchlist $now]
if {$index == -1} {
SetDefault $keyword
.cbPunch configure -fg red
lappend IllegalSettingList $::Punchlabel
} else {
.cbPunch select $index
.cbPunch configure -fg black
}
}
FXJobType {
set index [lsearch $::OptJobTypelist $now]
if {$index == -1} {
SetDefault $keyword
.cbJobType configure -fg red
lappend IllegalSettingList $::JobTypelabel
} else {
.cbJobType select [lsearch $::OptJobTypelist $now]
.cbJobType configure -fg black
}
}
FXUserName {
if {[ValidUserId $now 8] != 1} {
set ::bufUserId $::OptUserIdDefault
set ::UserIdNormalColor red
lappend IllegalSettingList $::UserIdlabel
} else {
set ::bufUserId $now
set ::UserIdNormalColor black
}
}
FXHoldKey {
set passdigit [decode $now]
if {[ValidDigit $passdigit 12] != 1} {
set ::bufPasswd $::OptPasswdDefault
set ::PasswdNormalColor red
lappend IllegalSettingList $::Passwdlabel
} else {
set ::bufPasswd $passdigit
set ::PasswdNormalColor black
}
}
}
} else {
SetDefault $keyword
if {[string compare $keyword FXUserName] == 0} {
set ::UserIdNormalColor black
}
}
}
IllegalSetting $IllegalSettingList
ChangeJobType
}
grid .lPri -row 0
grid .cbPri -row 0 -column 1 -columnspan 2 -sticky ew
# 入力チェック
proc ValidDigit {P validLen} {
if {[string is digit $P] == 1 && [string is ascii $P] == 1} {
set len [string length $P]
if {$len > $validLen} {
return 0
}
return 1
}
return 0
}
proc ValidUserId {P validLen} {
if {[string is alnum $P] == 1 && [string is ascii $P] == 1} {
set len [string length $P]
if {$len > $validLen} {
return 0
}
return 1
}
return 0
}
# 部単位
checkbutton .chCollate -text $collatelabel -state disable -variable bufCollate
grid .chCollate -row 1 -column 1 -sticky ew
set rownum 2
# カラーモード ~ パンチ コンボ作成
foreach cmb $ComboKeyWord {
set wlabel label
set Label [expr $$cmb$wlabel]
set wlist list
set List $cmb$wlist
label .l$cmb -text $Label -state disable
combobox::combobox .cb$cmb -editable false -state disabled -selectbackground cyan \
-background white -listvar $List -width $MaxTextWidth
#.cb$cmb configure -state disabled
grid .l$cmb -row $rownum
grid .cb$cmb -row $rownum -column 1 -columnspan 2 -sticky ew
incr rownum
}
# プリント種類
label .lJobType -text $JobTypelabel -state disable
combobox::combobox .cbJobType -editable false -selectbackground cyan \
-background white -command ChangeJobType -textvariable bufJobType \
-listvar JobTypelist -state disabled -width $MaxTextWidth
# ユーザID、暗証番号グレイアウト処理
proc ChangeJobType {args} {
set now [.cbJobType curselection]
if {$now == 0} {
.lUserId configure -state disable
.eUserId configure -state disable -bg gray85 -fg gray70
.lPasswd configure -state disable
.ePasswd configure -state disable -bg gray85 -fg gray70
set ::UserIdSaveColor gray70
set ::PasswdSaveColor gray70
} elseif {$now == 1} {
# secure print
.lUserId configure -state normal
.eUserId configure -state normal -bg white -fg $::UserIdNormalColor
.lPasswd configure -state normal
.ePasswd configure -state normal -bg white -fg $::PasswdNormalColor
set ::UserIdSaveColor black
set ::PasswdSaveColor black
} elseif {$now == 2} {
# sample print
.lUserId configure -state normal
.eUserId configure -state normal -bg white -fg $::UserIdNormalColor
.lPasswd configure -state disable
.ePasswd configure -state disable -bg gray85 -fg gray70
set ::UserIdSaveColor black
set ::PasswdSaveColor black
}
}
grid .lJobType -row $rownum
grid .cbJobType -row $rownum -column 1 -columnspan 2 -sticky ew
incr rownum
# ユーザID
label .lUserId -text $UserIdlabel -state disable
entry .eUserId -textvariable bufUserId -state disable -bg gray85 \
-validate key -vcmd {ValidUserId %P 8} -fg gray70
grid .lUserId -row $rownum
update
grid .eUserId -row $rownum -column 1 -columnspan 2 -sticky ew
incr rownum
# 暗証番号
label .lPasswd -text $Passwdlabel -state disable
entry .ePasswd -textvariable bufPasswd -show * -validate key \
-vcmd {ValidDigit %P 12} -state disable -bg gray85 \
-fg gray70
grid .lPasswd -row $rownum
update
grid .ePasswd -row $rownum -column 1 -columnspan 2 -sticky ew
incr rownum
# lpoptionsコマンド実行
proc ExecCommand {} {
set ColorValue [lindex $::OptColorlist [.cbColor curselection]]
set PaperSizeValue [lindex $::OptOutputSizelist [.cbOutputSize curselection]]
set PrintModeValue [lindex $::OptPrintModelist [.cbPrintMode curselection]]
set DuplexValue [lindex $::OptDuplexlist [.cbDuplex curselection]]
set LayoutValue [lindex $::OptLayoutlist [.cbLayout curselection]]
set PaperTypeValue [lindex $::OptPaperTypelist [.cbPaperType curselection]]
set PaperTrayValue [lindex $::OptPaperTraylist [.cbPaperTray curselection]]
set StapleValue [lindex $::OptStaplelist [.cbStaple curselection]]
set PunchValue [lindex $::OptPunchlist [.cbPunch curselection]]
set JobTypeValue [lindex $::OptJobTypelist [.cbJobType curselection]]
set UserIdValue ""
if {[.cbJobType curselection] != 0} {
if {[string length $::bufUserId] > 0} {
set UserIdValue "-o $::OptUserId=$::bufUserId"
set ::UserIdNormalColor black
}
}
set PasswdValue ""
if {[.cbJobType curselection] == 1} {
if {[string length $::bufPasswd] > 0} {
set encryptPass [encode $::bufPasswd]
set PasswdValue "-o $::OptPasswd='$encryptPass'"
}
set ::PasswdNormalColor black
}
if {$::bufCollate == 0} {
set CollateValue False
} else {
set CollateValue True
}
.cbColor configure -fg black
.cbOutputSize configure -fg black
.cbPrintMode configure -fg black
.cbDuplex configure -fg black
.cbLayout configure -fg black
.cbPaperType configure -fg black
.cbPaperTray configure -fg black
.cbStaple configure -fg black
.cbPunch configure -fg black
.cbJobType configure -fg black
.eUserId configure -fg $::UserIdSaveColor
.ePasswd configure -fg $::PasswdSaveColor
if {[.cbJobType curselection] == 1 && [string length $::bufPasswd] == 0} {
eval exec "lpoptions -p $::bufPrinter $UserIdValue -r $::OptPasswd -o $::OptPaperTray=$PaperTrayValue -o $::OptCollate=$CollateValue -o $::OptColor=$ColorValue -o $::OptOutputSize=$PaperSizeValue -o $::OptPrintMode=$PrintModeValue -o $::OptDuplex=$DuplexValue -o $::OptLayout=$LayoutValue -o $::OptPaperType=$PaperTypeValue -o $::OptStaple=$StapleValue -o $::OptPunch=$PunchValue -o $::OptJobType=$JobTypeValue"
} elseif {[string length $PasswdValue] > 0} {
eval exec "lpoptions -p $::bufPrinter $UserIdValue [subst -novariables {$PasswdValue}] -o $::OptPaperTray=$PaperTrayValue -o $::OptCollate=$CollateValue -o $::OptColor=$ColorValue -o $::OptOutputSize=$PaperSizeValue -o $::OptPrintMode=$PrintModeValue -o $::OptDuplex=$DuplexValue -o $::OptLayout=$LayoutValue -o $::OptPaperType=$PaperTypeValue -o $::OptStaple=$StapleValue -o $::OptPunch=$PunchValue -o $::OptJobType=$JobTypeValue"
} else {
eval exec "lpoptions -p $::bufPrinter $UserIdValue -o $::OptPaperTray=$PaperTrayValue -o $::OptCollate=$CollateValue -o $::OptColor=$ColorValue -o $::OptOutputSize=$PaperSizeValue -o $::OptPrintMode=$PrintModeValue -o $::OptDuplex=$DuplexValue -o $::OptLayout=$LayoutValue -o $::OptPaperType=$PaperTypeValue -o $::OptStaple=$StapleValue -o $::OptPunch=$PunchValue -o $::OptJobType=$JobTypeValue"
}
}
button .bExec -text $Applylabel -command SaveSetting -state disable -width 5
#
proc SaveSetting {} {
# ユーザIDチェック
if {[.cbJobType curselection] != 0} {
if {[string length $::bufUserId] == 0} {
if {![winfo exists .t0]} {
toplevel .t0
wm title .t0 $::Warninglabel
# Prohibit to resize, minimize and maxmize.
wm resizable .t0 false false
wm transient .t0 .
label .t0.lwarn -text $::WarningMessage1 -wraplength $::TextWrapLength -justify left
button .t0.bOK -text OK -command {destroy .t0}
pack .t0.lwarn .t0.bOK
}
# Anyway return if invalid username is given.
return
}
}
# lpoptions 実行
ExecCommand
}
frame .edummy -height 10
grid .edummy -row $rownum -columnspan 3
incr rownum
button .bDefault -text $Defaultlabel -state disable -command {foreach key $OptKeyWordlist {SetDefault $key}}
#grid .bDefault -row $rownum -columnspan 2
grid .bDefault -row $rownum -column 0
#grid .bExec -row $rownum -column 2 -sticky w
grid .bExec -row $rownum -column 1 -sticky w
button .bEnd -text $Endlabel -command exit -width 5
grid .bEnd -row $rownum -column 2 -sticky e
# end of fxlputil.tcl