- append v "Tcl version $tcl_patchLevel"
- append v ", Tk version $tk_patchLevel"
- }
-
- label $w.vers \
- -text $v \
- -padx 5 -pady 5 \
- -justify left \
- -anchor w \
- -borderwidth 1 \
- -relief solid \
- -font font_ui
- pack $w.vers -side top -fill x -padx 5 -pady 5
-
- menu $w.ctxm -tearoff 0
- $w.ctxm add command \
- -label {Copy} \
- -font font_ui \
- -command "
- clipboard clear
- clipboard append -format STRING -type STRING -- \[$w.vers cget -text\]
- "
-
- bind $w <Visibility> "grab $w; focus $w"
- bind $w <Key-Escape> "destroy $w"
- bind_button3 $w.vers "tk_popup $w.ctxm %X %Y; grab $w; focus $w"
- wm title $w "About [appname]"
- tkwait window $w
-}
-
-proc do_options {} {
- global repo_config global_config font_descs
- global repo_config_new global_config_new
-
- array unset repo_config_new
- array unset global_config_new
- foreach name [array names repo_config] {
- set repo_config_new($name) $repo_config($name)
- }
- load_config 1
- foreach name [array names repo_config] {
- switch -- $name {
- gui.diffcontext {continue}
- }
- set repo_config_new($name) $repo_config($name)
- }
- foreach name [array names global_config] {
- set global_config_new($name) $global_config($name)
- }
-
- set w .options_editor
- toplevel $w
- wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
-
- label $w.header -text "[appname] Options" \
- -font font_uibold
- pack $w.header -side top -fill x
-
- frame $w.buttons
- button $w.buttons.restore -text {Restore Defaults} \
- -font font_ui \
- -command do_restore_defaults
- pack $w.buttons.restore -side left
- button $w.buttons.save -text Save \
- -font font_ui \
- -command [list do_save_config $w]
- pack $w.buttons.save -side right
- button $w.buttons.cancel -text {Cancel} \
- -font font_ui \
- -command [list destroy $w]
- pack $w.buttons.cancel -side right -padx 5
- pack $w.buttons -side bottom -fill x -pady 10 -padx 10
-
- labelframe $w.repo -text "[reponame] Repository" \
- -font font_ui
- labelframe $w.global -text {Global (All Repositories)} \
- -font font_ui
- pack $w.repo -side left -fill both -expand 1 -pady 5 -padx 5
- pack $w.global -side right -fill both -expand 1 -pady 5 -padx 5
-
- set optid 0
- foreach option {
- {t user.name {User Name}}
- {t user.email {Email Address}}
-
- {b merge.summary {Summarize Merge Commits}}
- {i-1..5 merge.verbosity {Merge Verbosity}}
-
- {b gui.trustmtime {Trust File Modification Timestamps}}
- {i-1..99 gui.diffcontext {Number of Diff Context Lines}}
- {t gui.newbranchtemplate {New Branch Name Template}}
- } {
- set type [lindex $option 0]
- set name [lindex $option 1]
- set text [lindex $option 2]
- incr optid
- foreach f {repo global} {
- switch -glob -- $type {
- b {
- checkbutton $w.$f.$optid -text $text \
- -variable ${f}_config_new($name) \
- -onvalue true \
- -offvalue false \
- -font font_ui
- pack $w.$f.$optid -side top -anchor w
- }
- i-* {
- regexp -- {-(\d+)\.\.(\d+)$} $type _junk min max
- frame $w.$f.$optid
- label $w.$f.$optid.l -text "$text:" -font font_ui
- pack $w.$f.$optid.l -side left -anchor w -fill x
- spinbox $w.$f.$optid.v \
- -textvariable ${f}_config_new($name) \
- -from $min \
- -to $max \
- -increment 1 \
- -width [expr {1 + [string length $max]}] \
- -font font_ui
- bind $w.$f.$optid.v <FocusIn> {%W selection range 0 end}
- pack $w.$f.$optid.v -side right -anchor e -padx 5
- pack $w.$f.$optid -side top -anchor w -fill x
- }
- t {
- frame $w.$f.$optid
- label $w.$f.$optid.l -text "$text:" -font font_ui
- entry $w.$f.$optid.v \
- -borderwidth 1 \
- -relief sunken \
- -width 20 \
- -textvariable ${f}_config_new($name) \
- -font font_ui
- pack $w.$f.$optid.l -side left -anchor w
- pack $w.$f.$optid.v -side left -anchor w \
- -fill x -expand 1 \
- -padx 5
- pack $w.$f.$optid -side top -anchor w -fill x
- }
- }
- }
- }
-
- set all_fonts [lsort [font families]]
- foreach option $font_descs {
- set name [lindex $option 0]
- set font [lindex $option 1]
- set text [lindex $option 2]
-
- set global_config_new(gui.$font^^family) \
- [font configure $font -family]
- set global_config_new(gui.$font^^size) \
- [font configure $font -size]
-
- frame $w.global.$name
- label $w.global.$name.l -text "$text:" -font font_ui
- pack $w.global.$name.l -side left -anchor w -fill x
- eval tk_optionMenu $w.global.$name.family \
- global_config_new(gui.$font^^family) \
- $all_fonts
- spinbox $w.global.$name.size \
- -textvariable global_config_new(gui.$font^^size) \
- -from 2 -to 80 -increment 1 \
- -width 3 \
- -font font_ui
- bind $w.global.$name.size <FocusIn> {%W selection range 0 end}
- pack $w.global.$name.size -side right -anchor e
- pack $w.global.$name.family -side right -anchor e
- pack $w.global.$name -side top -anchor w -fill x
- }
-
- bind $w <Visibility> "grab $w; focus $w"
- bind $w <Key-Escape> "destroy $w"
- wm title $w "[appname] ([reponame]): Options"
- tkwait window $w
-}
-
-proc do_restore_defaults {} {
- global font_descs default_config repo_config
- global repo_config_new global_config_new
-
- foreach name [array names default_config] {
- set repo_config_new($name) $default_config($name)
- set global_config_new($name) $default_config($name)
- }
-
- foreach option $font_descs {
- set name [lindex $option 0]
- set repo_config(gui.$name) $default_config(gui.$name)
- }
- apply_config
-
- foreach option $font_descs {
- set name [lindex $option 0]
- set font [lindex $option 1]
- set global_config_new(gui.$font^^family) \
- [font configure $font -family]
- set global_config_new(gui.$font^^size) \
- [font configure $font -size]