# [PATCH 5/5] gitk: Use consistent font for all text input fields

5 messages from 2009-12-28 to 2009-12-28. Participants: Mark Hills.
Thread: https://gitlist.dev/t/22041

## Mark Hills, 2009-12-28 20:03

Subject: [PATCH 1/5] gitk: Remove forced use of sans-serif font
Message-ID: <1262030643-12952-1-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1262030643-12952-1-git-send-email-mark%40pogo.org.uk

```
The X resources set using uifont cover this case.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk-git/gitk |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 364c7a8..c58fd58 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -10513,7 +10513,6 @@ proc mkfontdisp {font top which} {
     set fontpref($font) [set $font]
     ${NS}::button $top.${font}but -text $which \
 	-command [list choosefont $font $which]
-    if {!$use_ttk} {$top.${font}but configure  -font optionfont}
     ${NS}::label $top.$font -relief flat -font $font \
 	-text $fontattr($font,family) -justify left
     grid x $top.${font}but $top.$font -sticky w
@@ -10776,15 +10775,6 @@ proc doprefs {} {
     mkfontdisp textfont $top [mc "Diff display font"]
     mkfontdisp uifont $top [mc "User interface font"]
 
-    if {!$use_ttk} {
-	foreach w {maxpctl maxwidthl showlocal autoselect tabstopl ntag
-	    ldiff lattr extdifff.l extdifff.b bgbut fgbut
-	    diffoldbut diffnewbut hunksepbut markbgbut selbgbut
-	    want_ttk ttk_note} {
-	    $top.$w configure -font optionfont
-	}
-    }
-
     ${NS}::frame $top.buts
     ${NS}::button $top.buts.ok -text [mc "OK"] -command prefsok -default active
     ${NS}::button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
@@ -11396,8 +11386,6 @@ namespace import ::msgcat::mc
 
 catch {source ~/.gitk}
 
-font create optionfont -family sans-serif -size -12
-
 parsefont mainfont $mainfont
 eval font create mainfont [fontflags mainfont]
 eval font create mainfontbold [fontflags mainfont 1]
-- 
1.6.6

```

## Mark Hills, 2009-12-28 20:04

Subject: [PATCH 2/5] gitk: Set the font for all spinbox widgets
Message-ID: <1262030643-12952-2-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1262030643-12952-2-git-send-email-mark%40pogo.org.uk
In-Reply-To: <1262030643-12952-1-git-send-email-mark@pogo.org.uk>

```
Use the X resources to set the font, removing the need to set the font
for specific widgets.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk-git/gitk |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index c58fd58..299a2ae 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -1876,6 +1876,7 @@ proc setoptions {} {
     option add *Message.font uifont startupFile
     option add *Entry.font uifont startupFile
     option add *Labelframe.font uifont startupFile
+    option add *Spinbox.font textfont startupFile
 }
 
 # Make a menu and submenus.
@@ -2226,7 +2227,7 @@ proc makewindow {} {
 	-command changediffdisp -variable diffelide -value {1 0}
     ${NS}::label .bleft.mid.labeldiffcontext -text "      [mc "Lines of context"]: "
     pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
-    spinbox .bleft.mid.diffcontext -width 5 -font textfont \
+    spinbox .bleft.mid.diffcontext -width 5 \
 	-from 0 -increment 1 -to 10000000 \
 	-validate all -validatecommand "diffcontextvalidate %P" \
 	-textvariable diffcontextstring
-- 
1.6.6

```

## Mark Hills, 2009-12-28 20:04

Subject: [PATCH 3/5] gitk: Set the font for all listbox widgets
Message-ID: <1262030643-12952-3-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1262030643-12952-3-git-send-email-mark%40pogo.org.uk
In-Reply-To: <1262030643-12952-2-git-send-email-mark@pogo.org.uk>

```
This affects the font chooser.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk-git/gitk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 299a2ae..5cbc885 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -1877,6 +1877,7 @@ proc setoptions {} {
     option add *Entry.font uifont startupFile
     option add *Labelframe.font uifont startupFile
     option add *Spinbox.font textfont startupFile
+    option add *Listbox.font mainfont startupFile
 }
 
 # Make a menu and submenus.
-- 
1.6.6

```

