Skip to content

Commit a27d76a

Browse files
committed
gitk: use $config_variables as list for save/restore
gitk offers many variables for configuration, and has all of these listed in $config_variables. gitk allows modification of many of these from a dialog box, and this dialog can be cancelled requiring that any configuration variable modified is restored to its prior value. But, gitk maintains lists of variables that can be used in the configuration dialog separately from $config_variables, and these lists exist independently in more than one place in the code. This is confusing, error prone, and unnecessary. Let's just use $config_variables as the authoritative list in all places: a new configuration variable need only be added to this list to be saved, restored, and returned to its prior value after the configuration dialog is cancelled. This does mean that more unchanged global variables are overwritten with their current values after cancelling the configuration dialog, but this no-op takes trivial cpu time. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 90ccd29 commit a27d76a

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

gitk

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3176,8 +3176,6 @@ proc resizecdetpanes {win w} {
31763176
set s0 $oldsash($win)
31773177
} elseif {$use_ttk} {
31783178
set s0 [$win sashpos 0]
3179-
} else {
3180-
set s0 [$win sash coord 0]
31813179
}
31823180
if {$w < 60} {
31833181
set sash0 [expr {int($w*3/4 - 2)}]
@@ -11716,10 +11714,8 @@ proc create_prefs_page {w} {
1171611714
}
1171711715
1171811716
proc prefspage_general {notebook} {
11719-
global NS maxwidth maxgraphpct showneartags showlocalchanges
11720-
global tabstop wrapcomment wrapdefault limitdiffs
11721-
global autocopy autoselect autosellen extdifftool perfile_attrs
11722-
global hideremotes want_ttk have_ttk maxrefs web_browser kscroll
11717+
global have_ttk NS
11718+
global {*}$::config_variables
1172311719
1172411720
set page [create_prefs_page $notebook.general]
1172511721
@@ -11875,21 +11871,17 @@ proc prefspage_fonts {notebook} {
1187511871
}
1187611872
1187711873
proc doprefs {} {
11878-
global maxwidth maxgraphpct use_ttk NS
11879-
global oldprefs prefstop showneartags showlocalchanges
11880-
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11881-
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11882-
global hideremotes want_ttk have_ttk wrapcomment wrapdefault kscroll
11874+
global use_ttk NS
11875+
global oldprefs prefstop
11876+
global {*}$::config_variables
1188311877
1188411878
set top .gitkprefs
1188511879
set prefstop $top
1188611880
if {[winfo exists $top]} {
1188711881
raise $top
1188811882
return
1188911883
}
11890-
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11891-
limitdiffs tabstop perfile_attrs hideremotes want_ttk \
11892-
wrapcomment wrapdefault kscroll} {
11884+
foreach v $::config_variables {
1189311885
set oldprefs($v) [set $v]
1189411886
}
1189511887
ttk_toplevel $top
@@ -12013,11 +12005,9 @@ proc setfg {c} {
1201312005
1201412006
proc prefscan {} {
1201512007
global oldprefs prefstop
12008+
global {*}$::config_variables
1201612009
12017-
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
12018-
limitdiffs tabstop perfile_attrs hideremotes want_ttk \
12019-
wrapcomment wrapdefault kscroll} {
12020-
global $v
12010+
foreach v $::config_variables {
1202112011
set $v $oldprefs($v)
1202212012
}
1202312013
catch {destroy $prefstop}
@@ -12026,11 +12016,10 @@ proc prefscan {} {
1202612016
}
1202712017
1202812018
proc prefsok {} {
12029-
global maxwidth maxgraphpct
12030-
global oldprefs prefstop showneartags showlocalchanges
12019+
global oldprefs prefstop
1203112020
global fontpref mainfont textfont uifont
1203212021
global limitdiffs treediffs perfile_attrs
12033-
global hideremotes wrapcomment wrapdefault
12022+
global {*}$::config_variables
1203412023
global ctext
1203512024
1203612025
catch {destroy $prefstop}

0 commit comments

Comments
 (0)