Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 1 | # Copyright 1999 Jean-Louis Thirot |
| 2 | # |
| 3 | # This library is free software; you can redistribute it and/or |
| 4 | # modify it under the terms of the GNU Lesser General Public |
| 5 | # License as published by the Free Software Foundation; either |
| 6 | # version 2.1 of the License, or (at your option) any later version. |
| 7 | # |
| 8 | # This library is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | # Lesser General Public License for more details. |
| 12 | # |
| 13 | # You should have received a copy of the GNU Lesser General Public |
| 14 | # License along with this library; if not, write to the Free Software |
| 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 16 | # |
| 17 | |
Jean-Louis Thirot | d7da0f6 | 1999-05-08 18:39:04 +0000 | [diff] [blame] | 18 | proc TkW:debug {msg} { |
| 19 | } |
| 20 | proc TkW:fixme {msg} { |
| 21 | } |
| 22 | proc TkW:wineconf1 {} { |
| 23 | |
| 24 | # propmt the user for a choice of the default config file: |
| 25 | # can be: |
| 26 | # Existing {--> menu ~/.winerc or /etc/wineconf or custom} |
| 27 | # autogenarated with tools/wineconf |
| 28 | # built-in the script |
| 29 | |
| 30 | # test of existing is preformed first; test of existing wineconf also |
| 31 | # |
| 32 | |
| 33 | set ExistEtc [TkW:ListConfig /etc/wine.conf] |
| 34 | set ExistHome [TkW:ListConfig "~/.winerc"] |
| 35 | |
| 36 | TkW:AskUserConfMethod $ExistEtc $ExistHome |
| 37 | tkwait vis .askConf |
| 38 | while [winfo exists .askConf] {update} |
| 39 | } |
| 40 | |
| 41 | proc TkW:ListConfig {fileConf} { |
| 42 | |
| 43 | global HOME |
| 44 | |
| 45 | set ExistConf 0 |
| 46 | if [file writa $fileConf] {return 1} {return 0} |
| 47 | } |
| 48 | |
| 49 | proc TkW:AskUserConfMethod {ExistEtc ExistHome} { |
| 50 | |
| 51 | global USER ChDefautConf DejaConf HOME OK CANCEL WAITfilename |
| 52 | global DefaultType EtcState HomeState GiveCustomDefault Default |
| 53 | global GetFileName GenereConf TkWBuiltConf |
| 54 | |
| 55 | toplevel .askConf -backgr #ffffff |
| 56 | label .askConf.banner -text $ChDefautConf -backgr #0000ff \ |
| 57 | -foregr #ffffff -height 2 |
| 58 | pack .askConf.banner -side top -fill x |
| 59 | |
| 60 | if {$USER == "root" && $ExistEtc == 1} { |
| 61 | set Default /etc/wine.conf |
| 62 | } else { |
| 63 | if {$ExistHome == 1} {set Default "~/.winerc"} \ |
| 64 | else {set Default Custom} |
| 65 | } |
| 66 | if {[file writable /etc/wine.conf]} {set EtcState normal} {set EtcState disabled} |
| 67 | if {$ExistHome == 1} {set HomeState normal} {set HomeState disabled} |
| 68 | set DefaultType 0 |
| 69 | frame .askConf.deja -width 200 -backgr #ffffff |
| 70 | radiobutton .askConf.deja.rad -backgr #dddddd -text $DejaConf\ |
| 71 | -anchor nw -value 0 -variable DefaultType \ |
| 72 | -indicatoron 1 -relief raised -selectcolor #00ff00 |
| 73 | pack .askConf.deja.rad -side left -padx 5 |
| 74 | menubutton .askConf.deja.men -backgr #dddddd \ |
| 75 | -menu .askConf.deja.men.m -width 50 -text $Default\ |
| 76 | -relief raised |
| 77 | |
| 78 | menu .askConf.deja.men.m -cursor {} -tearoff 0 |
| 79 | .askConf.deja.men.m add command \ |
| 80 | -command { |
| 81 | set Default "$HOME/.winerc" |
| 82 | .askConf.deja.men configure -text $Default |
| 83 | } -label "~/.winerc" -state $HomeState |
| 84 | .askConf.deja.men.m add command \ |
| 85 | -command { |
| 86 | set Default "/etc/wine.conf" |
| 87 | .askConf.deja.men configure -text $Default |
| 88 | } -state $EtcState \ |
| 89 | -label "/etc/wine.conf (System wide configuration)" |
| 90 | .askConf.deja.men.m add command \ |
| 91 | -command { |
| 92 | TkW:GetFileName $GiveCustomDefault $OK $CANCEL File |
| 93 | #set WAITfilename wait |
| 94 | #while {$WAITfilename == "wait"} {update} |
| 95 | if {$WAITfilename == "opt1"} { |
| 96 | set Default $GetFileName |
| 97 | } |
| 98 | .askConf.deja.men configure -text $Default |
| 99 | update |
| 100 | } \ |
| 101 | -label "Custom (Give your own configuration file)" |
| 102 | pack .askConf.deja -padx 5 -pady 10 |
| 103 | pack .askConf.deja.men |
| 104 | |
| 105 | label .askConf.img -image wine_half -backgr #ffffff -relief flat |
| 106 | pack .askConf.img -side right -anchor se -padx 5 -pady 5 |
| 107 | |
| 108 | # Next radiobutton: tools/wineconf: |
| 109 | |
| 110 | frame .askConf.radio -backgr #ffffff -relief flat |
| 111 | radiobutton .askConf.radio.generate -text $GenereConf\ |
| 112 | -anchor nw -value 1 -variable DefaultType \ |
| 113 | -selectcolor #00ff00 -relief raised |
| 114 | pack .askConf.radio.generate -padx 5 -pady 5 -anchor w -fill x |
| 115 | |
| 116 | # Next radiobutton : TkWine Built-in |
| 117 | |
| 118 | radiobutton .askConf.radio.tkwbuilt -text $TkWBuiltConf\ |
| 119 | -anchor nw -value 2 -variable DefaultType \ |
| 120 | -selectcolor #00ff00 -relief raised |
| 121 | pack .askConf.radio.tkwbuilt -padx 5 -pady 5 -anchor w -fill x |
| 122 | pack .askConf.radio -padx 0 -pady 0 -anchor w |
| 123 | |
| 124 | # now OK or CANCEL.... |
| 125 | frame .askConf.buttons -backgr #ffffff -relief flat -height 25 |
| 126 | button .askConf.buttons.ok -width 8 -text $OK -command { |
| 127 | destroy .askConf |
| 128 | TkW:CallWineConf |
| 129 | } |
| 130 | button .askConf.buttons.cancel -width 8 -text $CANCEL -command { |
| 131 | destroy .askConf |
| 132 | } |
| 133 | pack .askConf.buttons.ok -side left -padx 25 -pady 5 |
| 134 | pack .askConf.buttons.cancel -side left -padx 5 -pady 5 |
| 135 | pack .askConf.buttons -anchor w -padx 5 |
| 136 | |
| 137 | } |
| 138 | proc TkW:CallWineConf {} { |
| 139 | |
| 140 | global Default DefaultType TKW |
| 141 | switch $DefaultType { |
| 142 | 0 {TkW:wineconf $Default} |
| 143 | 1 { |
| 144 | set FoundWineConf 0 |
| 145 | set FoundWineConf [TkW:autoconf /tmp/auto_generated_wineconf] |
| 146 | while {$FoundWineConf == 0} update |
| 147 | TkW:wineconf /tmp/auto_generated_wineconf |
| 148 | |
| 149 | } |
| 150 | 2 {TkW:wineconf $TKW/setupfiles/wine.ini} |
| 151 | } |
| 152 | |
| 153 | } |
| 154 | |
| 155 | proc TkW:GenereTmpConf {wineconfTool} { |
| 156 | global specialwhere |
| 157 | set wherearewe ConfTool |
| 158 | set Pipe [open "| $wineconfTool " r+] |
| 159 | exec rm -f /tmp/auto_generated_wineconf |
| 160 | set TmpConf [open /tmp/auto_generated_wineconf w] |
| 161 | while {![eof $Pipe]} { |
| 162 | gets $Pipe line |
| 163 | puts $TmpConf $line |
| 164 | } |
| 165 | close $TmpConf |
| 166 | set specialwhere CloseWineAutoConf |
| 167 | close $Pipe |
| 168 | } |