Code

git-gui: Cleanup common font handling for font_ui
authorShawn O. Pearce <spearce@spearce.org>
Sun, 29 Apr 2007 02:00:02 +0000 (22:00 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 2 May 2007 17:06:10 +0000 (13:06 -0400)
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>
git-gui.sh

index ba2ee985f759ea0cfad619d9c2cc90ae69f13056..aa232f0e7e1e995917b2d5e3dfe1b0796ddd36bb 100755 (executable)
@@ -242,8 +242,6 @@ proc error_popup {msg} {
        if {[reponame] ne {}} {
                append title " ([reponame])"
        }
-       option add *Dialog.msg.font font_ui
-       option add *Button.font font_ui
        set cmd [list tk_messageBox \
                -icon error \
                -type ok \
@@ -260,8 +258,6 @@ proc warn_popup {msg} {
        if {[reponame] ne {}} {
                append title " ([reponame])"
        }
-       option add *Dialog.msg.font font_ui
-       option add *Button.font font_ui
        set cmd [list tk_messageBox \
                -icon warning \
                -type ok \
@@ -278,8 +274,6 @@ proc info_popup {msg {parent .}} {
        if {[reponame] ne {}} {
                append title " ([reponame])"
        }
-       option add *Dialog.msg.font font_ui
-       option add *Button.font font_ui
        tk_messageBox \
                -parent $parent \
                -icon info \
@@ -293,8 +287,6 @@ proc ask_popup {msg} {
        if {[reponame] ne {}} {
                append title " ([reponame])"
        }
-       option add *Dialog.msg.font font_ui
-       option add *Button.font font_ui
        return [tk_messageBox \
                -parent . \
                -icon question \
@@ -303,6 +295,15 @@ proc ask_popup {msg} {
                -message $msg]
 }
 
+auto_load tk_optionMenu
+rename tk_optionMenu real__tkOptionMenu
+proc tk_optionMenu {w varName args} {
+       set m [eval real__tkOptionMenu $w $varName $args]
+       $m configure -font font_ui
+       $w configure -font font_ui
+       return $m
+}
+
 ######################################################################
 ##
 ## version check
@@ -2114,10 +2115,7 @@ proc do_create_branch {} {
                -value head \
                -variable create_branch_revtype \
                -font font_ui
-       set lbranchm [eval tk_optionMenu $w.from.head_m create_branch_head \
-               $all_heads]
-       $lbranchm configure -font font_ui
-       $w.from.head_m configure -font font_ui
+       eval tk_optionMenu $w.from.head_m create_branch_head $all_heads
        grid $w.from.head_r $w.from.head_m -sticky w
        set all_trackings [all_tracking_branches]
        if {$all_trackings ne {}} {
@@ -2127,11 +2125,9 @@ proc do_create_branch {} {
                        -value tracking \
                        -variable create_branch_revtype \
                        -font font_ui
-               set tbranchm [eval tk_optionMenu $w.from.tracking_m \
+               eval tk_optionMenu $w.from.tracking_m \
                        create_branch_trackinghead \
-                       $all_trackings]
-               $tbranchm configure -font font_ui
-               $w.from.tracking_m configure -font font_ui
+                       $all_trackings
                grid $w.from.tracking_r $w.from.tracking_m -sticky w
        }
        set all_tags [load_all_tags]
@@ -2142,11 +2138,7 @@ proc do_create_branch {} {
                        -value tag \
                        -variable create_branch_revtype \
                        -font font_ui
-               set tagsm [eval tk_optionMenu $w.from.tag_m \
-                       create_branch_tag \
-                       $all_tags]
-               $tagsm configure -font font_ui
-               $w.from.tag_m configure -font font_ui
+               eval tk_optionMenu $w.from.tag_m create_branch_tag $all_tags
                grid $w.from.tag_r $w.from.tag_m -sticky w
        }
        radiobutton $w.from.exp_r \
@@ -2340,11 +2332,7 @@ proc do_delete_branch {} {
                -value head \
                -variable delete_branch_checktype \
                -font font_ui
-       set mergedlocalm [eval tk_optionMenu $w.validate.head_m \
-               delete_branch_head \
-               $all_heads]
-       $mergedlocalm configure -font font_ui
-       $w.validate.head_m configure -font font_ui
+       eval tk_optionMenu $w.validate.head_m delete_branch_head $all_heads
        grid $w.validate.head_r $w.validate.head_m -sticky w
        set all_trackings [all_tracking_branches]
        if {$all_trackings ne {}} {
@@ -2354,11 +2342,9 @@ proc do_delete_branch {} {
                        -value tracking \
                        -variable delete_branch_checktype \
                        -font font_ui
-               set mergedtrackm [eval tk_optionMenu $w.validate.tracking_m \
+               eval tk_optionMenu $w.validate.tracking_m \
                        delete_branch_trackinghead \
-                       $all_trackings]
-               $mergedtrackm configure -font font_ui
-               $w.validate.tracking_m configure -font font_ui
+                       $all_trackings
                grid $w.validate.tracking_r $w.validate.tracking_m -sticky w
        }
        radiobutton $w.validate.always_r \
@@ -2729,10 +2715,7 @@ proc do_push_anywhere {} {
                        -value remote \
                        -variable push_urltype \
                        -font font_ui
-               set remmenu [eval tk_optionMenu $w.dest.remote_m push_remote \
-                       $all_remotes]
-               $remmenu configure -font font_ui
-               $w.dest.remote_m configure -font font_ui
+               eval tk_optionMenu $w.dest.remote_m push_remote $all_remotes
                grid $w.dest.remote_r $w.dest.remote_m -sticky w
                if {[lsearch -sorted -exact $all_remotes origin] != -1} {
                        set push_remote origin
@@ -4715,11 +4698,9 @@ proc do_options {} {
                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
-               set fontmenu [eval tk_optionMenu $w.global.$name.family \
+               eval tk_optionMenu $w.global.$name.family \
                        global_config_new(gui.$font^^family) \
-                       $all_fonts]
-               $w.global.$name.family configure -font font_ui
-               $fontmenu configure -font font_ui
+                       $all_fonts
                spinbox $w.global.$name.size \
                        -textvariable global_config_new(gui.$font^^size) \
                        -from 2 -to 80 -increment 1 \
@@ -5068,6 +5049,8 @@ set font_descs {
 }
 load_config 0
 apply_config
+option add *Dialog.msg.font font_ui
+option add *Button.font     font_ui
 
 ######################################################################
 ##