summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 51f4d16)
raw | patch | inline | side by side (parent: 51f4d16)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sun, 12 Nov 2006 10:27:00 +0000 (05:27 -0500) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Sun, 12 Nov 2006 10:27:00 +0000 (05:27 -0500) |
This turned out to take a lot more time than I thought it would take;
but now users can edit the main UI font and the diff/fixed with font
by changing both the family name and/or the point size of the text.
We save the complete Tk font specification to the user's ~/.gitconfig
file upon saving options. This is probably more verbose than it needs
to be as there are many useless options recorded (e.g. -overstrike 0)
that a user won't really want to use in this application.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
but now users can edit the main UI font and the diff/fixed with font
by changing both the family name and/or the point size of the text.
We save the complete Tk font specification to the user's ~/.gitconfig
file upon saving options. This is probably more verbose than it needs
to be as there are many useless options recorded (e.g. -overstrike 0)
that a user won't really want to use in this application.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
git-gui | patch | blob | history |
index 520ec1efffe1bb2fe993bcbf141246060683059b..931a959307929de4b8a78c037ebdb6f3f5b78e04 100755 (executable)
--- a/git-gui
+++ b/git-gui
##
## config
-set default_config(gui.trustmtime) false
-
proc is_many_config {name} {
switch -glob -- $name {
remote.*.fetch -
}
proc save_config {} {
- global repo_config global_config default_config
+ global default_config font_descs
+ global repo_config global_config
global repo_config_new global_config_new
- foreach name [array names global_config_new] {
+ foreach option $font_descs {
+ set name [lindex $option 0]
+ set font [lindex $option 1]
+ font configure $font \
+ -family $global_config_new(gui.$font^^family) \
+ -size $global_config_new(gui.$font^^size)
+ font configure ${font}bold \
+ -family $global_config_new(gui.$font^^family) \
+ -size $global_config_new(gui.$font^^size)
+ set global_config_new(gui.$name) [font configure $font]
+ unset global_config_new(gui.$font^^family)
+ unset global_config_new(gui.$font^^size)
+ }
+
+ foreach name [array names default_config] {
set value $global_config_new($name)
if {$value != $global_config($name)} {
if {$value == $default_config($name)} {
}
}
- foreach name [array names repo_config_new] {
+ foreach name [array names default_config] {
set value $repo_config_new($name)
if {$value != $repo_config($name)} {
if {$value == $global_config($name)} {
set single_commit 1
}
-load_config
-
######################################################################
##
## task management
}
proc do_options {} {
- global appname gitdir
+ global appname gitdir font_descs
global repo_config global_config
global repo_config_new global_config_new
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 "save_config; destroy $w"
+ -command [list do_save_config $w]
pack $w.buttons.save -side right
button $w.buttons.cancel -text {Cancel} \
-font font_ui \
- -command "destroy $w"
+ -command [list destroy $w]
pack $w.buttons.cancel -side right
- pack $w.buttons -side bottom -anchor e -pady 10 -padx 10
+ pack $w.buttons -side bottom -fill x -pady 10 -padx 10
labelframe $w.repo -text {This Repository} \
+ -font font_ui \
-relief raised -borderwidth 2
labelframe $w.global -text {Global (All Repositories)} \
+ -font font_ui \
-relief raised -borderwidth 2
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 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
+ 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 ([lindex [file split \
tkwait window $w
}
+proc do_restore_defaults {} {
+ global font_descs default_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($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]
+ }
+}
+
+proc do_save_config {w} {
+ if {[catch {save_config} err]} {
+ error_popup "Failed to completely save options:\n\n$err"
+ }
+ destroy $w
+}
+
# shift == 1: left click
# 3: right click
proc click {w x y shift wx wy} {
######################################################################
##
-## ui init
+## config defaults
set cursor_ptr arrow
font create font_diff -family Courier -size 10
destroy .dummy
}
-eval font create font_uibold [font configure font_ui]
-font configure font_uibold -weight bold
-eval font create font_diffbold [font configure font_diff]
-font configure font_diffbold -weight bold
+font create font_uibold
+font create font_diffbold
set M1B M1
set M1T M1
set M1T Cmd
}
+proc apply_config {} {
+ global repo_config font_descs
+
+ foreach option $font_descs {
+ set name [lindex $option 0]
+ set font [lindex $option 1]
+ if {[catch {
+ foreach {cn cv} $repo_config(gui.$name) {
+ font configure $font $cn $cv
+ }
+ } err]} {
+ error_popup "Invalid font specified in gui.$name:\n\n$err"
+ }
+ foreach {cn cv} [font configure $font] {
+ font configure ${font}bold $cn $cv
+ }
+ font configure ${font}bold -weight bold
+ }
+}
+
+set default_config(gui.trustmtime) false
+set default_config(gui.fontui) [font configure font_ui]
+set default_config(gui.fontdiff) [font configure font_diff]
+set font_descs {
+ {fontui font_ui {Main Font}}
+ {fontdiff font_diff {Diff/Console Font}}
+}
+load_config
+apply_config
+
+######################################################################
+##
+## ui construction
+
# -- Menu Bar
menu .mbar -tearoff 0
.mbar add cascade -label Project -menu .mbar.project