## Mark Hills, 2009-12-28 20:04

Subject: [PATCH 4/5] gitk: Disable option when themed widgets are not available
Message-ID: <1262030643-12952-4-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1262030643-12952-4-git-send-email-mark%40pogo.org.uk
In-Reply-To: <1262030643-12952-3-git-send-email-mark@pogo.org.uk>

```
Disable the widget instead of using the label to indicate that themed
widgets are not available.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk-git/gitk |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 5cbc885..5008753 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -10721,14 +10721,14 @@ proc doprefs {} {
 
     ${NS}::label $top.lgen -text [mc "General options"]
     grid $top.lgen - -sticky w -pady 10
-    ${NS}::checkbutton $top.want_ttk -variable want_ttk \
-	-text [mc "Use themed widgets"]
     if {$have_ttk} {
-	${NS}::label $top.ttk_note -text [mc "(change requires restart)"]
+	${NS}::checkbutton $top.want_ttk -variable want_ttk \
+	    -text [mc "Use themed widgets (change requires restart)"]
     } else {
-	${NS}::label $top.ttk_note -text [mc "(currently unavailable)"]
+	${NS}::checkbutton $top.want_ttk \
+	    -text [mc "Use themed widgets"] -state disabled
     }
-    grid x $top.want_ttk $top.ttk_note -sticky w
+    grid x $top.want_ttk - -sticky w
 
     ${NS}::label $top.cdisp -text [mc "Colors: press to choose"]
     grid $top.cdisp - -sticky w -pady 10
-- 
1.6.6

```

## Mark Hills, 2009-12-28 20:04

Subject: [PATCH 5/5] gitk: Use consistent font for all text input fields
Message-ID: <1262030643-12952-5-git-send-email-mark@pogo.org.uk>
URL: https://gitlist.dev/e/1262030643-12952-5-git-send-email-mark%40pogo.org.uk
In-Reply-To: <1262030643-12952-4-git-send-email-mark@pogo.org.uk>

```
Instead of setting the font for specific widgets, set the font for the
widget type. If themed widgets are not available, this is via the X
resources. If themed widgets are available, the theme font is used.

The exception is the SHA1 ID which is forced to use the fixed-width
font, even where themed widgets are used.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
---
 gitk-git/gitk |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 5008753..13da663 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -1874,7 +1874,8 @@ proc setoptions {} {
     option add *Menubutton.font uifont startupFile
     option add *Label.font uifont startupFile
     option add *Message.font uifont startupFile
-    option add *Entry.font uifont startupFile
+    option add *Entry.font textfont startupFile
+    option add *Text.font textfont startupFile
     option add *Labelframe.font uifont startupFile
     option add *Spinbox.font textfont startupFile
     option add *Listbox.font mainfont startupFile
@@ -2173,7 +2174,7 @@ proc makewindow {} {
     set findstring {}
     set fstring .tf.lbar.findstring
     lappend entries $fstring
-    ${NS}::entry $fstring -width 30 -font textfont -textvariable findstring
+    ${NS}::entry $fstring -width 30 -textvariable findstring
     trace add variable findstring write find_change
     set findtype [mc "Exact"]
     set findtypemenu [makedroplist .tf.lbar.findtype \
@@ -2216,7 +2217,7 @@ proc makewindow {} {
     pack .bleft.top.search -side left -padx 5
     set sstring .bleft.top.sstring
     set searchstring ""
-    ${NS}::entry $sstring -width 20 -font textfont -textvariable searchstring
+    ${NS}::entry $sstring -width 20 -textvariable searchstring
     lappend entries $sstring
     trace add variable searchstring write incrsearch
     pack $sstring -side left -expand 1 -fill x
@@ -4036,7 +4037,7 @@ proc vieweditor {top n title} {
 	} elseif {$type eq "path"} {
 	    ${NS}::label $top.l -text $title
 	    pack $top.l -in $top -side top -pady [list 3 0] -anchor w -padx 3
-	    text $top.t -width 40 -height 5 -background $bgcolor -font uifont
+	    text $top.t -width 40 -height 5 -background $bgcolor
 	    if {[info exists viewfiles($n)]} {
 		foreach f $viewfiles($n) {
 		    $top.t insert end $f
-- 
1.6.6

```
