"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "OpenVerse/lib/SetFuncs.tcl" of archive OpenVerse-0.8-7.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) Tcl/Tk source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 # OpenVerse Setup Module
    2 #
    3 # This module contains all the functions needed for the setup
    4 # Window to work.
    5 #
    6 # Module Name		- Setup Module
    7 # Current Maintainter 	- Cruise <cruise@openverse.org>
    8 # Sourced By		- InitMainWindow
    9 #
   10 # Copyright (C) 1999 David Gale <cruise@openverse.org>
   11 # For more information visit http://OpenVerse.org/
   12 #
   13 # Modifications by KaosBeetl:
   14 #    Sort Passageways option, 02/07/2000
   15 #
   16 # This program is free software; you can redistribute it and/or
   17 # modify it under the terms of the GNU General Public License
   18 # as published by the Free Software Foundation; either version 2
   19 # of the License, or (at your option) any later version.
   20 #
   21 # This program is distributed in the hope that it will be useful,
   22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   24 # GNU General Public License for more details.
   25 #
   26 # You should have received a copy of the GNU General Public License
   27 # along with this program; if not, write to the Free Software
   28 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
   29 # USA.
   30 
   31 # Performance eenhancements using string compare
   32 # Perfomance increase by using curley braces around functions.
   33 
   34 proc InitSetVars {} {
   35 	global SET MV
   36 
   37 	#------------------------
   38 	# Bool
   39 	#------------------------
   40 	set SET(honor_exits) $MV(honor_exits)
   41 	set SET(honor_call) $MV(honor_call)
   42         set SET(sort_bookmarks) $MV(sort_bookmarks)
   43 	set SET(bell) $MV(bell)
   44 	set SET(use_windowmanager_colors) $MV(use_windowmanager_colors)
   45 	set SET(names) $MV(names)
   46 	set SET(tooltips) $MV(tooltips)
   47 	set SET(timestamp) $MV(timestamp)
   48 	set SET(download_avatars) $MV(download_avatars)
   49 	set SET(honor_effects) $MV(honor_effects)
   50 	set SET(connect_on_startup) $MV(connect_on_startup)
   51 	#-------------------------
   52 	# Numeric
   53 	#-------------------------
   54 	set SET(staytime) $MV(staytime)
   55 	set SET(movespeed) $MV(movespeed)
   56 	set SET(urltimeout) $MV(urltimeout)
   57 	set SET(font.balloon) $MV(font.balloon)
   58 	set SET(font.balloon.size) $MV(font.balloon.size)
   59 	#-------------------------
   60 	# Strings
   61 	#-------------------------
   62 	set SET(panel) "$MV(panel)"
   63 	set SET(nick) "$MV(nick)"
   64 	set SET(anim) "$MV(anim)"
   65 	set SET(language) "$MV(language)"
   66 	set SET(browser_cmd) "$MV(browser_cmd)"
   67 	set SET(default_host) "$MV(roomhost)"
   68 	set SET(default_port) "$MV(roomport)"
   69 	set SET(personal.sex) "$MV(personal.sex)"
   70 	set SET(personal.image) "$MV(personal.image)"
   71 	set SET(personal.realname) "$MV(personal.realname)"
   72 	set SET(personal.email) "$MV(personal.email)"
   73 	set SET(personal.homepage) "$MV(personal.homepage)"
   74 	set SET(personal.info) "$MV(personal.info)"
   75 	set SET(personal.availability) "$MV(personal.availability)"
   76 	set SET(font.balloon.style) "$MV(font.balloon.style)"
   77 }
   78 
   79 #
   80 # This sets up the setup window.
   81 #
   82 proc Setup {} {
   83 	global SET MV
   84 
   85 	if {[winfo exists .setup]} {destroy .setup}
   86 	InitSetVars
   87 	set SET(refresh_menu) 0
   88 	image create photo PERSONAL_IMAGE -file [file nativename "$SET(personal.image)"]
   89 
   90 	toplevel .setup
   91 	wm title .setup [Trns openverse_setup]
   92 	wm resizable .setup 0 0
   93 	frame .setup.na
   94 	frame .setup.na.l
   95 	frame .setup.na.l.t
   96 	frame .setup.na.l.b
   97 	frame .setup.na.l.t.nick
   98 	frame .setup.na.l.b.avatars
   99 	frame .setup.na.r
  100 	frame .setup.opta
  101 	frame .setup.optaaa
  102 	frame .setup.optaa
  103 	frame .setup.optb
  104 	frame .setup.optba
  105 	frame .setup.optc
  106 	frame .setup.cmds
  107 
  108 
  109 	checkbutton .setup.opta.colors -text [Trns color_buttons] -variable \
  110 		SET(use_windowmanager_colors) -onval 0 -offval 1 \
  111 		-relief raised -borderwidth 2
  112 	checkbutton .setup.opta.bell -text [Trns sound] -variable \
  113 		SET(bell) -onval 1 -offval 0 \
  114 		-relief raised -borderwidth 2
  115 	checkbutton .setup.opta.names -text [Trns names] -variable \
  116 		SET(names) -onval 1 -offval 0 \
  117 		-relief raised -borderwidth 2
  118 	checkbutton .setup.opta.ttips -text [Trns tooltips] -variable \
  119 		SET(tooltips) -onval 1 -offval 0 \
  120 		-relief raised -borderwidth 2
  121 	checkbutton .setup.opta.av -text [Trns download_avatars] -variable \
  122 		SET(download_avatars) -onval 1 -offval 0 \
  123 		-relief raised -borderwidth 2
  124 
  125 	checkbutton .setup.optaaa.ts -text [Trns show_timestamps] -variable \
  126 		SET(timestamp) -onval 1 -offval 0 \
  127 		-relief raised -borderwidth 2
  128 
  129 	checkbutton .setup.optaaa.cs -text [Trns connect_on_startup] -variable \
  130 		SET(connect_on_startup) -onval 1 -offval 0 \
  131 		-relief raised -borderwidth 2
  132 
  133 	checkbutton .setup.optaa.he -text [Trns honor_effects] -variable \
  134 		SET(honor_effects) -onval 1 -offval 0 \
  135 		-relief raised -borderwidth 2
  136 	checkbutton .setup.optaa.hc -text [Trns honor_calls] -variable \
  137 		SET(honor_call) -onval 1 -offval 0 \
  138 		-relief raised -borderwidth 2
  139 	checkbutton .setup.optaa.hex -text [Trns honor_exits] -variable \
  140 		SET(honor_exits) -onval 1 -offval 0 \
  141 		-relief raised -borderwidth 2
  142 	checkbutton .setup.optaa.sb -text [Trns sort_passageways] -variable \
  143 		SET(sort_bookmarks) -onval 1 -offval 0 \
  144 		-relief raised -borderwidth 2
  145 
  146 	label .setup.optb.http_l -text [Trns browser_cmd] -width 14
  147 	entry .setup.optb.http_e
  148 
  149 	frame .setup.optb.font -relief sunken -borderwidth 2
  150 	menubutton .setup.optb.font.balloon_font -text [Trns balloon_font] \
  151 		-indicatoron 1 -relief raised -borderwidth 1 \
  152 		-menu .setup.optb.font.balloon_font.m
  153 	menu .setup.optb.font.balloon_font.m
  154 	set depth 0
  155 	set rows 0
  156 	for {set c 0} {$c <= $MV(font_max)} {incr c} {
  157 		if {!$depth || $rows > 10} {
  158 			incr depth
  159 			set rows 0
  160 			set menulabel "[Trns fontlist] $depth"
  161 			.setup.optb.font.balloon_font.m add cascade -menu \
  162 				.setup.optb.font.balloon_font.m.m$depth \
  163 				-label $menulabel
  164 			menu .setup.optb.font.balloon_font.m.m$depth
  165 		}
  166 		.setup.optb.font.balloon_font.m.m$depth add radiobutton \
  167 			-label "$MV(font.balloon.$c.name)" \
  168 			-variable SET(font.balloon) \
  169 			-value $c
  170 		incr rows
  171 	}
  172 	menubutton .setup.optb.font.font_size -text [Trns size] \
  173 		-indicatoron 1 -relief raised -borderwidth 1 \
  174 		-menu .setup.optb.font.font_size.m
  175 	menu .setup.optb.font.font_size.m
  176 	.setup.optb.font.font_size.m add radiobutton \
  177 		-label "8" \
  178 		-variable SET(font.balloon.size) \
  179 		-value 8
  180 	.setup.optb.font.font_size.m add radiobutton \
  181 		-label "10" \
  182 		-variable SET(font.balloon.size) \
  183 		-value 10
  184 	.setup.optb.font.font_size.m add radiobutton \
  185 		-label "12" \
  186 		-variable SET(font.balloon.size) \
  187 		-value 12
  188 	.setup.optb.font.font_size.m add radiobutton \
  189 		-label "14" \
  190 		-variable SET(font.balloon.size) \
  191 		-value 14
  192 	.setup.optb.font.font_size.m add radiobutton \
  193 		-label "16" \
  194 		-variable SET(font.balloon.size) \
  195 		-value 16
  196 
  197 	radiobutton .setup.optb.font.normal -text [Trns normal] \
  198 		-variable SET(font.balloon.style) -value "normal"
  199 	radiobutton .setup.optb.font.bold -text [Trns bold] \
  200 		-variable SET(font.balloon.style) -value "bold"
  201 	radiobutton .setup.optb.font.italic -text [Trns italic] \
  202 		-variable SET(font.balloon.style) -value "italic"
  203 	radiobutton .setup.optb.font.bold_italic -text [Trns bold_italic] \
  204 		-variable SET(font.balloon.style) -value "bold_italic"
  205 
  206 	frame .setup.optba.serv
  207 	label .setup.optba.serv.l -text [Trns default_server] -width 14
  208 	entry .setup.optba.serv.e
  209 
  210 	frame .setup.optba.port
  211 	label .setup.optba.port.l -text [Trns default_port]
  212 	entry .setup.optba.port.e -width 6
  213 
  214 	frame .setup.optc.info -relief sunken -borderwidth 2
  215 	label .setup.optc.info.txt -relief raised -text [Trns personal_info] \
  216 		-borderwidth 2
  217 	frame .setup.optc.info.meat
  218 	frame .setup.optc.info.meat.img
  219 	button .setup.optc.info.meat.img.img -image PERSONAL_IMAGE \
  220 		-command {}
  221 
  222 	frame .setup.optc.info.meat.inf
  223 	frame .setup.optc.info.meat.inf.a
  224 	frame .setup.optc.info.meat.inf.b
  225 	frame .setup.optc.info.meat.inf.c
  226 	frame .setup.optc.info.meat.inf.d
  227 	label .setup.optc.info.meat.inf.a.l -text [Trns real_name] -width 15
  228 	label .setup.optc.info.meat.inf.b.l -text [Trns email_address] -width 15
  229 	label .setup.optc.info.meat.inf.c.l -text [Trns home_page] -width 15
  230 	menubutton .setup.optc.info.meat.inf.d.avail -text [Trns availability] -menu \
  231 		.setup.optc.info.meat.inf.d.avail.m -relief raised \
  232 		-underline 0 -width 15 -borderwidth 1
  233 	menu .setup.optc.info.meat.inf.d.avail.m
  234 	.setup.optc.info.meat.inf.d.avail.m add radiobutton \
  235 		-label [Trns always_send] -variable SET(personal.availability) \
  236 		-value "Always"
  237 	.setup.optc.info.meat.inf.d.avail.m add radiobutton \
  238 		-label [Trns never_send] -variable SET(personal.availability) \
  239 		-value "Never"
  240 	.setup.optc.info.meat.inf.d.avail.m add radiobutton \
  241 		-label [Trns ask_to_send] -variable SET(personal.availability) \
  242 		-value "Ask"
  243 
  244 	label .setup.optc.info.meat.inf.d.l -text [Trns sex] -width 15
  245 	entry .setup.optc.info.meat.inf.a.e
  246 	entry .setup.optc.info.meat.inf.b.e
  247 	entry .setup.optc.info.meat.inf.c.e
  248 	radiobutton .setup.optc.info.meat.inf.d.oa -text [Trns male] \
  249 		-variable SET(personal.sex) -value "Male"
  250 	radiobutton .setup.optc.info.meat.inf.d.ob -text [Trns female] \
  251 		-variable SET(personal.sex) -value "Female"
  252 	radiobutton .setup.optc.info.meat.inf.d.oc -text [Trns other] \
  253 		-variable SET(personal.sex) -value "Other"
  254 
  255 	frame .setup.optc.info.meat.txt
  256 	text .setup.optc.info.meat.txt.t -height 10 -width 50 -wrap word -yscrollcommand ".setup.optc.info.meat.txt.scrolly set"
  257         scrollbar .setup.optc.info.meat.txt.scrolly -command ".setup.optc.info.meat.txt.t yview"
  258 
  259 	frame .setup.optc.list -relief sunken -borderwidth 2
  260 
  261 	frame .setup.optc.list.top
  262 	label .setup.optc.list.top.txt -relief raised -text [Trns panel_style] \
  263 		-borderwidth 2
  264 	listbox .setup.optc.list.top.l -width 20 -height 4 \
  265 		-relief raised -yscrollcommand ".setup.optc.list.top.scrly set" \
  266 		-xscrollcommand ".setup.optc.list.top.scrlx set"
  267 	scrollbar .setup.optc.list.top.scrly -command ".setup.optc.list.top.l yview"
  268 	scrollbar .setup.optc.list.top.scrlx -command ".setup.optc.list.top.l xview" \
  269 		-orient horizontal
  270 
  271 	frame .setup.optc.list.bot
  272 	label .setup.optc.list.bot.ltxt -relief raised -text [Trns language] \
  273 		-borderwidth 2
  274 	listbox .setup.optc.list.bot.ll -width 20 -height 5 \
  275 		-relief raised -yscrollcommand ".setup.optc.list.bot.lscrly set" \
  276 		-xscrollcommand ".setup.optc.list.bot.lscrlx set"
  277 	scrollbar .setup.optc.list.bot.lscrly -command ".setup.optc.list.bot.ll yview"
  278 	scrollbar .setup.optc.list.bot.lscrlx -command ".setup.optc.list.bot.ll xview" \
  279 		-orient horizontal
  280 
  281 
  282 	scale .setup.na.r.bspeed -from 1 -to 20 -variable SET(staytime) \
  283 		-orient horizontal -label [Trns balloon_speed] -relief raised \
  284 		-borderwidth 2
  285 	scale .setup.na.r.mspeed -from 1 -to 20 -variable SET(movespeed) \
  286 		-orient horizontal -label [Trns move_speed] -relief raised \
  287 		-borderwidth 2
  288 	scale .setup.na.r.url -from 1 -to 300 -variable SET(urltimeout) \
  289 		-orient horizontal -label [Trns url_timeout] -relief raised \
  290 		-borderwidth 2
  291 
  292 
  293 	label .setup.na.l.t.nick.txt -text [Trns nick_name] -width 16
  294 	entry .setup.na.l.t.nick.entry
  295 	menubutton .setup.na.l.b.avatars.menu -text [Trns avatar] -menu \
  296 		.setup.na.l.b.avatars.menu.m -relief raised \
  297 		-underline 0 -width 15 -borderwidth 1
  298 	menu .setup.na.l.b.avatars.menu.m
  299 
  300 
  301 	set anims 0
  302 	set depth 0
  303 	set count 0
  304 	foreach file [List_Avatars] {
  305 		if !$depth {
  306 			incr depth
  307 			.setup.na.l.b.avatars.menu.m add cascade -menu \
  308 				.setup.na.l.b.avatars.menu.m.m$depth -label "[Trns avatars] $depth"
  309 			menu .setup.na.l.b.avatars.menu.m.m$depth
  310 		}
  311 		set SET(avatar_setup.$count) "[file tail $file]"
  312 		.setup.na.l.b.avatars.menu.m.m$depth add command -label [file tail $file] \
  313 			-command "SET_SetAvatar $count"
  314 		incr anims
  315 		incr count
  316 		if {$anims > 19} {
  317 			incr depth
  318 			.setup.na.l.b.avatars.menu.m add cascade -menu \
  319 				.setup.na.l.b.avatars.menu.m.m$depth -label "[Trns avatars] $depth"
  320 			menu .setup.na.l.b.avatars.menu.m.m$depth
  321 			set anims 0
  322 		}
  323 	}
  324 	entry .setup.na.l.b.avatars.entry
  325 
  326 	button .setup.cmds.cancel -text [Trns cancel] -command "destroy .setup"
  327 	button .setup.cmds.save -text [Trns save_apply] -command "SaveSetup 1"
  328 	button .setup.cmds.apply -text [Trns apply_only] -command "SaveSetup 2"
  329 	button .setup.cmds.saveo -text [Trns save_only] -command "SaveSetup 3"
  330 	button .setup.cmds.server -text [Trns start_server] -command "StartServer"
  331 
  332 	pack .setup.na -side top -fill both -expand y
  333 	pack .setup.na.l .setup.na.r .setup.na.r.url -side left -fill both \
  334 		-expand y
  335 	pack .setup.na.l.t -side top -fill both -expand y
  336 	pack .setup.na.l.b -side bottom -fill both -expand y
  337 	pack .setup.na.l.t.nick -fill both -expand y
  338 	pack .setup.na.l.b.avatars -fill both -expand y
  339 	pack .setup.na.l.t.nick.txt -side left
  340 	pack .setup.na.l.t.nick.entry -side left -fill both -expand y
  341 	pack .setup.na.l.b.avatars.menu -side left
  342 	pack .setup.na.l.b.avatars.entry -side left -fill both -expand y
  343 	pack .setup.opta -fill both -expand y
  344 	pack .setup.opta.ttips .setup.opta.bell .setup.opta.names \
  345 		.setup.opta.colors .setup.opta.av \
  346 		-side left -fill both -expand y
  347 	pack .setup.optaaa -fill both -expand y
  348 	pack .setup.optaaa.ts -side left -fill both -expand y
  349 	pack .setup.optaaa.cs -side left -fill both -expand y
  350 	pack .setup.optaa -fill both -expand y
  351 	pack .setup.optaa.he .setup.optaa.hc .setup.optaa.hex .setup.optaa.sb\
  352 		-side left -fill both -expand y
  353 	pack .setup.optb -fill both -expand y
  354 	pack .setup.optb.http_l -side left
  355 	pack .setup.optb.http_e -side left -fill both -expand y
  356 	pack .setup.optb.font -side left -fill both -expand y
  357 	pack .setup.optb.font.balloon_font .setup.optb.font.font_size .setup.optb.font.normal \
  358 		.setup.optb.font.bold .setup.optb.font.italic .setup.optb.font.bold_italic -side left
  359 	pack .setup.optba -fill both -expand y
  360 	pack .setup.optba.serv -side left -fill both -expand y
  361 	pack .setup.optba.port -side left
  362 	pack .setup.optba.serv.l -side left
  363 	pack .setup.optba.serv.e -side left -fill x -expand y
  364 	pack .setup.optba.port.l .setup.optba.port.e -side left
  365 	pack .setup.optc -fill both -expand y
  366 	pack .setup.optc.info -side left -fill both -expand y
  367 	pack .setup.optc.info.txt -side top -fill x -expand y
  368 	pack .setup.optc.info.meat -side bottom -fill both -expand y
  369 	pack .setup.optc.info.meat.txt -fill both -expand y -side bottom
  370 	pack .setup.optc.info.meat.img -side left
  371 	pack .setup.optc.info.meat.inf -side right -fill both -expand y
  372 	pack .setup.optc.info.meat.img.img -side top
  373 	pack .setup.optc.info.meat.inf.a -fill x -expand y
  374 	pack .setup.optc.info.meat.inf.b -fill x -expand y
  375 	pack .setup.optc.info.meat.inf.c -fill x -expand y
  376 	pack .setup.optc.info.meat.inf.d -fill x -expand y
  377 	pack .setup.optc.info.meat.inf.a.l -side left
  378 	pack .setup.optc.info.meat.inf.a.e -side left -fill x -expand y
  379 	pack .setup.optc.info.meat.inf.b.l -side left
  380 	pack .setup.optc.info.meat.inf.b.e -side left -fill x -expand y
  381 	pack .setup.optc.info.meat.inf.c.l -side left
  382 	pack .setup.optc.info.meat.inf.c.e -side left -fill x -expand y
  383 	pack .setup.optc.info.meat.inf.d.avail \
  384 		.setup.optc.info.meat.inf.d.l -side left
  385 	pack .setup.optc.info.meat.inf.d.oa .setup.optc.info.meat.inf.d.ob \
  386 		.setup.optc.info.meat.inf.d.oc -side left -fill x -expand y
  387 	pack .setup.optc.info.meat.txt.t -side left -fill both -expand y
  388 	pack .setup.optc.info.meat.txt.scrolly -side left -fill y
  389 
  390 	pack .setup.optc.list -side right
  391 	pack .setup.optc.list.top -side top
  392 	pack .setup.optc.list.bot -side bottom
  393 
  394 	pack .setup.optc.list.top.txt -fill x -expand y -side top
  395 	pack .setup.optc.list.top.scrlx -fill x -expand y
  396 	pack .setup.optc.list.top.l -side left -fill y -expand y
  397 	pack .setup.optc.list.top.scrly -side right -fill y -expand y
  398 
  399 	pack .setup.optc.list.bot.ltxt -fill x -expand y -side top
  400 	pack .setup.optc.list.bot.lscrlx -fill x -expand y
  401 	pack .setup.optc.list.bot.ll -side left -fill y -expand y
  402 	pack .setup.optc.list.bot.lscrly -side right -fill y -expand y
  403 
  404 	pack .setup.cmds -fill both -expand y
  405 
  406 	pack .setup.cmds.cancel .setup.cmds.save .setup.cmds.apply .setup.cmds.saveo .setup.cmds.server -side left -fill both \
  407 		-expand y
  408 	pack .setup.na.r.bspeed .setup.na.r.mspeed -side left -fill both \
  409 		-expand y
  410 
  411 	.setup.na.l.t.nick.entry insert end $SET(nick)
  412 	.setup.na.l.b.avatars.entry insert end $SET(anim)
  413 	.setup.optb.http_e insert end $SET(browser_cmd)
  414 	.setup.optba.serv.e insert end $SET(default_host)
  415 	.setup.optba.port.e insert end $SET(default_port)
  416 	.setup.optc.info.meat.inf.a.e insert end $SET(personal.realname)
  417 	.setup.optc.info.meat.inf.b.e insert end $SET(personal.email)
  418 	.setup.optc.info.meat.inf.c.e insert end $SET(personal.homepage)
  419 	.setup.optc.info.meat.txt.t insert end $SET(personal.info)
  420 
  421 	bind .setup.na.l.t.nick.entry <KeyRelease> {CheckNick}
  422 	bind .setup.na.l.t.nick.entry <ButtonPress> {CheckNick}
  423 	bind .setup.optc.list.top.l <ButtonRelease> {
  424 		set SET(panel) [selection get]
  425 		set SET(refresh_menu) 1
  426 	}
  427 	bind .setup.optc.list.bot.ll <ButtonRelease> {
  428 		set SET(language) [selection get]
  429 	}
  430 	bind .setup <Destroy> {Unset_Setup}
  431 	FillPanels
  432 
  433 }
  434 
  435 proc SET_SetAvatar {which} {
  436 	global SET
  437 
  438 	set SET(anim) "$SET(avatar_setup.$which)"
  439 	.setup.na.l.b.avatars.entry delete 0 end
  440 	.setup.na.l.b.avatars.entry insert end $SET(anim)
  441 }
  442 
  443 proc FillPanels {} {
  444 	global SET MV
  445 
  446 	foreach panel [List_Panels] {
  447 		.setup.optc.list.top.l insert end "[file tail $panel]"
  448 		if {[file tail $panel] == $SET(panel)} {
  449 			.setup.optc.list.top.l selection set end
  450 			.setup.optc.list.top.l see end
  451 		}
  452 	}
  453 	DebugIt "Languagedir $MV(languagedir)" other
  454 	foreach language [List_Languages] {
  455 		DebugIt "Language = $language" other
  456 		.setup.optc.list.bot.ll insert end "[file tail $language]"
  457 		if {[file tail $language] == $SET(language)} {
  458 			.setup.optc.list.bot.ll selection set end
  459 			.setup.optc.list.bot.ll see end
  460 		}
  461 	}
  462 }
  463 
  464 
  465 proc SaveSetup {how} {
  466 	global MV
  467 	switch $how {
  468 		1 {
  469 			# Save And Apply.
  470 			SaveSetSettings
  471 			ApplySetSettings
  472 		}
  473 		2 {
  474 			# Apply Only.
  475 			ApplySetSettings
  476 		}
  477 		3 {
  478 			# Save Only.
  479 			SaveSetSettings
  480 		}
  481 	}
  482 	AnimateMe "[.setup.na.l.b.avatars.entry get]" 3
  483 	destroy .setup
  484 }
  485 
  486 # StripQuote <input>
  487 #
  488 # This should escape characters which would cause problems when
  489 # loading these characters from quoted text (such as the config file)
  490 #
  491 proc StripQuote {input} {
  492 	set output ""
  493 	for {set c 0} {$c < [string length $input]} {incr c} {
  494 		switch -- [string range $input $c $c] {
  495 			\" {
  496 				append output \\
  497 				append output \"
  498 			}
  499 			\} {
  500 				append output \\
  501 				append output \}
  502 			}
  503 			\{ {
  504 				append output \\
  505 				append output \{
  506 			}
  507 			\[ {
  508 				append output \\
  509 				append output \[
  510 			}
  511 			\] {
  512 				append output \\
  513 				append output \]
  514 			}
  515 			default {
  516 				append output "[string range $input $c $c]"
  517 			}
  518 		}
  519 	}
  520 	return $output
  521 }
  522 
  523 
  524 proc SaveSetSettings {} {
  525 	global SET MV
  526 
  527 	set outfile [open "$MV(configfile)" w]
  528 	#------------------------
  529 	# Bool
  530 	#------------------------
  531 	puts $outfile "set MV(honor_effects) $SET(honor_effects)"
  532 	puts $outfile "set MV(honor_exits) $SET(honor_exits)"
  533 	puts $outfile "set MV(connect_on_startup) $SET(connect_on_startup)"
  534 	puts $outfile "set MV(honor_call) $SET(honor_call)"
  535         puts $outfile "set MV(sort_bookmarks) $SET(sort_bookmarks)"
  536 	puts $outfile "set MV(bell) $SET(bell)"
  537 	puts $outfile "set MV(use_windowmanager_colors) $SET(use_windowmanager_colors)"
  538 	puts $outfile "set MV(names) $SET(names)"
  539 	puts $outfile "set MV(tooltips) $SET(tooltips)"
  540 	puts $outfile "set MV(timestamp) $SET(timestamp)"
  541 	puts $outfile "set MV(download_avatars) $SET(download_avatars)"
  542 	#------------------------
  543 	# Numeric
  544 	#------------------------
  545 	puts $outfile "set MV(staytime) $SET(staytime)"
  546 	puts $outfile "set MV(movespeed) $SET(movespeed)"
  547 	puts $outfile "set MV(urltimeout) $SET(urltimeout)"
  548 	puts $outfile "set MV(font.balloon) $SET(font.balloon)"
  549 	puts $outfile "set MV(font.balloon.size) $SET(font.balloon.size)"
  550 	#------------------------
  551 	# Strings
  552 	#------------------------
  553 	puts $outfile "set MV(font.balloon.style) $SET(font.balloon.style)"
  554 	puts $outfile "set MV(panel) \"[StripQuote $SET(panel)]\""
  555 	puts $outfile "set MV(nick) \"[StripQuote [.setup.na.l.t.nick.entry get]]\""
  556 	puts $outfile "set MV(anim) \"[StripQuote [.setup.na.l.b.avatars.entry get]]\""
  557 	puts $outfile "set MV(language) \"[StripQuote $SET(language)]\""
  558 	puts $outfile "set MV(browser_cmd) \"[StripQuote [.setup.optb.http_e get]]\""
  559 	puts $outfile "set MV(roomhost) \"[StripQuote [.setup.optba.serv.e get]]\""
  560 	puts $outfile "set MV(roomport) \"[StripQuote [.setup.optba.port.e get]]\""
  561 	puts $outfile "set MV(personal.sex) \"$SET(personal.sex)\""
  562 	puts $outfile "set MV(personal.info) \"[StripQuote [.setup.optc.info.meat.txt.t get 0.0 end]]\""
  563 	puts $outfile "set MV(personal.realname) \"[StripQuote [.setup.optc.info.meat.inf.a.e get]]\""
  564 	puts $outfile "set MV(personal.email) \"[StripQuote [.setup.optc.info.meat.inf.b.e get]]\""
  565 	puts $outfile "set MV(personal.homepage) \"[StripQuote [.setup.optc.info.meat.inf.c.e get]]\""
  566 	puts $outfile "set MV(personal.image) \"[StripQuote $SET(personal.image)]\""
  567 	puts $outfile "set MV(personal.availability) \"[StripQuote $SET(personal.availability)]\""
  568 	close $outfile
  569 }
  570 
  571 proc ApplySetSettings {} {
  572 	global MV SET
  573 
  574 	#------------------------
  575 	# Bool
  576 	#------------------------
  577 	set MV(honor_exits) $SET(honor_exits)
  578 	set MV(honor_call) $SET(honor_call)
  579         set MV(sort_bookmarks) $SET(sort_bookmarks)
  580 	set MV(bell) $SET(bell)
  581 	set MV(use_windowmanager_colors) $MV(use_windowmanager_colors)
  582 	set MV(names) $SET(names)
  583 	set MV(tooltips) $SET(tooltips)
  584 	set MV(timestamp) $SET(timestamp)
  585 	set MV(download_avatars) $SET(download_avatars)
  586 	set MV(honor_effects) $SET(honor_effects)
  587 	set MV(connect_on_startup) $SET(connect_on_startup)
  588 	#------------------------
  589 	# Numeric
  590 	#------------------------
  591 	set MV(staytime) $SET(staytime)
  592 	set MV(movespeed) $SET(movespeed)
  593 	set MV(urltimeout) $SET(urltimeout)
  594 	set MV(font.balloon) $SET(font.balloon)
  595 	set MV(font.balloon.size) $SET(font.balloon.size)
  596 	#------------------------
  597 	# Strings
  598 	#------------------------
  599 	set MV(font.balloon.style) $SET(font.balloon.style)
  600 	if $SET(refresh_menu) {
  601 		set MV(panel) "$SET(panel)"
  602 		source "$MV(paneldir)/$MV(panel)"
  603 	}
  604 	set SET(nick) "[.setup.na.l.t.nick.entry get]"
  605 	#Perfoormance Enhancement
  606 	if {[string compare $MV(nick) $SET(nick)]} {
  607 		if $MV(names) {
  608 			KillName $MV(nick)
  609 		}
  610 		set MV($SET(nick).haschat) 0
  611 		set MV($SET(nick).chatque) {}
  612 		ChangeNick "$SET(nick)"
  613 		SendToServer "NICK $MV(nick)"
  614 	}
  615 	set MV(anim) "[.setup.na.l.b.avatars.entry get]"
  616 	set MV(browser_cmd) [split [.setup.optb.http_e get] " "]
  617 	set MV(language) $SET(language)
  618 	# Room Host not applied !
  619 	# Room Port not applied !
  620 	set MV(personal.sex) "$SET(personal.sex)"
  621 	set MV(personal.image) "$SET(personal.image)"
  622 	set MV(personal.realname) [.setup.optc.info.meat.inf.a.e get]
  623 	set MV(personal.email) [.setup.optc.info.meat.inf.b.e get]
  624 	set MV(personal.homepage) [.setup.optc.info.meat.inf.c.e get]
  625 	set MV(personal.info) [.setup.optc.info.meat.txt.t get 0.0 end]
  626 	set MV(personal.availability) $SET(personal.availability)
  627 }
  628 
  629 proc Unset_Setup {} {
  630 	global SET
  631 	catch {unset SET}
  632 }