Commits

Anonymous committed 2739291

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>

  • Participants
  • Parent commits d45b52b

Comments (0)

Files changed (1)

 	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 \
 	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 \
 	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 \
 	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 \
 		-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
 		-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 {}} {
 			-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]
 			-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 \
 		-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 {}} {
 			-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 \
 			-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
 		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 \
 }
 load_config 0
 apply_config
+option add *Dialog.msg.font font_ui
+option add *Button.font     font_ui
 
 ######################################################################
 ##