git-gui: Cleanup common font handling for font_ui
An earlier change tossed these optionMenu font configurations all over the code, when really we can just rename the proc to a hidden internal name and provide our own wrapper to install the font configuration we really want. We also don't need to set these option database entries in all of the procedures that open dialogs; instead we should just set one time, them after we have the font configuration ready for use. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Apr 28, 2007 at 22:00 UTC
2739291b77fefe7cfae16481756716f11a01e654
1 file changed
+21
-38
git-gui.sh
+21
-38
@@ -242,8 +242,6 @@ proc error_popup {msg} {
242
if {[reponame] ne {}} {
243
append title " ([reponame])"
244
}
245
- option add *Dialog.msg.font font_ui
246
- option add *Button.font font_ui
245
set cmd [list tk_messageBox \
246
-icon error \
247
-type ok \
@@ -260,8 +258,6 @@ proc warn_popup {msg} {
258
if {[reponame] ne {}} {
259
append title " ([reponame])"
260
}
263
- option add *Dialog.msg.font font_ui
264
- option add *Button.font font_ui
261
set cmd [list tk_messageBox \
262
-icon warning \
263
-type ok \
@@ -278,8 +274,6 @@ proc info_popup {msg {parent .}} {
274
if {[reponame] ne {}} {
275
append title " ([reponame])"
276
}
281
- option add *Dialog.msg.font font_ui
282
- option add *Button.font font_ui
277
tk_messageBox \
278
-parent $parent \
279
-icon info \
@@ -293,8 +287,6 @@ proc ask_popup {msg} {
287
if {[reponame] ne {}} {
288
append title " ([reponame])"
289
}
296
- option add *Dialog.msg.font font_ui
297
- option add *Button.font font_ui
290
return [tk_messageBox \
291
-parent . \
292
-icon question \
@@ -303,6 +295,15 @@ proc ask_popup {msg} {
295
-message $msg]
296
}
297
298
+auto_load tk_optionMenu
299
+rename tk_optionMenu real__tkOptionMenu
300
+proc tk_optionMenu {w varName args} {
301
+ set m [eval real__tkOptionMenu $w $varName $args]
302
+ $m configure -font font_ui
303
+ $w configure -font font_ui
304
+ return $m
305
+}
306
+
307
######################################################################
308
##
309
## version check
@@ -2114,10 +2115,7 @@ proc do_create_branch {} {
2115
-value head \
2116
-variable create_branch_revtype \
2117
-font font_ui
2117
- set lbranchm [eval tk_optionMenu $w.from.head_m create_branch_head \
2118
- $all_heads]
2119
- $lbranchm configure -font font_ui
2120
- $w.from.head_m configure -font font_ui
2118
+ eval tk_optionMenu $w.from.head_m create_branch_head $all_heads
2119
grid $w.from.head_r $w.from.head_m -sticky w
2120
set all_trackings [all_tracking_branches]
2121
if {$all_trackings ne {}} {
@@ -2127,11 +2125,9 @@ proc do_create_branch {} {
2125
-value tracking \
2126
-variable create_branch_revtype \
2127
-font font_ui
2130
- set tbranchm [eval tk_optionMenu $w.from.tracking_m \
2128
+ eval tk_optionMenu $w.from.tracking_m \
2129
create_branch_trackinghead \
2132
- $all_trackings]
2133
- $tbranchm configure -font font_ui
2134
- $w.from.tracking_m configure -font font_ui
2130
+ $all_trackings
2131
grid $w.from.tracking_r $w.from.tracking_m -sticky w
2132
}
2133
set all_tags [load_all_tags]
@@ -2142,11 +2138,7 @@ proc do_create_branch {} {
2138
-value tag \
2139
-variable create_branch_revtype \
2140
-font font_ui
2145
- set tagsm [eval tk_optionMenu $w.from.tag_m \
2146
- create_branch_tag \
2147
- $all_tags]
2148
- $tagsm configure -font font_ui
2149
- $w.from.tag_m configure -font font_ui
2141
+ eval tk_optionMenu $w.from.tag_m create_branch_tag $all_tags
2142
grid $w.from.tag_r $w.from.tag_m -sticky w
2143
}
2144
radiobutton $w.from.exp_r \
@@ -2340,11 +2332,7 @@ proc do_delete_branch {} {
2332
-value head \
2333
-variable delete_branch_checktype \
2334
-font font_ui
2343
- set mergedlocalm [eval tk_optionMenu $w.validate.head_m \
2344
- delete_branch_head \
2345
- $all_heads]
2346
- $mergedlocalm configure -font font_ui
2347
- $w.validate.head_m configure -font font_ui
2335
+ eval tk_optionMenu $w.validate.head_m delete_branch_head $all_heads
2336
grid $w.validate.head_r $w.validate.head_m -sticky w
2337
set all_trackings [all_tracking_branches]
2338
if {$all_trackings ne {}} {
@@ -2354,11 +2342,9 @@ proc do_delete_branch {} {
2342
-value tracking \
2343
-variable delete_branch_checktype \
2344
-font font_ui
2357
- set mergedtrackm [eval tk_optionMenu $w.validate.tracking_m \
2345
+ eval tk_optionMenu $w.validate.tracking_m \
2346
delete_branch_trackinghead \
2359
- $all_trackings]
2360
- $mergedtrackm configure -font font_ui
2361
- $w.validate.tracking_m configure -font font_ui
2347
+ $all_trackings
2348
grid $w.validate.tracking_r $w.validate.tracking_m -sticky w
2349
}
2350
radiobutton $w.validate.always_r \
@@ -2729,10 +2715,7 @@ proc do_push_anywhere {} {
2715
-value remote \
2716
-variable push_urltype \
2717
-font font_ui
2732
- set remmenu [eval tk_optionMenu $w.dest.remote_m push_remote \
2733
- $all_remotes]
2734
- $remmenu configure -font font_ui
2735
- $w.dest.remote_m configure -font font_ui
2718
+ eval tk_optionMenu $w.dest.remote_m push_remote $all_remotes
2719
grid $w.dest.remote_r $w.dest.remote_m -sticky w
2720
if {[lsearch -sorted -exact $all_remotes origin] != -1} {
2721
set push_remote origin
@@ -4715,11 +4698,9 @@ proc do_options {} {
4698
frame $w.global.$name
4699
label $w.global.$name.l -text "$text:" -font font_ui
4700
pack $w.global.$name.l -side left -anchor w -fill x
4718
- set fontmenu [eval tk_optionMenu $w.global.$name.family \
4701
+ eval tk_optionMenu $w.global.$name.family \
4702
global_config_new(gui.$font^^family) \
4720
- $all_fonts]
4721
- $w.global.$name.family configure -font font_ui
4722
- $fontmenu configure -font font_ui
4703
+ $all_fonts
4704
spinbox $w.global.$name.size \
4705
-textvariable global_config_new(gui.$font^^size) \
4706
-from 2 -to 80 -increment 1 \
@@ -5068,6 +5049,8 @@ set font_descs {
5049
}
5050
load_config 0
5051
apply_config
5052
+option add *Dialog.msg.font font_ui
5053
+option add *Button.font font_ui
5054
5055
######################################################################
5056
##