This file is indexed.

/usr/share/tkgate/scripts/options.tcl is in tkgate-data 2.0~b10-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
#   Copyright (C) 1987-2009 by Jeffery P. Hansen
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Last edit by hansen on Tue Dec 30 00:44:09 2008
#
#
#
# These methods are used for managing options in tkgate.  For each option "name"
# there are three (or fixe) variables that are used:
#
#     tkg_name        The currently active value of the parameter.
#     opts_name       The value to be shown in the options dialog box.
#     tkgdef_name     The default value of the option.
#     loctkg_name(l)  Locale specific versions of tkg_ (used only for some options). 
#
# Each option belongs to a class.  If no class is specified, then it will be added
# to the class "generic".
#
# Examples:
#
# Option::new smoothScroll 1 -optclass display		Defines an option "smoothScroll" belonging
#							to class "display" and with a default value of 1.
#
# Option::dialogLoad			Load all tkg_ variables into the opts_ variables.
# Option::dialogSave			ave all opts_ variables into the tkg_variables
# Option::writePreferences		Write the preferences file.
# Option::dialogLoadDefaults		Load all default values into the opts_ variables.
# Option::dialogLoadDefaults colors	Load all default values from class "colors" into the opts_ variables.
#
# Option::dialogSave -optclass Print -prefix pd
#     Save opts_ values in the Print class to variables with a pd_ prefix.
#
# Option::version ver			Indicate version of preferences file.
# Option::value name value		Set an option to a specified value
#
namespace eval Option {
  variable option_list
  variable minval
  variable maxval

  proc sfix {s} {
    set q ""
    set L [string length $s]

    set need_quotes [expr $L == 0]

    for { set i 0 } { $i < $L } { incr i } {
      set c [string index $s $i]
      if { $c == "\\" || $c == "\$" || $c == "\[" || $c == "\]" } {
	set c "\\$c"
      }
      if { $c == " " || $c == "\t"} {
	set need_quotes 1
      }

      set q $q$c
    }

    if { $need_quotes } {
      return "\"$q\""
    } else {
      return $q
    }
  }

  #
  # Load all options from
  #
  proc dialogLoad {args} {
    variable option_list

    set prefix "tkg"
    parseargs $args {-optclass -prefix}

    if {[info exists optclass]} {
      set names $optclass
    } else {
      set names [array names option_list "*"]
    }

    foreach n $names {
      foreach v $option_list($n) {
	global ${prefix}_$v opts_$v

	set opts_$v [set ${prefix}_$v]
      } 
    }
  }

  proc dialogSave {args} {
    variable option_list

    set prefix "tkg"
    parseargs $args {-optclass -prefix}

    if {[info exists optclass]} {
      set names $optclass
    } else {
      set names [array names option_list "*"]
    }

    foreach n $names {
      foreach v $option_list($n) {
	global ${prefix}_$v opts_$v

	set ${prefix}_$v [set opts_$v]
      } 
    }
  }

  proc writePreferences {args} {
    global tkg_prefFile tkg_progVer
    variable option_list


    set names [lindex $args 0]
    if { $names == "" } {
      set names [array names option_list "*"]
    }

    set fd [open $tkg_prefFile w]
    puts $fd "#"
    puts $fd "# Automatically generated preferences file - DO NOT EDIT"
    puts $fd "#"
    puts $fd ""
    puts $fd "Option::version $tkg_progVer"

    foreach n $names {
      puts $fd ""
      puts $fd "#"
      puts $fd "# $n settings"
      puts $fd "#"
      foreach v $option_list($n) {
	global tkg_$v tkgdef_$v
	global territory

	set value [set tkg_$v]
	set dvalue [set tkgdef_$v]

	if {[array exists ::loctkg_$v]} {
	  set did_my_locale 0
	  foreach {loc locvalue} [array get ::loctkg_$v] {
	    if {$loc == "*" } continue
	    if {$loc == $territory} {
	      set locvalue $value
	      set did_my_locale 1
	    }
	    puts $fd "Option::value ${v}($loc) [sfix $locvalue]"
	  }
	  if {!$did_my_locale} {
	    puts $fd "Option::value ${v}($territory) [sfix $value]"
	  }
	} else {
	  puts $fd "Option::value $v [sfix $value]"
	}
      } 
    }
    close $fd
  }

  proc version {ver} {
    global tkg_optionsVersion

    set tkg_optionsVersion $ver
  }

  #############################################################################
  #
  # Restore defaults from the tkgdef_ to opts_ variables.
  #
  proc restoreDefaults {args} {
    variable option_list

    set names [array names option_list "*"]
    foreach n $names {
      if {[llength $args] == 0 || [lsearch $args $n] >= 0 } {
	foreach v $option_list($n) {
	  set dvar tkgdef_$v
	  set ovar opts_$v
	  global $dvar $ovar

	  set $ovar [set $dvar]
	}
      }
    }
  }

  proc value {name val} {
    variable minval
    variable maxval

    if {[scan $name "%\[^(\](%\[^)\])" baseName locName] == 2} {
      global territory
      global loctkg_$baseName

      set name $baseName
      set loctkg_${name}($locName) $val
      if { $locName != $territory } { return }
    }

    global tkg_$name

    catch { if {$val < $minval($name) } { set val $minval($name) } }
    catch { if {$val > $maxval($name) } { set val $maxval($name) } }

    set tkg_$name $val
  }

  #
  # Set the default value of an option.
  #
  proc setDefault {name val} {
    variable minval
    variable maxval

    if {[scan $name "%\[^(\](%\[^)\])" baseName locName] == 2} {
      global territory
      global loctkg_$baseName

      set name $baseName
      set loctkg_${name}($locName) $val
      if { $locName != $territory } { return }
    }

    global tkg_$name tkgdef_$name

    catch { if {$val < $minval($name) } { set val $minval($name) } }
    catch { if {$val > $maxval($name) } { set val $maxval($name) } }

    set tkg_$name $val
    set tkgdef_$name $val
  }

  #
  # Decare a new option
  #
  proc new {name dval args} {
    variable option_list
    variable minval
    variable maxval

    set optclass "generic"
    parseargs $args {-optclass -minvalue -maxvalue}

    if {[scan $name "%\[^(\](%\[^)\])" baseName locName] == 2} {
      global territory
      global loctkg_$baseName

      set name $baseName
      set loctkg_${name}($locName) $dval

      if { $locName != $territory && ($locName != "*" ||  [info exists tkg_$name])} { return }
    }

    global tkg_$name tkgdef_$name opts_$name

    catch { set minval($name) $minvalue }
    catch { set maxval($name) $maxvalue }

    lappend option_list($optclass) $name

    set tkg_$name $dval
    set tkgdef_$name $dval
    set opts_$name $dval
  }
}