1 # git-gui options editor
2 # Copyright (C) 2006, 2007 Shawn Pearce
5 global default_config font_descs
6 global repo_config global_config
7 global repo_config_new global_config_new
9 foreach option $font_descs {
10 set name
[lindex $option 0]
11 set font [lindex $option 1]
12 font configure
$font \
13 -family $global_config_new(gui.
$font^^family
) \
14 -size $global_config_new(gui.
$font^^size
)
15 font configure
${font}bold
\
16 -family $global_config_new(gui.
$font^^family
) \
17 -size $global_config_new(gui.
$font^^size
)
18 font configure
${font}italic
\
19 -family $global_config_new(gui.
$font^^family
) \
20 -size $global_config_new(gui.
$font^^size
)
21 set global_config_new
(gui.
$name) [font configure
$font]
22 unset global_config_new
(gui.
$font^^family
)
23 unset global_config_new
(gui.
$font^^size
)
26 foreach name
[array names default_config
] {
27 set value
$global_config_new($name)
28 if {$value ne
$global_config($name)} {
29 if {$value eq
$default_config($name)} {
30 catch {git config
--global --unset $name}
32 regsub -all "\[{}\]" $value {"} value
33 git config --global $name $value
35 set global_config($name) $value
36 if {$value eq $repo_config($name)} {
37 catch {git config --unset $name}
38 set repo_config($name) $value
43 foreach name [array names default_config] {
44 set value $repo_config_new($name)
45 if {$value ne $repo_config($name)} {
46 if {$value eq $global_config($name)} {
47 catch {git config --unset $name}
49 regsub -all "\[{}\]" $value {"} value
50 git config
$name $value
52 set repo_config
($name) $value
58 global appvers copyright oguilib
59 global tcl_patchLevel tk_patchLevel
63 wm geometry
$w "+[winfo rootx .]+[winfo rooty .]"
65 label $w.header
-text "About [appname]" \
67 pack $w.header
-side top
-fill x
70 button $w.buttons.
close -text {Close
} \
72 -command [list destroy $w]
73 pack $w.buttons.
close -side right
74 pack $w.buttons
-side bottom
-fill x
-pady 10 -padx 10
77 -text "git-gui - a graphical user interface for Git.
84 pack $w.desc
-side top
-fill x
-padx 5 -pady 5
87 append v
"git-gui version $appvers\n"
88 append v
"[git version]\n"
90 if {$tcl_patchLevel eq
$tk_patchLevel} {
91 append v
"Tcl/Tk version $tcl_patchLevel"
93 append v
"Tcl version $tcl_patchLevel"
94 append v
", Tk version $tk_patchLevel"
98 append d
"git exec dir: [gitexec]\n"
99 append d
"git-gui lib: $oguilib"
108 pack $w.vers
-side top
-fill x
-padx 5 -pady 5
117 pack $w.dirs
-side top
-fill x
-padx 5 -pady 5
119 menu $w.ctxm
-tearoff 0
120 $w.ctxm add command
\
124 clipboard append -format STRING -type STRING -- \[$w.vers cget -text\]
127 bind $w <Visibility
> "grab $w; focus $w.buttons.close"
128 bind $w <Key-Escape
> "destroy $w"
129 bind $w <Key-Return
> "destroy $w"
130 bind_button3
$w.vers
"tk_popup $w.ctxm %X %Y; grab $w; focus $w"
131 wm title
$w "About [appname]"
136 global repo_config global_config font_descs
137 global repo_config_new global_config_new
139 array unset repo_config_new
140 array unset global_config_new
141 foreach name
[array names repo_config
] {
142 set repo_config_new
($name) $repo_config($name)
145 foreach name
[array names repo_config
] {
147 gui.diffcontext
{continue}
149 set repo_config_new
($name) $repo_config($name)
151 foreach name
[array names global_config
] {
152 set global_config_new
($name) $global_config($name)
155 set w .options_editor
157 wm geometry
$w "+[winfo rootx .]+[winfo rooty .]"
159 label $w.header
-text "Options" \
161 pack $w.header
-side top
-fill x
164 button $w.buttons.restore
-text {Restore Defaults
} \
166 -command do_restore_defaults
167 pack $w.buttons.restore
-side left
168 button $w.buttons.save
-text Save
\
170 -command [list do_save_config
$w]
171 pack $w.buttons.save
-side right
172 button $w.buttons.cancel
-text {Cancel
} \
174 -command [list destroy $w]
175 pack $w.buttons.cancel
-side right
-padx 5
176 pack $w.buttons
-side bottom
-fill x
-pady 10 -padx 10
178 labelframe $w.repo
-text "[reponame] Repository"
179 labelframe $w.
global -text {Global
(All Repositories
)}
180 pack $w.repo
-side left
-fill both
-expand 1 -pady 5 -padx 5
181 pack $w.
global -side right
-fill both
-expand 1 -pady 5 -padx 5
185 {t user.name
{User Name
}}
186 {t user.email
{Email Address
}}
188 {b merge.summary
{Summarize Merge Commits
}}
189 {i-1.
.5 merge.verbosity
{Merge Verbosity
}}
190 {b merge.diffstat
{Show Diffstat After Merge
}}
192 {b gui.trustmtime
{Trust File Modification Timestamps
}}
193 {b gui.pruneduringfetch
{Prune Tracking Branches During Fetch
}}
194 {i-0.
.99 gui.diffcontext
{Number of Diff Context Lines
}}
195 {t gui.newbranchtemplate
{New Branch Name Template
}}
197 set type
[lindex $option 0]
198 set name
[lindex $option 1]
199 set text [lindex $option 2]
201 foreach f
{repo
global} {
202 switch -glob -- $type {
204 checkbutton $w.
$f.
$optid -text $text \
205 -variable ${f
}_config_new
($name) \
208 pack $w.
$f.
$optid -side top
-anchor w
211 regexp -- {-(\d
+)\.
\.
(\d
+)$} $type _junk min max
213 label $w.
$f.
$optid.l
-text "$text:"
214 pack $w.
$f.
$optid.l
-side left
-anchor w
-fill x
215 spinbox $w.
$f.
$optid.v
\
216 -textvariable ${f
}_config_new
($name) \
220 -width [expr {1 + [string length
$max]}]
221 bind $w.
$f.
$optid.v
<FocusIn
> {%W
selection range
0 end
}
222 pack $w.
$f.
$optid.v
-side right
-anchor e
-padx 5
223 pack $w.
$f.
$optid -side top
-anchor w
-fill x
227 label $w.
$f.
$optid.l
-text "$text:"
228 entry $w.
$f.
$optid.v
\
232 -textvariable ${f
}_config_new
($name)
233 pack $w.
$f.
$optid.l
-side left
-anchor w
234 pack $w.
$f.
$optid.v
-side left
-anchor w
\
237 pack $w.
$f.
$optid -side top
-anchor w
-fill x
243 set all_fonts
[lsort [font families
]]
244 foreach option $font_descs {
245 set name
[lindex $option 0]
246 set font [lindex $option 1]
247 set text [lindex $option 2]
249 set global_config_new
(gui.
$font^^family
) \
250 [font configure
$font -family]
251 set global_config_new
(gui.
$font^^size
) \
252 [font configure
$font -size]
254 frame $w.
global.
$name
255 label $w.
global.
$name.l
-text "$text:"
256 pack $w.
global.
$name.l
-side left
-anchor w
-fill x
257 eval tk_optionMenu $w.
global.
$name.family
\
258 global_config_new
(gui.
$font^^family
) \
260 spinbox $w.
global.
$name.size
\
261 -textvariable global_config_new
(gui.
$font^^size
) \
262 -from 2 -to 80 -increment 1 \
264 bind $w.
global.
$name.size
<FocusIn
> {%W
selection range
0 end
}
265 pack $w.
global.
$name.size
-side right
-anchor e
266 pack $w.
global.
$name.family
-side right
-anchor e
267 pack $w.
global.
$name -side top
-anchor w
-fill x
270 bind $w <Visibility
> "grab $w; focus $w.buttons.save"
271 bind $w <Key-Escape
> "destroy $w"
272 bind $w <Key-Return
> [list do_save_config
$w]
273 wm title
$w "[appname] ([reponame]): Options"
277 proc do_restore_defaults
{} {
278 global font_descs default_config repo_config
279 global repo_config_new global_config_new
281 foreach name
[array names default_config
] {
282 set repo_config_new
($name) $default_config($name)
283 set global_config_new
($name) $default_config($name)
286 foreach option $font_descs {
287 set name
[lindex $option 0]
288 set repo_config
(gui.
$name) $default_config(gui.
$name)
292 foreach option $font_descs {
293 set name
[lindex $option 0]
294 set font [lindex $option 1]
295 set global_config_new
(gui.
$font^^family
) \
296 [font configure
$font -family]
297 set global_config_new
(gui.
$font^^size
) \
298 [font configure
$font -size]
302 proc do_save_config
{w
} {
303 if {[catch {save_config
} err
]} {
304 error_popup
"Failed to completely save options:\n\n$err"